From 50eefedbfd2f31be4054746bbcec7d8e05c0a2dd Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 7 Nov 2010 12:11:05 +0300 Subject: [PATCH] js: code cleanup --- feedlist.js | 12 +------- functions.js | 21 ++----------- functions.php | 6 ++-- modules/backend-rpc.php | 2 +- offline.js | 4 +-- prefs.js | 2 +- tt-rss.js | 68 ++++++++++++++++------------------------- viewfeed.js | 20 ++++++------ 8 files changed, 48 insertions(+), 87 deletions(-) diff --git a/feedlist.js b/feedlist.js index d1bb7f9a..3c6e881a 100644 --- a/feedlist.js +++ b/feedlist.js @@ -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("" + _infscroll_request_sent + " : " + timestamp + ""); + console.log(_infscroll_request_sent + " : " + timestamp); if (_infscroll_request_sent && _infscroll_request_sent + 30 > timestamp) { console.log("infscroll request in progress, aborting"); diff --git a/functions.js b/functions.js index f6b7ec33..2aa0dab4 100644 --- a/functions.js +++ b/functions.js @@ -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("all_counters_callback2 IN: " + transport + ""); parse_counters_reply(transport); - console.log("all_counters_callback2 OUT: " + transport + ""); } 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("loading_set_progress : " + p + " (" + last_progress_point + ")"); + 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) { } } - diff --git a/functions.php b/functions.php index 8b9c742e..d787b718 100644 --- a/functions.php +++ b/functions.php @@ -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()"; } diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 55babdaa..fee93a58 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -286,7 +286,7 @@ return; } - if ($subop == "forceUpdateAllFeeds" || $subop == "updateAllFeeds") { + if ($subop == "updateAllFeeds") { $global_unread_caller = sprintf("%d", $_REQUEST["uctr"]); $global_unread = getGlobalUnread($link); diff --git a/offline.js b/offline.js index 9abad919..a25f0c6f 100644 --- a/offline.js +++ b/offline.js @@ -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:')+ diff --git a/prefs.js b/prefs.js index 9fce9059..33887b15 100644 --- a/prefs.js +++ b/prefs.js @@ -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; } } diff --git a/tt-rss.js b/tt-rss.js index b0aa8470..51c1d3c5 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -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("updateFeedList"); - - 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() { diff --git a/viewfeed.js b/viewfeed.js index 5a0bf77e..a6065ecb 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -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) { -- 2.39.5