From: helge Date: Wed, 23 Feb 2005 23:59:53 +0000 (+0000) Subject: added query parameter functions X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0786680095c6110d49e65c5e834ff9d6fae73dcc;p=scalable-opengroupware.org added query parameter functions git-svn-id: http://svn.opengroupware.org/SOGo/trunk@613 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/UI/WebServerResources/ChangeLog b/SOGo/UI/WebServerResources/ChangeLog new file mode 100644 index 00000000..f2fa178f --- /dev/null +++ b/SOGo/UI/WebServerResources/ChangeLog @@ -0,0 +1,5 @@ +2005-02-24 Helge Hess + + * generic.js: added query dict parsing and generation functions + + * created ChangeLog diff --git a/SOGo/UI/WebServerResources/generic.js b/SOGo/UI/WebServerResources/generic.js index 8cb97c5b..1d71b973 100644 --- a/SOGo/UI/WebServerResources/generic.js +++ b/SOGo/UI/WebServerResources/generic.js @@ -76,6 +76,48 @@ function refreshOpener() { } } +/* query string */ + +function parseQueryString() { + var queryArray, queryDict + var key, value, s, idx; + queryDict.length = 0; + + queryDict = new Array(); + queryArray = location.search.substr(1).split('&'); + for (var i in queryArray) { + if (!queryArray[i]) continue ; + s = queryArray[i]; + idx = s.indexOf("="); + if (idx == -1) { + key = s; + value = ""; + } + else { + key = s.substr(0, idx); + value = unescape(s.substr(idx + 1)); + } + + if (typeof queryDict[key] == 'undefined') + queryDict.length++; + + queryDict[key] = value; + } + return queryDict; +} + +function generateQueryString(queryDict) { + var s = "": + for (var key in queryDict) { + if (s.length == 0) + s = "?"; + else + s = s + "&"; + s = s + key + "=" + escape(queryDict[key]); + } + return s; +} + function getQueryParaArray(s) { if (s.charAt(0) == "?") s = s.substr(1, s.length - 1); return s.split("&"); @@ -96,6 +138,8 @@ function getQueryParaValue(s, name) { return null; } +/* opener callback */ + function triggerOpenerCallback() { /* this code has some issue if the folder has no proper trailing slash! */ if (window.opener && !window.opener.closed) {