JS gevorderde |
|
Edit:
Ok, ik heb nu de volgende code:
function alertMsg(type,methode,error,msg){ // alert msg; 'n'=normal / 'g'=GM_log / 'c'=control: '1'=debug / '2'=info / '3'=warn / '4'=error
contact = "\nContact. : Please contact the owner/scripter about this problem.";
if (typeof(console)!="undefined"&&type!='g'&&type!='n') {
if (methode==1) console.debug("Error Nr : " + error + " (console)\n" + "Message : " + msg + contact);
else if (methode==2) console.info("Error Nr : " + error + " (console)\n" + "Message : " + msg + contact);
else if (methode==3) console.warn("Error Nr : " + error + " (console)\n" + "Message : " + msg + contact);
else if (methode==4) console.error("Error Nr : " + error + " (console)\n" + "Message : " + msg + contact);
else console.warn("Error Nr : " + error + " (console)\n" + "Message : " + msg + contact);
}
if (typeof(GM_log)!="undefined"&&type!='c'&&type!='n') {
GM_log("Error Nr. : " + error + " (GM_log)\n" + "Message : " + msg + contact);
}
if (type!='c'&&type!='g') alert("Error Nr. : " + error + " (normal)\n" + "Message : " + msg + contact);
else alert("Error Nr. : " + error + " (else)\n" + "Message : " + msg + contact);
}
// als n.v.t. vul dan '' in!
alertMsg('c',1,'0001',"test console debug");
alertMsg('c',2,'0002',"test console info");
alertMsg('c',3,'0003',"test console warn");
alertMsg('c',4,'0004',"test console error");
alertMsg('c',5,'0005',"test console -> warn");
alertMsg('g','','0006',"test GM");
alertMsg('n','','0007',"test normal");
alertMsg('','','0008',"test all ( + console -> warn)");
alertMsg('',4,'0009',"test all ( + console error)");
alertMsg('x',5,'0010',"test all ( + console -> warn");
function alertMsg(type,methode,error,msg){ // alert msg; 'n'=normal / 'g'=GM_log / 'c'=control: '1'=debug / '2'=info / '3'=warn / '4'=error contact = "\nContact. : Please contact the owner/scripter about this problem."; if (typeof(console)!="undefined"&&type!='g'&&type!='n') { if (methode==1) console.debug("Error Nr : " + error + " (console)\n" + "Message : " + msg + contact); else if (methode==2) console.info("Error Nr : " + error + " (console)\n" + "Message : " + msg + contact); else if (methode==3) console.warn("Error Nr : " + error + " (console)\n" + "Message : " + msg + contact); else if (methode==4) console.error("Error Nr : " + error + " (console)\n" + "Message : " + msg + contact); else console.warn("Error Nr : " + error + " (console)\n" + "Message : " + msg + contact); } if (typeof(GM_log)!="undefined"&&type!='c'&&type!='n') { GM_log("Error Nr. : " + error + " (GM_log)\n" + "Message : " + msg + contact); } if (type!='c'&&type!='g') alert("Error Nr. : " + error + " (normal)\n" + "Message : " + msg + contact); else alert("Error Nr. : " + error + " (else)\n" + "Message : " + msg + contact); } // als n.v.t. vul dan '' in! alertMsg('c',1,'0001',"test console debug"); alertMsg('c',2,'0002',"test console info"); alertMsg('c',3,'0003',"test console warn"); alertMsg('c',4,'0004',"test console error"); alertMsg('c',5,'0005',"test console -> warn"); alertMsg('g','','0006',"test GM"); alertMsg('n','','0007',"test normal"); alertMsg('','','0008',"test all ( + console -> warn)"); alertMsg('',4,'0009',"test all ( + console error)"); alertMsg('x',5,'0010',"test all ( + console -> warn");
Ik vroeg me af of iemand hem even kon testen, want ik heb wat problemen met GreaseMonkey in Firefox 2.
ps. ik heb um werkend getest in IE 5t/m7 & Opera 9.2 & Netscape 8.1 & Netscape 9 met FireBug (& Swift 0.2 & K-Meleon 1.1). |