- Timestamp:
- 2017-03-27T21:39:33+13:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/javascript-global-functions.js
r31537 r31542 424 424 // No function overloading in JavaScript. Can pass a custom object, however, see 425 425 // http://stackoverflow.com/questions/456177/function-overloading-in-javascript-best-practices 426 function callMetadataServer (callingFunction, url, responseFunction, opts)426 function callMetadataServerGET(callingFunction, url, responseFunction, opts) 427 427 { 428 428 var async_setting = true; // Internal processing of 'read' operations (get meta) is not order dependent … … 457 457 .success(function(response) 458 458 { 459 console.log("(" + callingFunction + ") Response received from server: " + response);459 console.log("(" + callingFunction + ") Response received from server: " + ajaxResponse); 460 460 461 461 ajaxResponse = response; … … 480 480 return ajaxResponse; 481 481 } 482 483 484 // No function overloading in JavaScript. Can pass a custom object, however, see 485 // http://stackoverflow.com/questions/456177/function-overloading-in-javascript-best-practices 486 function callMetadataServer(callingFunction, url, responseFunction, opts) 487 { 488 var async_setting = true; // Internal processing of 'read' operations (get meta) is not order dependent 489 490 // If doing set- or remove- (not get-) metadata, then rewrite URLs to call GS2Construct's ModfiyMetadata service instead (which will ensure this only works when authenticated). 491 // From: 492 // <gs3server>/cgi-bin/metadata-server.pl?a=set-archives-metadata&c=smallcol&site=localsite&d=HASH01454f31011f6b6b26eaf8d7&metaname=Title&metavalue=Moo&prevmetavalue=Blabla&metamode=override 493 // To: 494 // <gs3server>/library?a=g&rt=r&ro=1&s=ModifyMetadata&s1.a=set-archives-metadata&s1.collection=smallcol&s1.site=localsite&s1.d=HASH01454f31011f6b6b26eaf8d7&s1.metaname=Title&s1.metavalue=Moo&s1.prevmetavalue=Blabla&s1.metamode=override 495 496 // if we're doing a set- or remove- metadata operations, then we'll be changing the URL to make sure we go through GS3's authentication 497 if(url.indexOf("set-") != -1 || url.indexOf("remove-") != -1) { 498 499 url = url.replace("&c=", "&collection="); // c is a special param name for GS2Construct 500 url = url.replace(/(&|\?)([^=]*=)/g, "$1"+"s1.$2"); // prefix param names with "s1." 501 url = url.replace("cgi-bin/metadata-server.pl?", gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=ModifyMetadata&"); 502 503 //console.log("@@@@@ URL is " + url); 504 505 async_setting = false; // for 'write' operations (set/remove meta), we force sequential processing of the internal operation. 506 507 } // otherwise, such as for get- metadata operation, we proceed as before, which will not require authentication 508 509 if (opts != null) { 510 if(opts["forceSync"] != null) { 511 async_setting = (!opts["forceSync"]); 512 } 513 } 514 515 console.log("Away to call: " + url); 516 var ajaxResponse = "No response received yet, async ajax request"; 517 518 var splitURL = url.split("?"); 519 url = splitURL[0]; 520 var params = splitURL[1]; 521 var gsapi = new GSAjaxAPI(url); 522 523 // ajax calls default to using method GET, we want to do POST operations for get-meta and set-meta requests 524 // since get-meta-array and especially set-meta-array can be large, e.g. for user comments. 525 526 if(async_setting) { 527 gsapi.urlPostAsync(url, params, responseFunction); 528 } else { 529 ajaxResponse = gsapi.urlPostSync(url, params); 530 } 531 532 console.log("(" + callingFunction + ") Response received from server: " + ajaxResponse); 533 534 console.log("Finished ajax call to: " + url); 535 536 console.log("Got response: " + ajaxResponse); 537 return ajaxResponse; 538 } 539 482 540 483 541 /*************************
Note:
See TracChangeset
for help on using the changeset viewer.