mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 14:47:12 -04:00
UI refactoring and code clean-up
- Improved maintainability of UI (very much work still remaining) - Improved performance of UI - Consistent coding style
This commit is contained in:
parent
f93fba2511
commit
65ec8a1b47
29 changed files with 2069 additions and 3532 deletions
|
@ -1,37 +1,38 @@
|
|||
/**
|
||||
* This code is mostly from the old Etherpad. Please help us to comment this code.
|
||||
* This code is mostly from the old Etherpad. Please help us to comment this code.
|
||||
* This helps other people to understand this code better and helps them to improve it.
|
||||
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
|
||||
*/
|
||||
|
||||
var plugins = {
|
||||
callHook: function(hookName, args)
|
||||
{
|
||||
var global = (function () {return this}());
|
||||
var hook = ((global.clientVars || {}).hooks || {})[hookName];
|
||||
if (hook === undefined) return [];
|
||||
var res = [];
|
||||
for (var i = 0, N = hook.length; i < N; i++)
|
||||
{
|
||||
var plugin = hook[i];
|
||||
var pluginRes = eval(plugin.plugin)[plugin.original || hookName](args);
|
||||
if (pluginRes != undefined && pluginRes != null) res = res.concat(pluginRes);
|
||||
callHook: function(hookName, args) {
|
||||
var global = (function() {return this;}()),
|
||||
hook = ((global.clientVars || {}).hooks || {})[hookName],
|
||||
res = [];
|
||||
if (hook === undefined)
|
||||
return [];
|
||||
for (var i = 0, N = hook.length; i < N; i++) {
|
||||
var plugin = hook[i],
|
||||
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 = '';
|
||||
var newCallhooks = [];
|
||||
var callhooks = plugins.callHook(hookName, args);
|
||||
for (var i = 0, ii = callhooks.length; i < ii; i++) {
|
||||
callHookStr: function(hookName, args, sep, pre, post) {
|
||||
if (sep == undefined)
|
||||
sep = '';
|
||||
if (pre == undefined)
|
||||
pre = '';
|
||||
if (post == undefined)
|
||||
post = '';
|
||||
var newCallhooks = [],
|
||||
callhooks = plugins.callHook(hookName, args);
|
||||
for (var i=0, ii=callhooks.length; i < ii; i++) {
|
||||
newCallhooks[i] = pre + callhooks[i] + post;
|
||||
}
|
||||
return newCallhooks.join(sep || "");
|
||||
return newCallhooks.join(sep || '');
|
||||
}
|
||||
};
|
||||
|
||||
exports.plugins = plugins;
|
||||
exports.plugins = plugins;
|
Loading…
Add table
Add a link
Reference in a new issue