]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement j/k hotkeys to move between feeds (closes #292)
authorAndrew Dolgov <fox@fakecake.org>
Sat, 15 Jan 2011 17:14:45 +0000 (20:14 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Sat, 15 Jan 2011 17:14:45 +0000 (20:14 +0300)
FeedTree.js
help/3.php
tt-rss.js

index 26629e8cefeb83b79060e8629153b8537a685cc8..a0d4fc7eaf06f5083bf9b02cb592f29ce781501c 100644 (file)
@@ -52,6 +52,55 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
                if (treeItem)
                        return this.store.setValue(treeItem, key, value);
        },
+       getNextFeed: function (feed, is_cat) {
+               if (is_cat) {
+                       treeItem = this.store._itemsByIdentity['CAT:' + feed];
+               } else {
+                       treeItem = this.store._itemsByIdentity['FEED:' + feed];
+               }
+
+               items = this.store._arrayOfAllItems;
+               var item = items[0];
+
+               for (var i = 0; i < items.length; i++) {
+                       if (items[i] == treeItem) {
+                               item = items[i+1];
+                               break;
+                       }
+               }
+
+               if (item) {
+                       return [this.store.getValue(item, 'bare_id'), 
+                                               !this.store.getValue(item, 'id').match('FEED:')];
+               } else {
+                       return false;
+               }
+       },
+       getPreviousFeed: function (feed, is_cat) {
+               if (is_cat) {
+                       treeItem = this.store._itemsByIdentity['CAT:' + feed];
+               } else {
+                       treeItem = this.store._itemsByIdentity['FEED:' + feed];
+               }
+
+               items = this.store._arrayOfAllItems;
+               var item = items[items.length-1];
+
+               for (var i = 0; i < items.length; i++) {
+                       if (items[i] == treeItem) {
+                               item = items[i-1];
+                               break;
+                       }
+               }
+
+               if (item) {
+                       return [this.store.getValue(item, 'bare_id'), 
+                                               !this.store.getValue(item, 'id').match('FEED:')];
+               } else {
+                       return false;
+               }
+       },
+
        getNextUnreadFeed: function (feed, is_cat) {
                if (is_cat) {
                        treeItem = this.store._itemsByIdentity['CAT:' + feed];
index c45da86346af7f1d4e1b447c6e6d8f06face7958..d48adc6182c2dac60bd813608e40df0a87400b70 100644 (file)
@@ -5,7 +5,7 @@
        <h2><?php echo __("Navigation") ?></h2>
 
        <table>
-               <!-- <tr><td class='n'>j/k</td><td><?php echo __("Move between feeds") ?></td></tr> -->
+               <tr><td class='n'>j/k</td><td><?php echo __("Move between feeds") ?></td></tr>
                <tr><td class='n'>n/p</td><td><?php echo __("Move between articles") ?></td></tr>
                <tr><td class='n'>/</td><td><?php echo __("Show search dialog") ?></td></tr>
        </table>
index 546c221319e1352e08d24c821745eb9fec05fc2a..9c8f5590ae1cf464c8ef80599cdb038b0fad62db 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -704,12 +704,20 @@ function hotkey_handler(e) {
                        }
 
                        if (keycode == 74) { // j
-                               // TODO: move to previous feed
+                               var rv = dijit.byId("feedTree").model.getPreviousFeed(
+                                               getActiveFeedId(), activeFeedIsCat());
+
+                               if (rv) viewfeed(rv[0], '', rv[1]);
+
                                return;
                        }
        
                        if (keycode == 75) { // k
-                               // TODO: move to next feed
+                               var rv = dijit.byId("feedTree").model.getNextFeed(
+                                               getActiveFeedId(), activeFeedIsCat());
+
+                               if (rv) viewfeed(rv[0], '', rv[1]);
+
                                return;
                        }