]> git.wh0rd.org - tt-rss.git/blobdiff - js/viewfeed.js
af_comics_gocomics: fix indenting
[tt-rss.git] / js / viewfeed.js
index a786904e39d48859b8f0cf3d925435a294cb35e1..c319a8ed02e2c40c3ea362841d3680a110696ede 100644 (file)
@@ -8,7 +8,6 @@ var post_under_pointer = false;
 var last_requested_article = false;
 
 var catchup_id_batch = [];
-var catchup_go_next = false;
 var catchup_timeout_id = false;
 
 var cids_requested = [];
@@ -109,6 +108,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>)" +
@@ -148,9 +151,9 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
 
                                        if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
 
-                                       if (getInitParam("cdm_auto_catchup") == 1) {
+//                                     if (getInitParam("cdm_auto_catchup") == 1) {
                                                c.domNode.appendChild(hsp);
-                                       }
+//                                     }
 
                                        console.log("added " + new_elems.size() + " headlines");
 
@@ -177,7 +180,8 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
 
                                        var hsp = $("headlines-spacer");
 
-                                       if (hsp) hsp.innerHTML = "";
+                                       if (hsp) hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
+                                               __("Click to open next unread feed.") + "</a>";
                                }
                        }
 
@@ -1308,15 +1312,20 @@ 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 = "";
+                       if (hsp)
+                               if (_infscroll_disable)
+                                       hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" +
+                                               __("Click to open next unread feed.") + "</a>";
+                               else
+                                       hsp.innerHTML = "";
                }
 
                if (isCdmMode()) {
@@ -1329,8 +1338,6 @@ function headlines_scroll_handler(e) {
                        var ts = new Date().getTime();
                        if (ts - _last_headlines_update < 100) return;
 
-                       var atend = true;
-
                        $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
                                function(child) {
                                        if (child.hasClassName("Unread") && $("headlines-frame").scrollTop >
@@ -1342,18 +1349,10 @@ function headlines_scroll_handler(e) {
                                                        catchup_id_batch.push(id);
 
                                                //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
-                                       } else {
-                                               atend = false;
                                        }
 
                                });
 
-                       if (atend) {
-                               if (getInitParam("on_catchup_show_next_feed") == "1") {
-                                       catchup_go_next = true;
-                               }
-                       }
-
                        if (catchup_id_batch.length > 0) {
                                window.clearTimeout(catchup_timeout_id);
 
@@ -1362,6 +1361,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) {
@@ -1369,6 +1382,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) {
@@ -1399,12 +1422,6 @@ function catchupBatchedArticles() {
 
                                } });
                }
-               if (catchup_go_next) {
-                       catchup_go_next = false;
-                       var is_cat = activeFeedIsCat();
-                       var nuf = getNextUnreadFeed(getActiveFeedId(), is_cat);
-                       if (nuf) viewfeed(nuf, '', is_cat);
-               }
 
        } catch (e) {
                exception_error("catchupBatchedArticles", e);