]> git.wh0rd.org - tt-rss.git/blobdiff - js/viewfeed.js
cdmScrollToArticle: set article read on selection
[tt-rss.git] / js / viewfeed.js
index ed6e3642e1315929cb6aedd1e45cc236fe8c82f0..373aa7dd08b4ce093f3c3f89f4acca1f9eabff27 100755 (executable)
@@ -86,7 +86,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                        while (tmp.hasChildNodes()) {
                                var row = tmp.removeChild(tmp.firstChild);
 
-                               if (loaded_article_ids.indexOf(row.id) == -1 || row.hasClassName("cdmFeedTitle")) {
+                               if (loaded_article_ids.indexOf(row.id) == -1 || row.hasClassName("feed-title")) {
                                        dijit.byId("headlines-frame").domNode.appendChild(row);
 
                                        loaded_article_ids.push(row.id);
@@ -127,7 +127,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                                while (tmp.hasChildNodes()) {
                                        let row = tmp.removeChild(tmp.firstChild);
 
-                                       if (loaded_article_ids.indexOf(row.id) == -1 || row.hasClassName("cdmFeedTitle")) {
+                                       if (loaded_article_ids.indexOf(row.id) == -1 || row.hasClassName("feed-title")) {
                                                dijit.byId("headlines-frame").domNode.appendChild(row);
 
                                                loaded_article_ids.push(row.id);
@@ -325,7 +325,7 @@ function view(id, activefeed, noexpand) {
                query.mode = "prefetch";
                render_article(cached_article);
        } else if (cached_article) {
-        query.mode = "prefetch_old";
+               query.mode = "prefetch_old";
                render_article(cached_article);
 
                // if we don't need to request any relative ids, we might as well skip
@@ -344,7 +344,7 @@ function view(id, activefeed, noexpand) {
        }
 
        xhrPost("backend.php", query, (transport) => {
-        article_callback2(transport, id);
+               article_callback2(transport, id);
        })
 
        return false;
@@ -394,7 +394,7 @@ function toggleMark(id, client_only) {
        }
 
 function togglePub(id, client_only, no_effects, note) {
-    const query = { op: "rpc", id: id, method: "publ" };
+       const query = { op: "rpc", id: id, method: "publ" };
 
        if (note != undefined) {
                query.note = note;
@@ -490,7 +490,6 @@ function moveToPost(mode, noscroll, noexpand) {
                                        scrollArticle(ctr.offsetHeight/4);
 
                                } else if (next_id) {
-                                       cdmExpandArticle(next_id, noexpand);
                                        cdmScrollToArticleId(next_id, true);
                                }
 
@@ -509,24 +508,14 @@ function moveToPost(mode, noscroll, noexpand) {
                                const prev_article = $("RROW-" + prev_id);
                                var ctr = $("headlines-frame");
 
-                               if (!getInitParam("cdm_expanded")) {
-
-                                       if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
-                                               scrollArticle(-ctr.offsetHeight/4);
-                                       } else {
-                                               cdmExpandArticle(prev_id, noexpand);
-                                               cdmScrollToArticleId(prev_id, true);
-                                       }
-                               } else if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
-                                               scrollArticle(-ctr.offsetHeight/3);
-                                       } else if (!noscroll && prev_article &&
-                                                       prev_article.offsetTop < ctr.scrollTop) {
-                                               cdmExpandArticle(prev_id, noexpand);
-                                               scrollArticle(-ctr.offsetHeight/4);
-                                       } else if (prev_id) {
-                                               cdmExpandArticle(prev_id, noexpand);
-                                               cdmScrollToArticleId(prev_id, noscroll);
-                                       }
+                               if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
+                                       scrollArticle(-ctr.offsetHeight/3);
+                               } else if (!noscroll && prev_article &&
+                                               prev_article.offsetTop < ctr.scrollTop) {
+                                       scrollArticle(-ctr.offsetHeight/4);
+                               } else if (prev_id) {
+                                       cdmScrollToArticleId(prev_id, noscroll);
+                               }
 
                        } else if (prev_id) {
                                correctHeadlinesOffset(prev_id);
@@ -594,12 +583,12 @@ function toggleUnread(id, cmode) {
                }
 
                if (tmpClassName != row.className) {
-            if (cmode == undefined) cmode = 2;
+                       if (cmode == undefined) cmode = 2;
 
-            const query = {op: "rpc", method: "catchupSelected",
-                cmode: cmode, ids: id};
+                       const query = {op: "rpc", method: "catchupSelected",
+                               cmode: cmode, ids: id};
 
-            xhrPost("backend.php", query, (transport) => {
+                       xhrPost("backend.php", query, (transport) => {
                                        handle_rpc_json(transport);
 
                        });
@@ -619,8 +608,8 @@ function selectionRemoveLabel(id, ids) {
                ids: ids.toString(), lid: id };
 
        xhrPost("backend.php", query, (transport) => {
-        handle_rpc_json(transport);
-        show_labels_in_headlines(transport);
+               handle_rpc_json(transport);
+               show_labels_in_headlines(transport);
        });
 }
 
@@ -635,10 +624,10 @@ function selectionAssignLabel(id, ids) {
        const query = { op: "article", method: "assignToLabel",
                ids: ids.toString(), lid: id };
 
-    xhrPost("backend.php", query, (transport) => {
-        handle_rpc_json(transport);
-        show_labels_in_headlines(transport);
-    });
+       xhrPost("backend.php", query, (transport) => {
+               handle_rpc_json(transport);
+               show_labels_in_headlines(transport);
+       });
 }
 
 function selectionToggleUnread(set_state, callback, no_error, ids) {
@@ -689,10 +678,10 @@ function selectionToggleUnread(set_state, callback, no_error, ids) {
 
                notify_progress("Loading, please wait...");
 
-        xhrPost("backend.php", query, (transport) => {
-            handle_rpc_json(transport);
-            if (callback) callback(transport);
-        });
+               xhrPost("backend.php", query, (transport) => {
+                       handle_rpc_json(transport);
+                       if (callback) callback(transport);
+               });
 
        }
 }
@@ -714,10 +703,10 @@ function selectionToggleMarked(sel_state, callback, no_error, ids) {
                const query = { op: "rpc", method: "markSelected",
                        ids:  rows.toString(), cmode: 2 };
 
-        xhrPost("backend.php", query, (transport) => {
-            handle_rpc_json(transport);
-            if (callback) callback(transport);
-        });
+               xhrPost("backend.php", query, (transport) => {
+                       handle_rpc_json(transport);
+                       if (callback) callback(transport);
+               });
        }
 }
 
@@ -735,13 +724,13 @@ function selectionTogglePublished(sel_state, callback, no_error, ids) {
        }
 
        if (rows.length > 0) {
-        const query = { op: "rpc", method: "publishSelected",
-            ids:  rows.toString(), cmode: 2 };
+               const query = { op: "rpc", method: "publishSelected",
+                       ids:  rows.toString(), cmode: 2 };
 
-        xhrPost("backend.php", query, (transport) => {
-            handle_rpc_json(transport);
-            if (callback) callback(transport);
-        });
+               xhrPost("backend.php", query, (transport) => {
+                       handle_rpc_json(transport);
+                       if (callback) callback(transport);
+               });
        }
 }
 
@@ -858,52 +847,52 @@ function deleteSelection() {
        const query = { op: "rpc", method: "delete", ids: rows.toString() };
 
        xhrPost("backend.php", query, (transport) => {
-        handle_rpc_json(transport);
-        viewCurrentFeed();
+               handle_rpc_json(transport);
+               viewCurrentFeed();
        });
 }
 
 function archiveSelection() {
 
-    const rows = getSelectedArticleIds2();
+       const rows = getSelectedArticleIds2();
 
-    if (rows.length == 0) {
-        alert(__("No articles are selected."));
-        return;
-    }
+       if (rows.length == 0) {
+               alert(__("No articles are selected."));
+               return;
+       }
 
-    const fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
-    let str;
-    let op;
+       const fn = getFeedName(getActiveFeedId(), activeFeedIsCat());
+       let str;
+       let op;
 
-    if (getActiveFeedId() != 0) {
-        str = ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows.length);
-        op = "archive";
-    } else {
-        str = ngettext("Move %d archived article back?", "Move %d archived articles back?", rows.length);
+       if (getActiveFeedId() != 0) {
+               str = ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows.length);
+               op = "archive";
+       } else {
+               str = ngettext("Move %d archived article back?", "Move %d archived articles back?", rows.length);
 
-        str += " " + __("Please note that unstarred articles might get purged on next feed update.");
+               str += " " + __("Please note that unstarred articles might get purged on next feed update.");
 
-        op = "unarchive";
-    }
+               op = "unarchive";
+       }
 
-    str = str.replace("%d", rows.length);
-    str = str.replace("%s", fn);
+       str = str.replace("%d", rows.length);
+       str = str.replace("%s", fn);
 
-    if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
-        return;
-    }
+       if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
+               return;
+       }
 
-    for (let i = 0; i < rows.length; i++) {
-        cache_delete("article:" + rows[i]);
-    }
+       for (let i = 0; i < rows.length; i++) {
+               cache_delete("article:" + rows[i]);
+       }
 
-    const query = {op: "rpc", method: op, ids: rows.toString()};
+       const query = {op: "rpc", method: op, ids: rows.toString()};
 
-    xhrPost("backend.php", query, (transport) => {
-        handle_rpc_json(transport);
-        viewCurrentFeed();
-    });
+       xhrPost("backend.php", query, (transport) => {
+               handle_rpc_json(transport);
+               viewCurrentFeed();
+       });
 }
 
 function catchupSelection() {
@@ -946,24 +935,24 @@ function editArticleTags(id) {
                                notify_progress("Saving article tags...", true);
 
                                xhrPost("backend.php", this.attr('value'), (transport) => {
-                    try {
-                        notify('');
-                        dialog.hide();
+                                       try {
+                                               notify('');
+                                               dialog.hide();
 
-                        const data = JSON.parse(transport.responseText);
+                                               const data = JSON.parse(transport.responseText);
 
-                        if (data) {
-                            const id = data.id;
+                                               if (data) {
+                                                       const id = data.id;
 
-                            const tags = $("ATSTR-" + id);
-                            const tooltip = dijit.byId("ATSTRTIP-" + id);
+                                                       const tags = $("ATSTR-" + id);
+                                                       const tooltip = dijit.byId("ATSTRTIP-" + id);
 
-                            if (tags) tags.innerHTML = data.content;
-                            if (tooltip) tooltip.attr('label', data.content_full);
-                        }
-                    } catch (e) {
-                        exception_error(e);
-                    }
+                                                       if (tags) tags.innerHTML = data.content;
+                                                       if (tooltip) tooltip.attr('label', data.content_full);
+                                               }
+                                       } catch (e) {
+                                               exception_error(e);
+                                       }
                                });
                        }
                },
@@ -993,6 +982,9 @@ function cdmScrollToArticleId(id, force) {
 
                // expanded cdm has a 4px margin now
                ctr.scrollTop = parseInt(e.offsetTop) - 4;
+
+               // article is selected manually, set it read
+               toggleUnread(id, 0);1
        }
 }
 
@@ -1016,26 +1008,27 @@ function postMouseOut(id) {
 }
 
 function unpackVisibleHeadlines() {
-       if (!isCdmMode() || !getInitParam("cdm_expanded")) return;
+       if (!isCdmMode()) return;
 
-       $$("#headlines-frame span.cencw[id]").each(
-               function (child) {
-                       const row = $("RROW-" + child.id.replace("CENCW-", ""));
+       const rows = $$("#headlines-frame div[id*=RROW][data-content]");
+       const threshold = $("headlines-frame").scrollTop + $("headlines-frame").offsetHeight + 300;
 
-                       if (row && row.offsetTop <= $("headlines-frame").scrollTop +
-                               $("headlines-frame").offsetHeight) {
+       for (let i = 0; i < rows.length; i++) {
+               const row = rows[i];
 
-                               //console.log("unpacking: " + child.id);
+               if (row.offsetTop <= threshold) {
+                       console.log("unpacking: " + row.id);
 
-                               child.innerHTML = htmlspecialchars_decode(child.innerHTML);
-                               child.removeAttribute('id');
+                       const content = row.getAttribute("data-content");
 
-                               PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row);
+                       row.select(".content-inner")[0].innerHTML = content;
+                       row.removeAttribute("data-content");
 
-                               Element.show(child);
-                       }
+                       PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row);
+               } else {
+                       break;
                }
-       );
+       }
 }
 
 function headlines_scroll_handler(e) {
@@ -1048,30 +1041,27 @@ function headlines_scroll_handler(e) {
 
                _headlines_scroll_offset = e.scrollTop;
 
-               const hsp = $("headlines-spacer");
-
                unpackVisibleHeadlines();
 
                // set topmost child in the buffer as active
                if (isCdmMode() && getInitParam("cdm_auto_catchup") == 1 &&
-                               getSelectedArticleIds2().length <= 1 &&
-                               getInitParam("cdm_expanded")) {
+                               getSelectedArticleIds2().length <= 1) {
 
                        const rows = $$("#headlines-frame > div[id*=RROW]");
 
                        for (let i = 0; i < rows.length; i++) {
-                               const child = rows[i];
+                               const row = rows[i];
 
-                               if ($("headlines-frame").scrollTop <= child.offsetTop &&
-                                       child.offsetTop - $("headlines-frame").scrollTop < 100 &&
-                                       child.getAttribute("data-article-id") != _active_article_id) {
+                               if ($("headlines-frame").scrollTop <= row.offsetTop &&
+                                       row.offsetTop - $("headlines-frame").scrollTop < 100 &&
+                                       row.getAttribute("data-article-id") != _active_article_id) {
 
                                        if (_active_article_id) {
                                                const row = $("RROW-" + _active_article_id);
                                                if (row) row.removeClassName("active");
                                        }
 
-                                       _active_article_id = child.getAttribute("data-article-id");
+                                       _active_article_id = row.getAttribute("data-article-id");
                                        showArticleInHeadlines(_active_article_id, true);
                                        updateSelectedPrompt();
                                        break;
@@ -1080,6 +1070,8 @@ function headlines_scroll_handler(e) {
                }
 
                if (!_infscroll_disable) {
+                       const hsp = $("headlines-spacer");
+
                        if (hsp && hsp.offsetTop - 250 <= e.scrollTop + e.offsetHeight) {
 
                                hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " +
@@ -1095,33 +1087,31 @@ function headlines_scroll_handler(e) {
                        updateFloatingTitle();
                }
 
-               catchupCurrentBatchIfNeeded();
-
                if (getInitParam("cdm_auto_catchup") == 1) {
 
-                       // let's get DOM some time to settle down
-                       const ts = new Date().getTime();
-                       if (ts - _last_headlines_update < 100) return;
+                       let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]");
 
-                       $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
-                               function(child) {
-                                       if ($("headlines-frame").scrollTop > (child.offsetTop + child.offsetHeight/2)) {
+                       for (let i = 0; i < rows.length; i++) {
+                               const row = rows[i];
+                               
+                               if ($("headlines-frame").scrollTop > (row.offsetTop + row.offsetHeight/2)) {
 
-                                               const id = child.getAttribute("data-article-id")
+                                       const id = row.getAttribute("data-article-id")
 
-                                               if (catchup_id_batch.indexOf(id) == -1)
-                                                       catchup_id_batch.push(id);
+                                       if (catchup_id_batch.indexOf(id) == -1)
+                                               catchup_id_batch.push(id);
 
-                                               //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
-                                       }
-
-                               });
+                                       //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
+                               } else {
+                                       break;
+                               }
+                       }
 
                        if (_infscroll_disable) {
-                               const child = $$("#headlines-frame div[id*=RROW]").last();
+                               const row = $$("#headlines-frame div[id*=RROW]").last();
 
-                               if (child && $("headlines-frame").scrollTop >
-                                               (child.offsetTop + child.offsetHeight - 50)) {
+                               if (row && $("headlines-frame").scrollTop >
+                                               (row.offsetTop + row.offsetHeight - 50)) {
 
                                        console.log("we seem to be at an end");
 
@@ -1146,7 +1136,7 @@ function openNextUnreadFeed() {
 function catchupBatchedArticles() {
        if (catchup_id_batch.length > 0 && !_infscroll_request_sent && !_catchup_request_sent) {
 
-               console.log("catchupBatchedArticles: working");
+               console.log("catchupBatchedArticles, size=", catchup_id_batch.length);
 
                // make a copy of the array
                const batch = catchup_id_batch.slice();
@@ -1156,22 +1146,21 @@ function catchupBatchedArticles() {
                _catchup_request_sent = true;
 
                xhrPost("backend.php", query, (transport) => {
-            const reply = handle_rpc_json(transport);
+                       const reply = handle_rpc_json(transport);
 
-            _catchup_request_sent = false;
+                       _catchup_request_sent = false;
 
-            if (reply) {
-                const batch = reply.ids;
+                       if (reply) {
+                               const batch = reply.ids;
 
-                batch.each(function (id) {
-                    console.log(id);
-                    const elem = $("RROW-" + id);
-                    if (elem) elem.removeClassName("Unread");
-                    catchup_id_batch.remove(id);
-                });
-            }
+                               batch.each(function (id) {
+                                       const elem = $("RROW-" + id);
+                                       if (elem) elem.removeClassName("Unread");
+                                       catchup_id_batch.remove(id);
+                               });
+                       }
 
-            updateFloatingTitle(true);
+                       updateFloatingTitle(true);
                });
        }
 }
@@ -1231,117 +1220,12 @@ function catchupRelativeToArticle(below, id) {
                                cmode: 0, ids: ids_to_mark.toString() };
 
                        xhrPost("backend.php", query, (transport) => {
-                handle_rpc_json(transport);
+                               handle_rpc_json(transport);
                        });
                }
        }
 }
 
-function cdmCollapseArticle(event, id, unmark) {
-       if (unmark == undefined) unmark = true;
-
-       const row = $("RROW-" + id);
-       const elem = $("CICD-" + id);
-
-       if (elem && row) {
-               const collapse = row.select("span[class='collapseBtn']")[0];
-
-               Element.hide(elem);
-               Element.show("CEXC-" + id);
-               Element.hide(collapse);
-
-               if (unmark) {
-                       row.removeClassName("active");
-
-                       markHeadline(id, false);
-
-                       if (id == getActiveArticleId()) {
-                               setActiveArticleId(0);
-                       }
-
-                       updateSelectedPrompt();
-               }
-
-               if (event) Event.stop(event);
-
-               PluginHost.run(PluginHost.HOOK_ARTICLE_COLLAPSED, id);
-
-               if (row.offsetTop < $("headlines-frame").scrollTop)
-                       scrollToRowId(row.id);
-
-               $("floatingTitle").style.visibility = "hidden";
-               $("floatingTitle").setAttribute("data-article-id", 0);
-       }
-}
-
-function cdmExpandArticle(id, noexpand) {
-       console.log("cdmExpandArticle " + id);
-
-       const row = $("RROW-" + id);
-
-       if (!row) return false;
-
-       const oldrow = $("RROW-" + getActiveArticleId());
-
-       let elem = $("CICD-" + getActiveArticleId());
-
-       if (id == getActiveArticleId() && Element.visible(elem))
-               return true;
-
-       selectArticles("none");
-
-       const old_offset = row.offsetTop;
-
-       if (getActiveArticleId() && elem && !getInitParam("cdm_expanded")) {
-               let collapse = oldrow.select("span[class='collapseBtn']")[0];
-
-               Element.hide(elem);
-               Element.show("CEXC-" + getActiveArticleId());
-               Element.hide(collapse);
-       }
-
-       if (oldrow) oldrow.removeClassName("active");
-
-       setActiveArticleId(id);
-
-       elem = $("CICD-" + id);
-
-       let collapse = row.select("span[class='collapseBtn']")[0];
-
-       const cencw = $("CENCW-" + id);
-
-       if (!Element.visible(elem) && !noexpand) {
-               if (cencw) {
-                       cencw.innerHTML = htmlspecialchars_decode(cencw.innerHTML);
-                       cencw.setAttribute('id', '');
-                       Element.show(cencw);
-               }
-
-               Element.show(elem);
-               Element.hide("CEXC-" + id);
-               Element.show(collapse);
-       }
-
-       const new_offset = row.offsetTop;
-
-       if (old_offset > new_offset)
-               $("headlines-frame").scrollTop -= (old_offset - new_offset);
-
-       if (!noexpand) {
-               if (catchup_id_batch.indexOf(id) == -1)
-                       catchup_id_batch.push(id);
-
-               catchupCurrentBatchIfNeeded();
-       }
-
-       toggleSelected(id);
-       row.addClassName("active");
-
-       PluginHost.run(PluginHost.HOOK_ARTICLE_EXPANDED, id);
-
-       return false;
-}
-
 function getArticleUnderPointer() {
        return post_under_pointer;
 }
@@ -1378,42 +1262,37 @@ function cdmClicked(event, id, in_body) {
 
        if (!event.ctrlKey && !event.metaKey) {
 
-               if (!getInitParam("cdm_expanded")) {
-                       return cdmExpandArticle(id);
-               } else {
-
-                       let elem = $("RROW-" + getActiveArticleId());
+               let elem = $("RROW-" + getActiveArticleId());
 
-                       if (elem) elem.removeClassName("active");
+               if (elem) elem.removeClassName("active");
 
-                       selectArticles("none");
-                       toggleSelected(id);
+               selectArticles("none");
+               toggleSelected(id);
 
-                       elem = $("RROW-" + id);
-                       const article_is_unread = elem.hasClassName("Unread");
-
-                       elem.removeClassName("Unread");
-                       elem.addClassName("active");
+               elem = $("RROW-" + id);
+               const article_is_unread = elem.hasClassName("Unread");
 
-                       setActiveArticleId(id);
+               elem.removeClassName("Unread");
+               elem.addClassName("active");
 
-                       if (article_is_unread) {
-                decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
-                updateFloatingTitle(true);
+               setActiveArticleId(id);
 
-                const query = {
-                    op: "rpc", method: "catchupSelected",
-                    cmode: 0, ids: id
-                };
+               if (article_is_unread) {
+                       decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
+                       updateFloatingTitle(true);
 
-                xhrPost("backend.php", query, (transport) => {
-                    handle_rpc_json(transport);
-                });
-            }
+                       const query = {
+                               op: "rpc", method: "catchupSelected",
+                               cmode: 0, ids: id
+                       };
 
-                       return !event.shiftKey;
+                       xhrPost("backend.php", query, (transport) => {
+                               handle_rpc_json(transport);
+                       });
                }
 
+               return !event.shiftKey;
+
        } else if (!in_body) {
 
                toggleSelected(id, true);
@@ -1792,20 +1671,20 @@ function setSelectionScore() {
 
                        xhrJson("backend.php", query, (reply) => {
                                if (reply) {
-                    reply.id.each((id) => {
-                        const row = $("RROW-" + id);
-
-                        if (row) {
-                            const pic = row.getElementsByClassName("hlScorePic")[0];
-
-                            if (pic) {
-                                pic.src = pic.src.replace(/score_.*?\.png/,
-                                    reply["score_pic"]);
-                                pic.setAttribute("score", reply["score"]);
-                            }
-                        }
-                    });
-                }
+                                       reply.id.each((id) => {
+                                               const row = $("RROW-" + id);
+
+                                               if (row) {
+                                                       const pic = row.getElementsByClassName("score-pic")[0];
+
+                                                       if (pic) {
+                                                               pic.src = pic.src.replace(/score_.*?\.png/,
+                                                                       reply["score_pic"]);
+                                                               pic.setAttribute("score", reply["score"]);
+                                                       }
+                                               }
+                                       });
+                               }
                        });
                }
 
@@ -1814,31 +1693,6 @@ function setSelectionScore() {
        }
 }
 
-/*
-function updateScore(id) {
-       const pic = $$("#RROW-" + id + " .hlScorePic")[0];
-
-       if (pic) {
-
-               const query = "op=article&method=getScore&id=" + param_escape(id);
-
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function (transport) {
-                               console.log(transport.responseText);
-
-                               const reply = JSON.parse(transport.responseText);
-
-                               if (reply) {
-                                       pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
-                                       pic.setAttribute("score", reply["score"]);
-                                       pic.setAttribute("title", reply["score"]);
-                               }
-                       }
-               });
-       }
-} */
-
 function changeScore(id, pic) {
        const score = pic.getAttribute("score");
 
@@ -1848,11 +1702,11 @@ function changeScore(id, pic) {
                const query = { op: "article", method: "setScore", id: id, score: new_score };
 
                xhrJson("backend.php", query, (reply) => {
-            if (reply) {
-                pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
-                pic.setAttribute("score", new_score);
-                pic.setAttribute("title", new_score);
-            }
+                       if (reply) {
+                               pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
+                               pic.setAttribute("score", new_score);
+                               pic.setAttribute("title", new_score);
+                       }
                });
        }
 }
@@ -1861,9 +1715,9 @@ function displayArticleUrl(id) {
        const query = { op: "rpc", method: "getlinktitlebyid", id: id };
 
        xhrJson("backend.php", query, (reply) => {
-        if (reply && reply.link) {
-            prompt(__("Article URL:"), reply.link);
-        }
+               if (reply && reply.link) {
+                       prompt(__("Article URL:"), reply.link);
+               }
        });
 
 }
@@ -1888,7 +1742,7 @@ function updateFloatingTitle(unread_only) {
 
                if (child && child.offsetTop + child.offsetHeight > hf.scrollTop) {
 
-                       const header = child.getElementsByClassName("cdmHeader")[0];
+                       const header = child.getElementsByClassName("header")[0];
 
                        if (unread_only || child.getAttribute("data-article-id") != $("floatingTitle").getAttribute("data-article-id")) {
                                if (child.getAttribute("data-article-id") != $("floatingTitle").getAttribute("data-article-id")) {
@@ -1925,14 +1779,3 @@ function updateFloatingTitle(unread_only) {
                }
        }
 }
-
-function catchupCurrentBatchIfNeeded() {
-       if (catchup_id_batch.length > 0) {
-               window.clearTimeout(catchup_timeout_id);
-               catchup_timeout_id = window.setTimeout(catchupBatchedArticles, 1000);
-
-               if (catchup_id_batch.length >= 10) {
-                       catchupBatchedArticles();
-               }
-       }
-}