From d002edc715469b98d94150035d488ce5f1a79285 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 3 Feb 2010 16:06:24 +0300 Subject: [PATCH] code cleanup --- feedlist.js | 43 ------- functions.js | 251 ++++++--------------------------------- modules/popup-dialog.php | 6 +- offline.js | 1 - prefs.js | 81 +------------ tt-rss.js | 86 -------------- tt-rss.php | 1 - viewfeed.js | 6 - 8 files changed, 39 insertions(+), 436 deletions(-) diff --git a/feedlist.js b/feedlist.js index 8f623920e..d7b35ba98 100644 --- a/feedlist.js +++ b/feedlist.js @@ -240,11 +240,6 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) { } } - var date = new Date(); - var timestamp = Math.round(date.getTime() / 1000); - query = query + "&ts=" + timestamp - - disableContainerChildren("headlinesToolbar", false); Form.enable("main_toolbar_form"); // for piggybacked counters @@ -517,44 +512,6 @@ function hide_footer() { } } -/* -function init_hidden_feedlist(theme) { - try { - debug("init_hidden_feedlist"); - - if (theme != "" && theme != "compact") return; - - var fl = $("feeds-holder"); - var fh = $("headlines-frame"); - var fc = $("content-frame"); - var ft = $("toolbar"); - var ff = $("footer"); - var fhdr = $("header"); - - var fbtn = $("toggle_feeds_btn"); - - if (fbtn) Element.show(fbtn); - - fl.style.top = fh.offsetTop + "px"; - fl.style.backgroundColor = "white"; //FIXME - - Element.hide(fl); - - fh.style.left = "0px"; - ft.style.left = "0px"; - if (fc) fc.style.left = "0px"; - if (ff) ff.style.left = "0px"; - - if (theme == "compact") { - fhdr.style.left = "10px"; - fl.style.top = (fh.offsetTop + 1) + "px"; - } - - } catch (e) { - exception_error("init_hidden_feedlist", e); - } -} */ - function init_collapsable_feedlist() { try { debug("init_collapsable_feedlist"); diff --git a/functions.js b/functions.js index 56b7909d4..6ca221ace 100644 --- a/functions.js +++ b/functions.js @@ -356,39 +356,6 @@ function getCookie(name) { return unescape(dc.substring(begin + prefix.length, end)); } -function disableContainerChildren(id, disable, doc) { - - if (!doc) doc = document; - - var container = $(id); - - if (!container) { - //alert("disableContainerChildren: element " + id + " not found"); - return; - } - - for (var i = 0; i < container.childNodes.length; i++) { - var child = container.childNodes[i]; - - try { - child.disabled = disable; - } catch (E) { - - } - - if (disable) { - if (child.className && child.className.match("button")) { - child.className = "disabledButton"; - } - } else { - if (child.className && child.className.match("disabledButton")) { - child.className = "button"; - } - } - } - -} - function gotoPreferences() { document.location.href = "prefs.php"; } @@ -1116,7 +1083,6 @@ function getRelativeFeedId2(id, is_cat, direction, unread_only) { } } - function getRelativeFeedId(list, id, direction, unread_only) { var rows = list.getElementsByTagName("LI"); var feeds = new Array(); @@ -1861,130 +1827,9 @@ function remove_splash() { } } -function addLabelExample() { - try { - var form = document.forms["label_edit_form"]; - - var text = form.sql_exp; - var op = form.label_fields[form.label_fields.selectedIndex]; - var p = form.label_fields_param; - - if (op) { - op = op.value; - - var tmp = ""; - - if (text.value != "") { - if (text.value.substring(text.value.length-3, 3).toUpperCase() != "AND") { - tmp = " AND "; - } else { - tmp = " "; - } - } - - if (op == "unread") { - tmp = tmp + "unread = true"; - } - - if (op == "updated") { - tmp = tmp + "last_read is null and unread = false"; - } - - if (op == "kw_title") { - if (p.value == "") { - alert("This action requires a parameter."); - return false; - } - tmp = tmp + "ttrss_entries.title like '%"+p.value+"%'"; - } - - if (op == "kw_content") { - if (p.value == "") { - alert("This action requires a parameter."); - return false; - } - - tmp = tmp + "ttrss_entries.content like '%"+p.value+"%'"; - } - - if (op == "scoreE") { - if (isNaN(parseInt(p.value))) { - alert("This action expects numeric parameter."); - return false; - } - tmp = tmp + "score = " + p.value; - } - - if (op == "scoreG") { - if (isNaN(parseInt(p.value))) { - alert("This action expects numeric parameter."); - return false; - } - tmp = tmp + "score > " + p.value; - } - - if (op == "scoreL") { - if (isNaN(parseInt(p.value))) { - alert("This action expects numeric parameter."); - return false; - } - tmp = tmp + "score < " + p.value; - } - - if (op == "newerD") { - if (isNaN(parseInt(p.value))) { - alert("This action expects numeric parameter."); - return false; - } - tmp = tmp + "updated > NOW() - INTERVAL '"+parseInt(p.value)+" days'"; - } - - if (op == "newerH") { - if (isNaN(parseInt(p.value))) { - alert("This action expects numeric parameter."); - return false; - } - - tmp = tmp + "updated > NOW() - INTERVAL '"+parseInt(p.value)+" hours'"; - } - - text.value = text.value + tmp; - - p.value = ""; - - } - - } catch (e) { - exception_error("addLabelExample", e); - } - - return false; -} - -function labelFieldsCheck(elem) { - try { - var op = elem[elem.selectedIndex].value; - - var p = document.forms["label_edit_form"].label_fields_param; - - if (op == "kw_title" || op == "kw_content" || op == "scoreL" || - op == "scoreG" || op == "scoreE" || op == "newerD" || - op == "newerH" ) { - Element.show(p); - } else { - Element.hide(p); - } - - } catch (e) { - exception_error("labelFieldsCheck", e); - - } -} - function getSelectedFeedsFromBrowser() { var list = $("browseFeedList"); - if (!list) list = $("browseBigFeedList"); var selected = new Array(); @@ -2041,28 +1886,6 @@ function updateFeedBrowser() { } -function browseFeeds(limit) { - - try { - -/* var query = "?op=ialog&subop=browse"; - - notify_progress("Loading, please wait...", true); - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - infobox_callback2(transport); - } }); */ - - displayDlg('feedBrowser'); - - return false; - } catch (e) { - exception_error("browseFeeds", e); - } -} - function transport_error_check(transport) { try { if (transport.responseXML) { @@ -2094,43 +1917,6 @@ function truncate_string(s, length) { return tmp; } -/* -function switchToFlash(e) { - try { - var targ = e; - if (!e) var e = window.event; - if (e.target) targ = e.target; - else if (e.srcElement) targ = e.srcElement; - if (targ.nodeType == 3) // defeat Safari bug - targ = targ.parentNode; - - //targ is the link that was clicked - var audioTag=targ; - do { - audioTag=audioTag.previousSibling; - } while(audioTag && audioTag.nodeType != 1) - - var flashPlayer = audioTag.getElementsByTagName('span')[0]; - targ.parentNode.insertBefore(flashPlayer,targ); - targ.parentNode.removeChild(targ); - audioTag.parentNode.removeChild(audioTag); - - return false; - } catch (e) { - exception_error("switchToFlash", e); - } -} - -function html5AudioOrFlash(type) { - var audioTag = document.createElement('audio'); - if(! audioTag.canPlayType || audioTag.canPlayType(type) == "no" || - audioTag.canPlayType(type) == ""){ - if($('switchToFlashLink')){ - switchToFlash($('switchToFlashLink')); - } - } -} */ - function hotkey_prefix_timeout() { try { @@ -2324,3 +2110,40 @@ function uploadFeedIcon() { } } +function addLabel() { + + try { + + var caption = prompt(__("Please enter label caption:"), ""); + + if (caption != undefined) { + + if (caption == "") { + alert(__("Can't create label: missing caption.")); + return false; + } + + var query = "?op=pref-labels&subop=add&caption=" + + param_escape(caption); + + notify_progress("Loading, please wait...", true); + + if (inPreferences()) active_tab = "labelConfig"; + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + if (inPreferences()) { + infobox_submit_callback2(transport); + } else { + updateFeedList(); + } + } }); + + } + + } catch (e) { + exception_error("addLabel", e); + } +} + diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index e61329820..81a795a01 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -225,10 +225,6 @@ print "
"; - print " "; - print ""; @@ -291,7 +287,7 @@ print "
- +
"; return; diff --git a/offline.js b/offline.js index a2fe63c7e..976f8ba90 100644 --- a/offline.js +++ b/offline.js @@ -110,7 +110,6 @@ function viewfeed_offline(feed_id, subop, is_cat, subop_param, skip_history, off catchup_local_feed(feed_id, is_cat); } - disableContainerChildren("headlinesToolbar", false); Form.enable("main_toolbar_form"); var f = $("headlines-frame"); diff --git a/prefs.js b/prefs.js index 2a82ae692..018c62345 100644 --- a/prefs.js +++ b/prefs.js @@ -223,38 +223,6 @@ function updateUsersList(sort_key) { } } -function addLabel() { - - try { - - var caption = prompt(__("Please enter label caption:"), ""); - - if (caption == null) { - return false; - } - - if (caption == "") { - alert(__("Can't create label: missing caption.")); - return false; - } - - // we can be called from some other tab - active_tab = "labelConfig"; - - query = "?op=pref-labels&subop=add&caption=" + - param_escape(caption); - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - infobox_submit_callback2(transport); - } }); - - } catch (e) { - exception_error("addLabel", e); - } -} - function addFeed() { try { @@ -374,8 +342,6 @@ function editUser(id) { selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false); selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true); - disableContainerChildren("userOpToolbar", false); - var query = "?op=pref-users&subop=edit&id=" + param_escape(id); @@ -399,8 +365,6 @@ function editFilter(id) { notify_progress("Loading, please wait..."); - disableContainerChildren("filterOpToolbar", false); - selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false); selectTableRowById('FILRR-'+id, 'FICHK-'+id, true); @@ -429,8 +393,6 @@ function editFeed(feed) { selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false); selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true); - disableContainerChildren("feedOpToolbar", false); - var query = "?op=pref-feeds&subop=editfeed&id=" + param_escape(feed); @@ -1293,41 +1255,6 @@ function validatePrefsReset() { } -/*function feedBrowserSubscribe() { - try { - - var selected = getSelectedFeedsFromBrowser(); - - var mode = document.forms['feed_browser'].mode; - - mode = mode[mode.selectedIndex].value; - - if (selected.length > 0) { - closeInfoBox(); - - var query = "?op=pref-feeds&subop=massSubscribe&ids="+ - param_escape(selected.toString()) + "&mode=" + param_escape(mode); - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - feedlist_callback2(transport); - } }); - - } else { - alert(__("No feeds are selected.")); - } - - } catch (e) { - exception_error("feedBrowserSubscribe", e); - } -} */ - -function updateBigFeedBrowserBtn() { - notify_progress("Loading, please wait..."); - return updateBigFeedBrowser(); -} - function selectPrefRows(kind, select) { if (kind) { @@ -1370,7 +1297,6 @@ function selectPrefRows(kind, select) { if (opbarid) { selectTableRowsByIdPrefix(lname, nrow, nchk, select); - disableContainerChildren(opbarid, !select); } } @@ -1402,16 +1328,11 @@ function toggleSelectPrefRow(sender, kind) { nsel = getSelectedUsers(); } - if (opbarid && nsel != -1) { - disableContainerChildren(opbarid, nsel == false); - } - } } function toggleSelectFBListRow(sender) { toggleSelectListRow(sender); - disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0); } var seq = ""; @@ -1549,7 +1470,7 @@ function pref_hotkey_handler(e) { } if (keycode == 84 && shift_key) { // T - browseFeeds(); + displayDlg('feedBrowser'); return false; } diff --git a/tt-rss.js b/tt-rss.js index c816dc378..5d62fb25b 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -202,10 +202,6 @@ function scheduleFeedUpdate(force) { query_str = query_str + "&omode=" + omode; query_str = query_str + "&uctr=" + global_unread; - var date = new Date(); - var timestamp = Math.round(date.getTime() / 1000); - query_str = query_str + "&ts=" + timestamp - debug("REFETCH query: " + query_str); new Ajax.Request("backend.php", { @@ -234,10 +230,6 @@ function updateFeedList(silent, fetch) { if (getActiveFeedId() && !activeFeedIsCat()) { query_str = query_str + "&actid=" + getActiveFeedId(); } - - 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"; @@ -283,7 +275,6 @@ function viewCurrentFeed(subop) { if (getActiveFeedId() != undefined) { viewfeed(getActiveFeedId(), subop, activeFeedIsCat()); } else { - disableContainerChildren("headlinesToolbar", false, document); // viewfeed(-1, subop); // FIXME } return false; // block unneeded form submits @@ -363,8 +354,6 @@ function init() { init_gears(); - disableContainerChildren("headlinesToolbar", true); - Form.disable("main_toolbar_form"); if (!genericSanityCheck()) @@ -578,31 +567,6 @@ function quickMenuGo(opid) { return; } - if (opid == "qmcClearFeed") { - var actid = getActiveFeedId(); - - if (!actid) { - alert(__("Please select some feed first.")); - return; - } - - if (activeFeedIsCat() || actid < 0) { - alert(__("You can't clear this type of feed.")); - return; - } - - var fn = getFeedName(actid); - - var pr = __("Erase all non-starred articles in %s?").replace("%s", fn); - - if (confirm(pr)) { - clearFeedArticles(actid); - } - - return; - } - - if (opid == "qmcUpdateFeeds") { scheduleFeedUpdate(true); return; @@ -868,21 +832,6 @@ function feedEditSave() { } } -function clearFeedArticles(feed_id) { - - notify_progress("Clearing feed..."); - - var query = "?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id; - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - dlg_frefresh_callback(transport, feed_id); - } }); - - return false; -} - function collapse_feedlist() { try { debug("collapse_feedlist"); @@ -1427,41 +1376,6 @@ function feedsSortByUnread() { return feeds_sort_by_unread; } -function addLabel() { - - try { - - var caption = prompt(__("Please enter label caption:"), ""); - - if (caption != undefined) { - - if (caption == "") { - alert(__("Can't create label: missing caption.")); - return false; - } - - var query = "?op=pref-labels&subop=add&caption=" + - param_escape(caption); - - notify_progress("Loading, please wait...", true); - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - updateFeedList(); - } }); - - } - - } catch (e) { - exception_error("addLabel", e); - } -} - -function visitOfficialSite() { - window.open("http://tt-rss.org/"); -} - function inPreferences() { return false; } diff --git a/tt-rss.php b/tt-rss.php index aa3d70e1e..d96e612ab 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -180,7 +180,6 @@ - diff --git a/viewfeed.js b/viewfeed.js index 4b8edfb4d..f9fb8b607 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -438,8 +438,6 @@ function view(id) { var query = "?op=view&id=" + param_escape(id); - var date = new Date(); - var neighbor_ids = getRelativePostIds(active_post_id); /* only request uncached articles */ @@ -462,10 +460,6 @@ function view(id) { query = query + "&omode=flc"; } - var date = new Date(); - var timestamp = Math.round(date.getTime() / 1000); - query = query + "&ts=" + timestamp; - query = query + "&cids=" + cids_to_request.toString(); var crow = $("RROW-" + id);