From: Andrew Dolgov Date: Wed, 10 Nov 2010 11:48:35 +0000 (+0300) Subject: js: code cleanup; move to async counter sending mode X-Git-Tag: 1.5.0~314 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=5225d4209e52790af6bad454d7b6da6953551ace;p=tt-rss.git js: code cleanup; move to async counter sending mode --- diff --git a/backend.php b/backend.php index 5cef094d..c19c3b9e 100644 --- a/backend.php +++ b/backend.php @@ -208,8 +208,6 @@ } - $_SESSION["viewfeed:counters_stamp"] = time(); - outputFeedList($link, $tags); break; // feeds @@ -220,8 +218,6 @@ $mode = db_escape_string($_REQUEST["mode"]); $omode = db_escape_string($_REQUEST["omode"]); - $csync = $_REQUEST["csync"]; - print ""; // in prefetch mode we only output requested cids, main article @@ -243,14 +239,11 @@ } } -// if (get_pref($link, "SYNC_COUNTERS") || ($mode == "prefetch" && $csync)) { - - if (time() - $_SESSION["view:counters_stamp"] > 5 && $mode == "prefetch") { + /* if ($mode == "prefetch") { print ""; - $_SESSION["view:counters_stamp"] = time(); - } + } */ print ""; break; // view @@ -274,7 +267,6 @@ @$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 @@ -289,12 +281,9 @@ /* 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); @@ -394,15 +383,11 @@ 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 ""; - $_SESSION["viewfeed:counters_stamp"] = time(); - } - } + /* if (get_pref($link, 'COMBINED_DISPLAY_MODE') || $subop || !$offset) { + print ""; + } */ if ($_REQUEST["debug"]) $timing_info = print_checkpoint("30", $timing_info); diff --git a/feedlist.js b/feedlist.js index 3c6e881a..b7d47b4a 100644 --- a/feedlist.js +++ b/feedlist.js @@ -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)); diff --git a/functions.js b/functions.js index a4528b78..46716a40 100644 --- a/functions.js +++ b/functions.js @@ -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); diff --git a/functions.php b/functions.php index 813e3514..9b695894 100644 --- a/functions.php +++ b/functions.php @@ -2037,10 +2037,6 @@ 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 index c8ef4b28..00000000 --- a/lib/pngfix.js +++ /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" - img.outerHTML = strNewHTML - i = i-1 - } - } - } -window.attachEvent("onload", correctPNG); diff --git a/prefs.js b/prefs.js index c590c61f..ed8d1679 100644 --- 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(); diff --git a/tt-rss.js b/tt-rss.js index 5551dc2d..c310e267 100644 --- 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 { diff --git a/viewfeed.js b/viewfeed.js index 5df91c33..cb1f31b1 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -218,10 +218,7 @@ function headlines_callback2(transport, feed_cur_page) { f.innerHTML = "
" + __('Could not update headlines (missing XML object)') + "
"; } - 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) {