summaryrefslogtreecommitdiffstats
path: root/etherpad/src/static/js/plugins.js
blob: d1d6b1440653cdfd2ccd4a57eb8454c0d686affb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
  },

  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 || "");
  }
};