[Greasemonkey] A function to ask for passwords
Edward Lee
edilee at gmail.com
Tue Jul 5 11:23:41 EDT 2005
Just some quick comments.. You don't need to set the id's of the div
or buttons because you can just store them as variables. That'll
prevent the script from adding extra id's to the document. There'll
have to be a wrapper of some sort around the function to provide
storage for the div variable if you don't want to pollute the global
variable space (cont_function goes to the window right now..) But if
you have the buttons as variables instead of innerHTML stuff, you can
do buttonOK.addEventListener('onclick', function() { ...
And continuations do seem to be working.. at least in this example I tested.
function fact(n, k) {
if (n < 2) {
return k(1);
} else {
return fact(n - 1, function(r) {
return k(n * r);
});
}
}
fact(1, function(x) { return x;});
1
fact(3, function(x) { return x;});
6
fact(5, function(x) { return x;});
120
Fun with javascript :)
--
Ed
More information about the Greasemonkey
mailing list