summaryrefslogtreecommitdiff
path: root/js/PluginHost.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-05-07 15:36:14 +0400
committerAndrew Dolgov <[email protected]>2013-05-07 15:36:14 +0400
commit82076ce53113be9cc053f8740356e7e1b81e5643 (patch)
tree5eba36805f593ec7dd0aad671b5bcca0ae01cf53 /js/PluginHost.js
parent66af65f14b4f3c670bb3f9ca7b1c80081f9281d1 (diff)
parent23923fb29b345c1eea5b70a6df4d30395425bf37 (diff)
Merge branch 'master' into css-feedtree-counter
Conflicts: tt-rss.css
Diffstat (limited to 'js/PluginHost.js')
-rw-r--r--js/PluginHost.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/js/PluginHost.js b/js/PluginHost.js
new file mode 100644
index 000000000..668d215f9
--- /dev/null
+++ b/js/PluginHost.js
@@ -0,0 +1,34 @@
+// 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,
+ HOOK_ARTICLE_EXPANDED: 6,
+ HOOK_ARTICLE_COLLAPSED: 7,
+ HOOK_PARAMS_LOADED: 8,
+ HOOK_RUNTIME_INFO_LOADED: 9,
+ 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; }); */
+