#1537: Fix poor performance

This commit is contained in:
Toks
2013-07-28 12:48:49 -04:00
parent 79a7fe6ea9
commit 6fccb8ba69

View File

@@ -6,11 +6,7 @@
this.initialize_buttons();
$("#related-tags-container").hide();
$("#artist-tags-container").hide();
$("#upload_tag_string,#post_tag_string").keyup(function(e) {
if ($("#related-tags").is(":visible")) {
Danbooru.RelatedTag.build_all();
}
});
$("#upload_tag_string,#post_tag_string").keyup(Danbooru.RelatedTag.update_selected);
}
}
@@ -100,6 +96,18 @@
Danbooru.RelatedTag.build_all();
}
Danbooru.RelatedTag.update_selected = function(e) {
var current_tags = $("#upload_tag_string,#post_tag_string").val().toLowerCase().match(/\S+/g) || [];
var $all_tags = $("#related-tags a");
$all_tags.removeClass("selected");
$all_tags.each(function(i, tag) {
if (current_tags.indexOf(tag.textContent.replace(/ /g, "_")) > -1) {
$(tag).addClass("selected");
}
});
}
Danbooru.RelatedTag.build_all = function() {
if (Danbooru.RelatedTag.recent_search === null || Danbooru.RelatedTag.recent_search === undefined) {
return;