]> git.wh0rd.org Git - tt-rss.git/commitdiff
catchup in category view mode jumps to the next unread category
authorAndrew Dolgov <fox@madoka.spb.ru>
Wed, 1 Oct 2008 04:06:55 +0000 (05:06 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Wed, 1 Oct 2008 04:06:55 +0000 (05:06 +0100)
feedlist.js
functions.js
viewfeed.js

index 8400af52cd5708f249cbc48218ea30939ed64f8f..22b8aeab3b434e5d1b0f81d3d003677c11e70d31 100644 (file)
@@ -135,22 +135,41 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
 
                if (subop == "MarkAllRead") {
 
-                       var feedlist = document.getElementById('feedList');
-                       
-                       var next_unread_feed = getRelativeFeedId(feedlist,
-                                       feed, "next", true);
-
-                       if (!next_unread_feed) {
-                               next_unread_feed = getRelativeFeedId(feedlist,
-                                       -3, "next", true);
-                       }
-
                        var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
 
-                       if (next_unread_feed && show_next_feed && !activeFeedIsCat()) {
-                               query = query + "&nuf=" + param_escape(next_unread_feed);
-                               //setActiveFeedId(next_unread_feed);
-                               feed = next_unread_feed;
+                       if (show_next_feed) {
+
+                               if (!activeFeedIsCat()) {
+       
+                                       var feedlist = document.getElementById('feedList');
+                               
+                                       var next_unread_feed = getRelativeFeedId(feedlist,
+                                                       feed, "next", true);
+       
+                                       if (!next_unread_feed) {
+                                               next_unread_feed = getRelativeFeedId(feedlist,
+                                                       -3, "next", true);
+                                       }
+               
+                                       if (next_unread_feed) {
+                                               query = query + "&nuf=" + param_escape(next_unread_feed);
+                                               //setActiveFeedId(next_unread_feed);
+                                               feed = next_unread_feed;
+                                       }
+                               } else {
+       
+                                       var next_unread_feed = getNextUnreadCat(feed);
+
+                                       /* we don't need to specify that our next feed is actually
+                                       a category, because we're in the is_cat mode by definition
+                                       already */
+
+                                       if (next_unread_feed && show_next_feed) {
+                                               query = query + "&nuf=" + param_escape(next_unread_feed);
+                                               feed = next_unread_feed;
+                                       }
+
+                               }
                        }
                }
 
index 351f4dcc35489edffbfffddd9c268aee188b5ff2..77c5c13b12e96ab8453de8101632bcd60a33668f 100644 (file)
@@ -1035,6 +1035,40 @@ function toggleSelectRow(sender) {
        }
 }
 
+function getNextUnreadCat(id) {
+       try {
+               var rows = document.getElementById("feedList").getElementsByTagName("LI");
+               var feeds = new Array();
+
+               var unread_only = true;
+               var is_cat = true;
+
+               for (var i = 0; i < rows.length; i++) {
+                       if (rows[i].id.match("FCAT-")) {
+                               if (rows[i].id == "FCAT-" + id && is_cat || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) {
+
+                                       var cat_id = parseInt(rows[i].id.replace("FCAT-", ""));
+
+                                       if (cat_id >= 0) {
+                                               if (!unread_only || get_cat_unread(cat_id) > 0) {
+                                                       feeds.push(cat_id);
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               var idx = feeds.indexOf(id);
+               if (idx != -1 && idx < feeds.length) {
+                       return feeds[idx+1];                                    
+               } else {
+                       return feeds.shift();
+               }
+
+       } catch (e) {
+               exception_error("getNextUnreadCat", e);
+       }
+}
 
 function getRelativeFeedId2(id, is_cat, direction, unread_only) {      
        try {
index 4b90f1d051ca069a9a936c2f70bdf6263bf6c298..3810aed20a5db3d99b8a6a1d9c9766ee5ccd7e2a 100644 (file)
@@ -81,7 +81,7 @@ function headlines_callback2(transport, active_feed_id, is_cat, feed_cur_page) {
                if (is_cat != undefined) {
                        active_feed_is_cat = is_cat;
                }
-       
+
                if (!is_cat) {
                        var feedr = document.getElementById("FEEDR-" + active_feed_id);
                        if (feedr && !feedr.className.match("Selected")) {