c79deb301511fcf0de0ed376c7746e4902804472 chmalee Fri May 5 16:59:33 2023 -0700 Experiment number one, can succesfully upload a file and store it via hgCustom. New userdata library for managing where to store the files Get skeleton structure of new cgi together More work in progress, mostly stubbing out the CGI More work in progress, mostly stubbing out the html page diff --git src/hg/js/hgSearch.js src/hg/js/hgSearch.js index cd3c0fa..8902cd9 100644 --- src/hg/js/hgSearch.js +++ src/hg/js/hgSearch.js @@ -42,127 +42,30 @@ // This object that is the parent for all tracks currently visible on hgTracks var visibleTrackGroup = { id: "Visible Tracks", name: "Visible Tracks", label: "Visible Tracks", text: "Visible Tracks", numMatches: 0, searchTime: -1, li_attr: {title: "Search for track items in all the currently visible searchable tracks"}, children: [], state: {opened: true, loaded: true}, priority: 0.0 }; - // variables to parse url arguments correctly - var digitTest = /^\d+$/, - keyBreaker = /([^\[\]]+)|(\[\])/g, - plus = /\+/g, - paramTest = /([^?#]*)(#.*)?$/; - - function deparam(params) { - /* From https://github.com/jupiterjs/jquerymx/blob/master/lang/string/deparam/deparam.js - * Used by the cell browser */ - if(! params || ! paramTest.test(params) ) { - return {}; - } - - var data = {}, - pairs = params.split('&'), - current; - - for (var i=0; i < pairs.length; i++){ - current = data; - var pair = pairs[i].split('='); - - // if we find foo=1+1=2 - if(pair.length !== 2) { - pair = [pair[0], pair.slice(1).join("=")]; - } - - var key = decodeURIComponent(pair[0].replace(plus, " ")), - value = decodeURIComponent(pair[1].replace(plus, " ")), - parts = key.match(keyBreaker); - - for ( var j = 0; j < parts.length - 1; j++ ) { - var part = parts[j]; - if (!current[part] ) { - //if what we are pointing to looks like an array - current[part] = digitTest.test(parts[j+1]) || parts[j+1] === "[]" ? [] : {}; - } - current = current[part]; - } - var lastPart = parts[parts.length - 1]; - if (lastPart === "[]"){ - current.push(value); - } else{ - current[lastPart] = value; - } - } - return data; - } - - function changeUrl(vars, oldVars) { - /* Save the users search string to the url so web browser can easily - * cache search results into the browser history - * vars: object of new key: val pairs like CGI arguments - * oldVars: arguments we want to keep between calls */ - var myUrl = window.location.href; - myUrl = myUrl.replace('#',''); - var urlParts = myUrl.split("?"); - var baseUrl; - if (urlParts.length > 1) - baseUrl = urlParts[0]; - else - baseUrl = myUrl; - - var urlVars; - if (typeof oldVars === "undefined") { - var queryStr = urlParts[1]; - urlVars = deparam(queryStr); - } else { - urlVars = oldVars; - } - - for (var key in vars) { - var val = vars[key]; - if (val === null || val === "") { - if (key in urlVars) { - delete urlVars[key]; - } - } else { - urlVars[key] = val; - } - } - - var argStr = jQuery.param(urlVars); - argStr = argStr.replace(/%20/g, "+"); - - return {"baseUrl": baseUrl, "args": argStr, "urlVars": urlVars}; - } - - function saveHistory(obj, urlParts, replace) { - /* Save an object to the web browser's history stack. When we visit the page for the - * first time, we replace the basic state after we are done making the initial UI */ - if (replace) { - history.replaceState(obj, "", urlParts.baseUrl + (urlParts.args.length !== 0 ? "?" + urlParts.args : "")); - } else { - history.pushState(obj, "", urlParts.baseUrl + (urlParts.args.length !== 0 ? "?" + urlParts.args : "")); - } - } - function compareTrack(trackA, trackB) { /* comparator function for sorting tracks, lowest priority wins, * followed by short label */ priorityA = trackA.priority; priorityB = trackB.priority; // if both priorities are undefined or equal to each other, sort // on shortlabel alphabetically if (priorityA === priorityB) { if (trackA.name < trackB.name) { return -1; } else if (trackA.name > trackB.name) { return 1; } else { return 0;