summaryrefslogtreecommitdiff
path: root/js/tt-rss.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-02-28 13:06:54 +0400
committerAndrew Dolgov <[email protected]>2013-02-28 13:06:54 +0400
commit1b04a298efd0ea33086eeeb3fc7de6281c9881d1 (patch)
tree5a2f0da9c55824abbb9ae2cc04f101e1b0d4eee7 /js/tt-rss.js
parent271edfa6f9ac8ad387f98693a6c09496ddf72f1f (diff)
store active feed id in url hash and restore on reload
Diffstat (limited to 'js/tt-rss.js')
-rw-r--r--js/tt-rss.js32
1 files changed, 22 insertions, 10 deletions
diff --git a/js/tt-rss.js b/js/tt-rss.js
index 7462d933d..9814718f0 100644
--- a/js/tt-rss.js
+++ b/js/tt-rss.js
@@ -1,6 +1,4 @@
var global_unread = -1;
-var _active_feed_id = undefined;
-var _active_feed_is_cat = false;
var hotkey_prefix = false;
var hotkey_prefix_pressed = false;
var _widescreen_mode = false;
@@ -16,13 +14,12 @@ function get_seq() {
}
function activeFeedIsCat() {
- return _active_feed_is_cat;
+ return hash_get('c') == "1";
}
function getActiveFeedId() {
try {
- //console.log("gAFID: " + _active_feed_id);
- return _active_feed_id;
+ return hash_get('f');
} catch (e) {
exception_error("getActiveFeedId", e);
}
@@ -30,11 +27,8 @@ function getActiveFeedId() {
function setActiveFeedId(id, is_cat) {
try {
- _active_feed_id = id;
-
- if (is_cat != undefined) {
- _active_feed_is_cat = is_cat;
- }
+ hash_set('f', id);
+ hash_set('c', is_cat ? 1 : 0);
selectFeed(id, is_cat);
} catch (e) {
@@ -948,3 +942,21 @@ function update_random_feed() {
exception_error("update_random_feed", e);
}
}
+
+function hash_get(key) {
+ try {
+ kv = window.location.hash.substring(1).toQueryParams();
+ return kv[key];
+ } catch (e) {
+ exception_error("hash_set", e);
+ }
+}
+function hash_set(key, value) {
+ try {
+ kv = window.location.hash.substring(1).toQueryParams();
+ kv[key] = value;
+ window.location.hash = $H(kv).toQueryString();
+ } catch (e) {
+ exception_error("hash_set", e);
+ }
+}