diff options
author | Egil Moeller <egil.moller@freecode.no> | 2010-03-22 19:59:04 +0100 |
---|---|---|
committer | Egil Moeller <egil.moller@freecode.no> | 2010-03-22 19:59:04 +0100 |
commit | e19fc9f24ab128d4337d67d0e3f312a1ab0be38b (patch) | |
tree | 8a0b22c0842ee472df1e51d1277924d8a3796baf | |
parent | efffc8687a0fe92b993e9b65de3e4511df36815d (diff) | |
download | etherpad-e19fc9f24ab128d4337d67d0e3f312a1ab0be38b.tar.gz etherpad-e19fc9f24ab128d4337d67d0e3f312a1ab0be38b.tar.xz etherpad-e19fc9f24ab128d4337d67d0e3f312a1ab0be38b.zip |
Made the client side plugin API more similar to the server side one
-rw-r--r-- | etherpad/src/plugins/testplugin/static/js/test.js | 2 | ||||
-rw-r--r-- | etherpad/src/static/js/plugins.js | 38 |
2 files changed, 21 insertions, 19 deletions
diff --git a/etherpad/src/plugins/testplugin/static/js/test.js b/etherpad/src/plugins/testplugin/static/js/test.js index 0f30cd9..83fb40c 100644 --- a/etherpad/src/plugins/testplugin/static/js/test.js +++ b/etherpad/src/plugins/testplugin/static/js/test.js @@ -1 +1 @@ -callHook("kafoo"); +plugins.callHook("kafoo"); diff --git a/etherpad/src/static/js/plugins.js b/etherpad/src/static/js/plugins.js index 6d8804e..d1d6b14 100644 --- a/etherpad/src/static/js/plugins.js +++ b/etherpad/src/static/js/plugins.js @@ -1,19 +1,21 @@ -function callHook(hookName, args) { - if (clientVars.hooks[hookName] === undefined) - return []; - var res = []; - for (i = 0; i < clientVars.hooks[hookName].length; i++) { - var plugin = clientVars.hooks[hookName][i]; - var pluginRes = eval(plugin.plugin)[plugin.original || hookName](args); - if (pluginRes != undefined && pluginRes != null) - res = res.concat(pluginRes); - } - return res; -} +plugins = { + callHook: function (hookName, args) { + if (clientVars.hooks[hookName] === undefined) + return []; + var res = []; + for (i = 0; i < clientVars.hooks[hookName].length; i++) { + var plugin = clientVars.hooks[hookName][i]; + var pluginRes = eval(plugin.plugin)[plugin.original || hookName](args); + if (pluginRes != undefined && pluginRes != null) + res = res.concat(pluginRes); + } + return res; + }, -function callHookStr(hookName, args, sep, pre, post) { - if (sep == undefined) sep = ''; - if (pre == undefined) pre = ''; - if (post == undefined) post = ''; - return callHook(hookName, args).map(function (x) { return pre + x + post}).join(sep || ""); -} + callHookStr: function (hookName, args, sep, pre, post) { + if (sep == undefined) sep = ''; + if (pre == undefined) pre = ''; + if (post == undefined) post = ''; + return callHook(hookName, args).map(function (x) { return pre + x + post}).join(sep || ""); + } +}; |