{
"betaManifestVersion": 1,
- "version": "my_version_string",
+ "version": "0",
"entries": [
- { "url": "go_offline.html"},
- { "url": "go_offline.js"},
- { "url": "../gears_init.js"}
+ { "url": "tt-rss.php"},
+ { "url": "tt-rss.css"},
+ { "url": "viewfeed.js"},
+ { "url": "feedlist.js"},
+ { "url": "functions.js"},
+ { "url": "tt-rss.js"},
+ { "url": "lib/scriptaculous/effects.js"},
+ { "url": "lib/scriptaculous/controls.js"},
+ { "url": "lib/scriptaculous/dragdrop.js"},
+ { "url": "lib/scriptaculous/scriptaculous.js"},
+ { "url": "lib/prototype.js"},
+ { "url": "gears_init.js"}
]
-}
\ No newline at end of file
+}
var hor_offset = 0;
var feeds_sort_by_unread = false;
var feedlist_sortable_enabled = false;
+var offline_mode = false;
+var store = false;
+var localServer = false;
+var db = false;
function activeFeedIsCat() {
return _active_feed_is_cat;
}
if (!transport.responseXML) {
- fatalError(3, "Sanity check: Received reply is not XML", transport.responseText);
+ if (!google.gears) {
+ fatalError(3, "Sanity check: Received reply is not XML", transport.responseText);
+ } else {
+ init_offline();
+ }
return;
}
if (arguments.callee.done) return;
arguments.callee.done = true;
+ init_gears();
+
disableContainerChildren("headlinesToolbar", true);
Form.disable("main_toolbar_form");
}
}
+function init_gears() {
+ try {
+
+ if (google.gears) {
+ localServer = google.gears.factory.create("beta.localserver");
+ store = localServer.createManagedStore("tt-rss");
+ db = google.gears.factory.create('beta.database');
+ db.open('tt-rss');
+
+ db.execute("CREATE TABLE IF NOT EXISTS cache (id text, article text, param text, added text)");
+ }
+
+ } catch (e) {
+ exception_error("init_gears", e);
+ }
+}
+
+function init_offline() {
+ try {
+ offline_mode = true;
+
+ remove_splash();
+
+ } catch (e) {
+ exception_error("init_offline", e);
+ }
+}
+
function cache_inject(id, article, param) {
- if (!cache_check_param(id, param)) {
- debug("cache_article: miss: " + id + " [p=" + param + "]");
-
- var cache_obj = new Array();
-
- cache_obj["id"] = id;
- cache_obj["data"] = article;
- cache_obj["param"] = param;
+ try {
+ if (!cache_check_param(id, param)) {
+ debug("cache_article: miss: " + id + " [p=" + param + "]");
+
+
+ if (db) {
- article_cache.push(cache_obj);
+ var date = new Date();
+ var ts = Math.round(date.getTime() / 1000);
- } else {
- debug("cache_article: hit: " + id + " [p=" + param + "]");
+ db.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
+ [id, article, param, ts]);
+ } else {
+
+ var cache_obj = new Array();
+
+ cache_obj["id"] = id;
+ cache_obj["data"] = article;
+ cache_obj["param"] = param;
+
+ article_cache.push(cache_obj);
+ }
+
+ } else {
+ debug("cache_article: hit: " + id + " [p=" + param + "]");
+ }
+ } catch (e) {
+ exception_error("cache_inject", e);
}
}
function cache_find(id) {
- for (var i = 0; i < article_cache.length; i++) {
- if (article_cache[i]["id"] == id) {
- return article_cache[i]["data"];
+
+ if (db) {
+
+ } else {
+ for (var i = 0; i < article_cache.length; i++) {
+ if (article_cache[i]["id"] == id) {
+ return article_cache[i]["data"];
+ }
}
}
return false;
}
function cache_find_param(id, param) {
- for (var i = 0; i < article_cache.length; i++) {
- if (article_cache[i]["id"] == id && article_cache[i]["param"] == param) {
- return article_cache[i]["data"];
+
+ if (db) {
+ var rs = db.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
+ [id, param]);
+
+ if (rs.isValidRow()) {
+ return rs.field(0);
+ }
+
+ } else {
+ for (var i = 0; i < article_cache.length; i++) {
+ if (article_cache[i]["id"] == id && article_cache[i]["param"] == param) {
+ return article_cache[i]["data"];
+ }
}
}
return false;
}
function cache_check(id) {
- for (var i = 0; i < article_cache.length; i++) {
- if (article_cache[i]["id"] == id) {
- return true;
+
+ if (db) {
+ var rs = db.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
+ [id]);
+
+ if (rs.isValidRow()) {
+ return rs.field(0) != "0";
+ }
+
+ } else {
+ for (var i = 0; i < article_cache.length; i++) {
+ if (article_cache[i]["id"] == id) {
+ return true;
+ }
}
}
return false;
}
function cache_check_param(id, param) {
- for (var i = 0; i < article_cache.length; i++) {
-// debug("cache_check_param " + article_cache[i]["id"] + ":" +
-// article_cache[i]["param"] + " vs " + id + ":" + param);
+ if (db) {
+ var rs = db.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
+ [id, param]);
- if (article_cache[i]["id"] == id && article_cache[i]["param"] == param) {
- return true;
+ if (rs.isValidRow()) {
+ return rs.field(0) != "0";
+ }
+
+ } else {
+ for (var i = 0; i < article_cache.length; i++) {
+ if (article_cache[i]["id"] == id && article_cache[i]["param"] == param) {
+ return true;
+ }
}
}
return false;
}
function cache_expire() {
- while (article_cache.length > 25) {
- article_cache.shift();
+ if (!db) {
+ while (article_cache.length > 25) {
+ article_cache.shift();
+ }
}
}
}
function cache_invalidate(id) {
- var i = 0
-
try {
- while (i < article_cache.length) {
- if (article_cache[i]["id"] == id) {
- debug("cache_invalidate: removed id " + id);
- article_cache.splice(i, 1);
- return true;
+ if (db) {
+ rs = db.execute("DELETE FROM cache WHERE id = ?", [id]);
+ return rs.rowsAffected != 0;
+ } else {
+
+ var i = 0
+
+ while (i < article_cache.length) {
+ if (article_cache[i]["id"] == id) {
+ debug("cache_invalidate: removed id " + id);
+ article_cache.splice(i, 1);
+ return true;
+ }
+ i++;
}
- i++;
}
+
debug("cache_invalidate: id not found: " + id);
return false;
} catch (e) {