start work on showing number of unread articles in title

This commit is contained in:
Andrew Dolgov 2005-10-23 16:40:55 +01:00
parent bdd01d3f31
commit fc69e64169
2 changed files with 42 additions and 4 deletions

View File

@ -28,6 +28,13 @@
/* FIXME this needs reworking */ /* FIXME this needs reworking */
function getGlobalCounters($link) {
$result = db_query($link, "SELECT count(id) as c_id FROM ttrss_entries
WHERE unread = true");
$c_id = db_fetch_result($result, 0, "c_id");
print "<counter id='global-unread' counter='$c_id'/>";
}
function getTagCounters($link) { function getTagCounters($link) {
$result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count $result = db_query($link, "SELECT tag_name,count(ttrss_entries.id) AS count
FROM ttrss_tags,ttrss_entries WHERE FROM ttrss_tags,ttrss_entries WHERE
@ -276,8 +283,8 @@
getLabelCounters($link); getLabelCounters($link);
getFeedCounters($link); getFeedCounters($link);
getTagCounters($link); getTagCounters($link);
getGlobalCounters($link);
print "</rpc-reply>"; print "</rpc-reply>";
} }
if ($subop == "mark") { if ($subop == "mark") {
@ -321,6 +328,7 @@
if (strchr($omode, "l")) getLabelCounters($link); if (strchr($omode, "l")) getLabelCounters($link);
if (strchr($omode, "f")) getFeedCounters($link); if (strchr($omode, "f")) getFeedCounters($link);
if (strchr($omode, "t")) getTagCounters($link); if (strchr($omode, "t")) getTagCounters($link);
getGlobalCounters($link);
print "</rpc-reply>"; print "</rpc-reply>";
} }

View File

@ -13,6 +13,8 @@ var search_mode = "";
var display_tags = false; var display_tags = false;
var global_unread = 0;
/*@cc_on @*/ /*@cc_on @*/
/*@if (@_jscript_version >= 5) /*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions. // JScript gives us Conditional compilation, we can cope with old IE versions.
@ -68,8 +70,7 @@ function feedlist_callback() {
function refetch_callback() { function refetch_callback() {
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {
document.title = "Tiny Tiny RSS"; // document.title = "Tiny Tiny RSS";
notify("All feeds updated.");
if (!xmlhttp.responseXML) { if (!xmlhttp.responseXML) {
notify("refetch_callback: backend did not return valid XML"); notify("refetch_callback: backend did not return valid XML");
@ -93,6 +94,13 @@ function refetch_callback() {
var feedu = f_document.getElementById("FEEDU-" + id); var feedu = f_document.getElementById("FEEDU-" + id);
var feedr = f_document.getElementById("FEEDR-" + id); var feedr = f_document.getElementById("FEEDR-" + id);
/* TODO figure out how to update this from viewfeed.js->view()
disabled for now...
if (id == "global-unread") {
global_unread = ctr;
} */
if (feedctr && feedu && feedr) { if (feedctr && feedu && feedr) {
feedu.innerHTML = ctr; feedu.innerHTML = ctr;
@ -108,6 +116,10 @@ function refetch_callback() {
} }
} }
} }
updateTitle("");
notify("All feeds updated.");
} }
} }
@ -129,7 +141,9 @@ function scheduleFeedUpdate(force) {
notify("Updating feeds in background..."); notify("Updating feeds in background...");
document.title = "Tiny Tiny RSS - Updating..."; // document.title = "Tiny Tiny RSS - Updating...";
updateTitle("Updating...");
var query_str = "backend.php?op=rpc&subop="; var query_str = "backend.php?op=rpc&subop=";
@ -181,6 +195,9 @@ function catchupAllFeeds() {
feeds_frame.src = query_str; feeds_frame.src = query_str;
global_unread = 0;
updateTitle();
} }
function viewCurrentFeed(skip, subop) { function viewCurrentFeed(skip, subop) {
@ -341,6 +358,19 @@ function localHotkeyHandler(keycode) {
} }
function updateTitle(s) {
var tmp = "Tiny Tiny RSS";
if (global_unread > 0) {
tmp = tmp + " (" + global_unread + ")";
}
if (s) {
tmp = tmp + " - " + s;
}
document.title = tmp;
}
function genericSanityCheck() { function genericSanityCheck() {
if (!xmlhttp) { if (!xmlhttp) {