From a598370dde80604280f1a9708f8427902f376209 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 24 Jun 2008 08:43:20 +0100 Subject: [PATCH] add low bandwidth mode (less automatic requests in the background) --- backend.php | 10 ++++++---- feedlist.js | 2 ++ functions.php | 4 ++++ login_form.php | 31 +++++++++++++++++++++++++++++++ tt-rss.js | 2 ++ viewfeed.js | 2 ++ 6 files changed, 47 insertions(+), 4 deletions(-) diff --git a/backend.php b/backend.php index 97ce7b11f..fe54e36a7 100644 --- a/backend.php +++ b/backend.php @@ -206,9 +206,11 @@ catchupArticleById($link, $id, 0); } - foreach ($cids as $cid) { - if ($cid) { - outputArticleXML($link, $cid, $feed_id, false); + if (!$_SESSION["bw_limit"]) { + foreach ($cids as $cid) { + if ($cid) { + outputArticleXML($link, $cid, $feed_id, false); + } } } @@ -280,7 +282,7 @@ if ($_GET["debug"]) $timing_info = print_checkpoint("10", $timing_info); - if (is_array($topmost_article_ids) && !get_pref($link, 'COMBINED_DISPLAY_MODE')) { + if (is_array($topmost_article_ids) && !get_pref($link, 'COMBINED_DISPLAY_MODE') && !$_SESSION["bw_limit"]) { print ""; foreach ($topmost_article_ids as $id) { outputArticleXML($link, $id, $feed, false); diff --git a/feedlist.js b/feedlist.js index 1cd784524..5ae604493 100644 --- a/feedlist.js +++ b/feedlist.js @@ -537,6 +537,8 @@ function request_counters() { try { + if (getInitParam("bw_limit") == "1") return; + var date = new Date(); var timestamp = Math.round(date.getTime() / 1000); diff --git a/functions.php b/functions.php index b373ca91c..04ddaadbb 100644 --- a/functions.php +++ b/functions.php @@ -1848,6 +1848,7 @@ $_POST["password"] = ""; $_SESSION["language"] = $_POST["language"]; + $_SESSION["bw_limit"] = !!$_POST["bw_limit"]; header("Location: " . $_SERVER["REQUEST_URI"]); exit; @@ -3014,6 +3015,9 @@ print ""; + print ""; + print ""; } diff --git a/login_form.php b/login_form.php index e3f0475b1..6f3c61aca 100644 --- a/login_form.php +++ b/login_form.php @@ -22,6 +22,12 @@ function init() { var login = document.forms["loginForm"].login; + var limit_set = getCookie("ttrss_bwlimit"); + + if (limit_set == "true") { + document.forms["loginForm"].bw_limit.checked = true; + } + login.focus(); } @@ -37,6 +43,18 @@ function languageChange(elem) { } } +function bwLimitChange(elem) { + try { + var limit_set = elem.checked; + + setCookie("ttrss_bwlimit", limit_set, + ); + + } catch (e) { + exception_error("bwLimitChange", e); + } +} + function validateLoginForm(f) { try { @@ -100,6 +118,7 @@ window.onload = init; --> + @@ -111,6 +130,18 @@ window.onload = init; + + + +
+ +
+ + + + diff --git a/tt-rss.js b/tt-rss.js index 570be5e57..3c9ce336e 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -259,6 +259,8 @@ function viewfeed(feed, subop) { } function timeout() { + if (getInitParam("bw_limit") == "1") return; + scheduleFeedUpdate(false); var refresh_time = getInitParam("feeds_frame_refresh"); diff --git a/viewfeed.js b/viewfeed.js index 758fa6ad9..6e788cff3 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -1562,6 +1562,8 @@ function preload_article_callback(transport) { function preloadArticleUnderPointer(id) { try { + if (getInitParam("bw_limit") == "1") return; + if (post_under_pointer == id && !cache_check(id)) { debug("trying to preload article " + id);