From be0801a1619981931c813346b53de2d9f29bcede Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 21 Mar 2007 16:36:24 +0100 Subject: [PATCH] make storeInitParam actually work (move back to cookies) --- feedlist.js | 4 ++-- functions.js | 28 +++++++++++++++++++++++++--- functions.php | 2 ++ tt-rss.js | 4 ++-- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/feedlist.js b/feedlist.js index 79a39f34..ddf12f29 100644 --- a/feedlist.js +++ b/feedlist.js @@ -57,11 +57,11 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) { toolbar_form.query.value = ""; } -/* storeInitParam("toolbar_limit", + storeInitParam("toolbar_limit", toolbar_form.limit[toolbar_form.limit.selectedIndex].value); storeInitParam("toolbar_view_mode", - toolbar_form.view_mode[toolbar_form.view_mode.selectedIndex].value); */ + toolbar_form.view_mode[toolbar_form.view_mode.selectedIndex].value); var query = "backend.php?op=viewfeed&feed=" + feed + "&" + toolbar_query + "&subop=" + param_escape(subop); diff --git a/functions.js b/functions.js index b7e633ea..b6c656b6 100644 --- a/functions.js +++ b/functions.js @@ -428,7 +428,7 @@ function setCookie(name, value, lifetime, path, domain, secure) { if (lifetime) { d = new Date(); - d.setTime(lifetime * 1000); + d.setTime(d.getTime() + (lifetime * 1000)); } int_setCookie(name, value, d, path, domain, secure); @@ -1500,9 +1500,31 @@ function debug(msg) { } function getInitParam(key) { - return getMainContext().init_params[key]; + var c = getCookie("TTIP:" + key); + if (c) { + return c; + } else { + return getMainContext().init_params[key]; + } } +function storeInitParam(key, value) { + try { + init_params[key] = value; + debug("storeInitParam: " + key + " => " + value + + " (" + getInitParam("cookie_lifetime") + ")"); + if (getInitParam("cookie_lifetime") > 0) { + setCookie("TTIP:" + key, value, getInitParam("cookie_lifetime")); + } else { + setCookie("TTIP:" + key, value); + } + } catch (e) { + exception_error("storeInitParam", e); + } +} + + +/* function storeInitParam(key, value, is_client) { try { if (!is_client) { @@ -1519,7 +1541,7 @@ function storeInitParam(key, value, is_client) { } catch (e) { exception_error("storeInitParam", e); } -} +} */ /* function storeInitParams(params, is_client) { diff --git a/functions.php b/functions.php index 275efb1c..05ac12dd 100644 --- a/functions.php +++ b/functions.php @@ -2203,6 +2203,8 @@ print ""; + print ""; + print ""; } diff --git a/tt-rss.js b/tt-rss.js index eefc90e7..bc5bc820 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -388,8 +388,8 @@ function init_second_stage() { var tb = parent.document.forms["main_toolbar_form"]; -// dropboxSelect(tb.view_mode, getInitParam("toolbar_view_mode")); -// dropboxSelect(tb.limit, getInitParam("toolbar_limit")); + dropboxSelect(tb.view_mode, getInitParam("toolbar_view_mode")); + dropboxSelect(tb.limit, getInitParam("toolbar_limit")); daemon_enabled = getInitParam("daemon_enabled") == 1; daemon_refresh_only = getInitParam("daemon_refresh_only") == 1; -- 2.39.2