summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2005-08-22 06:58:37 +0100
committerAndrew Dolgov <[email protected]>2005-08-22 06:58:37 +0100
commit76798ff3f24b7c7b69bd12109228f769ceb650a6 (patch)
treebcb7763bf9367cf3f3e0cd260607827636e9faa8
parent0e091d38cf6419edf5e623a584dc28a404fc2613 (diff)
early title work
-rw-r--r--backend.php6
-rw-r--r--functions.php18
-rw-r--r--tt-rss.js23
3 files changed, 36 insertions, 11 deletions
diff --git a/backend.php b/backend.php
index d6e45098b..2dac4205f 100644
--- a/backend.php
+++ b/backend.php
@@ -28,6 +28,8 @@
$lnum = 0;
+ $total_unread = 0;
+
while ($line = pg_fetch_assoc($result)) {
$feed = $line["title"];
@@ -40,6 +42,8 @@
if ($unread > 0) $class .= "Unread";
+ $total_unread += $unread;
+
print "<tr class=\"$class\" id=\"FEEDR-$feed_id\">";
$feed = "<a href=\"javascript:viewfeed($feed_id, 0);\">$feed</a>";
@@ -58,6 +62,8 @@
print "</table>";
+ print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>";
+
}
if ($op == "view") {
diff --git a/functions.php b/functions.php
index 3da349f1d..cbaefa503 100644
--- a/functions.php
+++ b/functions.php
@@ -8,8 +8,10 @@
EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) > " .
MIN_UPDATE_TIME);
+ $num_unread = 0;
+
while ($line = pg_fetch_assoc($result)) {
- update_rss_feed($link, $line["feed_url"], $line["id"]);
+ $num_unread += update_rss_feed($link, $line["feed_url"], $line["id"]);
}
}
@@ -17,6 +19,8 @@
function update_rss_feed($link, $feed_url, $feed) {
$rss = fetch_rss($feed_url);
+
+ $num_unread = 0;
if ($rss) {
@@ -80,7 +84,9 @@
'$entry_timestamp', '$entry_content', '$feed',
'$content_md5')";
- pg_query($link, $query);
+ $result = pg_query($link, $query);
+
+ if ($result) ++$num_unread;
} else {
@@ -110,15 +116,15 @@
$result = pg_query($link, $query);
-
-// print "$entry_guid - $entry_timestamp - $entry_title -
-// $entry_link - $entry_id<br>";
+ if ($result) ++$num_unread;
}
}
- $result = pg_query($link, "UPDATE ttrss_feeds SET last_updated = NOW()");
+ if ($result) {
+ $result = pg_query($link, "UPDATE ttrss_feeds SET last_updated = NOW()");
+ }
}
diff --git a/tt-rss.js b/tt-rss.js
index 3f6aab00b..285d667e2 100644
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -5,6 +5,8 @@
var xmlhttp = false;
+var total_unread = 0;
+
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
@@ -28,6 +30,13 @@ function feedlist_callback() {
var container = document.getElementById('feeds');
if (xmlhttp.readyState == 4) {
container.innerHTML=xmlhttp.responseText;
+
+ var feedtu = document.getElementById("FEEDTU");
+
+ if (feedtu) {
+ total_unread = feedtu.innerHTML;
+ update_title();
+ }
}
}
@@ -112,7 +121,11 @@ function view(id,feed_id) {
var feedr = document.getElementById("FEEDR-" + feed_id);
feedr.className = feedr.className.replace("Unread", "");
}
- }
+
+ total_unread--;
+
+ update_title();
+ }
document.getElementById('content').innerHTML='Loading, please wait...';
@@ -144,11 +157,11 @@ function search(feed, sender) {
}
-function init() {
+function update_title() {
+ //document.title = "Tiny Tiny RSS (" + total_unread + " unread)";
+}
+function init() {
update_feed_list(false, false);
-
setTimeout("timeout()", 1800*1000);
-
-
}