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

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