Skip to content

Instantly share code, notes, and snippets.

@walf443
Forked from anonymous/gist:31956
Created December 4, 2008 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walf443/31957 to your computer and use it in GitHub Desktop.
Save walf443/31957 to your computer and use it in GitHub Desktop.
diff --git root/static/js/remedie.js root/static/js/remedie.js
index 303a631..a497f90 100644
--- root/static/js/remedie.js
+++ root/static/js/remedie.js
@@ -53,6 +53,26 @@ Remedie.prototype = {
});
this.installHotKey('shift+u', function(){ remedie.toggleChannelView(false) });
+
+ // LDRize like keyborad shortcut.
+ $(document).bind('keypress', 'j', function(){
+ remedie.moveChannelItemNext();
+ return false;
+ });
+ $(document).bind('keypress', 'k', function(){
+ remedie.moveChannelItemPrev();
+ return false;
+ });
+
+ $(document).bind('keypress', 'o', function(){
+ var items = $('.channel-item');
+ if ( items ) {
+ var item = items[remedie.channelItemPos];
+ remedie.playVideoInline(remedie.items[ item.id.replace("channel-item-", "") ]);
+ }
+ return false;
+ });
+
$(document).bind('keydown', 'esc', $.unblockUI);
},
@@ -860,6 +880,7 @@ Remedie.prototype = {
$.each(r.channels, function(index, channel) {
remedie.channels[channel.id] = channel;
remedie.renderChannelList(channel, $("#collection"));
+ remedie.resetChannelItemPos();
remedie.redrawUnwatchedCount(channel);
});
$.unblockUI();
@@ -916,6 +937,37 @@ Remedie.prototype = {
RemedieUtil.layoutImage($("#channel-thumbnail-image-" + channel.id), thumbnail, 192, 192);
},
+ channelItemPos: 0,
+
+ moveChannelItem: function(index) {
+ if ( ! $('.channel-item') ) {
+ return false;
+ }
+ var target = $('.channel-item')[index];
+ if ( !target ) {
+ return false;
+ }
+
+ target.scrollIntoView();
+ return window.scrollY;
+ },
+
+ moveChannelItemNext: function() {
+ if ( this.moveChannelItem(remedie.channelItemPos + 1) ) {
+ remedie.channelItemPos += 1;
+ }
+ },
+
+ moveChannelItemPrev: function() {
+ if ( remedie.channelItemPos >= 1 && this.moveChannelItem(remedie.channelItemPos - 1) ) {
+ remedie.channelItemPos -= 1;
+ }
+ },
+
+ resetChannelItemPos: function() {
+ remedie.channelItemPos = 0;
+ },
+
redrawChannel: function(channel) {
var id = "#channel-" + channel.id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment