]> git.wh0rd.org - tt-rss.git/commitdiff
add viewfeed_offline(); misc fixes
authorAndrew Dolgov <fox@bah.org.ru>
Tue, 3 Feb 2009 15:43:44 +0000 (18:43 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Tue, 3 Feb 2009 15:43:44 +0000 (18:43 +0300)
feedlist.js
modules/backend-rpc.php
modules/popup-dialog.php
tt-rss.js

index 6e26a92fc266835d39b4597056f2017525bd41dc..fbf3d9270b98d098c6dfe01debcd14ebdeaf79d6 100644 (file)
@@ -129,9 +129,21 @@ function viewNextFeedPage() {
        }
 }
 
+function viewfeed_offline(feed, subop, is_cat, subop_param, skip_history, offset) {
+       try {
+
+
+       } catch (e) {
+               exception_error("viewfeed_offline", e);
+       }
+}
+
 function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
        try {
 
+               if (offline_mode) return viewfeed_offline(feed, subop, is_cat, subop_param,
+                       skip_history, offset);
+
 //             if (!offset) page_offset = 0;
 
                last_requested_article = 0;
index 4212c1b8ce3b1843555a611aa7ab607dc6a7fef5..3b5b2d63f827d8f126e676d7435883b2e2c608d1 100644 (file)
 
                                                $line["marked"] = (int)sql_bool_to_bool($line["marked"]);
                                                $line["unread"] = (int)sql_bool_to_bool($line["unread"]);
+                                               $line["tags"] = format_tags_string(get_article_tags($link, $id), $id);
+
 
                                                print json_encode($line);
                                                print "]]></article>";
index d7e786684d7db5d9486de8bcfef501c782996653..8a1b2020937793cb9eea4dde4b54c9e4c2f73b6a 100644 (file)
 
                        print_select_hash("amount", 50, $amount);
 
-                       print " " . __("newest articles for offline reading.");
+                       print " " . __("latest articles for offline reading.");
 
                        print "<br/>";
 
                        print "</form>";
 
                        print "<div class=\"dlgButtons\">
-                               <input class=\"button\"                                 
-                                       type=\"submit\" onclick=\"return initiate_offline_download()\" value=\"".__('Download')."\">
+                               <input class=\"button\"
+                                       type=\"submit\" onclick=\"return initiate_offline_download(0, this)\" value=\"".__('Download')."\">
                                <input class=\"button\"
                                        type=\"submit\" onclick=\"return closeInfoBox()\" 
                                        value=\"".__('Cancel')."\"></div>";
index 666476778c8723b45bf5ea194e1d9b205a9b2400..b8b36e0956f8fd571ac39de0fc6d41522824b896 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -24,6 +24,7 @@ var store = false;
 var localServer = false;
 var db = false;
 var download_progress_last = 0;
+var offline_dl_max_id = 0;
 
 function activeFeedIsCat() {
        return _active_feed_is_cat;
@@ -1570,39 +1571,48 @@ function offline_download_parse(stage, transport) {
                                        if (a) {
                                                db.execute("DELETE FROM articles WHERE id = ?", [a.id]);
                                                db.execute("INSERT INTO articles "+
-                                                       "(id, feed_id, title, link, guid, updated, content, unread, marked) "+
-                                                       "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", 
+                                               "(id, feed_id, title, link, guid, updated, content, "+
+                                                       "unread, marked, tags) "+
+                                               "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", 
                                                        [a.id, a.feed_id, a.title, a.link, a.guid, a.updated, 
-                                                               a.content, a.unread, a.marked]);
+                                                               a.content, a.unread, a.marked, a.tags]);
 
                                        }
                                }
 
                                if (articles_found > 0) {
                                        window.setTimeout("initiate_offline_download("+(stage+1)+")", 50);
+                               } else {
+                                       notify_info("All done.");
+                                       closeInfoBox();
                                }
                        }
 
-                       notify_info("All done.");
-
                }
        } catch (e) {
                exception_error("offline_download_parse", e);
        }
 }
 
-function initiate_offline_download(stage) {
+function initiate_offline_download(stage, caller) {
        try {
 
                if (!stage) stage = 0;
+               if (caller) caller.disabled = true;
 
                notify_progress("Loading, please wait... (" + stage +")", true);
 
                var query = "backend.php?op=rpc&subop=download&stage=" + stage;
 
-               var rs = db.execute("SELECT MAX(id) FROM articles");
-               if (rs.isValidRow()) {
-                       query = query + "&cid=" + rs.field(0);
+               if (stage == 0) {
+                       var rs = db.execute("SELECT MAX(id) FROM articles");
+                       if (rs.isValidRow() && rs.field(0)) {
+                               offline_dl_max_id = rs.field(0);
+                       }
+               }
+
+               if (offline_dl_max_id) {
+                       query = query + "&cid=" + offline_dl_max_id;
                }
 
                if (document.getElementById("download_ops_form")) {