summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authoranonfagola <tmjwy@evopo.com>2014-09-23 16:50:32 -0700
committerczaks <marcin@6irc.net>2014-09-24 04:47:40 +0200
commit2a823ae786f279eaec154faf50cca1fd40085af6 (patch)
treedf6e82f9323aa9578df297697b1c7da277da0b8f /js
parentba49bc6c372040b8514e0e2409bf8b9d4496ea58 (diff)
Create threadscroll.js
Diffstat (limited to 'js')
-rw-r--r--js/threadscroll.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/js/threadscroll.js b/js/threadscroll.js
new file mode 100644
index 00000000..9b97074a
--- /dev/null
+++ b/js/threadscroll.js
@@ -0,0 +1,46 @@
+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){
+ console.log(e);
+ if(e.which == 38){
+ var ele = hoverElem;
+
+ if(ele.parent().attr("class") == "post op" || ele.attr("class") == "body" || ele.attr("class") == "post-image" || ele.parent().attr("class") == "body" || ele.parent().attr("class") == "body" || (ele.parent().attr("id")!= null && ele.parent().attr("id").match("^thread") != null) || (ele.parent().attr("for")!= null && ele.parent().attr("id").match("delete") != null)){
+ var thread = (ele.parent().attr("class") == "post op") ? ele.parent().parent() : ele.parent();
+ thread = (thread.attr("class") == "post reply") ? thread.parent() : thread;
+ thread = (thread.attr("class") == "body") ? thread.parent().parent() : thread;
+ thread = (ele.attr("class") == "post-image") ? thread.parent().parent().parent().parent() : thread;
+
+ if(thread.attr("id") == null) thread = ele.parent().parent().parent().parent(); //op image
+
+ if(thread.prev().attr("id") != null){
+ if(thread.prev().attr("id").match("^thread")){
+ window.location.href = window.location.protocol+"//"+window.location.host+window.location.pathname+"#"+thread.prev().attr("id");
+ }
+ }
+ }
+ }else if(e.which == 40){
+ var ele = hoverElem;
+
+ if(ele.parent().attr("class") == "post op" || ele.attr("class") == "body" || ele.attr("class") == "post-image" || ele.parent().attr("class") == "body" || ele.parent().attr("class") == "body" || (ele.parent().attr("id")!= null && ele.parent().attr("id").match("^thread") != null) || (ele.parent().attr("for")!= null && ele.parent().attr("id").match("delete") != null)){
+ var thread = (ele.parent().attr("class") == "post op") ? ele.parent().parent() : ele.parent();
+ thread = (thread.attr("class") == "post reply") ? thread.parent() : thread;
+ thread = (thread.attr("class") == "body") ? thread.parent().parent() : thread;
+ thread = (ele.attr("class") == "post-image") ? thread.parent().parent().parent().parent() : thread;
+
+ if(thread.attr("id") == null) thread = ele.parent().parent().parent().parent(); //op image
+
+ if(thread.next().attr("id") != null){
+ if(thread.next().attr("id").match("^thread")){
+ window.location.href = window.location.protocol+"//"+window.location.host+window.location.pathname+"#"+thread.next().attr("id");
+ }
+ }
+ }
+ }
+});