diff options
author | Andrew Dolgov <[email protected]> | 2018-11-30 13:26:41 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-11-30 13:26:41 +0300 |
commit | c8c9a26f3071edc2f0307336b6dd6062e4351773 (patch) | |
tree | 2cc1b6d1581eeab8984764758fbf07c8290cbaa3 /js/viewfeed.js | |
parent | da1a3c2cc5621bccdb844cfbd03e377ada079fa9 (diff) |
move to simpler CDM handling of encoded content (instead of CENCW... etc)
Diffstat (limited to 'js/viewfeed.js')
-rwxr-xr-x | js/viewfeed.js | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/js/viewfeed.js b/js/viewfeed.js index ed6e3642e..a24116e88 100755 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -1018,24 +1018,28 @@ function postMouseOut(id) { function unpackVisibleHeadlines() { if (!isCdmMode() || !getInitParam("cdm_expanded")) return; - $$("#headlines-frame span.cencw[id]").each( - function (child) { - const row = $("RROW-" + child.id.replace("CENCW-", "")); + $$("#headlines-frame div[id*=RROW][data-content]").each((row) => { + //console.log('checking', row.id); - if (row && row.offsetTop <= $("headlines-frame").scrollTop + - $("headlines-frame").offsetHeight) { + if (row.offsetTop <= $("headlines-frame").scrollTop + $("headlines-frame").offsetHeight) { + console.log("unpacking: " + row.id); - //console.log("unpacking: " + child.id); + let content; - child.innerHTML = htmlspecialchars_decode(child.innerHTML); - child.removeAttribute('id'); + try { + content = JSON.parse(row.getAttribute("data-content")); + } catch (e) { + content = "Error decoding content: " + row.getAttribute("data-content"); + } - PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row); + row.select(".cdmContentInner")[0].innerHTML = content; + row.removeAttribute("data-content"); - Element.show(child); - } + PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row); + } else { + throw $break; } - ); + }); } function headlines_scroll_handler(e) { |