summaryrefslogtreecommitdiff
path: root/offline.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2009-02-05 22:29:34 +0300
committerAndrew Dolgov <[email protected]>2009-02-05 22:29:34 +0300
commit75aa83ec611ed0af80232ababbef26363a498310 (patch)
tree84c8e194d01682f5edc0f3be35aa692f58bcf8cf /offline.js
parentd8781c912dc0476af3ac7b858aedf6f3089e604e (diff)
offline: store category collapsed state
Diffstat (limited to 'offline.js')
-rw-r--r--offline.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/offline.js b/offline.js
index ff65a76d9..fd3e7ef77 100644
--- a/offline.js
+++ b/offline.js
@@ -1,4 +1,4 @@
-var SCHEMA_VERSION = 4;
+var SCHEMA_VERSION = 5;
var offline_mode = false;
var store = false;
@@ -546,10 +546,26 @@ function offline_download_parse(stage, transport) {
var cat_id = feeds[i].getAttribute("cat_id");
db.execute("INSERT INTO feeds (id,title,has_icon,cat_id)"+
- "VALUES (?,?,?, ?)",
+ "VALUES (?,?,?,?)",
[id, title, has_icon, cat_id]);
}
-
+
+ var cats = transport.responseXML.getElementsByTagName("category");
+
+ if (feeds.length > 0) {
+ db.execute("DELETE FROM categories");
+ }
+
+ for (var i = 0; i < cats.length; i++) {
+ var id = cats[i].getAttribute("id");
+ var collapsed = cats[i].getAttribute("collapsed");
+ var title = cats[i].firstChild.nodeValue;
+
+ db.execute("INSERT INTO categories (id,title,collapsed)"+
+ "VALUES (?,?,?)",
+ [id, title, collapsed]);
+ }
+
window.setTimeout("update_offline_data("+(stage+1)+")", 10*1000);
} else {
@@ -790,7 +806,7 @@ function init_gears() {
db.execute("CREATE TABLE IF NOT EXISTS cache (id text, article text, param text, added text)");
db.execute("CREATE TABLE IF NOT EXISTS feeds (id integer, title text, has_icon integer, cat_id integer)");
- db.execute("CREATE TABLE IF NOT EXISTS categories (id integer, title text)");
+ db.execute("CREATE TABLE IF NOT EXISTS categories (id integer, title text, collapsed integer)");
db.execute("CREATE TABLE IF NOT EXISTS articles (id integer, feed_id integer, title text, link text, guid text, updated text, content text, tags text, unread text, marked text, added text, comments text)");
db.execute("DELETE FROM cache WHERE id LIKE 'F:%' OR id LIKE 'C:%'");