mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-23 23:20:57 +01:00
Create id_highlighter
This commit is contained in:
parent
cb7b7d070c
commit
fda530953b
40
js/id_highlighter
Normal file
40
js/id_highlighter
Normal file
@ -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");
|
||||
});
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user