From 29875c0c1161d537d68b81380fe422431bfdae4d Mon Sep 17 00:00:00 2001 From: anonfagola Date: Tue, 23 Sep 2014 16:50:32 -0700 Subject: [PATCH 1/5] Create threadscroll.js --- js/threadscroll.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 js/threadscroll.js 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"); + } + } + } + } +}); From c3c391be9ee8339948c0e8277f186c04e6af6fd8 Mon Sep 17 00:00:00 2001 From: anonfagola Date: Tue, 23 Sep 2014 16:54:19 -0700 Subject: [PATCH 2/5] Added scrolling threads with up and down keys For 8chan X. Redone so it's in js folder. @KillerWhale321 --- templates/index.html | 2 ++ 1 file changed, 2 insertions(+) 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 @@ + + From ab9f5d106e6a7ea45a090f47730adb22970c1d78 Mon Sep 17 00:00:00 2001 From: anonfagola Date: Tue, 23 Sep 2014 18:55:50 -0700 Subject: [PATCH 3/5] Update threadscroll.js Fixed a line left from debug, and added comments. --- js/threadscroll.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/threadscroll.js b/js/threadscroll.js index 9b97074a..4f623ed2 100644 --- a/js/threadscroll.js +++ b/js/threadscroll.js @@ -7,7 +7,7 @@ $(document).mouseover(function(e){ }); $(document).keydown(function(e){ - console.log(e); + //Up arrow if(e.which == 38){ var ele = hoverElem; @@ -25,6 +25,7 @@ $(document).keydown(function(e){ } } } + //Down arrow }else if(e.which == 40){ var ele = hoverElem; From 02ff632e50fe5155bcbacf8fa9bc7f9493878b60 Mon Sep 17 00:00:00 2001 From: anonfagola Date: Tue, 23 Sep 2014 19:27:41 -0700 Subject: [PATCH 4/5] Update threadscroll.js Made cleaner. --- js/threadscroll.js | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/js/threadscroll.js b/js/threadscroll.js index 4f623ed2..5cbcbbe8 100644 --- a/js/threadscroll.js +++ b/js/threadscroll.js @@ -10,36 +10,24 @@ $(document).keydown(function(e){ //Up arrow if(e.which == 38){ var ele = hoverElem; + var par = $(ele).parents('div[id^="thread_"]'); - 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"); + 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(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"); + 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"); } } } From 986db033e2be6ffcfafc791b4ba86b33bbf5fafe Mon Sep 17 00:00:00 2001 From: anonfagola Date: Tue, 23 Sep 2014 19:31:06 -0700 Subject: [PATCH 5/5] Update threadscroll.js Made compatible for use with additional_javascripts. --- js/threadscroll.js | 66 ++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/js/threadscroll.js b/js/threadscroll.js index 5cbcbbe8..c3c6deef 100644 --- a/js/threadscroll.js +++ b/js/threadscroll.js @@ -1,35 +1,37 @@ -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"); +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"); + } } } } - //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"); - } - } - } - } -}); + }); +}