js: code cleanup, disable some debugging

This commit is contained in:
Andrew Dolgov 2010-11-10 21:56:28 +03:00
parent 773adf8b42
commit f8fb44989f
6 changed files with 199 additions and 193 deletions

View File

@ -379,7 +379,7 @@ function feedlist_dragsorted(ctr) {
var query = "?op=feeds&subop=catsort&corder=" + var query = "?op=feeds&subop=catsort&corder=" +
param_escape(ordered_cats.toString()); param_escape(ordered_cats.toString());
console.log(query); //console.log(query);
new Ajax.Request("backend.php", { parameters: query }); new Ajax.Request("backend.php", { parameters: query });
} }
@ -393,7 +393,7 @@ function feedlist_init() {
try { try {
loading_set_progress(90); loading_set_progress(90);
console.log("in feedlist init"); //console.log("in feedlist init");
hideOrShowFeeds(getInitParam("hide_read_feeds") == 1); hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
document.onkeydown = hotkey_handler; document.onkeydown = hotkey_handler;
@ -470,7 +470,7 @@ function hide_footer() {
function init_collapsable_feedlist() { function init_collapsable_feedlist() {
try { try {
console.log("init_collapsable_feedlist"); //console.log("init_collapsable_feedlist");
var theme = getInitParam("theme"); var theme = getInitParam("theme");
var options = getInitParam("theme_options"); var options = getInitParam("theme_options");
@ -593,7 +593,7 @@ function request_counters_real() {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
try { try {
all_counters_callback2(transport); handle_rpc_reply(transport);
} catch (e) { } catch (e) {
exception_error("viewfeed/getcounters", e); exception_error("viewfeed/getcounters", e);
} }

View File

@ -520,7 +520,7 @@ function parse_counters(reply, scheduled_call) {
var feeds_stored = number_of_feeds; var feeds_stored = number_of_feeds;
console.log("Feed counters, C: " + feeds_found + ", S:" + feeds_stored); //console.log("Feed counters, C: " + feeds_found + ", S:" + feeds_stored);
if (feeds_stored != feeds_found) { if (feeds_stored != feeds_found) {
number_of_feeds = feeds_found; number_of_feeds = feeds_found;
@ -542,7 +542,7 @@ function parse_counters(reply, scheduled_call) {
} }
} }
function parse_counters_reply(transport, scheduled_call) { /*function parse_counters_reply(transport, scheduled_call) {
if (!transport.responseXML) { if (!transport.responseXML) {
notify_error("Backend did not return valid XML", true); notify_error("Backend did not return valid XML", true);
@ -575,17 +575,56 @@ function parse_counters_reply(transport, scheduled_call) {
hideOrShowFeeds(getInitParam("hide_read_feeds") == 1); hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
} } */
function all_counters_callback2(transport) { function handle_rpc_reply(transport, scheduled_call) {
try { try {
if (offline_mode) return; if (offline_mode) return false;
parse_counters_reply(transport); if (!transport.responseText && db) {
offlineConfirmModeChange();
return false;
}
if (transport.responseXML) {
if (!transport_error_check(transport)) return false;
var message = transport.responseXML.getElementsByTagName("message")[0];
if (message) {
message = message.firstChild.nodeValue;
if (message == "UPDATE_COUNTERS") {
setInitParam("last_article_id", -1);
_force_scheduled_update = true;
}
}
var counters = transport.responseXML.getElementsByTagName("counters")[0];
if (counters)
parse_counters(counters, scheduled_call);
var runtime_info = transport.responseXML.getElementsByTagName("runtime-info")[0];
if (runtime_info)
parse_runtime_info(runtime_info);
if (feedsSortByUnread())
resort_feedlist();
hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
} else {
notify_error("Error communicating with server.");
}
} catch (e) { } catch (e) {
exception_error("all_counters_callback2", e, transport); exception_error("handle_rpc_reply", e, transport);
} }
return true;
} }
function get_feed_unread(id) { function get_feed_unread(id) {
@ -724,7 +763,7 @@ function hideOrShowFeeds(hide) {
try { try {
console.log("hideOrShowFeeds: " + hide); //console.log("hideOrShowFeeds: " + hide);
if ($("FCATLIST--1")) { if ($("FCATLIST--1")) {
@ -766,7 +805,7 @@ function hideOrShowFeedsCategory(id, hide) {
var cat_unread = 0; var cat_unread = 0;
if (!node) { if (!node) {
console.log("hideOrShowFeeds: passed node is null, aborting"); console.warn("hideOrShowFeeds: passed node is null, aborting");
return; return;
} }
@ -1593,7 +1632,7 @@ function getRelativePostIds(id, limit) {
if (!limit) limit = 3; if (!limit) limit = 3;
console.log("getRelativePostIds: " + id + " limit=" + limit); //console.log("getRelativePostIds: " + id + " limit=" + limit);
var ids = new Array(); var ids = new Array();
var container = $("headlinesList"); var container = $("headlinesList");

View File

@ -3178,6 +3178,8 @@
$data['num_feeds'] = (int) $num_feeds; $data['num_feeds'] = (int) $num_feeds;
$data['last_article_id'] = getLastArticleId($link);
if (ENABLE_UPDATE_DAEMON) { if (ENABLE_UPDATE_DAEMON) {
$data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock"); $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock");
@ -7006,4 +7008,14 @@
} }
} }
function getLastArticleId($link) {
$result = db_query($link, "SELECT MAX(ref_id) AS id FROM ttrss_user_entries
WHERE owner_uid = " . $_SESSION["uid"]);
if (db_num_rows($result) == 1) {
return db_fetch_result($result, 0, "id");
} else {
return -1;
}
}
?> ?>

View File

@ -179,9 +179,9 @@
$result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark $result = db_query($link, "UPDATE ttrss_user_entries SET marked = $mark
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
print "<rpc-reply><counters><![CDATA["; print "<rpc-reply>";
print json_encode(getAllCounters($link)); print "<message>UPDATE_COUNTERS</message>";
print "]]></counters></rpc-reply>"; print "</rpc-reply>";
return; return;
} }
@ -192,9 +192,9 @@
$result = db_query($link, "DELETE FROM ttrss_user_entries $result = db_query($link, "DELETE FROM ttrss_user_entries
WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]); WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
print "<rpc-reply><counters><![CDATA["; print "<rpc-reply>";
print json_encode(getAllCounters($link)); print "<message>UPDATE_COUNTERS</message>";
print "]]></counters></rpc-reply>"; print "</rpc-reply>";
return; return;
} }
@ -206,9 +206,9 @@
SET feed_id = orig_feed_id, orig_feed_id = NULL SET feed_id = orig_feed_id, orig_feed_id = NULL
WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]); WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
print "<rpc-reply><counters><![CDATA["; print "<rpc-reply>";
print json_encode(getAllCounters($link)); print "<message>UPDATE_COUNTERS</message>";
print "]]></counters></rpc-reply>"; print "</rpc-reply>";
return; return;
} }
@ -220,9 +220,9 @@
archive_article($link, $id, $_SESSION["uid"]); archive_article($link, $id, $_SESSION["uid"]);
} }
print "<rpc-reply><counters><![CDATA["; print "<rpc-reply>";
print json_encode(getAllCounters($link)); print "<message>UPDATE_COUNTERS</message>";
print "]]></counters></rpc-reply>"; print "</rpc-reply>";
return; return;
} }
@ -253,10 +253,6 @@
print "<rpc-reply>"; print "<rpc-reply>";
print "<counters><![CDATA[";
print json_encode(getAllCounters($link));
print "]]></counters>";
if ($note != 'undefined') { if ($note != 'undefined') {
$note_size = strlen($note); $note_size = strlen($note);
print "<note id=\"$id\" size=\"$note_size\">"; print "<note id=\"$id\" size=\"$note_size\">";
@ -264,6 +260,8 @@
print "</note>"; print "</note>";
} }
print "<message>UPDATE_COUNTERS</message>";
print "</rpc-reply>"; print "</rpc-reply>";
return; return;
@ -274,26 +272,28 @@
update_rss_feed($link, $feed_id); update_rss_feed($link, $feed_id);
print "<rpc-reply>"; print "<rpc-reply>";
print "<counters><![CDATA["; print "<message>UPDATE_COUNTERS</message>";
print json_encode(getFeedCounters($link, $feed_id));
print "]]></counters>";
print "</rpc-reply>"; print "</rpc-reply>";
return; return;
} }
if ($subop == "updateAllFeeds" || $subop == "getAllCounters") { if ($subop == "updateAllFeeds" || $subop == "getAllCounters") {
$global_unread_caller = sprintf("%d", $_REQUEST["uctr"]); $last_article_id = (int) $_REQUEST["last_article_id"];
$global_unread = getGlobalUnread($link);
print "<rpc-reply>"; print "<rpc-reply>";
if ($global_unread_caller != $global_unread) { if ($last_article_id != getLastArticleId($link)) {
print "<counters><![CDATA["; print "<counters><![CDATA[";
$omode = $_REQUEST["omode"]; $omode = $_REQUEST["omode"];
print json_encode(getAllCounters($link, $omode));
if ($omode != "T")
print json_encode(getAllCounters($link, $omode));
else
print json_encode(getGlobalCounters($link));
print "]]></counters>"; print "]]></counters>";
} }
@ -313,11 +313,7 @@
catchupArticlesById($link, $ids, $cmode); catchupArticlesById($link, $ids, $cmode);
print "<rpc-reply>"; print "<rpc-reply>";
print "<counters><![CDATA["; print "<message>UPDATE_COUNTERS</message>";
print json_encode(getAllCounters($link, $_REQUEST['omode']));
print "]]></counters>";
print_runtime_info($link);
print "</rpc-reply>"; print "</rpc-reply>";
return; return;
@ -331,10 +327,7 @@
markArticlesById($link, $ids, $cmode); markArticlesById($link, $ids, $cmode);
print "<rpc-reply>"; print "<rpc-reply>";
print "<counters><![CDATA["; print "<message>UPDATE_COUNTERS</message>";
print json_encode(getAllCounters($link, $_REQUEST['omode']));
print "]]></counters>";
print_runtime_info($link);
print "</rpc-reply>"; print "</rpc-reply>";
return; return;
@ -348,10 +341,7 @@
publishArticlesById($link, $ids, $cmode); publishArticlesById($link, $ids, $cmode);
print "<rpc-reply>"; print "<rpc-reply>";
print "<counters><![CDATA["; print "<message>UPDATE_COUNTERS</message>";
print json_encode(getAllCounters($link, $_REQUEST['omode']));
print "]]></counters>";
print_runtime_info($link);
print "</rpc-reply>"; print "</rpc-reply>";
return; return;
@ -608,9 +598,8 @@
print "</info-for-headlines>"; print "</info-for-headlines>";
print "<counters><![CDATA["; print "<rpc-reply>";
print json_encode(getAllCounters($link, $_REQUEST['omode'])); print "<message>UPDATE_COUNTERS</message>";
print "]]></counters>";
print "</rpc-reply>"; print "</rpc-reply>";
return; return;
@ -645,9 +634,8 @@
print "</info-for-headlines>"; print "</info-for-headlines>";
print "<counters><![CDATA["; print "<rpc-reply>";
print json_encode(getAllCounters($link, $_REQUEST['omode'])); print "<message>UPDATE_COUNTERS</message>";
print "]]></counters>";
print "</rpc-reply>"; print "</rpc-reply>";
return; return;
@ -1061,7 +1049,7 @@
print "<error><![CDATA[" . $mail->ErrorInfo . "]]></error>"; print "<error><![CDATA[" . $mail->ErrorInfo . "]]></error>";
} else { } else {
save_email_address($link, db_escape_string($destination)); save_email_address($link, db_escape_string($destination));
print "<message>OK</message>"; print "<message>UPDATE_COUNTERS</message>";
} }
} else { } else {
@ -1133,7 +1121,9 @@
db_query($link, "DELETE FROM ttrss_access_keys WHERE db_query($link, "DELETE FROM ttrss_access_keys WHERE
owner_uid = " . $_SESSION["uid"]); owner_uid = " . $_SESSION["uid"]);
print "<rpc-reply><message>OK</message></rpc-reply>"; print "<rpc-reply>";
print "<message>UPDATE_COUNTERS</message>";
print "</rpc-reply>";
return; return;
} }

127
tt-rss.js
View File

@ -1,23 +1,19 @@
var total_unread = 0; var total_unread = 0;
var first_run = true;
var display_tags = false; var display_tags = false;
var global_unread = -1; var global_unread = -1;
var current_subtitle = "";
var daemon_enabled = false;
//var _qfd_deleted_feed = 0;
var firsttime_update = true; var firsttime_update = true;
var _active_feed_id = 0; var _active_feed_id = 0;
var _active_feed_is_cat = false; var _active_feed_is_cat = false;
var number_of_feeds = 0; var number_of_feeds = 0;
var _hfd_scrolltop = 0;
var hotkey_prefix = false; var hotkey_prefix = false;
var hotkey_prefix_pressed = false; var hotkey_prefix_pressed = false;
var init_params = new Object(); var init_params = {};
var ver_offset = 0; var ver_offset = 0;
var hor_offset = 0; var hor_offset = 0;
var feeds_sort_by_unread = false; var feeds_sort_by_unread = false;
var feedlist_sortable_enabled = false; var feedlist_sortable_enabled = false;
var _force_scheduled_update = false;
var last_scheduled_update = false;
function activeFeedIsCat() { function activeFeedIsCat() {
return _active_feed_is_cat; return _active_feed_is_cat;
@ -92,40 +88,9 @@ function dlg_frefresh_callback(transport, deleted_feed) {
closeInfoBox(); closeInfoBox();
} }
function scheduleFeedUpdate() {
window.clearTimeout(counter_timeout_id);
var query_str = "backend.php?op=rpc&subop=getAllCounters";
var omode;
if (firsttime_update && !navigator.userAgent.match("Opera")) {
firsttime_update = false;
omode = "T";
} else {
if (display_tags) {
omode = "tl";
} else {
omode = "flc";
}
}
query_str = query_str + "&omode=" + omode;
query_str = query_str + "&uctr=" + global_unread;
console.log("[scheduleFeedUpdate] " + query_str);
new Ajax.Request("backend.php", {
parameters: query_str,
onComplete: function(transport) {
parse_counters_reply(transport, true);
} });
}
function updateFeedList() { function updateFeedList() {
try { try {
console.log("updateFeedList"); //console.log("updateFeedList");
if (offline_mode) return render_offline_feedlist(); if (offline_mode) return render_offline_feedlist();
@ -160,7 +125,7 @@ function catchupAllFeeds() {
notify_progress("Marking all feeds as read..."); notify_progress("Marking all feeds as read...");
console.log("catchupAllFeeds Q=" + query_str); //console.log("catchupAllFeeds Q=" + query_str);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query_str, parameters: query_str,
@ -184,17 +149,56 @@ function viewCurrentFeed(subop) {
return false; // block unneeded form submits return false; // block unneeded form submits
} }
function viewfeed(feed, subop) { /*function viewfeed(feed, subop) {
var f = window.frames["feeds-frame"]; var f = window.frames["feeds-frame"];
f.viewfeed(feed, subop); f.viewfeed(feed, subop);
} } */
function timeout() { function timeout() {
if (getInitParam("bw_limit") == "1") return; if (getInitParam("bw_limit") == "1") return;
scheduleFeedUpdate(false); try {
var date = new Date();
var ts = Math.round(date.getTime() / 1000);
setTimeout("timeout()", 10*1000); if (ts - last_scheduled_update > 10 || _force_scheduled_update) {
window.clearTimeout(counter_timeout_id);
var query_str = "?op=rpc&subop=getAllCounters";
var omode;
if (firsttime_update && !navigator.userAgent.match("Opera")) {
firsttime_update = false;
omode = "T";
} else {
if (display_tags) {
omode = "tl";
} else {
omode = "flc";
}
}
query_str = query_str + "&omode=" + omode;
query_str = query_str + "&last_article_id=" + getInitParam("last_article_id");
//console.log("[timeout]" + query_str);
new Ajax.Request("backend.php", {
parameters: query_str,
onComplete: function(transport) {
handle_rpc_reply(transport, true);
} });
last_scheduled_update = ts;
}
} catch (e) {
exception_error("timeout", e);
}
setTimeout("timeout()", 3000);
} }
function resetSearch() { function resetSearch() {
@ -211,23 +215,13 @@ function search() {
viewCurrentFeed(0, ""); viewCurrentFeed(0, "");
} }
// if argument is undefined, current subtitle is not updated function updateTitle() {
// use blank string to clear subtitle
function updateTitle(s) {
var tmp = "Tiny Tiny RSS"; var tmp = "Tiny Tiny RSS";
if (s != undefined) {
current_subtitle = s;
}
if (global_unread > 0) { if (global_unread > 0) {
tmp = tmp + " (" + global_unread + ")"; tmp = tmp + " (" + global_unread + ")";
} }
if (current_subtitle) {
tmp = tmp + " - " + current_subtitle;
}
if (window.fluid) { if (window.fluid) {
if (global_unread > 0) { if (global_unread > 0) {
window.fluid.dockBadge = global_unread; window.fluid.dockBadge = global_unread;
@ -365,7 +359,6 @@ function init_second_stage() {
dropboxSelect(toolbar.view_mode, getInitParam("default_view_mode")); dropboxSelect(toolbar.view_mode, getInitParam("default_view_mode"));
dropboxSelect(toolbar.order_by, getInitParam("default_view_order_by")); dropboxSelect(toolbar.order_by, getInitParam("default_view_order_by"));
daemon_enabled = getInitParam("daemon_enabled") == 1;
feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1; feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1;
setTimeout('updateFeedList(false, false)', 50); setTimeout('updateFeedList(false, false)', 50);
@ -454,11 +447,6 @@ function quickMenuGo(opid) {
return; return;
} }
if (opid == "qmcUpdateFeeds") {
scheduleFeedUpdate(true);
return;
}
if (opid == "qmcCatchupAll") { if (opid == "qmcCatchupAll") {
catchupAllFeeds(); catchupAllFeeds();
return; return;
@ -550,19 +538,20 @@ function toggleDispRead() {
function parse_runtime_info(elem) { function parse_runtime_info(elem) {
if (!elem || !elem.firstChild) { if (!elem || !elem.firstChild) {
console.warn("parse_runtime_info: invalid node passed");
return; return;
} }
var data = JSON.parse(elem.firstChild.nodeValue); var data = JSON.parse(elem.firstChild.nodeValue);
console.log("parsing runtime info..."); //console.log("parsing runtime info...");
for (k in data) { for (k in data) {
var v = data[k]; var v = data[k];
console.log("RI: " + k + " => " + v); // console.log("RI: " + k + " => " + v);
if (k == "num_feeds") { if (k == "num_feeds" || k == "last_article_id") {
init_params[k] = v; init_params[k] = v;
} }
@ -697,7 +686,7 @@ function feedEditSave() {
function collapse_feedlist() { function collapse_feedlist() {
try { try {
console.log("collapse_feedlist"); //console.log("collapse_feedlist");
var theme = getInitParam("theme"); var theme = getInitParam("theme");
if (theme != "" && if (theme != "" &&
@ -906,10 +895,10 @@ function hotkey_handler(e) {
return false; return false;
} }
if (keycode == 82 && shift_key) { // R /* if (keycode == 82 && shift_key) { // R
scheduleFeedUpdate(true); scheduleFeedUpdate(true);
return; return;
} } */
if (keycode == 74) { // j if (keycode == 74) { // j
var feed = getActiveFeedId(); var feed = getActiveFeedId();
@ -1076,10 +1065,10 @@ function hotkey_handler(e) {
return false; return false;
} }
if (keycode == 85 && shift_key) { // U /* if (keycode == 85 && shift_key) { // U
scheduleFeedUpdate(true); scheduleFeedUpdate(true);
return false; return false;
} } */
if (keycode == 85) { // u if (keycode == 85) { // u
if (getActiveFeedId()) { if (getActiveFeedId()) {

View File

@ -24,7 +24,7 @@ function catchup_callback2(transport, callback) {
try { try {
console.log("catchup_callback2 " + transport + ", " + callback); console.log("catchup_callback2 " + transport + ", " + callback);
notify(""); notify("");
all_counters_callback2(transport); handle_rpc_reply(transport);
if (callback) { if (callback) {
setTimeout(callback, 10); setTimeout(callback, 10);
} }
@ -53,10 +53,7 @@ function clean_feed_selections() {
function headlines_callback2(transport, feed_cur_page) { function headlines_callback2(transport, feed_cur_page) {
try { try {
if (!transport.responseText && db) { if (!handle_rpc_reply(transport)) return;
offlineConfirmModeChange();
return;
}
loading_set_progress(100); loading_set_progress(100);
@ -106,7 +103,7 @@ function headlines_callback2(transport, feed_cur_page) {
var f = $("headlines-frame"); var f = $("headlines-frame");
try { try {
if (feed_cur_page == 0) { if (feed_cur_page == 0) {
console.log("resetting headlines scrollTop"); //console.log("resetting headlines scrollTop");
f.scrollTop = 0; f.scrollTop = 0;
} }
} catch (e) { }; } catch (e) { };
@ -119,8 +116,10 @@ function headlines_callback2(transport, feed_cur_page) {
if (headlines_info) if (headlines_info)
headlines_info = JSON.parse(headlines_info.firstChild.nodeValue); headlines_info = JSON.parse(headlines_info.firstChild.nodeValue);
else else {
console.log("didn't find headlines-info object in response"); console.error("didn't find headlines-info object in response");
return;
}
var headlines_count = headlines_info.count; var headlines_count = headlines_info.count;
var headlines_unread = headlines_info.unread; var headlines_unread = headlines_info.unread;
@ -158,14 +157,14 @@ function headlines_callback2(transport, feed_cur_page) {
} }
} else { } else {
console.log("headlines_callback: returned no data"); console.warn("headlines_callback: returned no data");
f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>"; f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
} }
} else { } else {
if (headlines) { if (headlines) {
if (headlines_count > 0) { if (headlines_count > 0) {
console.log("adding some more headlines..."); console.warn("adding some more headlines...");
var c = $("headlinesList"); var c = $("headlinesList");
@ -187,7 +186,7 @@ function headlines_callback2(transport, feed_cur_page) {
console.log("no new headlines received"); console.log("no new headlines received");
} }
} else { } else {
console.log("headlines_callback: returned no data"); console.warn("headlines_callback: returned no data");
notify_error("Error while trying to load more headlines"); notify_error("Error while trying to load more headlines");
} }
@ -196,30 +195,21 @@ function headlines_callback2(transport, feed_cur_page) {
if (articles) { if (articles) {
for (var i = 0; i < articles.length; i++) { for (var i = 0; i < articles.length; i++) {
var a_id = articles[i].getAttribute("id"); var a_id = articles[i].getAttribute("id");
console.log("found id: " + a_id); //console.log("found id: " + a_id);
cache_inject(a_id, articles[i].firstChild.nodeValue); cache_inject(a_id, articles[i].firstChild.nodeValue);
} }
} else { } else {
console.log("no cached articles received"); console.log("no cached articles received");
} }
if (counters) { request_counters();
console.log("parsing piggybacked counters: " + counters);
parse_counters(counters, false);
} else {
console.log("counters container not found in reply, requesting...");
request_counters();
}
if (runtime_info) { if (runtime_info) {
console.log("parsing runtime info: " + runtime_info[0]);
parse_runtime_info(runtime_info[0]); parse_runtime_info(runtime_info[0]);
} else { }
console.log("runtime info container not found in reply");
}
} else { } else {
console.log("headlines_callback: returned no XML object"); console.warn("headlines_callback: returned no XML object");
f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>"; f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
} }
@ -339,10 +329,7 @@ function article_callback2(transport, id) {
try { try {
console.log("article_callback2 " + id); console.log("article_callback2 " + id);
if (!transport.responseText && db) { if (!handle_rpc_reply(transport)) return;
offlineConfirmModeChange();
return;
}
if (transport.responseXML) { if (transport.responseXML) {
@ -366,17 +353,17 @@ function article_callback2(transport, id) {
active_post_id = id; active_post_id = id;
console.log("looking for articles to cache..."); //console.log("looking for articles to cache...");
var articles = transport.responseXML.getElementsByTagName("article"); var articles = transport.responseXML.getElementsByTagName("article");
for (var i = 0; i < articles.length; i++) { for (var i = 0; i < articles.length; i++) {
var a_id = articles[i].getAttribute("id"); var a_id = articles[i].getAttribute("id");
console.log("found id: " + a_id); //console.log("found id: " + a_id);
if (a_id == active_post_id) { if (a_id == active_post_id) {
console.log("active article, rendering..."); //console.log("active article, rendering...");
render_article(articles[i].firstChild.nodeValue); render_article(articles[i].firstChild.nodeValue);
} }
@ -393,7 +380,7 @@ function article_callback2(transport, id) {
var reply = transport.responseXML.firstChild.firstChild; var reply = transport.responseXML.firstChild.firstChild;
} else { } else {
console.log("article_callback: returned no XML object"); console.warn("article_callback: returned no XML object");
//var f = $("content-frame"); //var f = $("content-frame");
//f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>"; //f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
} }
@ -405,17 +392,7 @@ function article_callback2(transport, id) {
setTimeout('updateFeedList(false, false)', 50); setTimeout('updateFeedList(false, false)', 50);
_reload_feedlist_after_view = false; _reload_feedlist_after_view = false;
} else { } else {
if (transport.responseXML) { request_counters();
var counters = transport.responseXML.getElementsByTagName("counters")[0];
if (counters) {
console.log("parsing piggybacked counters: " + counters);
parse_counters(counters, false);
} else {
console.log("counters container not found in reply, requesting...");
request_counters();
}
}
} }
notify(""); notify("");
@ -518,7 +495,7 @@ function tMark_afh_off(effect) {
try { try {
var elem = effect.effects[0].element; var elem = effect.effects[0].element;
console.log("tMark_afh_off : " + elem.id); //console.log("tMark_afh_off : " + elem.id);
if (elem) { if (elem) {
elem.src = elem.src.replace("mark_set", "mark_unset"); elem.src = elem.src.replace("mark_set", "mark_unset");
@ -535,7 +512,7 @@ function tPub_afh_off(effect) {
try { try {
var elem = effect.effects[0].element; var elem = effect.effects[0].element;
console.log("tPub_afh_off : " + elem.id); //console.log("tPub_afh_off : " + elem.id);
if (elem) { if (elem) {
elem.src = elem.src.replace("pub_set", "pub_unset"); elem.src = elem.src.replace("pub_set", "pub_unset");
@ -598,12 +575,12 @@ function toggleMark(id, client_only, no_effects) {
if (!no_effects) update_local_feedlist_counters(); if (!no_effects) update_local_feedlist_counters();
if (!client_only) { if (!client_only) {
console.log(query); //console.log(query);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
all_counters_callback2(transport); handle_rpc_reply(transport);
} }); } });
} }
@ -661,7 +638,7 @@ function togglePub(id, client_only, no_effects, note) {
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
all_counters_callback2(transport); handle_rpc_reply(transport);
var note = transport.responseXML.getElementsByTagName("note")[0]; var note = transport.responseXML.getElementsByTagName("note")[0];
@ -907,7 +884,7 @@ function toggleUnread(id, cmode, effect) {
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
all_counters_callback2(transport); handle_rpc_reply(transport);
} }); } });
} }
@ -944,7 +921,7 @@ function selectionRemoveLabel(id) {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
show_labels_in_headlines(transport); show_labels_in_headlines(transport);
all_counters_callback2(transport); handle_rpc_reply(transport);
} }); } });
// } // }
@ -982,7 +959,7 @@ function selectionAssignLabel(id) {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
show_labels_in_headlines(transport); show_labels_in_headlines(transport);
all_counters_callback2(transport); handle_rpc_reply(transport);
} }); } });
// } // }
@ -1099,7 +1076,7 @@ function selectionToggleMarked() {
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
all_counters_callback2(transport); handle_rpc_reply(transport);
} }); } });
} }
@ -1135,7 +1112,7 @@ function selectionTogglePublished() {
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
all_counters_callback2(transport); handle_rpc_reply(transport);
} }); } });
} }
@ -1395,13 +1372,13 @@ function editTagsSave() {
query = "?op=rpc&subop=setArticleTags&" + query; query = "?op=rpc&subop=setArticleTags&" + query;
console.log(query); //console.log(query);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
try { try {
console.log("tags saved..."); //console.log("tags saved...");
closeInfoBox(); closeInfoBox();
notify(""); notify("");
@ -1623,7 +1600,7 @@ function cdmWatchdog() {
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
all_counters_callback2(transport); handle_rpc_reply(transport);
} }); } });
} }
@ -1641,7 +1618,7 @@ function cache_inject(id, article, param) {
try { try {
if (!cache_check_param(id, param)) { if (!cache_check_param(id, param)) {
console.log("cache_article: miss: " + id + " [p=" + param + "]"); //console.log("cache_article: miss: " + id + " [p=" + param + "]");
var date = new Date(); var date = new Date();
var ts = Math.round(date.getTime() / 1000); var ts = Math.round(date.getTime() / 1000);
@ -1669,7 +1646,7 @@ function cache_inject(id, article, param) {
} }
} else { } else {
console.log("cache_article: hit: " + id + " [p=" + param + "]"); //console.log("cache_article: hit: " + id + " [p=" + param + "]");
} }
} catch (e) { } catch (e) {
exception_error("cache_inject", e); exception_error("cache_inject", e);
@ -1893,7 +1870,7 @@ function cache_invalidate(id) {
while (i < article_cache.length) { while (i < article_cache.length) {
if (article_cache[i]["id"] == id) { if (article_cache[i]["id"] == id) {
console.log("cache_invalidate: removed id " + id); //console.log("cache_invalidate: removed id " + id);
article_cache.splice(i, 1); article_cache.splice(i, 1);
return true; return true;
} }
@ -1902,7 +1879,7 @@ function cache_invalidate(id) {
} }
} }
console.log("cache_invalidate: id not found: " + id); //console.log("cache_invalidate: id not found: " + id);
return false; return false;
} catch (e) { } catch (e) {
exception_error("cache_invalidate", e); exception_error("cache_invalidate", e);
@ -1964,7 +1941,7 @@ function preloadArticleUnderPointer(id) {
if (preload_id_batch.indexOf(id) == -1) if (preload_id_batch.indexOf(id) == -1)
preload_id_batch.push(id); preload_id_batch.push(id);
console.log("preload ids batch: " + preload_id_batch.toString()); //console.log("preload ids batch: " + preload_id_batch.toString());
window.clearTimeout(preload_timeout_id); window.clearTimeout(preload_timeout_id);
preload_batch_timeout_id = window.setTimeout('preloadBatchedArticles()', 1000); preload_batch_timeout_id = window.setTimeout('preloadBatchedArticles()', 1000);
@ -2009,7 +1986,6 @@ function headlines_scroll_handler() {
if (e.scrollTop + e.offsetHeight > e.scrollHeight - 100) { if (e.scrollTop + e.offsetHeight > e.scrollHeight - 100) {
if (!_infscroll_disable) { if (!_infscroll_disable) {
console.log("more cowbell!");
viewNextFeedPage(); viewNextFeedPage();
} }
} }