Ignore:
Timestamp:
2017-03-28T17:04:10+13:00 (7 years ago)
Author:
ak19
Message:

Next incremental change to adding user comments in GS3. This time to make the get-meta-array and set-meta-array functions be called asynchronously from user_comments.js (these operations can be called synchronously by any others wishing to tuse them, and do so by default). user_comments.js chooses to call get-meta-array and even set-meta-array asynchronously by passing in the appropriate flag to make the ajax calls asynchronous. To protect against any overlapping read/write issues and mutliple submit comments (set-meta-array calls) from being fired off with overlap, the submit button gets disabled until the set-meta-array call has returned and its callback is called. Similarly, the submit button is disabled until the page has finished loading existing user comments (get-meta-array call).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/javascript-global-functions.js

    r31542 r31543  
    592592// behaviour of calling set-metadata-array. E.g. where=import|archives|index
    593593// THIS METHOD IS SYNCHRONOUS
    594 gs.functions.setMetadataArray = function(collection, site, docArray, metamode, where, responseFunction)
     594gs.functions.setMetadataArray = function(collection, site, docArray, metamode, where, responseFunction, forceSync)
    595595{
    596596    docArrayJSON = JSON.stringify(docArray);
     
    610610    }
    611611   
    612 
    613     var response = callMetadataServer("Setting metadata in "+where, "cgi-bin/metadata-server.pl?"+params, responseFunction);
     612    // set operations are generally synchronous, but allow calling function to force ajax call
     613    // to be synchronous or not. Default is synchronous, as it was for GS2
     614    if(forceSync == null) {
     615    forceSync = true;
     616    }
     617
     618    var response = callMetadataServer("Setting metadata in "+where, "cgi-bin/metadata-server.pl?"+params, responseFunction, {"forceSync": forceSync});
    614619
    615620    return response;
     
    625630// See description for setMetadataArray above for information about the 'where' parameter.
    626631// THIS METHOD IS SYNCHRONOUS BY DEFAULT. Set forceSync to false to override this default behaviour
    627 gs.functions.getMetadataArray = function(collection, site, docArray, where, forceSync, responseFunction)
     632gs.functions.getMetadataArray = function(collection, site, docArray, where, responseFunction, forceSync)
    628633{
    629634    docArrayJSON = JSON.stringify(docArray);
Note: See TracChangeset for help on using the changeset viewer.