aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--underlays/javascript/ikiwiki.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/underlays/javascript/ikiwiki.js b/underlays/javascript/ikiwiki.js
index 29de7ec6f..14ddd0745 100644
--- a/underlays/javascript/ikiwiki.js
+++ b/underlays/javascript/ikiwiki.js
@@ -1,6 +1,6 @@
// ikiwiki's javascript utility function library
-var hooks = new Array;
+var hooks;
window.onload = run_hooks_onload;
function run_hooks_onload() {
@@ -8,16 +8,19 @@ function run_hooks_onload() {
}
function run_hooks(name) {
- for (var i = 0; i < hooks.length; i++) {
- if (hooks[i].name == name) {
- hooks[i].call();
+ if (typeof(hooks) != "undefined") {
+ for (var i = 0; i < hooks.length; i++) {
+ if (hooks[i].name == name) {
+ hooks[i].call();
+ }
}
}
}
function hook(name, call) {
- var h={name: name, call: call};
- hooks.push(h);
+ if (typeof(hooks) == "undefined")
+ hooks = new Array;
+ hooks.push({name: name, call: call});
}
function getElementsByClass(cls, node, tag) {