388 extraparams['rql'] = rql; |
388 extraparams['rql'] = rql; |
389 extraparams['vid'] = vid; |
389 extraparams['vid'] = vid; |
390 $(fragment.id).loadxhtml('json', ajaxFuncArgs('view', extraparams)); |
390 $(fragment.id).loadxhtml('json', ajaxFuncArgs('view', extraparams)); |
391 } |
391 } |
392 } |
392 } |
|
393 <<<<<<< /home/syt/src/fcubicweb/cubicweb/web/data/cubicweb.ajax.js |
393 jQuery(document).ready(function() { |
394 jQuery(document).ready(function() { |
394 _loadDynamicFragments(); |
395 _loadDynamicFragments(); |
395 }); |
396 }); |
|
397 ======= |
|
398 |
|
399 jQuery(document).ready(function() {loadDynamicFragments();}); |
|
400 |
|
401 //============= base AJAX functions to make remote calls =====================// |
|
402 |
|
403 function remoteCallFailed(err, req) { |
|
404 if (req.status == 500) { |
|
405 updateMessage(err); |
|
406 } else { |
|
407 log(err); |
|
408 updateMessage(_("an error occured while processing your request")); |
|
409 } |
|
410 } |
|
411 |
|
412 |
|
413 /* |
|
414 * This function will call **synchronously** a remote method on the cubicweb server |
|
415 * @param fname: the function name to call (as exposed by the JSONController) |
|
416 * |
|
417 * additional arguments will be directly passed to the specified function |
|
418 * |
|
419 * It looks at http headers to guess the response type. |
|
420 */ |
|
421 function remoteExec(fname /* ... */) { |
|
422 setProgressCursor(); |
|
423 var props = {'fname' : fname, 'pageid' : pageid, |
|
424 'arg': map(jQuery.toJSON, sliceList(arguments, 1))}; |
|
425 var result = jQuery.ajax({url: JSON_BASE_URL, data: props, async: false}).responseText; |
|
426 if (result) { |
|
427 result = evalJSON(result); |
|
428 } |
|
429 resetCursor(); |
|
430 return result; |
|
431 } |
|
432 |
|
433 /* |
|
434 * This function will call **asynchronously** a remote method on the json |
|
435 * controller of the cubicweb http server |
|
436 * |
|
437 * @param fname: the function name to call (as exposed by the JSONController) |
|
438 * |
|
439 * additional arguments will be directly passed to the specified function |
|
440 * |
|
441 * It looks at http headers to guess the response type. |
|
442 */ |
|
443 |
|
444 function asyncRemoteExec(fname /* ... */) { |
|
445 setProgressCursor(); |
|
446 var props = {'fname' : fname, 'pageid' : pageid, |
|
447 'arg': map(jQuery.toJSON, sliceList(arguments, 1))}; |
|
448 // XXX we should inline the content of loadRemote here |
|
449 var deferred = loadRemote(JSON_BASE_URL, props, 'POST'); |
|
450 deferred = deferred.addErrback(remoteCallFailed); |
|
451 deferred = deferred.addErrback(resetCursor); |
|
452 deferred = deferred.addCallback(resetCursor); |
|
453 return deferred; |
|
454 } |
|
455 |
|
456 |
|
457 /* emulation of gettext's _ shortcut |
|
458 */ |
|
459 function _(message) { |
|
460 return remoteExec('i18n', [message])[0]; |
|
461 } |
|
462 |
|
463 function userCallback(cbname) { |
|
464 asyncRemoteExec('user_callback', cbname); |
|
465 } |
|
466 >>>>>>> /tmp/cubicweb.ajax.js~other.YR3yr8 |
396 |
467 |
397 function unloadPageData() { |
468 function unloadPageData() { |
398 // NOTE: do not make async calls on unload if you want to avoid |
469 // NOTE: do not make async calls on unload if you want to avoid |
399 // strange bugs |
470 // strange bugs |
400 loadRemote('json', ajaxFuncArgs('unload_page_data'), 'GET', true); |
471 loadRemote('json', ajaxFuncArgs('unload_page_data'), 'GET', true); |