1 /* ---------------------------------------------------------------------------
2 * Copyright (C) 2008 Georgia Public Library Service
3 * Bill Erickson <erickson@esilibrary.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * ---------------------------------------------------------------------------
17 if(!dojo._hasResource["openils.CGI"]) {
19 dojo._hasResource["openils.CGI"] = true;
20 dojo.provide("openils.CGI");
21 dojo.declare('openils.CGI', null, {
23 constructor : function() {
25 this._keys = new Array();
26 this.data = new Object();
28 var string = location.search.replace(/^\?/,"");
29 this.server_name = location.href.replace(/^https?:\/\/([^\/]+).+$/,"$1");
36 for( var idx = 0; idx!= string.length; idx++ ) {
38 var c = string.charAt(idx);
46 if(c == "&" || c == ";") {
49 if( ! this.data[key] ) this.data[key] = [];
50 this.data[key].push(decodeURIComponent(value));
57 else if(invalue) value += c;
60 if( ! this.data[key] ) this.data[key] = [];
61 this.data[key].push(decodeURIComponent(value));
65 /* returns the value for the given param. If there is only one value for the
66 given param, it returns that value. Otherwise it returns an array of values
69 if(this.data[p] == null) return null;
70 if(this.data[p].length == 1)
71 return this.data[p][0];
75 /* returns an array of param names */
80 /* debugging method */
81 toString : function() {
83 var keys = this.keys();
85 for( var k in keys ) {
86 string += keys[k] + " : ";
87 var params = this.param(keys[k]);
89 for( var p in params ) {
90 string += params[p] + " ";