summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/backend-rpc.php41
-rw-r--r--modules/popup-dialog.php10
-rw-r--r--tt-rss.css14
-rw-r--r--tt-rss.js45
4 files changed, 70 insertions, 40 deletions
diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php
index 55ab73a20..53635f966 100644
--- a/modules/backend-rpc.php
+++ b/modules/backend-rpc.php
@@ -516,6 +516,10 @@
if ($subop == "download") {
$stage = (int) $_REQUEST["stage"];
+ $amount = (int) $_REQUEST["amount"];
+ $unread_only = db_escape_string($_REQUEST["unread_only"]);
+
+ if (!$amount) $amount = 50;
print "<rpc-reply>";
@@ -537,6 +541,43 @@
}
+ if ($stage > 0) {
+
+ print "<articles>";
+
+ $limit = 50;
+ $skip = $limit*($stage-1);
+
+ if ($amount > 0) $amount -= $skip;
+
+ if ($amount > 0) {
+
+ $limit = min($limit, $amount);
+
+ if ($unread_only) {
+ $unread_qpart = "unread = true AND ";
+ }
+
+ $result = db_query($link,
+ "SELECT DISTINCT id,title,guid,link,
+ feed_id,content,updated,unread,marked FROM
+ ttrss_user_entries,ttrss_entries
+ WHERE $unread_qpart
+ ref_id = id AND owner_uid = ".$_SESSION["uid"]."
+ ORDER BY updated DESC LIMIT $limit OFFSET $skip");
+
+ while ($line = db_fetch_assoc($result)) {
+ print "<article><![CDATA[";
+ print json_encode($line);
+ print "]]></article>";
+ }
+
+ }
+
+ print "</articles>";
+
+ }
+
print "</rpc-reply>";
return;
diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php
index d89547fe9..e62f84e9c 100644
--- a/modules/popup-dialog.php
+++ b/modules/popup-dialog.php
@@ -474,20 +474,22 @@
$amount = array(
50 => 50,
100 => 100,
- 0 => "All unread");
+ 250 => 250);
print_select_hash("amount", 50, $amount);
print " " . __("newest articles for offline reading.");
+ print "<br/>";
+
+ print "<input checked='yes' type='checkbox' name='unread_only' id='unread_only'>";
+ print "<label for='unread_only'>".__('Only include unread articles')."</label>";
+
print "</div>";
print "</form>";
print "<div class=\"dlgButtons\">
- <div id=\"d_progress_o\" style=\"display : none\">
- <div id=\"d_progress_i\"></div>
- </div>
<input class=\"button\"
type=\"submit\" onclick=\"return initiate_offline_download()\" value=\"".__('Download')."\">
<input class=\"button\"
diff --git a/tt-rss.css b/tt-rss.css
index 4909b20a3..95938bc91 100644
--- a/tt-rss.css
+++ b/tt-rss.css
@@ -1976,20 +1976,6 @@ div#l_progress_i {
height : 10px;
}
-div#d_progress_o {
- width : 100px;
- border : 1px solid black;
- background-color : white;
- float : left;
- margin-left : 10px;
-}
-
-div#d_progress_i {
- width : 10px;
- background-color : #88b0f0;
- height : 10px;
-}
-
#content-insert {
background-color : white;
overflow : auto;
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;