added more conditional checks for javascripts to reduce computation load
This commit is contained in:
@@ -2,22 +2,24 @@
|
||||
Danbooru.Favorite = {};
|
||||
|
||||
Danbooru.Favorite.initialize_all = function() {
|
||||
this.hide_or_show_add_to_favorites_link();
|
||||
if ($("#c-posts").length) {
|
||||
this.hide_or_show_add_to_favorites_link();
|
||||
}
|
||||
}
|
||||
|
||||
Danbooru.Favorite.hide_or_show_add_to_favorites_link = function() {
|
||||
var favorites = Danbooru.meta("favorites");
|
||||
var current_user_id = Danbooru.meta("current-user-id");
|
||||
if (current_user_id == "") {
|
||||
$("a#add-to-favorites").hide();
|
||||
$("a#remove-from-favorites").hide();
|
||||
$("#add-to-favorites").hide();
|
||||
$("#remove-from-favorites").hide();
|
||||
return;
|
||||
}
|
||||
var regexp = new RegExp("\\bfav:" + current_user_id + "\\b");
|
||||
if ((favorites != undefined) && (favorites.match(regexp))) {
|
||||
$("a#add-to-favorites").hide();
|
||||
$("#add-to-favorites").hide();
|
||||
} else {
|
||||
$("a#remove-from-favorites").hide();
|
||||
$("#remove-from-favorites").hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user