move to simpler CDM handling of encoded content (instead of CENCW... etc)

This commit is contained in:
Andrew Dolgov 2018-11-30 13:26:41 +03:00
parent da1a3c2cc5
commit c8c9a26f30
2 changed files with 21 additions and 22 deletions

View File

@ -499,8 +499,10 @@ class Feeds extends Handler_Protected {
$expanded_class = $expand_cdm ? "expanded" : "expandable"; $expanded_class = $expand_cdm ? "expanded" : "expandable";
$content_encoded = htmlspecialchars(json_encode($line["content"]));
$tmp_content = "<div class=\"cdm $hlc_suffix $expanded_class $class\" $tmp_content = "<div class=\"cdm $hlc_suffix $expanded_class $class\"
id=\"RROW-$id\" data-article-id='$id' data-orig-feed-id='$feed_id' $mouseover_attrs>"; id=\"RROW-$id\" data-content=\"$content_encoded\" data-article-id='$id' data-orig-feed-id='$feed_id' $mouseover_attrs>";
$tmp_content .= "<div class=\"cdmHeader\">"; $tmp_content .= "<div class=\"cdmHeader\">";
$tmp_content .= "<div style=\"vertical-align : middle\">"; $tmp_content .= "<div style=\"vertical-align : middle\">";
@ -616,14 +618,7 @@ class Feeds extends Handler_Protected {
} }
} }
$tmp_content .= "<span id=\"CWRAP-$id\">";
$tmp_content .= "<span id=\"CENCW-$id\" class=\"cencw\" style=\"display : none\">";
$tmp_content .= htmlspecialchars($line["content"]);
$tmp_content .= "</span>";
$tmp_content .= "</span>";
$tmp_content .= "</div>"; //cdmContentInner $tmp_content .= "</div>"; //cdmContentInner
$tmp_content .= "<div class=\"cdmIntermediate\">"; $tmp_content .= "<div class=\"cdmIntermediate\">";
$always_display_enclosures = $line["always_display_enclosures"]; $always_display_enclosures = $line["always_display_enclosures"];

View File

@ -1018,24 +1018,28 @@ function postMouseOut(id) {
function unpackVisibleHeadlines() { function unpackVisibleHeadlines() {
if (!isCdmMode() || !getInitParam("cdm_expanded")) return; if (!isCdmMode() || !getInitParam("cdm_expanded")) return;
$$("#headlines-frame span.cencw[id]").each( $$("#headlines-frame div[id*=RROW][data-content]").each((row) => {
function (child) { //console.log('checking', row.id);
const row = $("RROW-" + child.id.replace("CENCW-", ""));
if (row && row.offsetTop <= $("headlines-frame").scrollTop + if (row.offsetTop <= $("headlines-frame").scrollTop + $("headlines-frame").offsetHeight) {
$("headlines-frame").offsetHeight) { console.log("unpacking: " + row.id);
//console.log("unpacking: " + child.id); let content;
child.innerHTML = htmlspecialchars_decode(child.innerHTML); try {
child.removeAttribute('id'); content = JSON.parse(row.getAttribute("data-content"));
} catch (e) {
content = "Error decoding content: " + row.getAttribute("data-content");
}
row.select(".cdmContentInner")[0].innerHTML = content;
row.removeAttribute("data-content");
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row); PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row);
} else {
Element.show(child); throw $break;
} }
} });
);
} }
function headlines_scroll_handler(e) { function headlines_scroll_handler(e) {