fixes #697
This commit is contained in:
@@ -31,33 +31,23 @@
|
||||
});
|
||||
}
|
||||
|
||||
Danbooru.Blacklist.show_entry = function(e) {
|
||||
$(".blacklisted").addClass("blacklisted-active");
|
||||
|
||||
Danbooru.Blacklist.posts().each(function(i, post) {
|
||||
var $post = $(post);
|
||||
var tag = $(e.target).html();
|
||||
var entry = Danbooru.Blacklist.parse_entry(tag);
|
||||
|
||||
if (Danbooru.Blacklist.post_match($post, entry)) {
|
||||
$post.removeClass("blacklisted-active");
|
||||
Danbooru.Blacklist.toggle_entry = function(e) {
|
||||
var tags = $(e.target).html();
|
||||
var match = $.grep(Danbooru.Blacklist.entries, function(entry, i) {
|
||||
return entry.tags === tags;
|
||||
})[0];
|
||||
if (match) {
|
||||
match.disabled = !match.disabled;
|
||||
if (match.disabled) {
|
||||
$(e.target).addClass("blacklisted-active");
|
||||
} else {
|
||||
$(e.target).removeClass("blacklisted-active");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Danbooru.Blacklist.toggle_all = function(e) {
|
||||
if ($(".blacklisted-active").length) {
|
||||
$(".blacklisted").removeClass("blacklisted-active");
|
||||
} else {
|
||||
$(".blacklisted").addClass("blacklisted-active");
|
||||
}
|
||||
Danbooru.Blacklist.apply();
|
||||
}
|
||||
|
||||
Danbooru.Blacklist.update_sidebar = function() {
|
||||
if (this.entries.length > 0) {
|
||||
this.entries.unshift({"tags": "~all~", "hits": -1});
|
||||
}
|
||||
|
||||
$.each(this.entries, function(i, entry) {
|
||||
if (entry.hits === 0) {
|
||||
return;
|
||||
@@ -67,19 +57,12 @@
|
||||
var link = $("<a/>");
|
||||
var count = $("<span/>");
|
||||
|
||||
if (entry.tags === "~all~") {
|
||||
link.html("All");
|
||||
link.click(Danbooru.Blacklist.toggle_all);
|
||||
item.append(link);
|
||||
item.append(" ");
|
||||
} else {
|
||||
link.html(entry.tags);
|
||||
link.click(Danbooru.Blacklist.show_entry);
|
||||
count.html(entry.hits);
|
||||
item.append(link);
|
||||
item.append(" ");
|
||||
item.append(count);
|
||||
}
|
||||
link.html(entry.tags);
|
||||
link.click(Danbooru.Blacklist.toggle_entry);
|
||||
count.html(entry.hits);
|
||||
item.append(link);
|
||||
item.append(" ");
|
||||
item.append(count);
|
||||
|
||||
$("#blacklist-list").append(item);
|
||||
});
|
||||
@@ -95,13 +78,19 @@
|
||||
var count = 0
|
||||
|
||||
$.each(this.posts(), function(i, post) {
|
||||
var post_count = 0;
|
||||
$.each(Danbooru.Blacklist.entries, function(i, entry) {
|
||||
if (Danbooru.Blacklist.post_match(post, entry)) {
|
||||
Danbooru.Blacklist.post_hide(post);
|
||||
entry.hits += 1;
|
||||
count += 1;
|
||||
post_count += 1;
|
||||
}
|
||||
});
|
||||
if (post_count > 0) {
|
||||
Danbooru.Blacklist.post_hide(post);
|
||||
} else {
|
||||
$(post).removeClass("blacklisted-active");
|
||||
}
|
||||
});
|
||||
|
||||
return count;
|
||||
@@ -112,6 +101,10 @@
|
||||
}
|
||||
|
||||
Danbooru.Blacklist.post_match = function(post, entry) {
|
||||
if (entry.disabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var $post = $(post);
|
||||
var tags = String($post.data("tags")).match(/\S+/g) || [];
|
||||
tags.push("rating:" + $post.data("rating"));
|
||||
@@ -119,7 +112,6 @@
|
||||
$.each(String($post.data("flags")).match(/\S+/g) || [], function(i, v) {
|
||||
tags.push("status:" + v);
|
||||
});
|
||||
|
||||
return (entry.require.length > 0 || entry.exclude.length > 0) && Danbooru.is_subset(tags, entry.require) && !Danbooru.intersect(tags, entry.exclude).length;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,10 @@ article.post-preview {
|
||||
}
|
||||
}
|
||||
|
||||
a.blacklisted-active {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.post-preview.blacklisted-active {
|
||||
display: none;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user