]> git.wh0rd.org Git - tt-rss.git/commitdiff
js: code cleanup; move to async counter sending mode
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 10 Nov 2010 11:48:35 +0000 (14:48 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 10 Nov 2010 11:48:35 +0000 (14:48 +0300)
backend.php
feedlist.js
functions.js
functions.php
lib/pngfix.js [deleted file]
prefs.js
tt-rss.js
viewfeed.js

index 5cef094d69f862227f6f8fd3320d1d7e667bcb58..c19c3b9e3d393c29318a892c33cf78b72fc61cd5 100644 (file)
 
                        }
 
-                       $_SESSION["viewfeed:counters_stamp"] = time();
-
                        outputFeedList($link, $tags);
                break; // feeds
 
                        $mode = db_escape_string($_REQUEST["mode"]);
                        $omode = db_escape_string($_REQUEST["omode"]);
 
-                       $csync = $_REQUEST["csync"];
-
                        print "<reply>";
 
                        // in prefetch mode we only output requested cids, main article 
                                }
                        }
 
-//                     if (get_pref($link, "SYNC_COUNTERS") || ($mode == "prefetch" && $csync)) {
-
-                       if (time() - $_SESSION["view:counters_stamp"] > 5 && $mode == "prefetch") {
+                       /* if ($mode == "prefetch") {
                                print "<counters><![CDATA[";
                                print json_encode(getAllCounters($link, $omode));
                                print "]]></counters>";
-                               $_SESSION["view:counters_stamp"] = time();
-                       }
+                       } */
 
                        print "</reply>";
                break; // view
                        @$next_unread_feed = db_escape_string($_REQUEST["nuf"]);
                        @$offset = db_escape_string($_REQUEST["skip"]);
                        @$vgroup_last_feed = db_escape_string($_REQUEST["vgrlf"]);
-                       $csync = $_REQUEST["csync"];
                        $order_by = db_escape_string($_REQUEST["order_by"]);
 
                        /* Feed -5 is a special case: it is used to display auxiliary information
                        /* Updating a label ccache means recalculating all of the caches
                         * so for performance reasons we don't do that here */
 
-//                     if (time() - $_SESSION["viewfeed:ccache_update_stamp"] > 120) {
-                               if ($feed >= 0) {
-                                       ccache_update($link, $feed, $_SESSION["uid"], $cat_view);
-                               }
-                               $_SESSION["viewfeed:ccache_update_stamp"] = time();
-//                     }
+                       if ($feed >= 0) {
+                               ccache_update($link, $feed, $_SESSION["uid"], $cat_view);
+                       }
 
                        set_pref($link, "_DEFAULT_VIEW_MODE", $view_mode);
                        set_pref($link, "_DEFAULT_VIEW_LIMIT", $limit);
 
                        if ($_REQUEST["debug"]) $timing_info = print_checkpoint("20", $timing_info);
 
-                       if (get_pref($link, 'COMBINED_DISPLAY_MODE') || $subop || 
-                               time() - $_SESSION["viewfeed:counters_stamp"] > 5) {
-                               if (!$offset) {
-                                       print "<counters><![CDATA[";
-                                       print json_encode(getAllCounters($link, $omode, $feed));
-                                       print "]]></counters>";
-                                       $_SESSION["viewfeed:counters_stamp"] = time();
-                               }
-                       }
+                       /* if (get_pref($link, 'COMBINED_DISPLAY_MODE') || $subop || !$offset) {
+                               print "<counters><![CDATA[";
+                               print json_encode(getAllCounters($link, $omode, $feed));
+                               print "]]></counters>";
+                       } */
 
                        if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info);
 
index 3c6e881a04bbccf7529ae0580aa34b5f46b0e7ea..b7d47b4a59763f8f9e480cea4bd6f2dfc1e28df0 100644 (file)
@@ -7,6 +7,8 @@ var mouse_is_down = false;
 var mouse_y = 0;
 var mouse_x = 0;
 
+var counter_timeout_id = false;
+
 var resize_enabled = false;
 var selection_disabled = false;
 var counters_last_request = 0;
@@ -214,10 +216,6 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
                        query = query + "&omode=flc";
                }
 
-               if (!async_counters_work) {
-                       query = query + "&csync=true";
-               }
-
                console.log(query);
 
                var container = $("headlinesInnerContainer");
@@ -407,10 +405,6 @@ function feedlist_init() {
 
                setTimeout("hotkey_prefix_timeout()", 5*1000);
 
-               if (typeof correctPNG != 'undefined') {
-                       correctPNG();
-               }
-
                if (getActiveFeedId()) {
                        //console.log("some feed is open on feedlist refresh, reloading");
                        //setTimeout("viewCurrentFeed()", 100);
@@ -599,7 +593,7 @@ function request_counters_real() {
                        parameters: query,
                        onComplete: function(transport) { 
                                try {
-                                       all_counters_callback2(transport, true);
+                                       all_counters_callback2(transport);
                                } catch (e) {
                                        exception_error("viewfeed/getcounters", e);
                                }
@@ -620,9 +614,12 @@ function request_counters() {
                var date = new Date();
                var timestamp = Math.round(date.getTime() / 1000);
 
-               if (timestamp - counters_last_request > 15) {
+               if (timestamp - counters_last_request > 10) {
                        console.log("scheduling request of counters...");
-                       window.setTimeout("request_counters_real()", 1000);
+
+                       window.clearTimeout(counter_timeout_id);
+                       counter_timeout_id = window.setTimeout("request_counters_real()", 1000);
+
                        counters_last_request = timestamp;
                } else {
                        console.log("request_counters: rate limit reached: " + (timestamp - counters_last_request));
index a4528b78fbd56b2dbc81c7db7012763f5abd12e2..46716a4072fffdb9718bb4ddac524a08982d09dc 100644 (file)
@@ -1,7 +1,6 @@
 var hotkeys_enabled = true;
 var notify_silent = false;
 var last_progress_point = 0;
-var async_counters_work = false;
 var sanity_check_done = false;
 
 /* add method to remove element from array */
@@ -578,9 +577,8 @@ function parse_counters_reply(transport, scheduled_call) {
 
 }
 
-function all_counters_callback2(transport, async_call) {
+function all_counters_callback2(transport) {
        try {
-               if (async_call) async_counters_work = true;
                if (offline_mode) return;
 
                parse_counters_reply(transport);
index 813e3514511045c30914c4ac1f1c14ea2d6ae7f7..9b69589498df2657b4c16df3bfd90d18c33c37b8 100644 (file)
                                        setcookie("ttrss_lang", $_SESSION["language"], 
                                                time() + SESSION_COOKIE_LIFETIME);
                                }
-
-                               /* bump counters stamp since we're getting reloaded anyway */
-
-                               $_SESSION["get_all_counters_stamp"] = time();
                        }
 
                } else {
diff --git a/lib/pngfix.js b/lib/pngfix.js
deleted file mode 100644 (file)
index c8ef4b2..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-// stolen from http://homepage.ntlworld.com/bobosola/pngtestfixed.htm
-
-function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
-   {
-   for(var i=0; i<document.images.length; i++)
-      {
-         var img = document.images[i]
-         var imgName = img.src.toUpperCase()
-         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
-            {
-                var imgID = (img.id) ? "id='" + img.id + "' " : ""
-                var imgClass = (img.className) ? "class='" + img.className + "' " : ""
-                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
-                var imgStyle = "display:inline-block;" + img.style.cssText 
-                if (img.align == "left") imgStyle = "float:left;" + imgStyle
-                if (img.align == "right") imgStyle = "float:right;" + imgStyle
-                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle               
-                var strNewHTML = "<span " + imgID + imgClass + imgTitle
-                + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
-            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
-                + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
-                img.outerHTML = strNewHTML
-                i = i-1
-            }
-      }
-   }
-window.attachEvent("onload", correctPNG);
index c590c61f8fee0787187c3d7dc765ed49f194f2cf..ed8d1679c037b74dac7bf1b568e49da5f6d1984c 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -30,9 +30,6 @@ function feedlist_callback2(transport) {
 
                        caller_subop = false;
                }
-               if (typeof correctPNG != 'undefined') {
-                       correctPNG();
-               }
                notify("");
                remove_splash();
 
@@ -44,9 +41,6 @@ function feedlist_callback2(transport) {
 function filterlist_callback2(transport) {
        var container = $('prefContent');
        container.innerHTML=transport.responseText;
-       if (typeof correctPNG != 'undefined') {
-               correctPNG();
-       }
        notify("");
        remove_splash();
 }
@@ -84,9 +78,6 @@ function labellist_callback2(transport) {
 
                        init_label_inline_editor();
        
-                       if (typeof correctPNG != 'undefined') {
-                               correctPNG();
-                       }
                        notify("");
                        remove_splash();
 
index 5551dc2d1ba2dd8cf102652af0329203ccd15c7e..c310e267bc9b40f065da00aaad125486ea27bfc6 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -3,7 +3,6 @@ var total_unread = 0;
 var first_run = true;
 var display_tags = false;
 var global_unread = -1;
-var active_title_text = "";
 var current_subtitle = "";
 var daemon_enabled = false;
 //var _qfd_deleted_feed = 0;
@@ -233,10 +232,6 @@ function updateTitle(s) {
                tmp = tmp + " - " + current_subtitle;
        }
 
-       if (active_title_text.length > 0) {
-               tmp = tmp + " > " + active_title_text;
-       }
-
        if (window.fluid) {
                if (global_unread > 0) {
                        window.fluid.dockBadge = global_unread;
@@ -249,9 +244,6 @@ function updateTitle(s) {
 }
 
 function genericSanityCheck() {
-
-//     if (!Ajax.getTransport()) fatalError(1);
-
        setCookie("ttrss_test", "TEST");
        
        if (getCookie("ttrss_test") != "TEST") {
@@ -370,7 +362,6 @@ function init_second_stage() {
 
                delCookie("ttrss_test");
 
-//             document.onresize = resize_headlines;
                window.onresize=resize_headlines;
 
                var toolbar = document.forms["main_toolbar_form"];
@@ -381,19 +372,6 @@ function init_second_stage() {
                daemon_enabled = getInitParam("daemon_enabled") == 1;
                feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1;
 
-/*             var fl = cache_find_param("FEEDLIST", getInitParam("num_feeds"));
-
-               if (fl) {
-                       render_feedlist(fl);
-                       if ($("feedList")) {
-                               request_counters();
-                       } else {
-                               setTimeout('updateFeedList(false, false)', 50);
-                       }
-               } else {
-                       setTimeout('updateFeedList(false, false)', 50);
-               } */
-
                setTimeout('updateFeedList(false, false)', 50);
 
                console.log("second stage ok");
@@ -552,11 +530,6 @@ function quickMenuGo(opid) {
        }
 }
 
-function updateFeedTitle(t) {
-       active_title_text = t;
-       updateTitle();
-}
-
 function toggleDispRead() {
        try {
 
index 5df91c330b77da167a3cf5cdae834e5d48ea388e..cb1f31b1428a0103fd1b8e83435c241629c6ddea 100644 (file)
@@ -218,10 +218,7 @@ function headlines_callback2(transport, feed_cur_page) {
                        f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
                }
        
-               if (typeof correctPNG != 'undefined') {
-                       correctPNG();
-               }
-       
+
                if (_cdm_wd_timeout) window.clearTimeout(_cdm_wd_timeout);
        
                if (!$("headlinesList") && 
@@ -399,10 +396,6 @@ function article_callback2(transport, id) {
                var date = new Date();
                last_article_view = date.getTime() / 1000;
 
-               if (typeof correctPNG != 'undefined') {
-                       correctPNG();
-               }
-
                if (_reload_feedlist_after_view) {
                        setTimeout('updateFeedList(false, false)', 50);                 
                        _reload_feedlist_after_view = false;
@@ -468,10 +461,6 @@ function view(id) {
                var crow = $("RROW-" + id);
                var article_is_unread = crow.className.match("Unread");
 
-               if (!async_counters_work) {
-                       query = query + "&csync=true";
-               }
-
                showArticleInHeadlines(id);
 
                if (!cached_article) {
@@ -1836,7 +1825,13 @@ function cache_expire() {
 }
 
 function cache_flush() {
-       article_cache = new Array();
+       if (db) {
+               db.execute("DELETE FROM cache");
+       } else if (has_local_storage()) {
+               localStorage.clear();
+       } else {
+               article_cache = new Array();
+       }
 }
 
 function cache_invalidate(id) {