Don't wait for ajax response for recent/frequent related tags

fixes #1869
This commit is contained in:
Toks
2013-07-20 11:57:03 -04:00
parent 56946257ec
commit 63b699f5e1

View File

@@ -31,7 +31,10 @@
Danbooru.RelatedTag.common_bind = function(button_name, category) {
$(button_name).click(function(e) {
$("#related-tags").html("<em>Loading...</em>");
var $dest = $("#related-tags");
$dest.empty();
Danbooru.RelatedTag.build_recent_and_frequent($dest);
$dest.append("<em>Loading...</em>");
$("#related-tags-container").show();
$.get("/related_tag.json", {
"query": Danbooru.RelatedTag.current_tag(),
@@ -108,14 +111,8 @@
var $dest = $("#related-tags");
$dest.empty();
var recent_tags = Danbooru.Cookie.get("recent_tags_with_categories");
var favorite_tags = Danbooru.Cookie.get("favorite_tags_with_categories");
if (recent_tags.length) {
$dest.append(this.build_html("recent", this.other_tags(recent_tags)));
}
if (favorite_tags.length) {
$dest.append(this.build_html("frequent", this.other_tags(favorite_tags)));
}
this.build_recent_and_frequent($dest);
$dest.append(this.build_html(query, related_tags));
if (wiki_page_tags.length) {
$dest.append(Danbooru.RelatedTag.build_html("wiki:" + query, wiki_page_tags));
@@ -143,6 +140,17 @@
}
}
Danbooru.RelatedTag.build_recent_and_frequent = function($dest) {
var recent_tags = Danbooru.Cookie.get("recent_tags_with_categories");
var favorite_tags = Danbooru.Cookie.get("favorite_tags_with_categories");
if (recent_tags.length) {
$dest.append(this.build_html("recent", this.other_tags(recent_tags)));
}
if (favorite_tags.length) {
$dest.append(this.build_html("frequent", this.other_tags(favorite_tags)));
}
}
Danbooru.RelatedTag.other_tags = function(string) {
if (string && string.length) {
return $.map(string.match(/\S+ \d+/g), function(x, i) {