From: Andrew Dolgov Date: Wed, 24 Apr 2013 15:49:37 +0000 (+0400) Subject: add a simple JS-based hook host X-Git-Tag: 1.7.9~25^2~89 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=8d388f321b22691246393e3f812d42ab388c8c42;p=tt-rss.git add a simple JS-based hook host --- diff --git a/index.php b/index.php index bf78be1f..6a34be5e 100644 --- a/index.php +++ b/index.php @@ -100,7 +100,7 @@ require 'lib/jshrink/Minifier.php'; print get_minified_js(array("tt-rss", - "functions", "feedlist", "viewfeed", "FeedTree")); + "functions", "feedlist", "viewfeed", "FeedTree", "PluginHost")); foreach (PluginHost::getInstance()->get_plugins() as $n => $p) { if (method_exists($p, "get_js")) { diff --git a/js/feedlist.js b/js/feedlist.js index f4e07517..2c1acc31 100644 --- a/js/feedlist.js +++ b/js/feedlist.js @@ -139,6 +139,7 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req) { onComplete: function(transport) { setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif'); headlines_callback2(transport, offset, background, infscroll_req); + PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]); } }); } catch (e) { diff --git a/js/tt-rss.js b/js/tt-rss.js index 9e4cb63c..3f854514 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -40,6 +40,8 @@ function setActiveFeedId(id, is_cat) { $("headlines-frame").setAttribute("is-cat", is_cat ? 1 : 0); selectFeed(id, is_cat); + + PluginHost.run(PluginHost.HOOK_FEED_SET_ACTIVE, _active_article_id); } catch (e) { exception_error("setActiveFeedId", e); } diff --git a/js/viewfeed.js b/js/viewfeed.js index ddee1e46..14ef2f81 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -232,6 +232,8 @@ function render_article(article) { c.domNode.scrollTop = 0; } catch (e) { }; + PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED, article); + c.attr('content', article); correctHeadlinesOffset(getActiveArticleId()); @@ -1193,6 +1195,7 @@ function cdmScrollToArticleId(id, force) { function setActiveArticleId(id) { _active_article_id = id; + PluginHost.run(PluginHost.HOOK_ARTICLE_SET_ACTIVE, _active_article_id); } function getActiveArticleId() { @@ -1219,6 +1222,8 @@ function unpackVisibleHeadlines() { var cencw = $("CENCW-" + child.id.replace("RROW-", "")); if (cencw) { + PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, child); + cencw.innerHTML = htmlspecialchars_decode(cencw.innerHTML); cencw.setAttribute('id', ''); Element.show(cencw);