*/
var xmlhttp = false;
-var xmlhttp_rpc = false;
var total_unread = 0;
var first_run = true;
+var search_query = "";
+
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
- xmlhttp_rpc = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
- xmlhttp_rpc = new XMLHttpRequest();
-
-}
-
-function notify_callback() {
- var container = document.getElementById('notify');
- if (xmlhttp.readyState == 4) {
- container.innerHTML=xmlhttp.responseText;
- }
}
+/*
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();
-// }
-
if (first_run) {
scheduleFeedUpdate(false);
+ if (getCookie("ttrss_vf_actfeed")) {
+ viewfeed(getCookie("ttrss_vf_actfeed"), 0, "");
+ }
first_run = false;
} else {
notify("");
- }
- }
+ }
+ }
}
+*/
-function viewfeed_callback() {
- var container = document.getElementById('headlines');
- if (xmlhttp.readyState == 4) {
- container.innerHTML = xmlhttp.responseText;
-
- var factive = document.getElementById("FACTIVE");
- var funread = document.getElementById("FUNREAD");
- var ftotal = document.getElementById("FTOTAL");
-
- if (ftotal && factive && funread) {
- var feed_id = factive.innerHTML;
-
- var feedr = document.getElementById("FEEDR-" + feed_id);
- var feedt = document.getElementById("FEEDT-" + feed_id);
- var feedu = document.getElementById("FEEDU-" + feed_id);
-
- feedt.innerHTML = ftotal.innerHTML;
- feedu.innerHTML = funread.innerHTML;
-
- if (feedu.innerHTML > 0 && !feedr.className.match("Unread")) {
- feedr.className = feedr.className + "Unread";
- } else if (feedu.innerHTML <= 0) {
- feedr.className = feedr.className.replace("Unread", "");
- }
+function refetch_callback() {
- }
+ if (xmlhttp.readyState == 4) {
- notify("");
+ document.title = "Tiny Tiny RSS";
+ notify("All feeds updated.");
- }
+ updateFeedList();
+
+ }
}
-function view_callback() {
- var container = document.getElementById('content');
- if (xmlhttp.readyState == 4) {
- container.innerHTML=xmlhttp.responseText;
- }
-}
-function refetch_callback() {
- if (xmlhttp_rpc.readyState == 4) {
- notify("All feeds updated");
-
- var container = document.getElementById('feeds');
+function updateFeed(feed_id) {
- container.innerHTML = xmlhttp_rpc.responseText;
+ var query_str = "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id;
- document.title = "Tiny Tiny RSS";
+ if (xmlhttp_ready(xmlhttp)) {
+ xmlhttp.open("GET", query_str, true);
+ xmlhttp.onreadystatechange=feed_update_callback;
+ xmlhttp.send(null);
+ } else {
+ printLockingError();
+ }
- //updateFeedList(true, false);
- }
}
function scheduleFeedUpdate(force) {
query_str = query_str + "updateAllFeeds";
}
- if (xmlhttp_rpc.readyState == 4 || xmlhttp_rpc.readyState == 0) {
- xmlhttp_rpc.open("GET", query_str, true);
- xmlhttp_rpc.onreadystatechange=refetch_callback;
- xmlhttp_rpc.send(null);
+ if (xmlhttp_ready(xmlhttp)) {
+ xmlhttp.open("GET", query_str, true);
+ xmlhttp.onreadystatechange=refetch_callback;
+ xmlhttp.send(null);
} else {
printLockingError();
- }
+ }
}
function updateFeedList(silent, fetch) {
-
- if (silent != true) {
- notify("Loading feed list...");
- }
- var query_str = "backend.php?op=feeds";
+// if (silent != true) {
+// notify("Loading feed list...");
+// }
- if (fetch) query_str = query_str + "&fetch=yes";
+ var query_str = "backend.php?op=feeds";
- if (xmlhttp.readyState == 4 || xmlhttp.readyState == 0) {
- xmlhttp.open("GET", query_str, true);
- xmlhttp.onreadystatechange=feedlist_callback;
- xmlhttp.send(null);
- } else {
- printLockingError();
+ if (getActiveFeedId()) {
+ query_str = query_str + "&actid=" + getActiveFeedId();
}
-}
-function catchupPage(feed) {
+ if (fetch) query_str = query_str + "&fetch=yes";
- if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) {
- printLockingError();
- return
- }
+ var feeds_frame = document.getElementById("feeds-frame");
- var content = document.getElementById("headlinesList");
+ feeds_frame.src = query_str;
+}
- var rows = new Array();
+function catchupAllFeeds() {
- for (i = 0; i < content.rows.length; i++) {
- var row_id = content.rows[i].id.replace("RROW-", "");
- if (row_id.length > 0) {
- if (content.rows[i].className.match("Unread")) {
- rows.push(row_id);
- content.rows[i].className = content.rows[i].className.replace("Unread", "");
- }
- }
- }
+ var query_str = "backend.php?op=feeds&subop=catchupAll";
- if (rows.length > 0) {
+ notify("Marking all feeds as read...");
- var feedr = document.getElementById("FEEDR-" + feed);
- var feedu = document.getElementById("FEEDU-" + feed);
-
- feedu.innerHTML = feedu.innerHTML - rows.length;
-
- if (feedu.innerHTML > 0 && !feedr.className.match("Unread")) {
- feedr.className = feedr.className + "Unread";
- } else if (feedu.innerHTML <= 0) {
- feedr.className = feedr.className.replace("Unread", "");
- }
+ var feeds_frame = document.getElementById("feeds-frame");
- var query_str = "backend.php?op=rpc&subop=catchupPage&ids=" +
- param_escape(rows.toString());
-
- notify("Marking this page as read...");
-
- xmlhttp.open("GET", query_str, true);
- xmlhttp.onreadystatechange=notify_callback;
- xmlhttp.send(null);
+ feeds_frame.src = query_str;
- } else {
- notify("No unread items on this page.");
+}
+
+function viewCurrentFeed(skip, subop) {
+ if (getActiveFeedId()) {
+ viewfeed(getActiveFeedId(), skip, subop);
}
}
-function catchupAllFeeds() {
+function viewfeed(feed, skip, subop) {
- if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) {
- printLockingError();
- return
- }
- var query_str = "backend.php?op=feeds&subop=catchupAll";
+// notify("Loading headlines...");
- notify("Marking all feeds as read...");
+ enableHotkeys();
- xmlhttp.open("GET", query_str, true);
- xmlhttp.onreadystatechange=feedlist_callback;
- xmlhttp.send(null);
+ var searchbox = document.getElementById("searchbox");
-}
+ if (searchbox) {
+ search_query = searchbox.value;
+ } else {
+ search_query = "";
+ }
-function viewfeed(feed, skip, subop) {
+ var viewbox = document.getElementById("viewbox");
-// document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
-// document.getElementById('content').innerHTML=' ';
+ var view_mode;
- if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) {
- printLockingError();
- return
+ if (viewbox) {
+ view_mode = viewbox[viewbox.selectedIndex].text;
+ } else {
+ view_mode = "All Posts";
}
- xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) +
- "&skip=" + param_escape(skip) + "&subop=" + param_escape(subop) , true);
- xmlhttp.onreadystatechange=viewfeed_callback;
- xmlhttp.send(null);
+ setCookie("ttrss_vf_vmode", view_mode);
- notify("Loading headlines...");
-
-}
+ var limitbox = document.getElementById("limitbox");
-function view(id,feed_id) {
+ var limit;
- if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) {
- printLockingError();
- return
+ if (limitbox) {
+ limit = limitbox[limitbox.selectedIndex].text;
+ setCookie("ttrss_vf_limit", limit);
+ } else {
+ limit = "All";
}
- var crow = document.getElementById("RROW-" + id);
+ setActiveFeedId(feed);
+
+ var f_doc = frames["feeds-frame"].document;
+
+// f_doc.getElementById("ACTFEEDID").innerHTML = feed;
- if (crow.className.match("Unread")) {
- var umark = document.getElementById("FEEDU-" + feed_id);
- umark.innerHTML = umark.innerHTML - 1;
- crow.className = crow.className.replace("Unread", "");
+ if (subop == "MarkAllRead") {
- if (umark.innerHTML == "0") {
- var feedr = document.getElementById("FEEDR-" + feed_id);
+ var feedr = f_doc.getElementById("FEEDR-" + feed);
+ var feedctr = f_doc.getElementById("FEEDCTR-" + feed);
+
+ feedctr.className = "invisible";
+
+ if (feedr.className.match("Unread")) {
feedr.className = feedr.className.replace("Unread", "");
}
-
- total_unread--;
+ }
- update_title();
- }
+ var query = "backend.php?op=viewfeed&feed=" + param_escape(feed) +
+ "&skip=" + param_escape(skip) + "&subop=" + param_escape(subop) +
+ "&view=" + param_escape(view_mode) + "&limit=" + limit;
- var upd_img_pic = document.getElementById("FUPDPIC-" + id);
+ if (search_query != "") {
+ query = query + "&search=" + param_escape(search_query);
+ }
+
+ var headlines_frame = parent.frames["headlines-frame"];
- if (upd_img_pic) {
- upd_img_pic.innerHTML = "";
- }
+ headlines_frame.location.href = query + "&addheader=true";
- document.getElementById('content').innerHTML='Loading, please wait...';
+ cleanSelected("feedsList");
+ var feedr = document.getElementById("FEEDR-" + feed);
+ if (feedr) {
+ feedr.className = feedr.className + "Selected";
+ }
+
+ disableContainerChildren("headlinesToolbar", false, doc);
- xmlhttp.open("GET", "backend.php?op=view&id=" + param_escape(id), true);
- xmlhttp.onreadystatechange=view_callback;
- xmlhttp.send(null);
+// notify("");
}
-function timeout() {
+function timeout() {
scheduleFeedUpdate(true);
-
setTimeout("timeout()", 1800*1000);
-
}
-function search(feed, sender) {
+function resetSearch() {
+ var searchbox = document.getElementById("searchbox")
- if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) {
- printLockingError();
- return
+ if (searchbox.value != "" && getActiveFeedId()) {
+ searchbox.value = "";
+ viewfeed(getActiveFeedId(), 0, "");
}
-
- notify("Search: " + feed + ", " + sender.value)
-
- document.getElementById('headlines').innerHTML='Loading headlines, please wait...';
- document.getElementById('content').innerHTML=' ';
-
- xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) +
- "&search=" + param_escape(sender.value) + "&subop=search", true);
- xmlhttp.onreadystatechange=viewfeed_callback;
- xmlhttp.send(null);
-
}
-function update_title() {
- //document.title = "Tiny Tiny RSS (" + total_unread + " unread)";
+function search() {
+ checkActiveFeedId();
+ if (getActiveFeedId()) {
+ viewfeed(getActiveFeedId(), 0, "");
+ } else {
+ notify("Please select some feed first.");
+ }
}
function localPiggieFunction(enable) {
if (enable) {
var query_str = "backend.php?op=feeds&subop=piggie";
- if (xmlhttp.readyState == 4 || xmlhttp.readyState == 0) {
+ if (xmlhttp_ready(xmlhttp)) {
xmlhttp.open("GET", query_str, true);
xmlhttp.onreadystatechange=feedlist_callback;
}
}
+function localHotkeyHandler(keycode) {
+
+/* if (keycode == 78) {
+ return moveToPost('next');
+ }
+
+ if (keycode == 80) {
+ return moveToPost('prev');
+ } */
+
+ if (keycode == 82) {
+ return scheduleFeedUpdate(true);
+ }
+
+ if (keycode == 85) {
+ return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
+ }
+
+// notify("KC: " + keycode);
+
+}
+
+function genericSanityCheck() {
+
+ if (!xmlhttp) {
+ document.getElementById("headlines").innerHTML =
+ "<b>Fatal error:</b> This program requires XmlHttpRequest " +
+ "to function properly. Your browser doesn't seem to support it.";
+ return false;
+ }
+
+ setCookie("ttrss_vf_test", "TEST");
+ if (getCookie("ttrss_vf_test") != "TEST") {
+
+ document.getElementById("headlines").innerHTML =
+ "<b>Fatal error:</b> This program requires cookies " +
+ "to function properly. Your browser doesn't seem to support them.";
+
+ return false;
+ }
+
+ return true;
+}
function init() {
+
+ disableContainerChildren("headlinesToolbar", true);
+
+ if (!genericSanityCheck())
+ return;
+
updateFeedList(false, false);
document.onkeydown = hotkey_handler;
+
setTimeout("timeout()", 1800*1000);
+ scheduleFeedUpdate(true);
+
+ var content = document.getElementById("content");
+
+ if (getCookie("ttrss_vf_vmode")) {
+ var viewbox = document.getElementById("viewbox");
+ viewbox.value = getCookie("ttrss_vf_vmode");
+ }
+
+ if (getCookie("ttrss_vf_limit")) {
+ var limitbox = document.getElementById("limitbox");
+ limitbox.value = getCookie("ttrss_vf_limit");
+ }
+
+// if (getCookie("ttrss_vf_actfeed")) {
+// viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');
+// }
+
+ setCookie("ttrss_vf_actfeed", "");
+
}
+
+