]> git.wh0rd.org Git - tt-rss.git/commitdiff
code cleanup
authorAndrew Dolgov <fox@bah.org.ru>
Wed, 3 Feb 2010 13:06:24 +0000 (16:06 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Wed, 3 Feb 2010 13:06:24 +0000 (16:06 +0300)
feedlist.js
functions.js
modules/popup-dialog.php
offline.js
prefs.js
tt-rss.js
tt-rss.php
viewfeed.js

index 8f623920ec89b7245539b17f08573b17b8757afa..d7b35ba98684026df506345901dc446c195eec1d 100644 (file)
@@ -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");
index 56b7909d4d4825555609acc84d6e5d6c189b38c9..6ca221acef714163cc27d94da1950f2dd91e1133 100644 (file)
@@ -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);
+       }
+}
+
index e61329820b42153c5c9c85db6c4cf07c856abaf0..81a795a0185b30c97041149856d3f6f2f4836d52 100644 (file)
                        
                        print "<div align='center'>";
 
-                       print "<input class=\"button\"
-                               type=\"submit\" onclick=\"return visitOfficialSite()\" 
-                               value=\"".__('Visit official site')."\"> ";
-
                        print "<input class=\"button\"
                                type=\"submit\" onclick=\"return closeInfoBox()\" 
                                value=\"".__('Close this window')."\">";
                        print "<div class=\"dlgButtons\">
                                <button class=\"button\" id=\"fadd_submit_btn\"
                                        onclick=\"return subscribeToFeed()\">".__('Subscribe')."</button>
-                               <button onclick=\"return browseFeeds()\">".__('More feeds')."</button>
+                               <button onclick=\"return displayDlg('feedBrowser')\">".__('More feeds')."</button>
                                <button onclick=\"return closeInfoBox()\">".__('Cancel')."</button></div>";
                        
                        return;
index a2fe63c7e0a6c94b7b386c12dccfa989609ee9a7..976f8ba90b2af39a0135a98412740f80a9d89cad 100644 (file)
@@ -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");
index 2a82ae692a384a86eb431eacbe00e5cf51df0077..018c6234576475b5ff67b69ce90d26bbd91ce2fe 100644 (file)
--- 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;
                        }
 
index c816dc3788bdf89e738c8639cbc224d7feda1add..5d62fb25be081416461411d42eda56e48d16f6c3 100644 (file)
--- 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;
 }
index aa3d70e1e168bfb4686014c8a56494ba3a4a8932..d96e612abcc2620ee27c867d5007ea2470d8459f 100644 (file)
                                        <optgroup label="<?php echo __('Feed actions:') ?>">
                                        <option value="qmcAddFeed"><?php echo __('Subscribe to feed...') ?></option>
                                        <option value="qmcEditFeed"><?php echo __('Edit this feed...') ?></option>
-                                       <!-- <option value="qmcClearFeed"><?php echo __('Clear articles') ?></option> -->
                                        <option value="qmcRescoreFeed"><?php echo __('Rescore feed') ?></option>
                                        <option value="qmcRemoveFeed"><?php echo __('Unsubscribe') ?></option>
                                        </optgroup>
index 4b8edfb4d37446f983e163711558ef9e68cb1c6d..f9fb8b607163f9cd5c6ee5a255c922525d5a2371 100644 (file)
@@ -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);