diff --git a/js/threadscroll.js b/js/threadscroll.js new file mode 100644 index 00000000..c3c6deef --- /dev/null +++ b/js/threadscroll.js @@ -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"); + } + } + } + } + }); +} diff --git a/templates/index.html b/templates/index.html index 178c1ed0..6c89bb0e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -94,5 +94,7 @@ + +