summaryrefslogtreecommitdiff
path: root/js/threadscroll.js
diff options
context:
space:
mode:
authorSimon McFarlane <simon@piston.pw>2015-06-01 16:08:19 -0700
committerSimon McFarlane <simon@piston.pw>2015-06-01 16:08:19 -0700
commit209bc5400144e448e95a68e01d842c6fab53ae71 (patch)
treeab4cc6ad241e8daccb546514330d3a5f2906e846 /js/threadscroll.js
parentd1c1e5a589f30d640f5eb6303e7059105a6297f8 (diff)
parent7ab9cc43d101ed002bce392beefe1c435ab2d5b1 (diff)
Merge pull request #18 from lainchan/vichan-merge
Merge with the latest upstream vichan
Diffstat (limited to 'js/threadscroll.js')
-rw-r--r--js/threadscroll.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/js/threadscroll.js b/js/threadscroll.js
new file mode 100644
index 00000000..0a233f58
--- /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")){
+ par.prev()[0].scrollIntoView(true);
+ }
+ }
+ }
+ //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")){
+ par.next()[0].scrollIntoView(true);
+ }
+ }
+ }
+ }
+ });
+}