31f2c965632c23b0e0982d5a2f71de429bdda4eb larrym Mon Mar 7 17:10:17 2011 -0800 use built-in autocomplete if newJQuery is true diff --git src/hg/js/autocomplete.js src/hg/js/autocomplete.js index 31c0516..ec6123f 100644 --- src/hg/js/autocomplete.js +++ src/hg/js/autocomplete.js @@ -1,78 +1,79 @@ // support stuff for auto-complete using jquery.autocomplete.js // // requires ajax.js // requires utils.js var suggestCache; -function ajaxGet(getDb, cache) +function ajaxGet(getDb, cache, newJQuery) { // Returns jquery.autocomplete.js ajax_get function object // getDb should be a function which returns the relevant assembly (e.g. "hg18") // cache is an optional object used as a hash to cache responses from the server. suggestCache = cache; - return function (key, cont) { + return function (request, callback) { + var key = newJQuery ? request.term : request; if(suggestCache == null || suggestCache[key] == null) { $.ajax({ url: "../cgi-bin/hgSuggest", data: "db=" + getDb() + "&prefix=" + key, // dataType: "json", // XXXX this doesn't work under IE, so we retrieve as text and do an eval to force to an object. trueSuccess: handleSuggest, success: catchErrorOrDispatch, error: function (request, status, errorThrown) { if (typeof console != "undefined") { console.dir(request); console.log(status); } var msg = "ajax call failed"; if(status != "error") msg = msg + "; error: " + status; showWarning(msg + "; statusText: " + request.statusText + "; responseText: " + request.responseText); }, key: key, - cont: cont + cont: callback }); } else { - cont(eval(suggestCache[key])); + callback(eval(suggestCache[key])); } // showWarning(request.term); } } function handleSuggest(response, status) { // We seem to get a lot of duplicate requests (especially the first letters of words), // so we keep a cache of the suggestions lists we've retreived. if(suggestCache != null) suggestCache[this.key] = response; this.cont(eval(response)); } function lookupGene(db, gene) { // returns coordinates for gene (requires an exact match). // Warning: this function does a synchronous ajax call. // first look in our local cache. if(suggestCache && suggestCache[gene]) { var list = eval(suggestCache[gene]); for(var i=0;i