1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-01-31 04:13:49 +01:00

Merge pull request #20 from anonfagola/master

Added scrolling threads with up and down keys
This commit is contained in:
Fredrick Brennan 2014-09-23 22:41:49 -04:00
commit 21b207df65
2 changed files with 39 additions and 0 deletions

37
js/threadscroll.js Normal file
View File

@ -0,0 +1,37 @@
if(active_page == "index" || active_page == "ukko"){
var hoverElem = null;
$(document).mouseover(function(e){
var x = e.clientX, y = e.clientY,
elementOnMouseOver = document.elementFromPoint(x, y);
hoverElem = $(elementOnMouseOver);
});
$(document).keydown(function(e){
//Up arrow
if(e.which == 38){
var ele = hoverElem;
var par = $(ele).parents('div[id^="thread_"]');
if(par.length == 1){
if(par.prev().attr("id") != null){
if(par.prev().attr("id").match("^thread")){
window.location.href = window.location.protocol+"//"+window.location.host+window.location.pathname+"#"+par.prev().attr("id");
}
}
}
//Down arrow
}else if(e.which == 40){
var ele = hoverElem;
var par = $(ele).parents('div[id^="thread_"]');
if(par.length == 1){
if(par.next().attr("id") != null){
if(par.next().attr("id").match("^thread")){
window.location.href = window.location.protocol+"//"+window.location.host+window.location.pathname+"#"+par.next().attr("id");
}
}
}
}
});
}

View File

@ -94,5 +94,7 @@
<script type="text/javascript">{% raw %}
ready();
{% endraw %}</script>
<script src="js/threadscroll.js"></script>
</body>
</html>