var global_unread = -1;
var active_title_text = "";
var current_subtitle = "";
-
+var daemon_enabled = false;
var _qfd_deleted_feed = 0;
+var firsttime_update = true;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
}
}
+function hide_unread_callback() {
+ if (xmlhttp.readyState == 4) {
+
+ try {
+
+ var reply = xmlhttp.responseXML.firstChild.firstChild;
+ var value = reply.getAttribute("value");
+ var hide_read_feeds = (value != "false")
+ var feeds_doc = window.frames["feeds-frame"].document;
+
+ hideOrShowFeeds(feeds_doc, hide_read_feeds);
+
+ if (hide_read_feeds) {
+ setCookie("ttrss_vf_hreadf", 1);
+ } else {
+ setCookie("ttrss_vf_hreadf", 0);
+ }
+
+ } catch (e) {
+ exception_error("hide_unread_callback", e);
+ }
+
+ }
+}
+
function refetch_callback() {
if (xmlhttp.readyState == 4) {
try {
if (!reply) {
notify("refetch_callback: backend did not return expected XML object");
+ updateTitle("");
return;
}
var f_document = window.frames["feeds-frame"].document;
parse_counters(reply, f_document, window);
-
- updateTitle("");
- notify("All feeds updated.");
+
+ debug("refetch_callback: done");
+
+ if (!daemon_enabled) {
+ notify("All feeds updated.");
+ updateTitle("");
+ } else {
+ notify("");
+ }
} catch (e) {
exception_error("refetch_callback", e);
+ updateTitle("");
}
}
}
try {
if (!xmlhttp.responseXML) {
- fatalError(3);
+ fatalError(3, "D001;" + xmlhttp.responseText);
return;
}
var reply = xmlhttp.responseXML.firstChild;
if (!reply) {
- fatalError(3);
+ fatalError(3, "D002;" + xmlhttp.responseText);
return;
}
return fatalError(error_code);
}
+ debug("sanity check ok");
+
init_second_stage();
} catch (e) {
function scheduleFeedUpdate(force) {
- notify("Updating feeds, please wait.");
-
-// document.title = "Tiny Tiny RSS - Updating...";
-
- updateTitle("Updating");
+ if (!daemon_enabled) {
+ notify("Updating feeds, please wait.");
+ updateTitle("Updating");
+ }
var query_str = "backend.php?op=rpc&subop=";
var omode;
- if (display_tags) {
- omode = "t";
+ if (firsttime_update && !navigator.userAgent.match("Opera")) {
+ firsttime_update = false;
+ omode = "T";
} else {
- omode = "fl";
+ if (display_tags) {
+ omode = "t";
+ } else {
+ omode = "flc";
+ }
}
-
+
query_str = query_str + "&omode=" + omode;
+ query_str = query_str + "&uctr=" + global_unread;
+
+ debug("in scheduleFeedUpdate");
if (xmlhttp_ready(xmlhttp)) {
xmlhttp.open("GET", query_str, true);
query_str = query_str + "&actid=" + getActiveFeedId();
}
+ if (navigator.userAgent.match("Opera")) {
+ var date = new Date();
+ var timestamp = Math.round(date.getTime() / 1000);
+ query_str = query_str + "&ts=" + timestamp
+ }
+
if (fetch) query_str = query_str + "&fetch=yes";
var feeds_frame = document.getElementById("feeds-frame");
function timeout() {
scheduleFeedUpdate(false);
- setTimeout("timeout()", 900*1000);
+
+ var refresh_time = getCookie('ttrss_vf_refresh');
+
+ if (!refresh_time) refresh_time = 600;
+
+ setTimeout("timeout()", refresh_time*1000);
}
function resetSearch() {
}
function search() {
- closeDlg();
+ closeDlg();
viewCurrentFeed(0, "");
}
function localHotkeyHandler(keycode) {
-/* if (keycode == 78) {
- return moveToPost('next');
- }
-
- if (keycode == 80) {
- return moveToPost('prev');
- } */
-
if (keycode == 82) { // r
return scheduleFeedUpdate(true);
}
function updateTitle(s) {
var tmp = "Tiny Tiny RSS";
- if (s && s.length > 0) {
+ if (s != undefined) {
current_subtitle = s;
}
tmp = tmp + " (" + global_unread + ")";
}
- if (s) {
+ if (current_subtitle) {
tmp = tmp + " - " + current_subtitle;
}
try {
+ // this whole shebang is based on http://www.birnamdesigns.com/misc/busted2.html
+
+ if (arguments.callee.done) return;
+ arguments.callee.done = true;
+
disableContainerChildren("headlinesToolbar", true);
if (!genericSanityCheck())
return;
+ if (getURLParam('debug')) {
+ document.getElementById('debug_output').style.display = 'block';
+ debug('debug mode activated');
+ }
+
xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
xmlhttp.onreadystatechange=backend_sanity_check_callback;
xmlhttp.send(null);
}
}
+function resize_feeds_frame() {
+ var f = document.getElementById("feeds-frame");
+ var tf = document.getElementById("mainFooter");
+ var th = document.getElementById("mainHeader");
+
+ f.style.height = document.body.scrollHeight - tf.scrollHeight -
+ th.scrollHeight - 50 + "px";
+}
+
function init_second_stage() {
try {
dropboxSelect(viewbox, getCookie("ttrss_vf_vmode"));
dropboxSelect(limitbox, getCookie("ttrss_vf_limit"));
+
+ daemon_enabled = getCookie("ttrss_vf_daemon");
+
+ // FIXME should be callled after window resize
+
+ if (navigator.userAgent.match("Opera")) {
+ resize_feeds_frame();
+
+/* // fix headlines frame height for Opera
+ var h = document.getElementById("headlines");
+ var c = document.getElementById("content");
+ var nh = document.body.scrollHeight * 0.25;
+
+ h.style.height = nh + "px";
+ c.style.height = c.scrollHeight - nh + "px"; */
+
+ }
+
+ debug("second stage ok");
} catch (e) {
exception_error("init_second_stage", e);
}
}
-function quickMenuGo() {
-
+function quickMenuChange() {
var chooser = document.getElementById("quickMenuChooser");
var opid = chooser[chooser.selectedIndex].id;
+ chooser.selectedIndex = 0;
+ quickMenuGo(opid);
+}
+
+function quickMenuGo(opid) {
+
+
if (opid == "qmcPrefs") {
gotoPreferences();
}
if (opid == "qmcSearch") {
- displayDlg("search");
+ displayDlg("search", getActiveFeedId());
return;
}
function displayDlg(id, param) {
+ if (!xmlhttp_ready(xmlhttp)) {
+ printLockingError();
+ return
+ }
+
notify("");
xmlhttp.open("GET", "backend.php?op=dlg&id=" +
notify("Removing feed...");
+ if (!xmlhttp_ready(xmlhttp)) {
+ printLockingError();
+ return
+ }
+
// var feeds_doc = window.frames["feeds-frame"].document;
// feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
}
-function allFeedsMenuGo() {
+function allFeedsMenuChange() {
var chooser = document.getElementById("allFeedsChooser");
var opname = chooser[chooser.selectedIndex].text;
+ chooser.selectedIndex = 0;
+
if (opname == "Update") {
scheduleFeedUpdate(true);
return;
}
function toggleDispRead() {
- var hide_read_feeds = (getCookie("ttrss_vf_hreadf") == 1);
+ try {
- hide_read_feeds = !hide_read_feeds;
+ if (!xmlhttp_ready(xmlhttp)) {
+ printLockingError();
+ return
+ }
- var feeds_doc = window.frames["feeds-frame"].document;
+ var hide_read_feeds = (getCookie("ttrss_vf_hreadf") == 1);
- hideOrShowFeeds(feeds_doc, hide_read_feeds);
+ hide_read_feeds = !hide_read_feeds;
+
+ var query = "backend.php?op=rpc&subop=setpref" +
+ "&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds);
- if (hide_read_feeds) {
- setCookie("ttrss_vf_hreadf", 1);
- } else {
- setCookie("ttrss_vf_hreadf", 0);
+ xmlhttp.open("GET", query);
+ xmlhttp.onreadystatechange=hide_unread_callback;
+ xmlhttp.send(null);
+
+ } catch (e) {
+ exception_error("toggleDispRead", e);
}
-
}
+function debug(msg) {
+ var c = document.getElementById('debug_output');
+ if (c && c.style.display == "block") {
+ while (c.firstChild != 'undefined' && c.childNodes.length > 15) {
+ c.removeChild(c.firstChild);
+ }
+
+ var d = new Date();
+ var ts = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds();
+ c.innerHTML = c.innerHTML + "<li>[" + ts + "] " + msg + "</li>";
+ }
+}