]> git.wh0rd.org - tt-rss.git/blobdiff - js/feedlist.js
Update messages.po
[tt-rss.git] / js / feedlist.js
index ae4c3a2fb6aafbf4c435d8717414ef5649d4c84e..7c2e08052d41888afa630db048d5d36fc46f5a9d 100644 (file)
@@ -2,6 +2,7 @@ var _infscroll_disable = 0;
 var _infscroll_request_sent = 0;
 var _search_query = false;
 var _viewfeed_last = 0;
+var _viewfeed_timeout = false;
 
 var counters_last_request = 0;
 
@@ -34,10 +35,7 @@ function loadMoreHeadlines() {
                } else if (_search_query) {
                        offset = num_all;
                } else if (view_mode == "adaptive") {
-                       if (num_unread > 0)
-                               offset = unread_in_buffer;
-                       else
-                               offset = num_all;
+                       offset = num_unread > 0 ? unread_in_buffer : num_all;
                } else {
                        offset = num_all;
                }
@@ -52,7 +50,7 @@ function loadMoreHeadlines() {
 }
 
 
-function viewfeed(feed, method, is_cat, offset, background, infscroll_req) {
+function viewfeed(feed, method, is_cat, offset, background, infscroll_req, can_wait) {
        try {
                if (is_cat == undefined)
                        is_cat = false;
@@ -88,15 +86,13 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req) {
 
                                _infscroll_request_sent = timestamp;
                        }
-
-                       hideAuxDlg();
                }
 
                Form.enable("main_toolbar_form");
 
                var toolbar_query = Form.serialize("main_toolbar_form");
 
-               var query = "?op=feeds&method=view&feed=" + feed + "&" +
+               var query = "?op=feeds&method=view&feed=" + param_escape(feed) + "&" +
                        toolbar_query;
 
                if (method) {
@@ -125,23 +121,33 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req) {
 
                        Form.enable("main_toolbar_form");
 
-                       if (!offset) {
-                               if (!setFeedExpandoIcon(feed, is_cat,
-                                                       (is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif'))
+                       if (!setFeedExpandoIcon(feed, is_cat,
+                               (is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif'))
                                        notify_progress("Loading, please wait...", true);
-                       }
                }
 
                query += "&cat=" + is_cat;
 
                console.log(query);
 
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) {
-                               setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
-                               headlines_callback2(transport, offset, background, infscroll_req);
-                       } });
+               if (can_wait && _viewfeed_timeout) {
+                       setFeedExpandoIcon(getActiveFeedId(), activeFeedIsCat(), 'images/blank_icon.gif');
+                       clearTimeout(_viewfeed_timeout);
+               }
+
+               setActiveFeedId(feed, is_cat);
+
+               timeout_ms = can_wait ? 250 : 0;
+               _viewfeed_timeout = setTimeout(function() {
+
+                       new Ajax.Request("backend.php", {
+                               parameters: query,
+                               onComplete: function(transport) {
+                                       setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
+                                       headlines_callback2(transport, offset, background, infscroll_req);
+                                       PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
+                               } });
+               }, timeout_ms); // Wait 250ms
 
        } catch (e) {
                exception_error("viewfeed", e);
@@ -152,6 +158,8 @@ function feedlist_init() {
        try {
                console.log("in feedlist init");
 
+               loading_set_progress(50);
+
                document.onkeydown = hotkey_handler;
                setTimeout("hotkey_prefix_timeout()", 5*1000);
 
@@ -208,23 +216,6 @@ function request_counters(force) {
        }
 }
 
-function displayNewContentPrompt(id) {
-       try {
-
-               var msg = "<a href='#' onclick='viewCurrentFeed()'>" +
-                       __("New articles available in this feed (click to show)") + "</a>";
-
-               msg = msg.replace("%s", getFeedName(id));
-
-               $('auxDlg').innerHTML = msg;
-
-               new Effect.Appear('auxDlg', {duration : 0.5});
-
-       } catch (e) {
-               exception_error("displayNewContentPrompt", e);
-       }
-}
-
 function parse_counters(elems, scheduled_call) {
        try {
                for (var l = 0; l < elems.length; l++) {
@@ -235,6 +226,7 @@ function parse_counters(elems, scheduled_call) {
                        var error = elems[l].error;
                        var has_img = elems[l].has_img;
                        var updated = elems[l].updated;
+                       var auxctr = parseInt(elems[l].auxcounter);
 
                        if (id == "global-unread") {
                                global_unread = ctr;
@@ -247,15 +239,12 @@ function parse_counters(elems, scheduled_call) {
                                continue;
                        }
 
-                       if (id == getActiveFeedId() && ctr > getFeedUnread(id) && scheduled_call) {
-                               displayNewContentPrompt(id);
-                       }
-
                        if (getFeedUnread(id, (kind == "cat")) != ctr ||
                                        (kind == "cat")) {
                        }
 
                        setFeedUnread(id, (kind == "cat"), ctr);
+                       setFeedValue(id, (kind == "cat"), 'auxcounter', auxctr);
 
                        if (kind != "cat") {
                                setFeedValue(id, false, 'error', error);
@@ -405,8 +394,8 @@ function getNextUnreadFeed(feed, is_cat) {
        }
 }
 
-function catchupCurrentFeed() {
-       return catchupFeed(getActiveFeedId(), activeFeedIsCat());
+function catchupCurrentFeed(mode) {
+       catchupFeed(getActiveFeedId(), activeFeedIsCat(), mode);
 }
 
 function catchupFeedInGroup(id) {
@@ -425,11 +414,26 @@ function catchupFeedInGroup(id) {
        }
 }
 
-function catchupFeed(feed, is_cat) {
+function catchupFeed(feed, is_cat, mode) {
        try {
                if (is_cat == undefined) is_cat = false;
 
-               var str = __("Mark all articles in %s as read?");
+               var str = false;
+
+               switch (mode) {
+               case "1day":
+                       str = __("Mark all articles in %s older than 1 day as read?");
+                       break;
+               case "1week":
+                       str = __("Mark all articles in %s older than 1 week as read?");
+                       break;
+               case "2week":
+                       str = __("Mark all articles in %s older than 2 weeks as read?");
+                       break;
+               default:
+                       str = __("Mark all articles in %s as read?");
+               }
+
                var fn = getFeedName(feed, is_cat);
 
                str = str.replace("%s", fn);
@@ -438,20 +442,8 @@ function catchupFeed(feed, is_cat) {
                        return;
                }
 
-               var max_id = 0;
-
-               if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
-                       $$("#headlines-frame > div[id*=RROW]").each(
-                               function(child) {
-                                       var id = parseInt(child.id.replace("RROW-", ""));
-
-                                       if (id > max_id) max_id = id;
-                               }
-                       );
-               }
-
                var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" +
-                       feed + "&is_cat=" + is_cat + "&max_id=" + max_id;
+                       feed + "&is_cat=" + is_cat + "&mode=" + mode;
 
                console.log(catchup_query);
 
@@ -462,15 +454,6 @@ function catchupFeed(feed, is_cat) {
                        onComplete: function(transport) {
                                        handle_rpc_json(transport);
 
-                                       if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
-
-                                               $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
-                                                       function(child) {
-                                                               child.removeClassName("Unread");
-                                                       }
-                                               );
-                                       }
-
                                        var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
 
                                        if (show_next_feed) {
@@ -479,6 +462,10 @@ function catchupFeed(feed, is_cat) {
                                                if (nuf) {
                                                        viewfeed(nuf, '', is_cat);
                                                }
+                                       } else {
+                                               if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
+                                                       viewCurrentFeed();
+                                               }
                                        }
 
                                        notify("");
@@ -515,3 +502,5 @@ function decrementFeedCounter(feed, is_cat) {
                exception_error("decrement_feed_counter", e);
        }
 }
+
+