]> git.wh0rd.org Git - tt-rss.git/commitdiff
move more stuff to offline.js
authorAndrew Dolgov <fox@bah.org.ru>
Wed, 4 Feb 2009 07:19:36 +0000 (10:19 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Wed, 4 Feb 2009 07:19:36 +0000 (10:19 +0300)
feedlist.js
offline.js

index 9f431fe848cdd736c6adef08188909d3f7dee724..3cf2380470b368245bbf50a4cec3cd6c65b65da7 100644 (file)
@@ -64,91 +64,6 @@ function printFeedEntry(id, title, row_class, unread, icon) {
        return tmp;
 }
 
-function get_local_feed_unread(id) {
-       try {
-               var rs;
-
-               if (id == -4) {
-                       rs = db.execute("SELECT SUM(unread) FROM articles");
-               } else if (id == -1) {
-                       rs = db.execute("SELECT SUM(unread) FROM articles WHERE marked = 1");
-               } else {
-                       rs = db.execute("SELECT SUM(unread) FROM articles WHERE feed_id = ?", [id]);
-               }
-
-               if (rs.isValidRow()) {
-                       return rs.field(0);
-               } else {
-                       return 0;
-               }
-
-       } catch (e) {
-               exception_error("get_local_feed_unread", e);
-       }
-}
-
-function render_offline_feedlist() {
-       try {
-               var tmp = "<ul class=\"feedList\" id=\"feedList\">";
-
-               var unread = get_local_feed_unread(-4);
-
-               global_unread = unread;
-               updateTitle();
-
-               tmp += printFeedEntry(-4, __("All articles"), "feed", unread,
-                       "images/tag.png");
-
-               var unread = get_local_feed_unread(-1);
-
-               tmp += printFeedEntry(-1, __("Starred articles"), "feed", unread,
-                       "images/mark_set.png");
-
-               tmp += "<li><hr/></li>";
-
-               var rs = db.execute("SELECT feeds.id,feeds.title,has_icon,COUNT(articles.id) "+
-                       "FROM feeds LEFT JOIN articles ON (feed_id = feeds.id) "+
-                       "WHERE unread = 1 OR unread IS NULL GROUP BY feeds.id "+
-                       "ORDER BY feeds.title");
-
-               while (rs.isValidRow()) {
-
-                       var id = rs.field(0);
-                       var title = rs.field(1);
-                       var has_icon = rs.field(2);
-                       var unread = rs.field(3);
-
-                       var icon = "";
-
-                       if (has_icon) {
-                               icon = "icons/" + id + ".ico";
-                       }
-
-
-                       var feed_icon = "";
-
-                       var row_class = "feed";
-
-                       if (unread > 0) {
-                               row_class += "Unread";
-                               fctr_class = "feedCtrHasUnread";
-                       } else {
-                               fctr_class = "feedCtrNoUnread";
-                       }
-
-                       tmp += printFeedEntry(id, title, "feed", unread, icon);
-
-                       rs.next();
-               }
-
-               tmp += "</ul>";
-
-               render_feedlist(tmp);
-       } catch (e) {
-               exception_error("render_offline_feedlist", e);
-       }
-}
-
 function render_feedlist(data) {
        try {
 
index 371aeecf0c95354532da093d120f8083096757d4..58c2377c2f738b19eb2779d760e358e5fcf4ae08 100644 (file)
@@ -490,3 +490,28 @@ function update_local_feedlist_counters() {
                exception_error("update_local_feedlist_counters", e);
        }
 }
+
+function get_local_feed_unread(id) {
+       try {
+               var rs;
+
+               if (id == -4) {
+                       rs = db.execute("SELECT SUM(unread) FROM articles");
+               } else if (id == -1) {
+                       rs = db.execute("SELECT SUM(unread) FROM articles WHERE marked = 1");
+               } else {
+                       rs = db.execute("SELECT SUM(unread) FROM articles WHERE feed_id = ?", [id]);
+               }
+
+               if (rs.isValidRow()) {
+                       return rs.field(0);
+               } else {
+                       return 0;
+               }
+
+       } catch (e) {
+               exception_error("get_local_feed_unread", e);
+       }
+}
+
+