summaryrefslogtreecommitdiff
path: root/tt-rss.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2009-02-04 10:07:15 +0300
committerAndrew Dolgov <[email protected]>2009-02-04 10:07:15 +0300
commit20919a06a15e7695ec8e0de29fd097f7c892d82e (patch)
tree40a4e13be7fcdfe8ed7adeb6fdb5b187e0ddc5f7 /tt-rss.js
parentc8a9fe5b07aebbc7120599606c7740e840d15562 (diff)
move offline stuff to offline.js
Diffstat (limited to 'tt-rss.js')
-rw-r--r--tt-rss.js113
1 files changed, 0 insertions, 113 deletions
diff --git a/tt-rss.js b/tt-rss.js
index 96f0b3472..883eb2997 100644
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -1544,117 +1544,4 @@ function init_gears() {
}
}
-function init_offline() {
- try {
- offline_mode = true;
-
- Element.hide("dispSwitchPrompt");
- Element.hide("feedBrowserPrompt");
- Element.hide("quickMenuChooser");
-
- init_params["theme"] = "";
-
- render_offline_feedlist();
- remove_splash();
- } catch (e) {
- exception_error("init_offline", e);
- }
-}
-
-function offline_download_parse(stage, transport) {
- try {
- if (transport.responseXML) {
-
- if (stage == 0) {
-
- var feeds = transport.responseXML.getElementsByTagName("feed");
-
- if (feeds.length > 0) {
- db.execute("DELETE FROM feeds");
- }
-
- for (var i = 0; i < feeds.length; i++) {
- var id = feeds[i].getAttribute("id");
- var has_icon = feeds[i].getAttribute("has_icon");
- var title = feeds[i].firstChild.nodeValue;
-
- db.execute("INSERT INTO feeds (id,title,has_icon)"+
- "VALUES (?,?,?)",
- [id, title, has_icon]);
- }
-
- window.setTimeout("update_offline_data("+(stage+1)+")", 60*1000);
- } else {
-
- var articles = transport.responseXML.getElementsByTagName("article");
-
- var articles_found = 0;
-
- for (var i = 0; i < articles.length; i++) {
- var a = eval("("+articles[i].firstChild.nodeValue+")");
- articles_found++;
- if (a) {
-
- var date = new Date();
- var ts = Math.round(date.getTime() / 1000);
-
- db.execute("DELETE FROM articles WHERE id = ?", [a.id]);
- db.execute("INSERT INTO articles "+
- "(id, feed_id, title, link, guid, updated, content, "+
- "unread, marked, tags, added) "+
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
- [a.id, a.feed_id, a.title, a.link, a.guid, a.updated,
- a.content, a.unread, a.marked, a.tags, ts]);
-
- }
- }
-
- if (articles_found > 0) {
- window.setTimeout("update_offline_data("+(stage+1)+")", 60*1000);
- } else {
- window.setTimeout("update_offline_data(0)", 1800*1000);
-
- var date = new Date();
- var ts = Math.round(date.getTime() / 1000);
-
- db.execute("DELETE FROM articles WHERE added < ? - 2592000", [ts]);
-
- }
- }
-
- }
- } catch (e) {
- exception_error("offline_download_parse", e);
- }
-}
-
-function update_offline_data(stage) {
- try {
-
- if (!stage) stage = 0;
- debug("update_offline_data: stage " + stage);
-
-// notify_progress("Loading, please wait... (" + stage +")", true);
-
- var query = "backend.php?op=rpc&subop=download&stage=" + stage;
-
- var rs = db.execute("SELECT MAX(id), MIN(id) FROM articles");
- if (rs.isValidRow() && rs.field(0)) {
- var offline_dl_max_id = rs.field(0);
- var offline_dl_min_id = rs.field(1);
-
- query = query + "&cidt=" + offline_dl_max_id;
- query = query + "&cidb=" + offline_dl_min_id;
- }
-
- new Ajax.Request(query, {
- onComplete: function(transport) {
- offline_download_parse(stage, transport);
- debug("update_offline_data: done " + stage);
- } });
-
- } catch (e) {
- exception_error("initiate_offline_download", e);
- }
-}