Hi there,
I saw a web site using the following code to assign parameters for a
dynamic menu. If I want to do it using the variables. (for example:
menuwidth = 150; FontFamily = "Arial";...) How can I make the same
function as this code? I tried several way, but failed at last.
Thanks for your help!
Wendy
a_Parameters = [
["MenuWidth", 150, "number"],
["FontFamily", "Arial,sans-serif"],
["FontSize", 10, "number"],
["FontBold", false, "boolean"],
["FontItalic", false, "boolean"],
["ItemPadding", 3, "number"],
["BorderWidth", 2, "number"],
["BorderColor", "red"],
["SeparatorSize", 1, "number"],
["ImageSrc", "tri.gif"],
["ImageSrcLeft", "triL.gif"],
["ImageSize", 5, "number"],
["ImageSpc", 0, "number"],
["KeepHilite", false, "boolean"],
["ClickStart", false, "boolean"],
["TopSecondsVisible", .5, "number"],
["ChildSecondsVisible",.3, "number"],
["StatusDisplayLink", 1, "boolean"],
["UponDisplay", null, "delayed"],
["UponHide", null, "delayed"],
["RightToLeft", false, "boolean"],
["CreateTopOnly", 0, "boolean"],
["ShowLinkCursor", false, "boolean"],
["NSFontOver", true, "boolean"]
]
Function.prototype.isFunction = true;
Function.prototype.isString = false;
String.prototype.isFunction = false;
String.prototype.isString = true;
String.prototype.isBoolean = false;
String.prototype.isNumber = false;
Number.prototype.isString = false;
Number.prototype.isFunction = false;
Number.prototype.isBoolean = false;
Number.prototype.isNumber = true;
Boolean.prototype.isString = false;
Boolean.prototype.isFunction = false;
Boolean.prototype.isBoolean = true;
Boolean.prototype.isNumber = false;
function f_AssignParameters(paramarray){
var ParamName = paramarray[0];
var DefaultValue = paramarray[1];
eval(ParamName + "= DefaultValue");
}
function f_EvalParameters(valuenew,valueold,valuetype){
var TestString, ParPosition;
if(typeof valuenew == "undefined" || valuenew == null ||
(valuenew.isString && valuenew.length == 0)){
return valueold;
}
if(valuetype != "delayed"){
while(valuenew.isString) {
ParPosition = valuenew.indexOf("(");
if(ParPosition !=-1) {
TestString = "window." + valuenew.substr
(0,ParPosition);
if (typeof eval(TestString) != "undefined"
&& eval(TestString).isFunction) {
valuenew = eval(valuenew);
}
}
else break
}
}
while(valuenew.isFunction) {valuenew = valuenew()}
switch(valuetype){
case "number":
while (valuenew.isString) {valuenew = eval
(valuenew)}
break;
case "boolean":
while (!valuenew.isBoolean) {
valuenew = (valuenew.isNumber) ?
valuenew ? true : false : eval(valuenew);
}
break;
}
return valuenew;
}
for (i=0;i<a_Parameters.length;i++) {
f_AssignParameters(a_Parameters[i]);
eval(a_Parameters[i][0] + "= f_EvalParameters("+ a_Parameters[i]
[0] +",null,a_Parameters[i][2])")
}