summaryrefslogtreecommitdiff
path: root/web-app/static/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'web-app/static/util.js')
-rw-r--r--web-app/static/util.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/web-app/static/util.js b/web-app/static/util.js
new file mode 100644
index 0000000..8c4e948
--- /dev/null
+++ b/web-app/static/util.js
@@ -0,0 +1,31 @@
+
+function parse_query(s) {
+ var searchStr = s;
+ var section = location.hash.substring(1,location.hash.length);
+ var searchArray = new Array();
+
+ while (searchStr!='') {
+ var name, value;
+ // strip off leading ? or &
+ if ((searchStr.charAt(0)=='?')||(searchStr.charAt(0)=='&')) searchStr = searchStr.substring(1,searchStr.length);
+ // find name
+ name = searchStr.substring(0,searchStr.indexOf('='));
+ // find value
+ if (searchStr.indexOf('&')!=-1)
+ value = searchStr.substring(searchStr.indexOf('=')+1,searchStr.indexOf('&'));
+ else
+ value = searchStr.substring(searchStr.indexOf('=')+1,searchStr.length);
+ // add pair to an associative array
+ searchArray[name] = value;
+ // cut first pair from string
+ if (searchStr.indexOf('&')!=-1)
+ searchStr = searchStr.substring(searchStr.indexOf('&')+1,searchStr.length);
+ else
+ searchStr = '';
+ // debug step
+ //document.write(name + ': ' + value + ': ' + searchStr + '<br>');
+ }
+
+ return searchArray;
+}
+