summaryrefslogtreecommitdiff
path: root/js/id_highlighter.js
diff options
context:
space:
mode:
authoranonfagola <anonfagola@users.noreply.github.com>2014-09-27 11:55:39 -0700
committerczaks <marcin@6irc.net>2014-10-05 17:46:57 +0200
commitb419c85f8c9c79e6bb0425db93967b36240ebbed (patch)
tree846d859f9f3cce17bfbe5db6212e8a6ed5460c46 /js/id_highlighter.js
parentfda530953bb50b10a132fbf56d10952e7d9d0267 (diff)
Forgot .js extension
Diffstat (limited to 'js/id_highlighter.js')
-rw-r--r--js/id_highlighter.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/js/id_highlighter.js b/js/id_highlighter.js
new file mode 100644
index 00000000..60052031
--- /dev/null
+++ b/js/id_highlighter.js
@@ -0,0 +1,40 @@
+Array.prototype.remove = function(v) { this.splice(this.indexOf(v) == -1 ? this.length : this.indexOf(v), 1); }
+
+var idshighlighted = [];
+
+function getPostsById(id){
+ return $(".poster_id").filter(function(i){
+ return $(this).text() == id;
+ });
+}
+
+function getMasterPosts(parents){
+ if(!parents.hasClass("post")) return;
+
+ var toRet = [];
+
+ $(parents).each(function(){
+ if($(this).hasClass("post"))
+ toRet.push($(this));
+ });
+
+ return toRet;
+}
+
+$(".poster_id").click(function(){
+ var id = $(this).text();
+
+ if($.inArray(id, idshighlighted) !== -1){
+ idshighlighted.remove(id);
+
+ $(getMasterPosts(getPostsById(id).parents())).each(function(i){
+ $(this).removeClass("highlighted");
+ });
+ }else{
+ idshighlighted.push(id);
+
+ $(getMasterPosts(getPostsById(id).parents())).each(function(i){
+ $(this).addClass("highlighted");
+ });
+ }
+});