]> git.wh0rd.org Git - tt-rss.git/commitdiff
move some cookies to init-params
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 23 May 2006 05:34:50 +0000 (06:34 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 23 May 2006 05:34:50 +0000 (06:34 +0100)
backend-rpc.php
backend.php
feedlist.js
functions.js
functions.php
tt-rss.js

index 2b2f612796528374243389ccffc02cefd82c1597..1e98aa125bcd2be4d96b5a370820a7542a1ed387 100644 (file)
                }
 
                if ($subop == "sanityCheck") {
+                       print "<rpc-reply>";
                        if (sanity_check($link)) {
                                print "<error error-code=\"0\"/>";
+                               print_init_params($link);
                        }
-               }
+                       print "</rpc-reply>";
+               }               
 
                if ($subop == "globalPurge") {
 
                        print "</rpc-reply>";
 
                }
+
+               if ($subop == "storeParam") {
+                       $key = $_GET["key"];
+                       $value = $_GET["value"];
+                       $_SESSION["stored-params"][$key] = $value;
+               }
        }
 ?>
index bad5253c991e74a725898f19812f4ea8635dd057..d48d814971a1696c9bcf5c378e3af8d81313d625 100644 (file)
                        setcookie("ttrss_vf_hreadf", 0);
                }  
 
-               setcookie('ttrss_vf_refresh', FEEDS_FRAME_REFRESH);
-               setcookie('ttrss_vf_daemon', ENABLE_UPDATE_DAEMON);
+//             setcookie('ttrss_vf_refresh', FEEDS_FRAME_REFRESH);
+//             setcookie('ttrss_vf_daemon', ENABLE_UPDATE_DAEMON);
 
-               if (get_pref($link, "ON_CATCHUP_SHOW_NEXT_FEED")) {             
+/*             if (get_pref($link, "ON_CATCHUP_SHOW_NEXT_FEED")) {             
                        setcookie('ttrss_vf_catchupnext', 1);
                } else {
                        setcookie('ttrss_vf_catchupnext', 0);
-               }               
+               } */
        }
 
        $fetch = $_GET["fetch"];
index 65025ecac0d6fc3b870ba7f4ad506dcd86887823..66ae169cdf0fcc7f24a0440ae81fb99f5bf57bb5 100644 (file)
@@ -42,8 +42,14 @@ function viewfeed(feed, skip, subop, doc, is_cat, subop_param) {
                        toolbar_form.query.value = "";
                }
 
-               setCookie("ttrss_vf_limit", toolbar_form.limit[toolbar_form.limit.selectedIndex].value);
-               setCookie("ttrss_vf_vmode", toolbar_form.view_mode[toolbar_form.view_mode.selectedIndex].value);
+//             setCookie("ttrss_vf_limit", toolbar_form.limit[toolbar_form.limit.selectedIndex].value);
+//             setCookie("ttrss_vf_vmode", toolbar_form.view_mode[toolbar_form.view_mode.selectedIndex].value);
+
+               parent.storeInitParam("toolbar_limit", 
+                       toolbar_form.limit[toolbar_form.limit.selectedIndex].value);
+
+               parent.storeInitParam("toolbar_view_mode", 
+                       toolbar_form.view_mode[toolbar_form.view_mode.selectedIndex].value);
 
                var query = "backend.php?op=viewfeed&feed=" + feed + "&" +
                        toolbar_query + "&subop=" + param_escape(subop);
@@ -85,7 +91,9 @@ function viewfeed(feed, skip, subop, doc, is_cat, subop_param) {
                        var next_unread_feed = getRelativeFeedId(feedlist,
                                        getActiveFeedId(), "next", true);
 
-                       if (next_unread_feed && getCookie('ttrss_vf_catchupnext') == 1) {
+                       var show_next_feed = parent.getInitParam("on_catchup_show_next_feed") == "1";
+
+                       if (next_unread_feed && show_next_feed) {
                                query = query + "&nuf=" + param_escape(next_unread_feed);
                                setActiveFeedId(next_unread_feed);
                        }
index 46c812ed5d1ebe619bd398f5a7b3b56f177acf7f..5940174d30b646f4239d6adca13b30b164985768 100644 (file)
@@ -1054,3 +1054,4 @@ function filterCR(e)
           return true;
 }
 
+
index c97be42c88c43cee3c5ef0390993533e2b229f49..30f309dd3c8ba4d9bf26fab1367f4b68f416df47 100644 (file)
        function get_session_cookie_name() {
                return ((!defined('TTRSS_SESSION_NAME')) ? "ttrss_sid" : TTRSS_SESSION_NAME);
        }
+
+       function print_init_params($link) {
+               print "<init-params>";
+               if ($_SESSION["stored-params"]) {
+                       foreach (array_keys($_SESSION["stored-params"]) as $key) {
+                               $value = htmlspecialchars($_SESSION["stored-params"][$key]);
+                               print "<param key=\"$key\" value=\"$value\"/>";
+                       }
+               }
+
+               print "<param key=\"daemon_enabled\" value=\"" . ENABLE_UPDATE_DAEMON . "\"/>";
+               print "<param key=\"feeds_frame_refresh\" value=\"" . FEEDS_FRAME_REFRESH . "\"/>";
+
+               print "<param key=\"on_catchup_show_next_feed\" value=\"" . 
+                       get_pref($link, "ON_CATCHUP_SHOW_NEXT_FEED") . "\"/>";
+
+               print "</init-params>";
+       }
 ?>
index 98cb9c71244cea0589beee3d7770cda36cf26efe..c7e6cbcd79c79da0b99ea1eac955d2d6063a5e8e 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -13,6 +13,8 @@ var cookie_lifetime = 0;
 
 var xmlhttp = Ajax.getTransport();
 
+var init_params = new Array();
+
 function toggleTags() {
        display_tags = !display_tags;
 
@@ -123,7 +125,7 @@ function backend_sanity_check_callback() {
                                return;
                        }
        
-                       var reply = xmlhttp.responseXML.firstChild;
+                       var reply = xmlhttp.responseXML.firstChild.firstChild;
        
                        if (!reply) {
                                fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText);
@@ -138,6 +140,21 @@ function backend_sanity_check_callback() {
        
                        debug("sanity check ok");
 
+                       var params = reply.nextSibling;
+
+                       if (params) {
+                               debug('reading init-params...');
+                               var param = params.firstChild;
+
+                               while (param) {
+                                       var k = param.getAttribute("key");
+                                       var v = param.getAttribute("value");
+                                       debug(k + " => " + v);
+                                       init_params[k] = v;                                     
+                                       param = param.nextSibling;
+                               }
+                       }
+
                        init_second_stage();
 
                } catch (e) {
@@ -259,9 +276,9 @@ function viewfeed(feed, skip, subop) {
 function timeout() {
        scheduleFeedUpdate(false);
 
-       var refresh_time = getCookie('ttrss_vf_refresh');
+       var refresh_time = getInitParam("feeds_frame_refresh");
 
-       if (!refresh_time) refresh_time = 600;
+       if (!refresh_time) refresh_time = 600; 
 
        setTimeout("timeout()", refresh_time*1000);
 }
@@ -423,10 +440,10 @@ function init_second_stage() {
 
                var tb = parent.document.forms["main_toolbar_form"];
 
-               dropboxSelect(tb.view_mode, getCookie("ttrss_vf_vmode"));
-               dropboxSelect(tb.limit, getCookie("ttrss_vf_limit"));
+               dropboxSelect(tb.view_mode, getInitParam("toolbar_view_mode"));
+               dropboxSelect(tb.limit, getInitParam("toolbar_limit"));
 
-               daemon_enabled = getCookie("ttrss_vf_daemon");
+               daemon_enabled = getInitParam("daemon_enabled");
 
                // FIXME should be callled after window resize
 
@@ -592,3 +609,12 @@ function fatalError(code, message) {
                exception_error("fatalError", e);
        }
 }
+
+function getInitParam(key) {
+       return init_params[key];
+}
+
+function storeInitParam(key, value) {
+       new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" + 
+               param_escape(key) + "&value=" + param_escape(value));           
+}