]> git.wh0rd.org Git - tt-rss.git/commitdiff
render feedlist using local data when in offline mode
authorAndrew Dolgov <fox@bah.org.ru>
Tue, 3 Feb 2009 14:03:35 +0000 (17:03 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Tue, 3 Feb 2009 14:03:35 +0000 (17:03 +0300)
feedlist.js
modules/backend-rpc.php
tt-rss.js

index 4a892a9076904f5b9712cacba699fd65d2232c52..d56f28d1e9092d5fa98f5840c1ddb40e386559ba 100644 (file)
@@ -32,7 +32,60 @@ function viewCategory(cat) {
 
 function render_offline_feedlist() {
        try {
-               // FIXME
+               var tmp = "<ul class=\"feedList\" id=\"feedList\">";
+
+               var rs = db.execute("SELECT id,title,has_icon FROM offline_feeds ORDER BY title");
+
+               while (rs.isValidRow()) {
+
+                       var id = rs.field(0);
+                       var title = rs.field(1);
+                       var has_icon = rs.field(2);
+
+                       var rs_u = db.execute("SELECT SUM(unread) FROM offline_data WHERE feed_id = ?",
+                               [id]);
+                       var unread = 0;
+
+                       if (rs.isValidRow()) {
+                               unread = rs_u.field(0);
+                               if (!unread) unread = 0;
+                       }
+
+                       var feed_icon = "";
+
+                       if (has_icon) {
+                               feed_icon = "<img id='FIMG-"+id+"' src='" + "icons/" + id + ".ico'>";
+                       } else {
+                               feed_icon = "<img id='FIMG-"+id+"' src='images/blank_icon.gif'>";
+                       }
+
+                       var row_class = "feed";
+
+                       if (unread > 0) {
+                               row_class += "Unread";
+                               fctr_class = "feedCtrHasUnread";
+                       } else {
+                               fctr_class = "feedCtrNoUnread";
+                       }
+
+                       var link = "<a title=\"FIXME\" id=\"FEEDL-"+id+"\""+
+                               "href=\"javascript:viewfeed('"+id+"', '', false, '', false, 0);\">"+
+                               title + "</a>";
+
+                       tmp += "<li id='FEEDR-"+id+"' class="+row_class+">" + feed_icon + 
+                               "<span id=\"FEEDN-"+id+"\">" + link + "</span>";
+
+                       tmp += " <span class='"+fctr_class+"' id=\"FEEDCTR-"+id+"\">" +
+                  "(<span id=\"FEEDU-"+id+"\">"+unread+"</span>)</span>";
+                               
+                       tmp += "</li>";
+
+                       rs.next();
+               }
+
+               tmp += "</ul>";
+
+               render_feedlist(tmp);
        } catch (e) {
                exception_error("render_offline_feedlist", e);
        }
index 751934f351668e669fe91783c8b62f252f96371b..64e7df2f0c26db36e41f5e32102f5842e4f194b6 100644 (file)
                                        ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]);
 
                                while ($line = db_fetch_assoc($result)) {
-                                       print "<feed id=\"".$line["id"]."\"><![CDATA[";
+
+                                       $has_icon = (int) feed_has_icon($line["id"]);
+
+                                       print "<feed has_icon=\"$has_icon\" id=\"".$line["id"]."\"><![CDATA[";
                                        print $line["title"];
                                        print "]]></feed>";
                                }
index e1ca160af0d7fc3d123358108c684ef345102320..5089fcf278afd11974e8189f34c82e134dedf980 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -1507,7 +1507,7 @@ function init_gears() {
 
                        db.execute("CREATE TABLE IF NOT EXISTS cache (id text, article text, param text, added text)");
 
-                       db.execute("CREATE TABLE if not exists offline_feeds (id integer, title text)");
+                       db.execute("CREATE TABLE if not exists offline_feeds (id integer, title text, has_icon integer)");
 
                        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, unread text, marked text)");
 
@@ -1549,10 +1549,12 @@ function offline_download_parse(stage, transport) {
 
                                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 offline_feeds (id,title) VALUES (?,?)",
-                                               [id, title]);
+                                       db.execute("INSERT INTO offline_feeds (id,title,has_icon)"+
+                                               "VALUES (?,?,?)",
+                                               [id, title, has_icon]);
                                }
                
                                window.setTimeout("initiate_offline_download("+(stage+1)+")", 50);