]> git.wh0rd.org Git - tt-rss.git/commitdiff
move to simpler CDM handling of encoded content (instead of CENCW... etc)
authorAndrew Dolgov <noreply@fakecake.org>
Fri, 30 Nov 2018 10:26:41 +0000 (13:26 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Fri, 30 Nov 2018 10:26:41 +0000 (13:26 +0300)
classes/feeds.php
js/viewfeed.js

index cf9ca64c596c4d748167988604326a005d4e0810..0c1db62b6765b5c2f607e50be7c7fb35fda44085 100755 (executable)
@@ -499,8 +499,10 @@ class Feeds extends Handler_Protected {
 
                                        $expanded_class = $expand_cdm ? "expanded" : "expandable";
 
-                                       $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>";
+                    $content_encoded = htmlspecialchars(json_encode($line["content"]));
+
+                    $tmp_content = "<div class=\"cdm $hlc_suffix $expanded_class $class\"
+                        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 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 class=\"cdmIntermediate\">";
 
                                        $always_display_enclosures = $line["always_display_enclosures"];
index ed6e3642e1315929cb6aedd1e45cc236fe8c82f0..a24116e8808e777975ad2c3aa141415d6c1c5e6d 100755 (executable)
@@ -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) {