]> git.wh0rd.org Git - tt-rss.git/blob - js/PluginHost.js
body: disable overflow
[tt-rss.git] / js / PluginHost.js
1 // based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system
2
3 var 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         HOOK_ARTICLE_EXPANDED: 6,
10         HOOK_ARTICLE_COLLAPSED: 7,
11         HOOK_PARAMS_LOADED: 8,
12         HOOK_RUNTIME_INFO_LOADED: 9,
13         HOOK_FLOATING_TITLE: 10,
14         hooks: [],
15         register: function (name, callback) {
16                 if (typeof(this.hooks[name]) == 'undefined')
17                         this.hooks[name] = [];
18
19                 this.hooks[name].push(callback);
20         },
21         run: function (name, args) {
22                 console.warn('PluginHost::run ' + name);
23
24                 if (typeof(this.hooks[name]) != 'undefined')
25                         for (i = 0; i < this.hooks[name].length; i++)
26                                 if (!this.hooks[name][i](args)) break;
27         }
28 };
29
30 /* PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED,
31                 function (args) { console.log('ARTICLE_RENDERED: ' + args); return true; });
32
33 PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM,
34                 function (args) { console.log('ARTICLE_RENDERED_CDM: ' + args); return true; }); */
35