]> git.wh0rd.org Git - tt-rss.git/commitdiff
add low bandwidth mode (less automatic requests in the background)
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 24 Jun 2008 07:43:20 +0000 (08:43 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 24 Jun 2008 07:43:20 +0000 (08:43 +0100)
backend.php
feedlist.js
functions.php
login_form.php
tt-rss.js
viewfeed.js

index 97ce7b11f409f4148a8f3bf862b23f6f711bcdb9..fe54e36a70d95998ad4fc1170655ad870918331f 100644 (file)
                                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);
+                                       }
                                }
                        }
 
        
                                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 "<articles>";
                                        foreach ($topmost_article_ids as $id) {
                                                outputArticleXML($link, $id, $feed, false);
index 1cd784524a0ab8b833ed31c5da31ea752c609014..5ae6044937a0cb392d882063b0b2bb282c10403d 100644 (file)
@@ -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);
 
index b373ca91c9912c1b581bccfce68bab8331187c31..04ddaadbbdf7c79155feafb1127a53f6801e6531 100644 (file)
                                        $_POST["password"] = "";
 
                                        $_SESSION["language"] = $_POST["language"];
+                                       $_SESSION["bw_limit"] = !!$_POST["bw_limit"];
 
                                        header("Location: " . $_SERVER["REQUEST_URI"]);
                                        exit;
                print "<param key=\"hide_feedlist\" value=\"" .
                        (int) get_pref($link, "HIDE_FEEDLIST") . "\"/>";
 
+               print "<param key=\"bw_limit\" value=\"".
+                       (int) $_SESSION["bw_limit"]."\"/>";
+
                print "</init-params>";
        }
 
index e3f0475b1dcdbd64439225a51db854834a562ca5..6f3c61aca971a4c1988c6219efe3ea4b1ccb2d8c 100644 (file)
@@ -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, 
+                       <?php print SESSION_COOKIE_LIFETIME ?>);
+
+       } catch (e) {
+               exception_error("bwLimitChange", e);
+       }
+}
+
 function validateLoginForm(f) {
        try {
 
@@ -100,6 +118,7 @@ window.onload = init;
                                <input type="checkbox" name="remember_me" id="remember_me">
                                <label for="remember_me">Remember me on this computer</label>
                        </td></tr> -->
+
                        <tr><td colspan="2" align="right" class="innerLoginCell">
 
                        <?php if (defined('_ENABLE_REGISTRATION')) { ?>
@@ -111,6 +130,18 @@ window.onload = init;
                                <input type="hidden" name="rt" 
                                        value="<?php if ($return_to != 'none') { echo $return_to; } ?>">
                        </td></tr>
+
+                       <tr><td colspan="2" align="right" class="innerLoginCell">
+
+                       <div class="small">
+                       <input name="bw_limit" id="bw_limit" type="checkbox"
+                               onchange="bwLimitChange(this)">
+                       <label for="bw_limit">
+                       <?php echo __("Limit bandwidth use") ?></label></div>
+
+                       </td></tr>
+
+
                </table>
        </td>
 </tr><tr>
index 570be5e57ed20f8d06e673f010857bd3ae4ebe25..3c9ce336e632edd58bafbbc772e719bbe6264c8a 100644 (file)
--- 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");
index 758fa6ad94ff61bd3822e600bf8b1809b62582c5..6e788cff324de4428c752af356bd7a54d96e1a1f 100644 (file)
@@ -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);