2 /* load up the url parameters */
4 this._keys = new Array();
5 this.data = new Object();
7 var string = location.search.replace(/^\?/,"");
14 for( var idx = 0; idx!= string.length; idx++ ) {
16 var c = string.charAt(idx);
24 if(c == "&" || c == ";") {
27 if( ! this.data[key] ) this.data[key] = [];
28 this.data[key].push(decodeURIComponent(value));
35 else if(invalue) value += c;
38 if( ! this.data[key] ) this.data[key] = [];
39 this.data[key].push(decodeURIComponent(value));
43 /* returns the value for the given param. If there is only one value for the
44 given param, it returns that value. Otherwise it returns an array of values
46 CGI.prototype.param = function(p) {
47 if(this.data[p] == null) return null;
48 if(this.data[p].length == 1)
49 return this.data[p][0];
53 /* returns an array of param names */
54 CGI.prototype.keys = function() {
59 CGI.prototype.toString = function() {
61 var keys = this.keys();
63 for( var k in keys ) {
64 string += keys[k] + " : ";
65 var params = this.param(keys[k]);
67 for( var p in params ) {
68 string += params[p] + " ";