summaryrefslogtreecommitdiff
path: root/tt-rss.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2009-02-03 16:11:44 +0300
committerAndrew Dolgov <[email protected]>2009-02-03 16:11:44 +0300
commit6a1cd59192bf4319b90319f7d623fae9011728ff (patch)
tree6743d18cbffd34a71649c052a19d27b3bc950580 /tt-rss.js
parent87b16a0a6156e90f549f13f59e657ff03a33a7e4 (diff)
implement dumb article downloader
Diffstat (limited to 'tt-rss.js')
-rw-r--r--tt-rss.js45
1 files changed, 23 insertions, 22 deletions
diff --git a/tt-rss.js b/tt-rss.js
index 3a4486707..5a92282d8 100644
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -1505,7 +1505,7 @@ function init_gears() {
db.execute("CREATE TABLE if not exists offline_feeds (id integer, title text)");
- db.execute("CREATE TABLE if not exists offline_data (id integer, feed_id integer, title text, updated text, content text, tags text)");
+ db.execute("CREATE TABLE if not exists offline_data (id integer, feed_id integer, title text, link text, guid text, updated text, content text, tags text)");
var qmcDownload = document.getElementById("qmcDownload");
if (qmcDownload) Element.show(qmcDownload);
@@ -1552,33 +1552,35 @@ function offline_download_parse(stage, transport) {
}
window.setTimeout("initiate_offline_download("+(stage+1)+")", 50);
- }
+ } else {
- notify_info("All done.");
+ var articles = transport.responseXML.getElementsByTagName("article");
- }
- } catch (e) {
- exception_error("offline_download_parse", e);
- }
-}
+ var articles_found = 0;
-function download_set_progress(p) {
- try {
- var o = document.getElementById("d_progress_i");
+ for (var i = 0; i < articles.length; i++) {
+ var a = eval("("+articles[i].firstChild.nodeValue+")");
+ articles_found++;
+ if (a) {
+ db.execute("DELETE FROM offline_data WHERE id = ?", [a.id]);
+ db.execute("INSERT INTO offline_data "+
+ "(id, feed_id, title, link, guid, updated, content) "+
+ "VALUES (?, ?, ?, ?, ?, ?, ?)",
+ [a.id, a.feed_id, a.title, a.link, a.guid, a.updated, a.content]);
- if (!o) return;
+ }
+ }
- Element.show(o);
+ if (articles_found > 0) {
+ window.setTimeout("initiate_offline_download("+(stage+1)+")", 50);
+ }
+ }
- new Effect.Scale(o, p, {
- scaleY : false,
- scaleFrom : download_progress_last,
- scaleMode: { originalWidth : 100 },
- queue: { position: 'end', scope: 'LSP-Q', limit: 3 } });
+ notify_info("All done.");
- download_progress_last = p;
+ }
} catch (e) {
- exception_error("download_progress", e);
+ exception_error("offline_download_parse", e);
}
}
@@ -1587,8 +1589,7 @@ function initiate_offline_download(stage) {
if (!stage) stage = 0;
- notify_progress("Loading, please wait... S" + stage, true);
- download_set_progress(20);
+ notify_progress("Loading, please wait... (" + stage +")", true);
var query = "backend.php?op=rpc&subop=download&stage=" + stage;