/**//*
* This function parses comma-separated name = value argument pairs from
* The query string of the URL. It stores the name = value pairs in
* Properties of an object and returns that object.
*/
Function getargs ()...{
VaR ARGs = new object ();
VaR query = location. Search. substring (1); // get query string.
VaR pairs = query. Split (","); // break at comma.
For (VAR I = 0; I <pairs. length; I ++ )...{
VaR Pos = pairs [I]. indexof ('='); // look for "name = value ".
If (Pos =-1) continue; // if not found, Skip.
VaR argname = pairs [I]. substring (0, POS); // extract the name.
VaR value = pairs [I]. substring (Pos + 1); // extract the value.
ARGs [argname] = Unescape (value); // store as a property.
// In JavaScript 1.5, use decodeuricomponent () instead of escape ()
}
Return ARGs; // return the object.
}
/**//*
* Example test. php? X = 1 & Y = 2 ....
*/
VaR ARGs = getargs (); // get arguments.
If (ARGs. X) x = parseint (ARGs. X); // If arguments are defined...
If (ARGs. Y) y = parseint (ARGs. Y); //... Override default values.
If (ARGs. W) W = parseint (ARGs. W );
If (ARGs. h) H = parseint (ARGs. H );
If (ARGs. dx) dx = parseint (ARGs. dx );
If (ARGs. Dy) dy = parseint (ARGs. Dy );
If (ARGs. interval) interval = parseint (ARGs. interval );