2 /* load up the url parameters */
4 this._keys = new Array();
5 this.data = new Object();
7 var string = location.search.replace(/^\?/,"");
8 this.server_name = location.href.replace(/^https?:\/\/([^\/]+).+$/,"$1");
15 for( var idx = 0; idx!= string.length; idx++ ) {
17 var c = string.charAt(idx);
25 if(c == "&" || c == ";") {
28 if( ! this.data[key] ) this.data[key] = [];
29 this.data[key].push(decodeURIComponent(value));
36 else if(invalue) value += c;
39 if( ! this.data[key] ) this.data[key] = [];
40 this.data[key].push(decodeURIComponent(value));
44 /* returns the value for the given param. If there is only one value for the
45 given param, it returns that value. Otherwise it returns an array of values
47 CGI.prototype.param = function(p) {
48 if(this.data[p] == null) return null;
49 if(this.data[p].length == 1)
50 return this.data[p][0];
54 /* returns an array of param names */
55 CGI.prototype.keys = function() {
60 CGI.prototype.toString = function() {
62 var keys = this.keys();
64 for( var k in keys ) {
65 string += keys[k] + " : ";
66 var params = this.param(keys[k]);
68 for( var p in params ) {
69 string += params[p] + " ";