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 this.data[key] = decodeURIComponent(value);
34 else if(invalue) value += c;
37 this.data[key] = decodeURIComponent(value);
41 /* returns the value for the given param. If there is only one value for the
42 given param, it returns that value. Otherwise it returns an array of values
44 CGI.prototype.param = function(p) {
45 if(this.data[p] == null) return null;
47 if(this.data[p].length == 1)
48 return this.data[p][0];
52 /* returns an array of param names */
53 CGI.prototype.keys = function() {
58 CGI.prototype.toString = function() {
60 var keys = this.keys();
62 for( var k in keys ) {
63 string += keys[k] + " : ";
64 var params = this.param(keys[k]);
66 for( var p in params ) {
67 string += params[p] + " ";