<?
-// header("Content-Type: application/xml");
+ $op = $_GET["op"];
+
+ if ($op == "rpc") {
+ header("Content-Type: application/xml");
+ }
require_once "config.php";
require_once "db.php";
if (DB_TYPE == "pgsql") {
pg_query("set client_encoding = 'utf-8'");
}
-
- $op = $_GET["op"];
+
$fetch = $_GET["fetch"];
+ function getLabelCounters($link) {
+
+ $result = db_query($link, "SELECT count(id) as count FROM ttrss_entries
+ WHERE marked = true");
+
+ $count = pg_fetch_result($result, 0, "count");
+
+ print "<label id=\"-1\" counter=\"$count\"/>";
+
+ $result = db_query($link, "SELECT id,sql_exp,description FROM
+ ttrss_labels ORDER by description");
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $id = -$line["id"] - 11;
+
+ error_reporting (0);
+
+ $tmp_result = pg_query("SELECT count(id) as count FROM ttrss_entries
+ WHERE " . $line["sql_exp"]);
+
+ $count = pg_fetch_result($tmp_result, 0, "count");
+
+ print "<feed id=\"$id\" counter=\"$count\"/>";
+
+ error_reporting (E_ERROR | E_WARNING | E_PARSE);
+
+ }
+ }
+
+ 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
+ FROM ttrss_feeds");
+
+ while ($line = db_fetch_assoc($result)) {
+
+ $id = $line["id"];
+ $count = $line["count"];
+
+ print "<feed id=\"$id\" counter=\"$count\"/>";
+ }
+ }
+
function outputFeedList($link) {
print "<html><head>
if (ENABLE_LABELS) {
- $result = db_query($link, "SELECT id,description FROM
+ $result = db_query($link, "SELECT id,sql_exp,description FROM
ttrss_labels ORDER by description");
if (db_num_rows($result) > 0) {
}
while ($line = db_fetch_assoc($result)) {
+
+ error_reporting (0);
+ $tmp_result = pg_query("SELECT count(id) as count FROM ttrss_entries
+ WHERE " . $line["sql_exp"]);
+
+ $count = pg_fetch_result($tmp_result, 0, "count");
+
+ error_reporting (E_ERROR | E_WARNING | E_PARSE);
+
printFeedEntry(-$line["id"]-11,
- "odd", $line["description"], 0, "images/label.png");
+ "odd", $line["description"], $count, "images/label.png");
}
}
$subop = $_GET["subop"];
+ if ($subop == "getLabelCounters") {
+ print "<rpc-reply>";
+ getLabelCounters($link);
+ print "</rpc-reply>";
+ }
+
+ if ($subop == "getFeedCounters") {
+ print "<rpc-reply>";
+ getFeedCounters($link);
+ print "</rpc-reply>";
+ }
+
+ if ($subop == "getAllCounters") {
+ print "<rpc-reply>";
+ getLabelCounters($link);
+ getFeedCounters($link);
+ print "</rpc-reply>";
+
+ }
+
if ($subop == "mark") {
$mark = $_GET["mark"];
$id = db_escape_string($_GET["id"]);
return;
}
- if ($subop == "forceUpdateAllFeeds") {
+ if ($subop == "forceUpdateAllFeeds" || $subop == "updateAllFeeds") {
update_all_feeds($link, true);
- }
- if ($subop == "updateAllFeeds") {
- update_all_feeds($link, false);
+ print "<rpc-reply>";
+ getLabelCounters($link);
+ getFeedCounters($link);
+ print "</rpc-reply>";
}
if ($subop == "catchupPage") {
print "Marked active page as read.";
}
-
}
if ($op == "feeds") {
print "</div>";
+ print "<script type=\"text/javascript\">
+ update_label_counters();
+ </script>";
}
if ($addheader) {
} else {
// print "[viewfeed] feed type not implemented<br>";
- $unread = 0;
+
+ error_reporting(0);
+ $result = db_query($link, "SELECT count(id) as unread FROM ttrss_entries
+ WHERE $query_strategy_part");
+
+ $unread = db_fetch_result($result, 0, "unread");
+
+ error_reporting (E_ERROR | E_WARNING | E_PARSE);
}
+ if (!$unread) $unread = 0;
+
// update unread/total counters and status for active feed in the feedlist
// kludge, because iframe doesn't seem to support onload()
var feedctr = p_document.getElementById(\"FEEDCTR-\" + $feed);
- if ($unread > 0 && $feed != -1 && !feedr.className.match(\"Unread\")) {
+ if ($unread > 0 && $feed >= 0 && !feedr.className.match(\"Unread\")) {
feedr.className = feedr.className + \"Unread\";
feedctr.className = '';
} else if ($unread <= 0) {
feedctr.className = 'invisible';
}
+ update_label_counters();
+
// p_notify(\"\");
</script>";
function setActiveFeedId(id) {
return setCookie("ttrss_vf_actfeed", id);
}
+
+var xmlhttp_rpc = false;
+
+/*@cc_on @*/
+/*@if (@_jscript_version >= 5)
+// JScript gives us Conditional compilation, we can cope with old IE versions.
+// and security blocked creation of the objects.
+try {
+ xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP");
+} catch (e) {
+ try {
+ xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (E) {
+ xmlhttp_rpc = false;
+ }
+}
+@end @*/
+
+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;
+
+ var f_document = parent.frames["feeds-frame"].document;
+
+ for (var l = 0; l < reply.childNodes.length; l++) {
+ var id = reply.childNodes[l].getAttribute("id");
+ var ctr = reply.childNodes[l].getAttribute("counter");
+
+ var feedctr = f_document.getElementById("FEEDCTR-" + id);
+ var feedu = f_document.getElementById("FEEDU-" + id);
+
+ feedu.innerHTML = ctr;
+
+ if (ctr > 0) {
+ feedctr.className = "odd";
+ } else {
+ feedctr.className = "invisible";
+ }
+ }
+ }
+}
+
+function update_label_counters() {
+ if (xmlhttp_ready(xmlhttp_rpc)) {
+ var query = "backend.php?op=rpc&subop=getLabelCounters";
+ xmlhttp_rpc.open("GET", query, true);
+ xmlhttp_rpc.onreadystatechange=label_counters_callback;
+ xmlhttp_rpc.send(null);
+ }
+}
*/
function refetch_callback() {
-
if (xmlhttp.readyState == 4) {
document.title = "Tiny Tiny RSS";
notify("All feeds updated.");
- updateFeedList();
-
- }
-}
+ var reply = xmlhttp.responseXML.firstChild;
+
+ var f_document = window.frames["feeds-frame"].document;
+
+ for (var l = 0; l < reply.childNodes.length; l++) {
+ var id = reply.childNodes[l].getAttribute("id");
+ var ctr = reply.childNodes[l].getAttribute("counter");
+ var feedctr = f_document.getElementById("FEEDCTR-" + id);
+ var feedu = f_document.getElementById("FEEDU-" + id);
+ var feedr = f_document.getElementById("FEEDR-" + id);
+
+ feedu.innerHTML = ctr;
+
+ if (ctr > 0) {
+ feedctr.className = "odd";
+ if (id > 0 && !feedr.className.match("Unread")) {
+ feedr.className = feedr.className + "Unread";
+ }
+ } else {
+ feedctr.className = "invisible";
+ feedr.className = feedr.className.replace("Unread", "");
+ }
+ }
+ }
+}
function updateFeed(feed_id) {
--- /dev/null
+var xmlhttp_rpc = false;
+
+/*@cc_on @*/
+/*@if (@_jscript_version >= 5)
+// JScript gives us Conditional compilation, we can cope with old IE versions.
+// and security blocked creation of the objects.
+try {
+ xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP");
+} catch (e) {
+ try {
+ xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (E) {
+ xmlhttp_rpc = false;
+ }
+}
+@end @*/
+
+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;
+
+ var f_document = parent.frames["feeds-frame"].document;
+
+ for (var l = 0; l < reply.childNodes.length; l++) {
+ var id = reply.childNodes[l].getAttribute("id");
+ var ctr = reply.childNodes[l].getAttribute("counter");
+
+ var feedctr = f_document.getElementById("FEEDCTR-" + id);
+ var feedu = f_document.getElementById("FEEDU-" + id);
+
+ feedu.innerHTML = ctr;
+
+ if (ctr > 0) {
+ feedctr.className = "odd";
+ } else {
+ feedctr.className = "invisible";
+ }
+ }
+ }
+}
+
+function update_label_counters() {
+ if (xmlhttp_ready(xmlhttp_rpc)) {
+ var query = "backend.php?op=rpc&subop=getLabelCounters";
+ xmlhttp_rpc.open("GET", query, true);
+ xmlhttp_rpc.onreadystatechange=label_counters_callback;
+ xmlhttp_rpc.send(null);
+ }
+}
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
- xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
+ xmlhttp_rpc = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
// p_notify("Loading article...");
- enableHotkeys();
+ var f_document = parent.frames["feeds-frame"].document;
+ var h_document = document;
+ var m_document = parent.document;
- var crow = document.getElementById("RROW-" + id);
+ enableHotkeys();
- var f_doc = parent.frames["feeds-frame"].document;
+ var crow = h_document.getElementById("RROW-" + id);
if (crow.className.match("Unread")) {
- var umark = f_doc.getElementById("FEEDU-" + feed_id);
+ var umark = f_document.getElementById("FEEDU-" + feed_id);
umark.innerHTML = umark.innerHTML - 1;
crow.className = crow.className.replace("Unread", "");
if (umark.innerHTML == "0") {
- var feedr = f_doc.getElementById("FEEDR-" + feed_id);
+ var feedr = f_document.getElementById("FEEDR-" + feed_id);
feedr.className = feedr.className.replace("Unread", "");
- var feedctr = f_doc.getElementById("FEEDCTR-" + feed_id);
+ var feedctr = f_document.getElementById("FEEDCTR-" + feed_id);
if (feedctr) {
feedctr.className = "invisible";
cleanSelected("headlinesList");
- var upd_img_pic = document.getElementById("FUPDPIC-" + id);
+ var upd_img_pic = h_document.getElementById("FUPDPIC-" + id);
if (upd_img_pic) {
upd_img_pic.src = "images/blank_icon.gif";
var unread_rows = getVisibleUnreadHeadlines();
if (unread_rows.length == 0) {
- var button = document.getElementById("btnCatchupPage");
+ var button = h_document.getElementById("btnCatchupPage");
if (button) {
button.className = "disabledButton";
button.href = "";
active_post_id = id;
setActiveFeedId(feed_id);
- var content = parent.document.getElementById("content-frame");
+ var content = m_document.getElementById("content-frame");
if (content) {
content.src = "backend.php?op=view&addheader=true&id=" + param_escape(id);
markHeadline(active_post_id);
}
+
}
function toggleMark(id, toggle) {
+ var f_document = parent.frames["feeds-frame"].document;
+
if (!xmlhttp_ready(xmlhttp_rpc)) {
printLockingError();
return;
var query = "backend.php?op=rpc&id=" + id + "&subop=mark";
- var f_doc = parent.frames["feeds-frame"].document;
+ var vfeedu = f_document.getElementById("FEEDU--1");
- var vfeedu = f_doc.getElementById("FEEDU--1");
+// alert(vfeedu);
if (toggle == true) {
mark_img.src = "images/mark_set.png";
}
- var vfeedctr = f_doc.getElementById("FEEDCTR--1");
+ var vfeedctr = f_document.getElementById("FEEDCTR--1");
if (vfeedu && vfeedctr) {
if ((+vfeedu.innerHTML) > 0) {