js: code cleanup

This commit is contained in:
Andrew Dolgov 2010-11-07 12:11:05 +03:00
parent b4fdbcf4b7
commit 50eefedbfd
8 changed files with 48 additions and 87 deletions

View File

@ -44,16 +44,6 @@ function render_feedlist(data) {
}
}
function feedlist_callback2(transport) {
try {
console.log("feedlist_callback2");
if (!transport_error_check(transport)) return;
render_feedlist(transport.responseText);
} catch (e) {
exception_error("feedlist_callback2", e);
}
}
function viewNextFeedPage() {
try {
//if (!getActiveFeedId()) return;
@ -112,7 +102,7 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) {
var date = new Date();
var timestamp = Math.round(date.getTime() / 1000);
console.log("<b>" + _infscroll_request_sent + " : " + timestamp + "</b>");
console.log(_infscroll_request_sent + " : " + timestamp);
if (_infscroll_request_sent && _infscroll_request_sent + 30 > timestamp) {
console.log("infscroll request in progress, aborting");

View File

@ -581,12 +581,9 @@ function parse_counters_reply(transport, scheduled_call) {
function all_counters_callback2(transport, async_call) {
try {
if (async_call) async_counters_work = true;
if (offline_mode) return;
console.log("<b>all_counters_callback2 IN: " + transport + "</b>");
parse_counters_reply(transport);
console.log("<b>all_counters_callback2 OUT: " + transport + "</b>");
} catch (e) {
exception_error("all_counters_callback2", e, transport);
@ -1723,21 +1720,11 @@ function displayHelpInfobox(topic_id) {
}
function focus_element(id) {
try {
var e = $(id);
if (e) e.focus();
} catch (e) {
exception_error("focus_element", e);
}
return false;
}
function loading_set_progress(p) {
try {
if (p < last_progress_point || !Element.visible("overlay")) return;
console.log("<b>loading_set_progress : " + p + " (" + last_progress_point + ")</b>");
console.log("loading_set_progress : " + p + " (" + last_progress_point + ")");
var o = $("l_progress_i");
@ -1892,7 +1879,7 @@ function displayNewContentPrompt(id) {
$('auxDlg').innerHTML = msg;
Element.show('auxDlg');
new Effect.Appear('auxDlg', {duration : 0.5});
} catch (e) {
exception_error("displayNewContentPrompt", e);
@ -2167,7 +2154,6 @@ function backend_sanity_check_callback(transport) {
if (params) {
console.log('reading init-params...');
//var param = params.firstChild;
params = JSON.parse(params.firstChild.nodeValue);
@ -2177,7 +2163,7 @@ function backend_sanity_check_callback(transport) {
var k = params[i].param;
var v = params[i].value;
console.log(k + " => " + v);
if (getURLParam('debug')) console.log(k + " => " + v);
init_params[k] = v;
if (db) {
@ -2198,4 +2184,3 @@ function backend_sanity_check_callback(transport) {
}
}

View File

@ -4131,9 +4131,9 @@
$sel_inv_link = "javascript:invertHeadlineSelection()";
$tog_unread_link = "javascript:selectionToggleUnread(true)";
$tog_marked_link = "javascript:selectionToggleMarked(true)";
$tog_published_link = "javascript:selectionTogglePublished(true)";
$tog_unread_link = "javascript:selectionToggleUnread()";
$tog_marked_link = "javascript:selectionToggleMarked()";
$tog_published_link = "javascript:selectionTogglePublished()";
}

View File

@ -286,7 +286,7 @@
return;
}
if ($subop == "forceUpdateAllFeeds" || $subop == "updateAllFeeds") {
if ($subop == "updateAllFeeds") {
$global_unread_caller = sprintf("%d", $_REQUEST["uctr"]);
$global_unread = getGlobalUnread($link);

View File

@ -166,8 +166,8 @@ function viewfeed_offline(feed_id, subop, is_cat, subop_param, skip_history, off
sel_none_link = "javascript:cdmSelectArticles('none')";
sel_inv_link = "javascript:invertHeadlineSelection()";
tog_unread_link = "javascript:selectionToggleUnread(true)";
tog_marked_link = "javascript:selectionToggleMarked(true)";
tog_unread_link = "javascript:selectionToggleUnread()";
tog_marked_link = "javascript:selectionToggleMarked()";
}
tmp += __('Select:')+

View File

@ -1380,7 +1380,7 @@ function pref_hotkey_handler(e) {
for (var i = 0; i < search_boxes.length; i++) {
var elem = $(search_boxes[i]);
if (elem) {
focus_element(search_boxes[i]);
$(search_boxes[i]).focus();
return false;
}
}

View File

@ -26,7 +26,7 @@ function activeFeedIsCat() {
function getActiveFeedId() {
try {
console.log("gAFID: " + _active_feed_id);
//console.log("gAFID: " + _active_feed_id);
return _active_feed_id;
} catch (e) {
exception_error("getActiveFeedId", e);
@ -35,7 +35,7 @@ function getActiveFeedId() {
function setActiveFeedId(id, is_cat) {
try {
console.log("sAFID(" + id + ", " + is_cat + ")");
//console.log("sAFID(" + id + ", " + is_cat + ")");
_active_feed_id = id;
if (is_cat != undefined) {
@ -93,17 +93,11 @@ function dlg_frefresh_callback(transport, deleted_feed) {
closeInfoBox();
}
function scheduleFeedUpdate(force) {
function scheduleFeedUpdate() {
console.log("in scheduleFeedUpdate");
var query_str = "backend.php?op=rpc&subop=";
if (force) {
query_str = query_str + "forceUpdateAllFeeds";
} else {
query_str = query_str + "updateAllFeeds";
}
var query_str = "backend.php?op=rpc&subop=updateAllFeeds";
var omode;
@ -130,39 +124,31 @@ function scheduleFeedUpdate(force) {
} });
}
function updateFeedList(silent, fetch) {
// if (silent != true) {
// notify("Loading feed list...");
// }
console.log("<b>updateFeedList</b>");
if (offline_mode) return render_offline_feedlist();
var query_str = "backend.php?op=feeds";
if (display_tags) {
query_str = query_str + "&tags=1";
}
if (getActiveFeedId() && !activeFeedIsCat()) {
query_str = query_str + "&actid=" + getActiveFeedId();
}
function updateFeedList() {
try {
console.log("updateFeedList");
if (fetch) query_str = query_str + "&fetch=yes";
// var feeds_frame = $("feeds-frame");
// feeds_frame.src = query_str;
console.log("updateFeedList Q=" + query_str);
new Ajax.Request("backend.php", {
parameters: query_str,
onComplete: function(transport) {
feedlist_callback2(transport);
} });
if (offline_mode) return render_offline_feedlist();
var query_str = "backend.php?op=feeds";
if (display_tags) {
query_str = query_str + "&tags=1";
}
if (getActiveFeedId() && !activeFeedIsCat()) {
query_str = query_str + "&actid=" + getActiveFeedId();
}
new Ajax.Request("backend.php", {
parameters: query_str,
onComplete: function(transport) {
render_feedlist(transport.responseText);
} });
} catch (e) {
exception_error("updateFeedList", e);
}
}
function catchupAllFeeds() {

View File

@ -1001,11 +1001,11 @@ function selectionAssignLabel(id) {
}
}
function selectionToggleUnread(cdm_mode, set_state, callback_func, no_error) {
function selectionToggleUnread(set_state, callback_func, no_error) {
try {
var rows;
if (cdm_mode) {
if (isCdmMode()) {
rows = cdmGetSelectedArticles();
} else {
rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
@ -1085,12 +1085,12 @@ function selectionToggleUnread(cdm_mode, set_state, callback_func, no_error) {
}
}
function selectionToggleMarked(cdm_mode) {
function selectionToggleMarked() {
try {
var rows;
if (cdm_mode) {
if (isCdmMode()) {
rows = cdmGetSelectedArticles();
} else {
rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
@ -1129,12 +1129,12 @@ function selectionToggleMarked(cdm_mode) {
}
}
function selectionTogglePublished(cdm_mode) {
function selectionTogglePublished() {
try {
var rows;
if (cdm_mode) {
if (isCdmMode()) {
rows = cdmGetSelectedArticles();
} else {
rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
@ -1266,11 +1266,11 @@ function catchupPage() {
if ($("headlinesList")) {
selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
selectionToggleUnread(false, 'viewCurrentFeed()', true);
selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
} else {
cdmSelectArticles('all');
selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
selectionToggleUnread(false, 'viewCurrentFeed()', true)
cdmSelectArticles('none');
}
}
@ -1411,9 +1411,9 @@ function catchupSelection() {
}
if ($("headlinesList")) {
selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
selectionToggleUnread(false, 'viewCurrentFeed()', true);
} else {
selectionToggleUnread(true, false, 'viewCurrentFeed()', true)
selectionToggleUnread(false, 'viewCurrentFeed()', true)
}
} catch (e) {