Created
October 22, 2010 12:45
-
-
Save 8th713/640483 to your computer and use it in GitHub Desktop.
[Sleipnir]HLR LDRize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- append to line 6 by descript_compact.html --> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script> | |
<script type="text/javascript" src="$PNIR_DESCRIPTION_PATH$LDRize.js"></script> | |
<style type="text/css"> #current a { color:gold; } </style> | |
<!-- end --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.easing.easeOutCubic = function (x, t, b, c, d) { return c*((t=t/d-1)*t*t + 1) + b; }; | |
jQuery(function($){ | |
var LDRize = {}; | |
LDRize.move = function(i){ | |
var headers = $('h1.title'); | |
var max = headers.length - 1; | |
var now = $('#current').index('h1.title'); | |
var next = now + i; | |
if(next < 0){ | |
return; | |
} | |
else if(next > max){ | |
var a = $('a[href="headline:nextpage"]').get(0) | |
if(a) a.click(); | |
return; | |
} | |
else{ | |
headers.eq(now).removeAttr('id'); | |
var next = headers.eq(next).attr('id','current'); | |
var top = next.offset().top -10; | |
$('html,body').animate({scrollTop:top},'normal','easeOutCubic'); | |
} | |
} | |
LDRize.open = function(){ | |
var current = $('#current>a'); | |
if(current.length) | |
current.get(0).click(); | |
} | |
LDRize.star = function(){ | |
var current = $('#current>span>a'); | |
if(current.length) | |
current.get(0).click(); | |
} | |
function keyUp(evt){ | |
switch(evt.keyCode){ | |
case 74: // J | |
LDRize.move(1); break; | |
case 75: // K | |
LDRize.move(-1); break; | |
case 80: // P | |
LDRize.star(); break; | |
case 86: // V | |
LDRize.open(); break; | |
}; | |
} | |
$(document).keyup(keyUp); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment