660387765d7bd58729c204580b26bd016b0afeaa chmalee Mon Nov 21 14:30:49 2022 -0800 Do a quick async chromosome name lookup before sending a full search request from hgTracks/hgGateway diff --git src/hg/js/model/lib/cart.js src/hg/js/model/lib/cart.js index c02668e..40c91b0 100644 --- src/hg/js/model/lib/cart.js +++ src/hg/js/model/lib/cart.js @@ -31,30 +31,31 @@ // jqueryFileInput, // handleServerResponse, handleServerFailure); // // After all UI handlers have executed (ImModel does this): // cart.flush(); var cart = (function() { 'use strict'; // Private variables: var cgiBinUrl = '../cgi-bin/'; // cart.setCgi(name) sets this to cgiBinUrl + name, and must be called before sending requests: var cgiUrl; + var cgiName; // get sets by cart.setCgi() // accumulator for cgiVars passed in to send() before flush() is called: var cgiVars = {}; // queue of commands from send() and uploadFile(), to send with accumulated cgiVars // when flush() is called: var requestQueue = []; // debugging flag for console.log messages var debug = false; // Private functions: function checkCommandObjType(commandObj) { // Make sure commandObj has the correct structure: an object of objects. @@ -194,34 +195,38 @@ fileInputs: jqFileInput }); debugLog('cart.flush: using jquery.bifrost plugin for input ' + fileInputName + ', data =', reqObj, ', params = ' + paramString); } return ajaxParams; } // Return cart object with public methods. return { defaultErrorCallback: function (jqXHR, textStatus) { defaultErrorCallback(jqXHR, textStatus); }, + cgi: function() { + return cgiName; + }, setCgi: function(newCgi) { // Sets the name of the CGI (e.g. hgIntegrator, hgChooseDb etc). // This must be called before cart.send. + cgiName = newCgi; cgiUrl = cgiBinUrl + newCgi; }, send: function(commandObj, successCallback, errorCallback) { // Queue up commandObj and callbacks, merging cgiVars with those of othere queued reqs. // successCallback and the optional errorCallback are functions(jqXHR, textStatus) // Throws [message, badValue] if something is not as expected. var cmdObjNoCgiVar = processCommandObj(commandObj); // If this request contained only cgiVars (empty cmdObjNoCgiVar) then let those // go out with other requests. Below, flush will make sure that at least one request // is sent out if there are cgiVars. if (! _.isEmpty(cmdObjNoCgiVar) || successCallback || errorCallback) { requestQueue.push({ commandObj: cmdObjNoCgiVar, successCallback: successCallback, errorCallback: errorCallback });