]> git.wh0rd.org - tt-rss.git/blobdiff - js/viewfeed.js
(experimental) disable infscroll requests while marking auto catched up articles...
[tt-rss.git] / js / viewfeed.js
index ec7706547d47893d6e3568397acbb6c0ba2c5a44..e1425a3820fd056e0e8f834d78ace9a74015617d 100644 (file)
@@ -13,6 +13,7 @@ var catchup_timeout_id = false;
 var cids_requested = [];
 var loaded_article_ids = [];
 var _last_headlines_update = 0;
+var current_first_id = 0;
 
 var has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null;
 
@@ -45,7 +46,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                                return;
                        }
 
-                       if (feed_id != getActiveFeedId() || is_cat != activeFeedIsCat())
+                       if (feed_id != -7 && (feed_id != getActiveFeedId() || is_cat != activeFeedIsCat()))
                                return;
 
                        /* dijit.getEnclosingWidget(
@@ -56,7 +57,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                                if (infscroll_req == false) {
                                        $("headlines-frame").scrollTop = 0;
 
-                                       Element.hide("floatingTitle");
+                                       $("floatingTitle").style.visibility = "hidden";
                                        $("floatingTitle").setAttribute("rowid", 0);
                                        $("floatingTitle").innerHTML = "";
                                }
@@ -77,6 +78,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                                _infscroll_disable = 0;
                        }
 
+                       current_first_id = reply['headlines']['first_id'];
                        var counters = reply['counters'];
                        var articles = reply['articles'];
                        //var runtime_info = reply['runtime-info'];
@@ -84,18 +86,16 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                        if (infscroll_req == false) {
                                loaded_article_ids = [];
 
-                               dijit.byId("headlines-frame").attr('content',
-                                       reply['headlines']['content']);
+                               dojo.html.set($("headlines-toolbar"),
+                                               reply['headlines']['toolbar'],
+                                               {parseContent: true});
 
-                               dijit.byId("headlines-toolbar").attr('content',
-                                       reply['headlines']['toolbar']);
+                               dojo.html.set($("headlines-frame"),
+                                       reply['headlines']['content'],
+                                       {parseContent: true});
 
-                               $$("#headlines-frame > div[id*=RROW]").each(function(row) {
-                                       if (loaded_article_ids.indexOf(row.id) != -1) {
-                                               row.parentNode.removeChild(row);
-                                       } else {
-                                               loaded_article_ids.push(row.id);
-                                       }
+                               $$("#headlines-frame div[id*='RROW']").each(function(row) {
+                                       loaded_article_ids.push(row.id);
                                });
 
                                var hsp = $("headlines-spacer");
@@ -104,6 +104,10 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
 
                                initHeadlinesMenu();
 
+                               if (_infscroll_disable)
+                                       hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
+                                               __("Click to open next unread feed.") + "</a>";
+
                                if (_search_query) {
                                        $("feed_title").innerHTML += "<span id='cancel_search'>" +
                                                " (<a href='#' onclick='cancelSearch()'>" + __("Cancel search") + "</a>)" +
@@ -117,40 +121,31 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
 
                                        var c = dijit.byId("headlines-frame");
                                        var ids = getSelectedArticleIds2();
-                                       var new_elems = [];
-
-                                       $("headlines-tmp").innerHTML = reply['headlines']['content'];
 
                                        var hsp = $("headlines-spacer");
 
                                        if (hsp)
                                                c.domNode.removeChild(hsp);
 
-                                       $$("#headlines-tmp > div").each(function(row) {
-                                               if (row.className == 'cdmFeedTitle') {
-                                                       row.style.display = 'none';
-                                                       c.domNode.appendChild(row);
-                                                       new_elems.push(row);
-                                               } else if (loaded_article_ids.indexOf(row.id) == -1) {
-                                                       row.style.display = 'none';
-                                                       c.domNode.appendChild(row);
-                                                       new_elems.push(row);
-                                                       loaded_article_ids.push(row.id);
-                                               } else {
-                                                       row.parentNode.removeChild(row);
-                                               }
-                                       });
+                                       var tmp = new Element("div");
+                                       tmp.innerHTML = reply['headlines']['content'];
+                                       dojo.parser.parse(tmp);
 
-                                       if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
+                                       while (tmp.hasChildNodes()) {
+                                               var row = tmp.removeChild(tmp.firstChild);
 
-                                       if (getInitParam("cdm_auto_catchup") == 1) {
-                                               c.domNode.appendChild(hsp);
+                                               if (loaded_article_ids.indexOf(row.id) == -1 || row.hasClassName("cdmFeedTitle")) {
+                                                       dijit.byId("headlines-frame").domNode.appendChild(row);
+                                                       Element.hide(row);
+                                                       new Effect.Appear(row, {duration:0.5});
+                                                       loaded_article_ids.push(row.id);
+                                               }
                                        }
 
-                                       console.log("added " + new_elems.size() + " headlines");
+                                       if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
+                                       c.domNode.appendChild(hsp);
 
-                                       if (new_elems.size() == 0)
-                                               _infscroll_disable = true;
+                                       if (headlines_count < 30) _infscroll_disable = true;
 
                                        console.log("restore selected ids: " + ids);
 
@@ -160,19 +155,30 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
 
                                        initHeadlinesMenu();
 
-                                       new_elems.each(function(child) {
-                                               dojo.parser.parse(child);
-
-                                               if (!Element.visible(child))
-                                                       new Effect.Appear(child, { duration : 0.5 });
-                                       });
+                                       if (_infscroll_disable) {
+                                               hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
+                                               __("Click to open next unread feed.") + "</a>";
+                                       }
 
                                } else {
                                        console.log("no new headlines received");
 
+                                       var first_id_changed = reply['headlines']['first_id_changed'];
+                                       console.log("first id changed:" + first_id_changed);
+
                                        var hsp = $("headlines-spacer");
 
-                                       if (hsp) hsp.innerHTML = "";
+                                       if (hsp) {
+                                               if (first_id_changed) {
+                                                       hsp.innerHTML = "<a href='#' onclick='viewCurrentFeed()'>" +
+                                                       __("New articles found, reload feed to continue.") + "</a>";
+                                               } else {
+                                                       hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
+                                                       __("Click to open next unread feed.") + "</a>";
+                                               }
+
+                                       }
+
                                }
                        }
 
@@ -190,14 +196,11 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
                        else
                                request_counters(true);
 
-               } else if (transport.responseText) {
+               } else {
                        console.error("Invalid object received: " + transport.responseText);
                        dijit.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
                                        __('Could not update headlines (invalid object received - see error console for details)') +
                                        "</div>");
-               } else {
-                       //notify_error("Error communicating with server.");
-                       Element.show(dijit.byId("net-alert").domNode);
                }
 
                _infscroll_request_sent = 0;
@@ -314,30 +317,16 @@ function article_callback2(transport, id) {
 //                             return;
 //                     }
 
-               } else if (transport.responseText) {
+               } else {
                        console.error("Invalid object received: " + transport.responseText);
 
                        render_article("<div class='whiteBox'>" +
                                        __('Could not display article (invalid object received - see error console for details)') + "</div>");
-               } else {
-                       Element.show(dijit.byId("net-alert").domNode);
                }
 
                var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
                request_counters(unread_in_buffer == 0);
 
-               //headlines_scroll_handler($("headlines-frame"));
-
-/*             try {
-                       if (!_infscroll_disable &&
-                                       $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
-
-                               loadMoreHeadlines();
-                       }
-               } catch (e) {
-                       console.warn(e);
-               } */
-
                notify("");
        } catch (e) {
                exception_error("article_callback2", e, transport);
@@ -403,19 +392,6 @@ function view(id, activefeed, noexpand) {
                        // if we don't need to request any relative ids, we might as well skip
                        // the server roundtrip altogether
                        if (cids_to_request.length == 0) {
-
-/*                             try {
-                                       if (!_infscroll_disable &&
-                                               $$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
-
-                                                       loadMoreHeadlines();
-                                       }
-                               } catch (e) {
-                                       console.warn(e);
-                               } */
-
-                               //headlines_scroll_handler($("headlines-frame"));
-
                                return;
                        }
                }
@@ -835,6 +811,8 @@ function selectionToggleUnread(set_state, callback, no_error, ids) {
                        }
                }
 
+               updateFloatingTitle(true);
+
                if (rows.length > 0) {
 
                        var cmode = "";
@@ -959,10 +937,12 @@ function getLoadedArticleIds() {
 }
 
 // mode = all,none,unread,invert,marked,published
-function selectArticles(mode) {
+function selectArticles(mode, query) {
        try {
 
-               var children = $$("#headlines-frame > div[id*=RROW]");
+               if (!query) query = "#headlines-frame > div[id*=RROW]";
+
+               var children = $$(query);
 
                children.each(function(child) {
                        var id = child.id.replace("RROW-", "");
@@ -1188,7 +1168,7 @@ function editArticleTags(id) {
                                        }});
                                }
                        },
-                       href: query,
+                       href: query
                });
 
                var tmph = dojo.connect(dialog, 'onLoad', function() {
@@ -1241,7 +1221,7 @@ function postMouseOut(id) {
 
 function unpackVisibleHeadlines() {
        try {
-               if (!isCdmMode()) return;
+               if (!isCdmMode() || !getInitParam("cdm_expanded")) return;
 
                $$("#headlines-frame > div[id*=RROW]").each(
                        function(child) {
@@ -1273,15 +1253,15 @@ function headlines_scroll_handler(e) {
                unpackVisibleHeadlines();
 
                // set topmost child in the buffer as active
-               if (getInitParam("cdm_auto_catchup") == 1 &&
+               if (isCdmMode() && getInitParam("cdm_auto_catchup") == 1 &&
                                getSelectedArticleIds2().length <= 1 &&
-                               (!isCdmMode() || getInitParam("cdm_expanded"))) {
+                               getInitParam("cdm_expanded")) {
                        var rows = $$("#headlines-frame > div[id*=RROW]");
 
                        for (var i = 0; i < rows.length; i++) {
                                var child = rows[i];
 
-                               if ($("headlines-frame").scrollTop < child.offsetTop &&
+                               if ($("headlines-frame").scrollTop <= child.offsetTop &&
                                        child.offsetTop - $("headlines-frame").scrollTop < 100 &&
                                        child.id.replace("RROW-", "") != _active_article_id) {
 
@@ -1304,18 +1284,24 @@ function headlines_scroll_handler(e) {
                                                ((e.scrollTop + e.offsetHeight) / e.scrollHeight >= 0.7))) {
 
                                if (hsp)
-                                       hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
-                                               __("Loading, please wait...");
+                                       hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " +
+                                               __("Loading, please wait...") + "</span>";
 
                                loadMoreHeadlines();
                                return;
 
                        }
-               } else {
-                       if (hsp) hsp.innerHTML = "";
+               /*} else {
+                       if (hsp) {
+                               if (_infscroll_disable)
+                                       hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
+                                               __("Click to open next unread feed.") + "</a>";
+                               else
+                                       hsp.innerHTML = "";
+                       }*/
                }
 
-               if (getInitParam("cdm_expanded") && isCdmMode()) {
+               if (isCdmMode()) {
                        updateFloatingTitle();
                }
 
@@ -1348,6 +1334,20 @@ function headlines_scroll_handler(e) {
                                                500);
                                }
                        }
+
+                       if (_infscroll_disable) {
+                               var child = $$("#headlines-frame div[id*=RROW]").last();
+
+                               if (child && $("headlines-frame").scrollTop >
+                                               (child.offsetTop + child.offsetHeight - 50)) {
+
+                                       console.log("we seem to be at an end");
+
+                                       if (getInitParam("on_catchup_show_next_feed") == "1") {
+                                               openNextUnreadFeed();
+                                       }
+                               }
+                       }
                }
 
        } catch (e) {
@@ -1355,6 +1355,16 @@ function headlines_scroll_handler(e) {
        }
 }
 
+function openNextUnreadFeed() {
+       try {
+               var is_cat = activeFeedIsCat();
+               var nuf = getNextUnreadFeed(getActiveFeedId(), is_cat);
+               if (nuf) viewfeed(nuf, '', is_cat);
+       } catch (e) {
+               exception_error("openNextUnreadFeed", e);
+       }
+}
+
 function catchupBatchedArticles() {
        try {
                if (catchup_id_batch.length > 0 && !_infscroll_request_sent) {
@@ -1374,6 +1384,8 @@ function catchupBatchedArticles() {
                                        reply = JSON.parse(transport.responseText);
                                        var batch = reply.ids;
 
+                                       _infscroll_tmp_disable = 1;
+
                                        batch.each(function(id) {
                                                console.log(id);
                                                var elem = $("RROW-" + id);
@@ -1381,6 +1393,10 @@ function catchupBatchedArticles() {
                                                catchup_id_batch.remove(id);
                                        });
 
+                                       _infscroll_tmp_disable = 0;
+
+                                       updateFloatingTitle(true);
+
                                } });
                }
 
@@ -1489,6 +1505,12 @@ function cdmCollapseArticle(event, id, unmark) {
                        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("rowid", false);
                }
 
        } catch (e) {
@@ -1593,9 +1615,9 @@ function show_labels_in_headlines(transport) {
 
                if (data) {
                        data['info-for-headlines'].each(function(elem) {
-                               var ctr = $("HLLCTR-" + elem.id);
-
-                               if (ctr) ctr.innerHTML = elem.labels;
+                               $$(".HLLCTR-" + elem.id).each(function(ctr) {
+                                       ctr.innerHTML = elem.labels;
+                               });
                        });
                }
        } catch (e) {
@@ -1736,6 +1758,7 @@ function cdmClicked(event, id) {
 
                                if (article_is_unread) {
                                        decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
+                                       updateFloatingTitle(true);
                                }
 
                                var query = "?op=rpc&method=catchupSelected" +
@@ -1750,7 +1773,8 @@ function cdmClicked(event, id) {
                                return !event.shiftKey;
                        }
 
-               } else {
+               } else if (event.target.parents(".cdmHeader").length > 0) {
+
                        toggleSelected(id, true);
 
                        var elem = $("RROW-" + id);
@@ -1910,58 +1934,39 @@ function closeArticlePanel() {
                        dijit.byId("content-insert"));
 }
 
-function initHeadlinesMenu() {
+function initFloatingMenu() {
        try {
-               if (dijit.byId("headlinesMenu"))
-                       dijit.byId("headlinesMenu").destroyRecursive();
-
-               var ids = [];
-
-               if (!isCdmMode()) {
-                       nodes = $$("#headlines-frame > div[id*=RROW]");
-               } else {
-                       nodes = $$("#headlines-frame span[id*=RTITLE]");
-               }
-
-               nodes.each(function(node) {
-                       ids.push(node.id);
-               });
+               if (dijit.byId("floatingMenu"))
+                       dijit.byId("floatingMenu").destroyRecursive();
 
-               var menu = new dijit.Menu({
-                       id: "headlinesMenu",
-                       targetNodeIds: ids,
-               });
+                       var menu = new dijit.Menu({
+                               id: "floatingMenu",
+                               targetNodeIds: ["floatingTitle"]
+                       });
 
-               var tmph = dojo.connect(menu, '_openMyself', function (event) {
-                       var callerNode = event.target, match = null, tries = 0;
+                       var id = $("floatingTitle").getAttribute("rowid").replace("RROW-", "");
 
-                       while (match == null && callerNode && tries <= 3) {
-                               match = callerNode.id.match("^[A-Z]+[-]([0-9]+)$");
-                               callerNode = callerNode.parentNode;
-                               ++tries;
-                       }
-
-                       if (match) this.callerRowId = parseInt(match[1]);
+                       headlinesMenuCommon(menu, id);
 
-               });
+                       menu.startup();
+       } catch (e) {
+               exception_error("initFloatingMenu", e);
+       }
+}
 
-/*             if (!isCdmMode())
-                       menu.addChild(new dijit.MenuItem({
-                               label: __("View article"),
-                               onClick: function(event) {
-                                       view(this.getParent().callerRowId);
-                               }})); */
+function headlinesMenuCommon(menu, base_id) {
+       try {
 
                menu.addChild(new dijit.MenuItem({
                        label: __("Open original article"),
                        onClick: function(event) {
-                               openArticleInNewWindow(this.getParent().callerRowId);
+                               openArticleInNewWindow(base_id ? base_id : this.getParent().callerRowId);
                        }}));
 
                menu.addChild(new dijit.MenuItem({
                        label: __("Display article URL"),
                        onClick: function(event) {
-                               displayArticleUrl(this.getParent().callerRowId);
+                               displayArticleUrl(base_id ? base_id : this.getParent().callerRowId);
                        }}));
 
                menu.addChild(new dijit.MenuSeparator());
@@ -1971,7 +1976,7 @@ function initHeadlinesMenu() {
                        onClick: function(event) {
                                var ids = getSelectedArticleIds2();
                                // cast to string
-                               var id = this.getParent().callerRowId + "";
+                               var id = (base_id ? base_id : this.getParent().callerRowId) + "";
                                ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
 
                                selectionToggleUnread(undefined, false, true, ids);
@@ -1982,7 +1987,7 @@ function initHeadlinesMenu() {
                        onClick: function(event) {
                                var ids = getSelectedArticleIds2();
                                // cast to string
-                               var id = this.getParent().callerRowId + "";
+                               var id = (base_id ? base_id : this.getParent().callerRowId) + "";
                                ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
 
                                selectionToggleMarked(undefined, false, true, ids);
@@ -1993,7 +1998,7 @@ function initHeadlinesMenu() {
                        onClick: function(event) {
                                var ids = getSelectedArticleIds2();
                                // cast to string
-                               var id = this.getParent().callerRowId + "";
+                               var id = (base_id ? base_id : this.getParent().callerRowId) + "";
                                ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
 
                                selectionTogglePublished(undefined, false, true, ids);
@@ -2004,13 +2009,13 @@ function initHeadlinesMenu() {
                menu.addChild(new dijit.MenuItem({
                        label: __("Mark above as read"),
                        onClick: function(event) {
-                               catchupRelativeToArticle(0, this.getParent().callerRowId);
+                               catchupRelativeToArticle(0, base_id ? base_id : this.getParent().callerRowId);
                                }}));
 
                menu.addChild(new dijit.MenuItem({
                        label: __("Mark below as read"),
                        onClick: function(event) {
-                               catchupRelativeToArticle(1, this.getParent().callerRowId);
+                               catchupRelativeToArticle(1, base_id ? base_id : this.getParent().callerRowId);
                                }}));
 
 
@@ -2036,7 +2041,7 @@ function initHeadlinesMenu() {
                                        onClick: function(event) {
                                                var ids = getSelectedArticleIds2();
                                                // cast to string
-                                               var id = this.getParent().ownerMenu.callerRowId + "";
+                                               var id = (base_id ? base_id : this.getParent().ownerMenu.callerRowId) + "";
 
                                                ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
 
@@ -2049,7 +2054,7 @@ function initHeadlinesMenu() {
                                        onClick: function(event) {
                                                var ids = getSelectedArticleIds2();
                                                // cast to string
-                                               var id = this.getParent().ownerMenu.callerRowId + "";
+                                               var id = (base_id ? base_id : this.getParent().ownerMenu.callerRowId) + "";
 
                                                ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
 
@@ -2060,18 +2065,127 @@ function initHeadlinesMenu() {
 
                        menu.addChild(new dijit.PopupMenuItem({
                                label: __("Assign label"),
-                               popup: labelAddMenu,
+                               popup: labelAddMenu
                        }));
 
                        menu.addChild(new dijit.PopupMenuItem({
                                label: __("Remove label"),
-                               popup: labelDelMenu,
+                               popup: labelDelMenu
                        }));
 
                }
 
+
+       } catch (e) {
+               exception_error("headlinesMenuCommon", e);
+       }
+}
+
+function initHeadlinesMenu() {
+       try {
+               if (dijit.byId("headlinesMenu"))
+                       dijit.byId("headlinesMenu").destroyRecursive();
+
+               var ids = [];
+
+               if (!isCdmMode()) {
+                       nodes = $$("#headlines-frame > div[id*=RROW]");
+               } else {
+                       nodes = $$("#headlines-frame span[id*=RTITLE]");
+               }
+
+               nodes.each(function(node) {
+                       ids.push(node.id);
+               });
+
+               var menu = new dijit.Menu({
+                       id: "headlinesMenu",
+                       targetNodeIds: ids
+               });
+
+               var tmph = dojo.connect(menu, '_openMyself', function (event) {
+                       var callerNode = event.target, match = null, tries = 0;
+
+                       while (match == null && callerNode && tries <= 3) {
+                               match = callerNode.id.match("^[A-Z]+[-]([0-9]+)$");
+                               callerNode = callerNode.parentNode;
+                               ++tries;
+                       }
+
+                       if (match) this.callerRowId = parseInt(match[1]);
+
+               });
+
+               headlinesMenuCommon(menu, false);
+
                menu.startup();
 
+               /* vgroup feed title menu */
+
+               var nodes = $$("#headlines-frame > div[class='cdmFeedTitle']");
+               var ids = [];
+
+               nodes.each(function(node) {
+                       ids.push(node.id);
+               });
+
+               if (ids.length > 0) {
+                       if (dijit.byId("headlinesFeedTitleMenu"))
+                               dijit.byId("headlinesFeedTitleMenu").destroyRecursive();
+
+                       var menu = new dijit.Menu({
+                               id: "headlinesFeedTitleMenu",
+                               targetNodeIds: ids
+                       });
+
+                       var tmph = dojo.connect(menu, '_openMyself', function (event) {
+                               var callerNode = event.target, match = null, tries = 0;
+
+                               while (match == null && callerNode && tries <= 3) {
+                                       console.log(callerNode.id);
+
+                                       match = callerNode.id.match("^[A-Z]+[-]([0-9]+)$");
+                                       callerNode = callerNode.parentNode;
+                                       ++tries;
+
+                                       console.log(match[1]);
+                               }
+
+                               if (match) this.callerRowId = parseInt(match[1]);
+
+                       });
+
+                       menu.addChild(new dijit.MenuItem({
+                               label: __("Select articles in group"),
+                               onClick: function(event) {
+                                       selectArticles("all",
+                                               "#headlines-frame > div[id*=RROW]"+
+                                               "[orig-feed-id='"+menu.callerRowId+"']");
+
+                               }}));
+
+                       menu.addChild(new dijit.MenuItem({
+                               label: __("Mark group as read"),
+                               onClick: function(event) {
+                                       selectArticles("none");
+                                       selectArticles("all",
+                                               "#headlines-frame > div[id*=RROW]"+
+                                               "[orig-feed-id='"+menu.callerRowId+"']");
+
+                                       catchupSelection();
+                               }}));
+
+
+                       menu.addChild(new dijit.MenuItem({
+                               label: __("Mark feed as read"),
+                               onClick: function(event) {
+                                       catchupFeedInGroup(menu.callerRowId);
+                               }}));
+
+                       menu.startup();
+
+               }
+
        } catch (e) {
                exception_error("initHeadlinesMenu", e);
        }
@@ -2156,6 +2270,34 @@ function setSelectionScore() {
        }
 }
 
+function updateScore(id) {
+       try {
+               var pic = $$("#RROW-" + id + " .hlScorePic")[0];
+
+               if (pic) {
+
+                       var query = "op=article&method=getScore&id=" + param_escape(id);
+
+                       new Ajax.Request("backend.php", {
+                               parameters: query,
+                               onComplete: function(transport) {
+                                       console.log(transport.responseText);
+
+                                       var 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"]);
+                                       }
+                               } });
+               }
+
+       } catch (e) {
+               exception_error("updateScore", e);
+       }
+}
+
 function changeScore(id, pic) {
        try {
                var score = pic.getAttribute("score");
@@ -2175,6 +2317,7 @@ function changeScore(id, pic) {
                                        if (reply) {
                                                pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
                                                pic.setAttribute("score", new_score);
+                                               pic.setAttribute("title", new_score);
                                        }
                                } });
                }
@@ -2220,24 +2363,20 @@ function scrollToRowId(id) {
                var row = $(id);
 
                if (row)
-                       $("headlines-frame").scrollTop = row.offsetTop;
+                       $("headlines-frame").scrollTop = row.offsetTop - 4;
 
        } catch (e) {
                exception_error("scrollToRowId", e);
        }
 }
 
-function updateFloatingTitle() {
+function updateFloatingTitle(unread_only) {
        try {
-               var hf = $("headlines-frame");
-               var child = $("RROW-" + _active_article_id);
+               if (!isCdmMode()) return;
 
-               var elems;
+               var hf = $("headlines-frame");
 
-               if (getInitParam("cdm_auto_catchup"))
-                       elems = [$$("RROW-" + _active_article_id)];
-               else
-                       elems = $$("#headlines-frame > div[id*=RROW]");
+               var elems = $$("#headlines-frame > div[id*=RROW]");
 
                for (var i = 0; i < elems.length; i++) {
 
@@ -2247,18 +2386,34 @@ function updateFloatingTitle() {
 
                                var header = child.getElementsByClassName("cdmHeader")[0];
 
-                               if (child.id != $("floatingTitle").getAttribute("rowid")) {
-                                       $("floatingTitle").setAttribute("rowid", child.id);
-                                       $("floatingTitle").innerHTML = header.innerHTML;
-                                       $("floatingTitle").firstChild.innerHTML = "<img class='anchor markedPic' src='images/page_white_go.png' onclick=\"scrollToRowId('"+child.id+"')\">" + $("floatingTitle").firstChild.innerHTML;
+                               if (unread_only || child.id != $("floatingTitle").getAttribute("rowid")) {
+                                       if (child.id != $("floatingTitle").getAttribute("rowid")) {
+                                               $("floatingTitle").setAttribute("rowid", child.id);
+                                               $("floatingTitle").innerHTML = header.innerHTML;
+                                               $("floatingTitle").firstChild.innerHTML = "<img class='anchor markedPic' src='images/page_white_go.png' onclick=\"scrollToRowId('"+child.id+"')\">" + $("floatingTitle").firstChild.innerHTML;
+
+                                               initFloatingMenu();
+
+                                               var cb = $$("#floatingTitle .dijitCheckBox")[0];
+
+                                               if (cb)
+                                                       cb.parentNode.removeChild(cb);
+                                       }
+
+                                       if (child.hasClassName("Unread"))
+                                               $("floatingTitle").addClassName("Unread");
+                                       else
+                                               $("floatingTitle").removeClassName("Unread");
 
                                        PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, child);
                                }
 
-                               if (child.offsetTop < hf.scrollTop - header.offsetHeight)
-                                       Element.show("floatingTitle");
+                               $("floatingTitle").style.marginRight = hf.offsetWidth - child.offsetWidth + "px";
+                               if (header.offsetTop + header.offsetHeight < hf.scrollTop + $("floatingTitle").offsetHeight - 5 &&
+                                   child.offsetTop + child.offsetHeight >= hf.scrollTop + $("floatingTitle").offsetHeight - 5)
+                                       $("floatingTitle").style.visibility = "visible";
                                else
-                                       Element.hide("floatingTitle");
+                                       $("floatingTitle").style.visibility = "hidden";
 
                                return;
 
@@ -2269,3 +2424,7 @@ function updateFloatingTitle() {
                exception_error("updateFloatingTitle", e);
        }
 }
+
+function cdmFooterClick(event) {
+       event.stopPropagation();
+}
\ No newline at end of file