]> git.wh0rd.org - tt-rss.git/blame - js/PluginHost.js
add missing pluginhost source
[tt-rss.git] / js / PluginHost.js
CommitLineData
a06045ad
AD
1// based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system
2
3var PluginHost = {
4 HOOK_ARTICLE_RENDERED: 1,
5 HOOK_ARTICLE_RENDERED_CDM: 2,
6 HOOK_ARTICLE_SET_ACTIVE: 3,
7 HOOK_FEED_SET_ACTIVE: 4,
8 HOOK_FEED_LOADED: 5,
9 hooks: [],
10 register: function (name, callback) {
11 if (typeof(this.hooks[name]) == 'undefined')
12 this.hooks[name] = [];
13
14 this.hooks[name].push(callback);
15 },
16 run: function (name, args) {
17 console.warn('PluginHost::run ' + name);
18
19 if (typeof(this.hooks[name]) != 'undefined')
20 for (i = 0; i < this.hooks[name].length; i++)
21 if (!this.hooks[name][i](args)) break;
22 }
23};
24
25/* PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED,
26 function (args) { console.log('ARTICLE_RENDERED: ' + args); return true; });
27
28PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM,
29 function (args) { console.log('ARTICLE_RENDERED_CDM: ' + args); return true; }); */
30