Don't wait for ajax response for recent/frequent related tags
fixes #1869
This commit is contained in:
@@ -31,7 +31,10 @@
|
|||||||
|
|
||||||
Danbooru.RelatedTag.common_bind = function(button_name, category) {
|
Danbooru.RelatedTag.common_bind = function(button_name, category) {
|
||||||
$(button_name).click(function(e) {
|
$(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();
|
$("#related-tags-container").show();
|
||||||
$.get("/related_tag.json", {
|
$.get("/related_tag.json", {
|
||||||
"query": Danbooru.RelatedTag.current_tag(),
|
"query": Danbooru.RelatedTag.current_tag(),
|
||||||
@@ -108,14 +111,8 @@
|
|||||||
var $dest = $("#related-tags");
|
var $dest = $("#related-tags");
|
||||||
$dest.empty();
|
$dest.empty();
|
||||||
|
|
||||||
var recent_tags = Danbooru.Cookie.get("recent_tags_with_categories");
|
this.build_recent_and_frequent($dest);
|
||||||
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)));
|
|
||||||
}
|
|
||||||
$dest.append(this.build_html(query, related_tags));
|
$dest.append(this.build_html(query, related_tags));
|
||||||
if (wiki_page_tags.length) {
|
if (wiki_page_tags.length) {
|
||||||
$dest.append(Danbooru.RelatedTag.build_html("wiki:" + query, wiki_page_tags));
|
$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) {
|
Danbooru.RelatedTag.other_tags = function(string) {
|
||||||
if (string && string.length) {
|
if (string && string.length) {
|
||||||
return $.map(string.match(/\S+ \d+/g), function(x, i) {
|
return $.map(string.match(/\S+ \d+/g), function(x, i) {
|
||||||
|
|||||||
Reference in New Issue
Block a user