]> git.wh0rd.org - tt-rss.git/blobdiff - viewfeed.js
infinite scrolling
[tt-rss.git] / viewfeed.js
index 4fd9db30f8e64654d52e72f920ac0c4065c7f193..e464f21981fbb1b7f42eb51eb70cb2b38dfb2314 100644 (file)
@@ -38,7 +38,10 @@ function headlines_callback() {
                debug("headlines_callback");
                var f = document.getElementById("headlines-frame");
                try {
-                       f.scrollTop = 0;
+                       if (feed_cur_page == 0) { 
+                               debug("resetting headlines scrollTop");
+                               f.scrollTop = 0; 
+                       }
                } catch (e) { };
 
                if (xmlhttp.responseXML) {
@@ -47,11 +50,29 @@ function headlines_callback() {
                        var articles = xmlhttp.responseXML.getElementsByTagName("article");
                        var runtime_info = xmlhttp.responseXML.getElementsByTagName("runtime-info");
 
-                       if (headlines) {
-                               f.innerHTML = headlines.firstChild.nodeValue;
+                       if (feed_cur_page == 0) {
+                               if (headlines) {
+                                       f.innerHTML = headlines.firstChild.nodeValue;
+                               } else {
+                                       debug("headlines_callback: returned no data");
+                               f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
+       
+                               }
                        } else {
-                               debug("headlines_callback: returned no data");
-                       f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
+                               if (headlines) {
+                                       debug("adding some more headlines...");
+
+                                       var c = document.getElementById("headlinesList");
+
+                                       if (!c) {
+                                               c = document.getElementById("headlinesInnerContainer");
+                                       }
+
+                                       c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue;
+                               } else {
+                                       debug("headlines_callback: returned no data");
+                                       notify_error("Error while trying to load more headlines");      
+                               }
 
                        }
 
@@ -103,6 +124,8 @@ function headlines_callback() {
                        try {
                                document.getElementById("headlinesInnerContainer").scrollTop = _tag_cdm_scroll;
                                _tag_cdm_scroll = false;
+                               debug("resetting headlinesInner scrollTop");
+
                        } catch (e) { }
                }
 
@@ -647,6 +670,14 @@ function cdmSelectArticles(mode) {
 
 function catchupPage() {
 
+       var fn = getFeedName(getActiveFeedId(), active_feed_is_cat);
+       
+       var str = "Mark all visible articles in " + fn + " as read?";
+
+       if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
+               return;
+       }
+
        if (document.getElementById("headlinesList")) {
                selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
                selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
@@ -913,3 +944,35 @@ function cache_invalidate(id) {
 function getActiveArticleId() {
        return active_post_id;
 }
+
+function cdmMouseIn(elem) {
+       try {
+               if (elem.id && elem.id.match("RROW-")) {
+                       var id = elem.id.replace("RROW-", "");
+                       active_post_id = id;
+               }
+       } catch (e) {
+               exception_error("cdmMouseIn", e);
+       }
+
+}
+
+function cdmMouseOut(elem) {
+       active_post_id = false;
+}
+
+function headlines_scroll_handler() {
+       try {
+
+               var e = document.getElementById("headlinesInnerContainer");
+
+               if (e.scrollTop + e.offsetHeight == e.scrollHeight) {
+                       debug("more cowbell!");
+
+                       viewNextFeedPage();
+               }
+
+       } catch (e) {
+               exception_error("headlines_scroll_handler", e);
+       }
+}