From a06045adf033a232c12cfdce1ebcc8fdaedcc3eb Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 24 Apr 2013 19:51:57 +0400 Subject: [PATCH] add missing pluginhost source --- js/PluginHost.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 js/PluginHost.js diff --git a/js/PluginHost.js b/js/PluginHost.js new file mode 100644 index 000000000..a3a31ce9c --- /dev/null +++ b/js/PluginHost.js @@ -0,0 +1,30 @@ +// based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system + +var PluginHost = { + HOOK_ARTICLE_RENDERED: 1, + HOOK_ARTICLE_RENDERED_CDM: 2, + HOOK_ARTICLE_SET_ACTIVE: 3, + HOOK_FEED_SET_ACTIVE: 4, + HOOK_FEED_LOADED: 5, + hooks: [], + register: function (name, callback) { + if (typeof(this.hooks[name]) == 'undefined') + this.hooks[name] = []; + + this.hooks[name].push(callback); + }, + run: function (name, args) { + console.warn('PluginHost::run ' + name); + + if (typeof(this.hooks[name]) != 'undefined') + for (i = 0; i < this.hooks[name].length; i++) + if (!this.hooks[name][i](args)) break; + } +}; + +/* PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED, + function (args) { console.log('ARTICLE_RENDERED: ' + args); return true; }); + +PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, + function (args) { console.log('ARTICLE_RENDERED_CDM: ' + args); return true; }); */ +