]> git.wh0rd.org Git - tt-rss.git/commitdiff
add hotkey f w: resort feedlist by name or unread count
authorAndrew Dolgov <fox@bah.spb.su>
Tue, 20 May 2008 12:04:30 +0000 (13:04 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Tue, 20 May 2008 12:04:30 +0000 (13:04 +0100)
functions.js
help/3.php
tt-rss.js

index a27336d6d42835106c3b6556840e91c4f7b04044..962ddc65212cdcaa86fe9db45a5d25e96658b749 100644 (file)
@@ -618,9 +618,9 @@ function parse_counters_reply(transport, scheduled_call) {
 
        parse_runtime_info(runtime_info);
 
-       if (getInitParam("feeds_sort_by_unread") == 1) {
-                       resort_feedlist();              
-       }       
+       if (feedsSortByUnread()) {
+               resort_feedlist();
+       }
 
        hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
 
@@ -661,9 +661,17 @@ function get_feed_entry_unread(elem) {
        }
 }
 
+function get_feed_entry_name(elem) {
+       var id = elem.id.replace("FEEDR-", "");
+       return getFeedName(id);
+}
+
+
 function resort_category(node) {
        debug("resort_category: " + node);
 
+       var by_unread = feedsSortByUnread();
+
        if (node.hasChildNodes() && node.firstChild.nextSibling != false) {  
                for (i = 0; i < node.childNodes.length; i++) {
                        if (node.childNodes[i].nodeName != "LI") { continue; }
@@ -678,7 +686,10 @@ function resort_category(node) {
                                var tmp_val = get_feed_entry_unread(node.childNodes[i]);
                                var cur_val = get_feed_entry_unread(node.childNodes[j]);
 
-                               if (cur_val > tmp_val) {
+                               var tmp_name = get_feed_entry_name(node.childNodes[i]);
+                               var cur_name = get_feed_entry_name(node.childNodes[j]);
+
+                               if ((by_unread && (cur_val > tmp_val)) || (!by_unread && (cur_name < tmp_name))) {
                                        tempnode_i = node.childNodes[i].cloneNode(true);
                                        tempnode_j = node.childNodes[j].cloneNode(true);
                                        node.replaceChild(tempnode_i, node.childNodes[j]);
index 633f5c903951b7ce31263cb4805d2d03e85bd07f..fa65df2ccc21e6fbfc1300797a8df1513001dda6 100644 (file)
@@ -41,6 +41,7 @@
                <tr><td class='n'>f a</td><td><?php echo __("(Un)hide read feeds") ?></td></tr>
                <tr><td class='n'>f s</td><td><?php echo __("Subscribe to feed") ?></td></tr>
                <tr><td class='n'>f e</td><td><?php echo __("Edit feed") ?></td></tr>
+               <tr><td class='n'>f w</td><td><?php echo __("Sort by name or unread count") ?></td></tr>
                <tr><td class='n'>q</td><td><?php echo __("Mark feed as read") ?></td></tr>
                <tr><td class='n'>Q</td><td><?php echo __("Mark all feeds as read") ?></td></tr>
        </table>
index e81987ef7e69e828e8f7b9d71c82d6fd5d4e197a..4b0b694fc232c2b4e2221bc9d3032480c44cad7c 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -17,6 +17,7 @@ var hotkey_prefix = false;
 var init_params = new Object();
 var ver_offset = 0;
 var hor_offset = 0;
+var feeds_sort_by_unread = false;
 
 function tagsAreDisplayed() {
        return display_tags;
@@ -451,6 +452,7 @@ function init_second_stage() {
 
                daemon_enabled = getInitParam("daemon_enabled") == 1;
                daemon_refresh_only = getInitParam("daemon_refresh_only") == 1;
+               feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1;
 
                setTimeout('updateFeedList(false, false)', 50);
 
@@ -1220,6 +1222,7 @@ function hotkey_handler(e) {
                        }
 
                        if (keycode == 87) { // w
+                               feeds_sort_by_unread = !feeds_sort_by_unread;
                                return resort_feedlist();
                        }
 
@@ -1288,3 +1291,7 @@ function hotkey_handler(e) {
                exception_error("hotkey_handler", e);
        }
 }
+
+function feedsSortByUnread() {
+       return feeds_sort_by_unread;
+}