]> git.wh0rd.org Git - tt-rss.git/commitdiff
further label/vfeed/feed behaviour unification
authorAndrew Dolgov <fox@bah.spb.su>
Fri, 9 Sep 2005 02:47:39 +0000 (03:47 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Fri, 9 Sep 2005 02:47:39 +0000 (03:47 +0100)
backend.php
functions.js
tt-rss.js
view.js
viewfeed.js

index 572fb092ade7845854bf9ac77b36f3af2ad2d38f..9993d88a98d5a487b016b7e402b37b7ea91b670d 100644 (file)
@@ -21,7 +21,7 @@
        function getLabelCounters($link) {
 
                $result = db_query($link, "SELECT count(id) as count FROM ttrss_entries
-                       WHERE marked = true");
+                       WHERE marked = true AND unread = true");
 
                $count = db_fetch_result($result, 0, "count");
 
                }
        }
 
-       function getFeedCounters($link) {
+       function getFeedCounter($link, $id) {
+       
+               $result = db_query($link, "SELECT 
+                               count(id) as count FROM ttrss_entries
+                       WHERE feed_id = '$id'   AND unread = true");
+       
+                       $count = db_fetch_result($result, 0, "count");
+                       
+                       print "<feed id=\"$id\" counter=\"$count\"/>";          
+       }
 
+       function getFeedCounters($link) {
+       
                $result = db_query($link, "SELECT id,
                        (SELECT count(id) FROM ttrss_entries WHERE feed_id = ttrss_feeds.id 
                                AND unread = true) as count
@@ -79,7 +90,7 @@
                /* virtual feeds */
 
                $result = db_query($link, "SELECT count(id) as num_starred 
-                       FROM ttrss_entries WHERE marked = true");
+                       FROM ttrss_entries WHERE marked = true AND unread = true");
                $num_starred = db_fetch_result($result, 0, "num_starred");
 
                printFeedEntry(-1, "odd", "Starred articles", $num_starred, "images/mark_set.png");
                $subop = $_GET["subop"];
 
                if ($subop == "getLabelCounters") {
+                       $aid = $_GET["aid"];            
                        print "<rpc-reply>";
                        getLabelCounters($link);
+                       if ($aid) {
+                               getFeedCounter($link, $aid);
+                       }
                        print "</rpc-reply>";
                }
 
        if ($op == "view") {
 
                $id = $_GET["id"];
+               $feed_id = $_GET["feed"];
 
                $result = db_query($link, "UPDATE ttrss_entries SET unread = false,last_read = NOW() WHERE id = '$id'");
 
                        print "</div>";
 
                        print "<script type=\"text/javascript\">
-                               update_label_counters();
+                               update_label_counters($feed_id);
                        </script>";
                }
 
                                        feedctr.className = 'invisible';
                        }       
 
-                       update_label_counters();
+                       update_label_counters($feed);
 
 //                     p_notify(\"\");
 
index 8e7b9995787ba12b1b14d428030e69a8d976c3a4..909d34e12789435f71f79627aaebd42dc64204ab 100644 (file)
@@ -318,7 +318,7 @@ function label_counters_callback() {
 
                        if (ctr > 0) {
                                feedctr.className = "odd";
-                               if (!feedr.className.match("Unread") && id != -1) {
+                               if (!feedr.className.match("Unread")) {
                                        feedr.className = feedr.className + "Unread";
                                }
                        } else {
@@ -329,9 +329,9 @@ function label_counters_callback() {
        }
 }
 
-function update_label_counters() {
+function update_label_counters(feed) {
        if (xmlhttp_ready(xmlhttp_rpc)) {
-               var query = "backend.php?op=rpc&subop=getLabelCounters";        
+               var query = "backend.php?op=rpc&subop=getLabelCounters&aid=" + feed;    
                xmlhttp_rpc.open("GET", query, true);
                xmlhttp_rpc.onreadystatechange=label_counters_callback;
                xmlhttp_rpc.send(null);
index ae16052cb05735d8e2bf80a5e324f2793667c1ab..31f5b29c6393d23359e86cbcfac74499df683765 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -70,7 +70,7 @@ function refetch_callback() {
 
                        if (ctr > 0) {
                                feedctr.className = "odd";
-                               if (id != -1 && !feedr.className.match("Unread")) {
+                               if (!feedr.className.match("Unread")) {
                                        feedr.className = feedr.className + "Unread";
                                }
                        } else {
diff --git a/view.js b/view.js
index 6450a0b7af8cd0a0e2e31e48dab084556379a21d..1d2584889e47422374bad3c3919bab5d74cdb40a 100644 (file)
--- a/view.js
+++ b/view.js
@@ -19,6 +19,7 @@ if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') {
        xmlhttp_rpc = new XMLHttpRequest();
 }
 
+/*
 function label_counters_callback() {
        if (xmlhttp_rpc.readyState == 4) {
                var reply = xmlhttp_rpc.responseXML.firstChild;
@@ -51,3 +52,4 @@ function update_label_counters() {
                xmlhttp_rpc.send(null);
        }
 }
+*/
index 4bded27625c2fdbc720931dea8fd5454f9c44540..9d891ec66dedefb253db83870230899577ba2f1a 100644 (file)
@@ -34,7 +34,7 @@ function view(id, feed_id) {
 
        var crow = h_document.getElementById("RROW-" + id);
 
-       if (crow.className.match("Unread")) {
+/*     if (crow.className.match("Unread")) {
                var umark = f_document.getElementById("FEEDU-" + feed_id);
                
                umark.innerHTML = umark.innerHTML - 1;
@@ -52,8 +52,9 @@ function view(id, feed_id) {
                }
 
                total_unread--;
-       }       
+       }        */
 
+       crow.className = crow.className.replace("Unread", "");
 
        cleanSelected("headlinesList");
 
@@ -63,23 +64,14 @@ function view(id, feed_id) {
                upd_img_pic.src = "images/blank_icon.gif";
        } 
 
-       var unread_rows = getVisibleUnreadHeadlines();
-
-       if (unread_rows.length == 0) {
-               var button = h_document.getElementById("btnCatchupPage");
-               if (button) {
-                       button.className = "disabledButton";
-                       button.href = "";
-               }
-       }
-
        active_post_id = id; 
        setActiveFeedId(feed_id);
 
        var content = m_document.getElementById("content-frame");
 
        if (content) {
-               content.src = "backend.php?op=view&addheader=true&id=" + param_escape(id);
+               content.src = "backend.php?op=view&addheader=true&id=" + param_escape(id) +
+                       "&feed=" + param_escape(feed_id);
                markHeadline(active_post_id);
        }