]> git.wh0rd.org - tt-rss.git/blobdiff - feedlist.js
restyle resizer
[tt-rss.git] / feedlist.js
index 62fceca37edd628b47f77921768a8fb41c26d46b..5ba9ec0b83fc38b23d2b67fcccc14c85fe2cf113 100644 (file)
@@ -8,6 +8,7 @@ var mouse_y = 0;
 var mouse_x = 0;
 
 var resize_enabled = false;
+var counters_last_request = 0;
 
 function viewCategory(cat) {
        active_feed_is_cat = true;
@@ -45,6 +46,9 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
 
 //             if (!offset) page_offset = 0;
 
+               last_requested_article = 0;
+               counters_last_request = 0;
+
                if (feed == getActiveFeedId()) {
                        cache_invalidate("F:" + feed);
                }
@@ -164,6 +168,10 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
                        query = query + "&omode=flc";
                }
 
+               if (!async_counters_work) {
+                       query = query + "&csync=true";
+               }
+
                debug(query);
 
                var container = document.getElementById("headlinesInnerContainer");
@@ -210,22 +218,7 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
 
                        f.innerHTML = cache_find_param(cache_prefix + feed, unread_ctr);
 
-                       var query = "backend.php?op=rpc&subop=getAllCounters";
-
-                       if (tagsAreDisplayed()) {
-                               query = query + "&omode=tl";
-                       } else {
-                               query = query + "&omode=flc";
-                       }
-
-                       new Ajax.Request(query, {
-                               onComplete: function(transport) { 
-                                       try {
-                                               all_counters_callback2(transport);
-                                       } catch (e) {
-                                               exception_error("viewfeed/getcounters", e);
-                                       }
-                               } });
+                       request_counters();
 
                } else {
 
@@ -332,7 +325,7 @@ function feedlist_init() {
 
                debug("in feedlist init");
                
-               hideOrShowFeeds(document, getInitParam("hide_read_feeds") == 1);
+               hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
                document.onkeydown = hotkey_handler;
                document.onmousemove = mouse_move_handler;
                document.onmousedown = mouse_down_handler;
@@ -496,6 +489,7 @@ function mouse_down_handler(e) {
                        mouse_x = 0;
                        mouse_y = 0;
                        document.onselectstart = function() { return false; };
+                       return false;
                }
        } catch (e) {
                exception_error("mouse_move_handler", e);
@@ -510,3 +504,58 @@ function mouse_up_handler(e) {
                exception_error("mouse_move_handler", e);
        }
 }
+
+function request_counters_real() {
+
+       try {
+
+               debug("requesting counters...");
+
+               var query = "backend.php?op=rpc&subop=getAllCounters";
+
+               if (tagsAreDisplayed()) {
+                       query = query + "&omode=tl";
+               } else {
+                       query = query + "&omode=flc";
+               }
+
+               new Ajax.Request(query, {
+                       onComplete: function(transport) { 
+                               try {
+                                       all_counters_callback2(transport, true);
+                               } catch (e) {
+                                       exception_error("viewfeed/getcounters", e);
+                               }
+                       } });
+
+       } catch (e) {
+               exception_error("request_counters_real", e);
+       }
+}
+
+
+function request_counters() {
+
+       try {
+
+               if (getInitParam("bw_limit") == "1") return;
+
+               var date = new Date();
+               var timestamp = Math.round(date.getTime() / 1000);
+
+//             if (getInitParam("sync_counters") == "1" || 
+//                             timestamp - counters_last_request > 10) {
+
+               if (timestamp - counters_last_request > 10) {
+
+                       debug("scheduling request of counters...");
+                       window.setTimeout("request_counters_real()", 1000);
+                       counters_last_request = timestamp;
+               } else {
+                       debug("request_counters: rate limit reached: " + (timestamp - counters_last_request));
+               }
+
+       } catch (e) {
+               exception_error("request_counters", e);
+       }
+}