Kill trailing whitespaces in javascript files
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
(function() {
|
||||
Danbooru.Artist = {};
|
||||
|
||||
|
||||
Danbooru.Artist.initialize_all = function() {
|
||||
if ($("#c-artists").length) {
|
||||
Danbooru.Artist.initialize_check_name_link();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Artist.initialize_check_name_link = function() {
|
||||
$("#check-name-link").click(function(e) {
|
||||
var artist_name = $("#artist_name").val();
|
||||
|
||||
@@ -57,12 +57,12 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Blacklist.update_sidebar = function() {
|
||||
if (this.blacklists.length > 0) {
|
||||
this.blacklists.unshift({"tags": "~all~", "hits": -1});
|
||||
}
|
||||
|
||||
|
||||
$.each(this.blacklists, function(i, blacklist) {
|
||||
if (blacklist.hits === 0) {
|
||||
return;
|
||||
@@ -71,7 +71,7 @@
|
||||
var item = $("<li/>");
|
||||
var link = $("<a/>");
|
||||
var count = $("<span/>");
|
||||
|
||||
|
||||
if (blacklist.tags === "~all~") {
|
||||
link.html("All");
|
||||
link.click(Danbooru.Blacklist.toggle_all);
|
||||
@@ -85,7 +85,7 @@
|
||||
item.append(" ");
|
||||
item.append(count);
|
||||
}
|
||||
|
||||
|
||||
$("#blacklist-list").append(item);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
(function() {
|
||||
Danbooru.Comment = {};
|
||||
|
||||
|
||||
Danbooru.Comment.initialize_all = function() {
|
||||
if ($("#c-posts").length || $("#c-comments").length) {
|
||||
this.initialize_response_link();
|
||||
this.initialize_reply_links();
|
||||
this.initialize_expand_links();
|
||||
}
|
||||
|
||||
|
||||
if ($("#c-posts").length && $("#a-show").length) {
|
||||
Danbooru.Comment.highlight_threshold_comments(Danbooru.meta("post-id"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Comment.quote_message = function(data) {
|
||||
var stripped_body = data["body"].replace(/\[quote\](?:.|\n|\r)+?\[\/quote\](?:\r\n|\r|\n)*/gm, "");
|
||||
return "[quote]\n" + data["creator_name"] + " said:\n" + stripped_body + "\n[/quote]\n\n";
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Comment.quote = function(e) {
|
||||
$.get(
|
||||
"/comments/" + $(e.target).data('comment-id') + ".json",
|
||||
@@ -36,11 +36,11 @@
|
||||
);
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Comment.initialize_reply_links = function() {
|
||||
$(".reply-link").click(Danbooru.Comment.quote);
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Comment.initialize_expand_links = function() {
|
||||
$(".comment-section form").hide();
|
||||
$(".comment-section input.expand-comment-response").click(function(e) {
|
||||
@@ -50,7 +50,7 @@
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Comment.initialize_response_link = function() {
|
||||
$("a.expand-comment-response").click(function(e) {
|
||||
$(e.target).hide();
|
||||
@@ -59,10 +59,10 @@
|
||||
Danbooru.scroll_to($form);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
$("div.new-comment form").hide();
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Comment.highlight_threshold_comments = function(post_id) {
|
||||
var threshold = parseInt(Danbooru.meta("user-comment-threshold"));
|
||||
var articles = $("article.comment[data-post-id=" + post_id + "]");
|
||||
@@ -73,7 +73,7 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Comment.hide_threshold_comments = function(post_id) {
|
||||
var threshold = parseInt(Danbooru.meta("user-comment-threshold"));
|
||||
var articles = $("article.comment[data-post-id=" + post_id + "]");
|
||||
|
||||
@@ -2,14 +2,14 @@ $(function() {
|
||||
// Table striping
|
||||
$(".striped tbody tr:even").addClass("even");
|
||||
$(".striped tbody tr:odd").addClass("odd");
|
||||
|
||||
|
||||
// Account notices
|
||||
$("#hide-sign-up-notice").click(function(e) {
|
||||
$("#sign-up-notice").hide();
|
||||
Danbooru.Cookie.put("hide_sign_up_notice", "1", 7);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
$("#hide-upgrade-account-notice").click(function(e) {
|
||||
$("#upgrade-account-notice").hide();
|
||||
Danbooru.Cookie.put('hide_upgrade_account_notice', '1', 7);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
Danbooru.Cookie = {};
|
||||
|
||||
|
||||
Danbooru.Cookie.put = function(name, value, days) {
|
||||
if (days == null) {
|
||||
days = 365;
|
||||
@@ -11,7 +11,7 @@
|
||||
var expires = "; expires=" + date.toGMTString();
|
||||
document.cookie = name + "=" + encodeURIComponent(value) + expires + "; path=/";
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Cookie.raw_get = function(name) {
|
||||
var nameEq = name + "=";
|
||||
var ca = document.cookie.split(";");
|
||||
@@ -30,11 +30,11 @@
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Cookie.get = function(name) {
|
||||
return this.unescape(this.raw_get(name));
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Cookie.remove = function(name) {
|
||||
this.put(name, "", -1);
|
||||
}
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
Danbooru.Cookie.initialize = function() {
|
||||
var loc = location.href;
|
||||
|
||||
|
||||
if (loc.match(/^http/)) {
|
||||
loc = loc.replace(/^https?:\/\/[^\/]+/, "")
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
(function() {
|
||||
Danbooru.Dtext = {};
|
||||
|
||||
|
||||
Danbooru.Dtext.initialize_links = function() {
|
||||
$(".simple_form .dtext-preview").hide();
|
||||
$(".simple_form input[value=Preview]").click(Danbooru.Dtext.click_button);
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Dtext.call_preview = function(e, $button, $input, $preview) {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
@@ -20,18 +20,18 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Dtext.call_edit = function(e, $button, $input, $preview) {
|
||||
$button.val("Preview");
|
||||
$preview.hide();
|
||||
$input.slideDown("fast");
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Dtext.click_button = function(e) {
|
||||
var $button = $(e.target);
|
||||
var $input = $("#" + $button.data("input-id"));
|
||||
var $preview = $("#" + $button.data("preview-id"));
|
||||
|
||||
|
||||
if ($button.val().match(/preview/i)) {
|
||||
Danbooru.Dtext.call_preview(e, $button, $input, $preview);
|
||||
} else {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
(function() {
|
||||
Danbooru.Favorite = {};
|
||||
|
||||
|
||||
Danbooru.Favorite.initialize_all = function() {
|
||||
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");
|
||||
@@ -19,13 +19,13 @@
|
||||
if ((favorites != undefined) && (favorites.match(regexp))) {
|
||||
$("#add-to-favorites").hide();
|
||||
} else {
|
||||
$("#remove-from-favorites").hide();
|
||||
$("#remove-from-favorites").hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Favorite.create = function(post_id) {
|
||||
Danbooru.Post.notice_update("inc");
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/favorites",
|
||||
@@ -40,10 +40,10 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Favorite.destroy = function(post_id) {
|
||||
Danbooru.Post.notice_update("inc");
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "DELETE",
|
||||
url: "/favorites/" + post_id,
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
$(function() {
|
||||
var $sidebar = $("#sidebar");
|
||||
var $content = $("#content");
|
||||
|
||||
|
||||
if (!$sidebar.length || !$content.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var sidebar_offset = $sidebar.offset().top + $sidebar.height();
|
||||
var content_offset = $content.offset().top + $content.height();
|
||||
var offset = null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
Danbooru.ModQueue = {};
|
||||
|
||||
|
||||
Danbooru.ModQueue.initialize_approve_all_button = function() {
|
||||
$("#approve-all-button").click(function(e) {
|
||||
if (!confirm("Are you sure you want to approve every post on this page?")) {
|
||||
@@ -11,7 +11,7 @@
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.ModQueue.initialize_hide_all_button = function() {
|
||||
$("#hide-all-button").click(function(e) {
|
||||
if (!confirm("Are you sure you want to hide every post on this page?")) {
|
||||
@@ -22,7 +22,7 @@
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.ModQueue.initialize_hilights = function() {
|
||||
$.each($("article.post"), function(i, v) {
|
||||
var $post = $(v);
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
(function() {
|
||||
Danbooru.NewsUpdate = {};
|
||||
|
||||
|
||||
Danbooru.NewsUpdate.initialize = function() {
|
||||
var key = $("#news-updates").data("updated-at");
|
||||
|
||||
|
||||
if (Danbooru.Cookie.get("news-ticker") === key) {
|
||||
$("#news-updates").hide();
|
||||
} else {
|
||||
$("#close-news-ticker-link").click(function(e) {
|
||||
$("#news-updates").hide();
|
||||
Danbooru.Cookie.put("news-ticker", key);
|
||||
|
||||
|
||||
// need to reset the more link
|
||||
$("#more-links").hide().offset({top: $("#site-map-link").offset().top + $("#site-map-link").height() + 10, left: $("#site-map-link").offset().left});
|
||||
|
||||
$("#more-links").hide().offset({top: $("#site-map-link").offset().top + $("#site-map-link").height() + 10, left: $("#site-map-link").offset().left});
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -383,14 +383,14 @@ Danbooru.Note = {
|
||||
|
||||
TranslationMode: {
|
||||
active: false,
|
||||
|
||||
|
||||
start: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (Danbooru.Note.TranslationMode.active) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Note.TranslationMode.active = true;
|
||||
$("#original-file-link").click();
|
||||
$("#image").one("click", Danbooru.Note.TranslationMode.create_note);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
Danbooru.Paginator = {};
|
||||
|
||||
|
||||
Danbooru.Paginator.next_page = function() {
|
||||
var href = $(".paginator a[rel=next]").attr("href");
|
||||
if (href) {
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
(function() {
|
||||
Danbooru.Pool = {};
|
||||
|
||||
|
||||
Danbooru.Pool.initialize_all = function() {
|
||||
if ($("#c-posts").length && $("#a-show").length) {
|
||||
this.initialize_add_to_pool_link();
|
||||
}
|
||||
|
||||
|
||||
if ($("#c-pool-orders").length) {
|
||||
this.initialize_simple_edit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Pool.initialize_add_to_pool_link = function() {
|
||||
$("#add-to-pool-dialog").dialog({autoOpen: false});
|
||||
|
||||
|
||||
$("#c-pool-elements #a-new input[type=text]").autocomplete({
|
||||
source: function(req, resp) {
|
||||
$.getJSON(
|
||||
@@ -25,24 +25,24 @@
|
||||
},
|
||||
minLength: 2,
|
||||
});
|
||||
|
||||
|
||||
$("#pool").click(function(e) {
|
||||
e.preventDefault();
|
||||
$("#add-to-pool-dialog").dialog("open");
|
||||
});
|
||||
|
||||
|
||||
$("#recent-pools li").click(function(e) {
|
||||
e.preventDefault();
|
||||
$("#pool_name").val($(this).html());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Pool.initialize_simple_edit = function() {
|
||||
$("#sortable").sortable({
|
||||
placeholder: "ui-state-placeholder"
|
||||
});
|
||||
$("#sortable").disableSelection();
|
||||
|
||||
|
||||
$("#ordering-form").submit(function(e) {
|
||||
$.ajax({
|
||||
type: "put",
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
(function() {
|
||||
Danbooru.PostAppeal = {};
|
||||
|
||||
|
||||
Danbooru.PostAppeal.initialize_all = function() {
|
||||
if ($("#c-posts").length && $("#a-show").length) {
|
||||
this.initialize_appeal();
|
||||
this.hide_or_show_appeal_link();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostAppeal.hide_or_show_appeal_link = function() {
|
||||
if (Danbooru.meta("post-is-flagged") !== "true") {
|
||||
$("#appeal").hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostAppeal.initialize_appeal = function() {
|
||||
$("#appeal-dialog").dialog({
|
||||
autoOpen: false,
|
||||
autoOpen: false,
|
||||
width: 700,
|
||||
modal: true,
|
||||
buttons: {
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
(function() {
|
||||
Danbooru.PostFlag = {};
|
||||
|
||||
|
||||
Danbooru.PostFlag.initialize_all = function() {
|
||||
if ($("#c-posts").length && $("#a-show").length) {
|
||||
this.initialize_flag();
|
||||
this.hide_or_show_flag_link();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostFlag.hide_or_show_flag_link = function() {
|
||||
if (Danbooru.meta("post-is-deleted") === "true") {
|
||||
$("#flag").hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostFlag.initialize_flag = function() {
|
||||
$("#flag-dialog").dialog({
|
||||
autoOpen: false,
|
||||
autoOpen: false,
|
||||
width: 700,
|
||||
modal: true,
|
||||
buttons: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
Danbooru.PostModeMenu = {};
|
||||
|
||||
|
||||
Danbooru.PostModeMenu.initialize = function() {
|
||||
if ($("#c-posts").length || $("#c-favorites").length || $("#c-pools").length) {
|
||||
this.initialize_selector();
|
||||
@@ -9,7 +9,7 @@
|
||||
Danbooru.PostModeMenu.change();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostModeMenu.initialize_selector = function() {
|
||||
if (Danbooru.Cookie.get("mode") === "") {
|
||||
Danbooru.Cookie.put("mode", "view");
|
||||
@@ -20,18 +20,18 @@
|
||||
|
||||
$("#mode-box select").change(Danbooru.PostModeMenu.change);
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostModeMenu.initialize_preview_link = function() {
|
||||
$(".post-preview a").click(Danbooru.PostModeMenu.click);
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostModeMenu.initialize_edit_form = function() {
|
||||
$("#quick-edit-div").hide();
|
||||
$("#quick-edit-form input[value=Cancel]").click(function(e) {
|
||||
$("#quick-edit-div").slideUp("fast");
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
$("#quick-edit-form").submit(function(e) {
|
||||
$.ajax({
|
||||
type: "put",
|
||||
@@ -47,11 +47,11 @@
|
||||
Danbooru.notice("Post #" + data.id + " updated");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostModeMenu.change = function(e) {
|
||||
$("#quick-edit-div").slideUp("fast");
|
||||
var s = $("#mode-box select").val();
|
||||
@@ -62,11 +62,11 @@
|
||||
$body.removeClass();
|
||||
$body.addClass("mode-" + s);
|
||||
Danbooru.Cookie.put("mode", s, 1);
|
||||
|
||||
|
||||
if (s === "edit-tag-script") {
|
||||
var script = Danbooru.Cookie.get("tag-script");
|
||||
script = prompt("Enter a tag script", script);
|
||||
|
||||
|
||||
if (script) {
|
||||
Danbooru.Cookie.put("tag-script", script);
|
||||
$("#mode-box select").val("apply-tag-script");
|
||||
@@ -77,18 +77,18 @@
|
||||
Danbooru.PostModeMenu.change(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostModeMenu.open_edit = function(post_id) {
|
||||
var $post = $("#post_" + post_id);
|
||||
$("#quick-edit-div").slideDown("fast");
|
||||
$("#quick-edit-form").attr("action", "/posts/" + post_id + ".json");
|
||||
$("#post_tag_string").val($post.data("tags")).focus();
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostModeMenu.click = function(e) {
|
||||
var s = $("#mode-box select").val();
|
||||
var post_id = $(e.target).closest("article").data("id");
|
||||
|
||||
|
||||
if (s === "add-fav") {
|
||||
Danbooru.Favorite.create(post_id);
|
||||
} else if (s === "remove-fav") {
|
||||
@@ -117,7 +117,7 @@
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
(function() {
|
||||
Danbooru.PostModeration = {};
|
||||
|
||||
|
||||
Danbooru.PostModeration.initialize_all = function() {
|
||||
if ($("#c-posts").length && $("#a-show").length) {
|
||||
this.hide_or_show_approve_and_disapprove_links();
|
||||
this.hide_or_show_delete_and_undelete_links();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() {
|
||||
if (Danbooru.meta("post-is-approvable") !== "true") {
|
||||
$("#approve").hide();
|
||||
$("#disapprove").hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostModeration.hide_or_show_delete_and_undelete_links = function() {
|
||||
if (Danbooru.meta("post-is-deleted") === "true") {
|
||||
$("#delete").hide();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.PostPopular.nav_next = function() {
|
||||
if ($("#popular-nav-links").length) {
|
||||
var href = $("#popular-nav-links a[rel=next]").attr("href");
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Post.initialize_similar = function() {
|
||||
$("#similar-button").click(function(e) {
|
||||
var old_source_name = $("#post_source").attr("name");
|
||||
@@ -44,11 +44,11 @@
|
||||
$("#post_source").attr("name", old_source_name);
|
||||
$("#form").attr("target", "");
|
||||
$("#form").attr("action", old_action);
|
||||
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Post.nav_prev = function() {
|
||||
if ($("#search-seq-nav").length) {
|
||||
var href = $("#search-seq-nav a[rel=prev]").attr("href");
|
||||
@@ -62,7 +62,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Post.nav_next = function() {
|
||||
if ($("#search-seq-nav").length) {
|
||||
var href = $("#search-seq-nav a[rel=next]").attr("href");
|
||||
@@ -74,7 +74,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Post.nav_scroll_down = function() {
|
||||
var scroll_top = $(window).scrollTop() + ($(window).height() * 0.85);
|
||||
Danbooru.scroll_to(scroll_top);
|
||||
@@ -316,7 +316,7 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Post.approve = function(post_id) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
Danbooru.RelatedTag = {};
|
||||
|
||||
|
||||
Danbooru.RelatedTag.initialize_all = function() {
|
||||
if ($("#c-posts").length || $("#c-uploads").length) {
|
||||
this.initialize_buttons();
|
||||
@@ -8,7 +8,7 @@
|
||||
$("#artist-tags-container").hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.RelatedTag.initialize_buttons = function() {
|
||||
this.common_bind("#related-tags-button", "");
|
||||
this.common_bind("#related-artists-button", "artist");
|
||||
@@ -22,7 +22,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.RelatedTag.common_bind = function(button_name, category) {
|
||||
$(button_name).click(function(e) {
|
||||
$("#related-tags").html("<em>Loading...</em>");
|
||||
@@ -35,7 +35,7 @@
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.RelatedTag.current_tag = function() {
|
||||
// 1. abc def | -> def
|
||||
// 2. abc def| -> def
|
||||
@@ -45,7 +45,7 @@
|
||||
// 6. ab|c def -> abc
|
||||
// 7. |abc def -> abc
|
||||
// 8. | abc def -> abc -- not supported by this code but a pretty rare case
|
||||
|
||||
|
||||
var $field = $("#upload_tag_string,#post_tag_string");
|
||||
var string = $field.val().trim();
|
||||
var n = string.length;
|
||||
@@ -55,7 +55,7 @@
|
||||
if ((a > 0) && (a < (n - 1)) && (string[a] !== " ") && (string[a - 1] === " ")) {
|
||||
// 4 is the only case where we need to scan forward. in all other cases we
|
||||
// can drag a backwards, and then drag b forwards.
|
||||
|
||||
|
||||
while ((b < n) && (string[b] !== " ")) {
|
||||
b++;
|
||||
}
|
||||
@@ -64,39 +64,39 @@
|
||||
a--;
|
||||
b--;
|
||||
}
|
||||
|
||||
|
||||
while ((a > 0) && (string[a - 1] !== " ")) {
|
||||
a--;
|
||||
b--;
|
||||
}
|
||||
|
||||
|
||||
while ((b < (n - 1)) && (string[b] !== " ")) {
|
||||
b++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
b++;
|
||||
return string.slice(a, b);
|
||||
}
|
||||
|
||||
|
||||
Danbooru.RelatedTag.process_response = function(data) {
|
||||
Danbooru.RelatedTag.recent_search = data;
|
||||
Danbooru.RelatedTag.build_all();
|
||||
}
|
||||
|
||||
|
||||
Danbooru.RelatedTag.build_all = function() {
|
||||
if (Danbooru.RelatedTag.recent_search === null || Danbooru.RelatedTag.recent_search === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$("#related-tags").show();
|
||||
|
||||
|
||||
var query = Danbooru.RelatedTag.recent_search.query;
|
||||
var related_tags = Danbooru.RelatedTag.recent_search.tags.sort();
|
||||
var wiki_page_tags = Danbooru.RelatedTag.recent_search.wiki_page_tags;
|
||||
var $dest = $("#related-tags");
|
||||
$dest.empty();
|
||||
|
||||
|
||||
if (Danbooru.Cookie.get("recent_tags")) {
|
||||
$dest.append(Danbooru.RelatedTag.build_html("recent", Danbooru.RelatedTag.recent_tags()));
|
||||
}
|
||||
@@ -108,7 +108,7 @@
|
||||
$dest.append(Danbooru.RelatedTag.build_html("wiki:" + query, wiki_page_tags));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.RelatedTag.favorite_tags = function() {
|
||||
var string = Danbooru.meta("favorite-tags");
|
||||
if (string) {
|
||||
@@ -119,7 +119,7 @@
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.RelatedTag.recent_tags = function() {
|
||||
var string = Danbooru.Cookie.get("recent_tags");
|
||||
if (string && string.length) {
|
||||
@@ -130,7 +130,7 @@
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.RelatedTag.build_html = function(query, related_tags) {
|
||||
if (query === null || query === "") {
|
||||
return "";
|
||||
@@ -146,7 +146,7 @@
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$.each(related_tags, function(i, tag) {
|
||||
var $link = $("<a/>");
|
||||
$link.html(tag[0].replace(/_/g, " "));
|
||||
@@ -160,11 +160,11 @@
|
||||
$("<li/>").append($link)
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
$div.append($ul);
|
||||
return $div;
|
||||
}
|
||||
|
||||
|
||||
Danbooru.RelatedTag.toggle_tag = function(e) {
|
||||
var $field = $("#upload_tag_string,#post_tag_string");
|
||||
var tags = $field.val().match(/\S+/g) || [];
|
||||
@@ -180,7 +180,7 @@
|
||||
Danbooru.RelatedTag.build_all();
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
|
||||
Danbooru.RelatedTag.find_artist = function(e) {
|
||||
$("#artist-tags").html("<em>Loading...</em>");
|
||||
Danbooru.RelatedTag.recent_search = null;
|
||||
@@ -188,12 +188,12 @@
|
||||
$.get("/artists.json", {"search[name]": url.val()}).success(Danbooru.RelatedTag.process_artist);
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
|
||||
Danbooru.RelatedTag.process_artist = function(data) {
|
||||
$("#artist-tags-container").show();
|
||||
var $dest = $("#artist-tags");
|
||||
$dest.empty();
|
||||
|
||||
|
||||
if (data.length === 0) {
|
||||
$dest.html("No artists found");
|
||||
return;
|
||||
@@ -201,7 +201,7 @@
|
||||
$dest.html("Too many matching artists found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$.each(data, function(i, json) {
|
||||
if (!json.other_names) {
|
||||
json.other_names = "";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
(function() {
|
||||
Danbooru.Sources = {};
|
||||
|
||||
|
||||
Danbooru.Sources.get = function(url) {
|
||||
$.get("/sources.json", {
|
||||
url: url
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Danbooru.TagScript.parse = function(script) {
|
||||
return script.match(/\[.+?\]|\S+/g);
|
||||
}
|
||||
|
||||
|
||||
Danbooru.TagScript.test = function(tags, predicate) {
|
||||
var split_pred = predicate.match(/\S+/g);
|
||||
var is_true = true;
|
||||
@@ -46,7 +46,7 @@
|
||||
var commands = Danbooru.TagScript.parse(tag_script);
|
||||
var $post = $("#post_" + post_id);
|
||||
var old_tags = $post.data("tags");
|
||||
|
||||
|
||||
$.each(commands, function(i, x) {
|
||||
var array = String($post.data("tags")).match(/\S+/g);
|
||||
$post.data("tags", Danbooru.TagScript.process(array, x).join(" "));
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
(function() {
|
||||
Danbooru.Upload = {};
|
||||
|
||||
|
||||
Danbooru.Upload.initialize_all = function() {
|
||||
if ($("#c-uploads,#c-posts").length) {
|
||||
this.initialize_enter_on_tags();
|
||||
}
|
||||
|
||||
|
||||
if ($("#c-uploads").length) {
|
||||
this.initialize_image();
|
||||
this.initialize_info();
|
||||
@@ -15,7 +15,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Upload.initialize_enter_on_tags = function() {
|
||||
$("#upload_tag_string,#post_tag_string").bind("keydown.return", function(e) {
|
||||
$("#form").trigger("submit");
|
||||
@@ -41,11 +41,11 @@
|
||||
$("#upload_file").attr("name", old_file_name);
|
||||
$("#form").attr("target", "");
|
||||
$("#form").attr("action", old_action);
|
||||
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Upload.initialize_info = function() {
|
||||
$("#source-info ul").hide();
|
||||
$("#fetch-data").click(function(e) {
|
||||
@@ -54,10 +54,10 @@
|
||||
$.each(data.tags, function(i, v) {
|
||||
tag_html += ('<a href="' + v[1] + '">' + v[0] + '</a> ');
|
||||
});
|
||||
|
||||
|
||||
$("#source-artist").html('<a href="' + data.profile_url + '">' + data.artist_name + '</a>');
|
||||
$("#source-tags").html(tag_html);
|
||||
|
||||
|
||||
var new_artist_link = '<a href="/artists/new?name=' + data.unique_id + '&other_names=' + data.artist_name + '&urls=' + encodeURIComponent(data.profile_url) + '+' + encodeURIComponent(data.image_url) + '">new</a>';
|
||||
|
||||
if (data.danbooru_id) {
|
||||
@@ -65,7 +65,7 @@
|
||||
} else {
|
||||
$("#source-record").html(new_artist_link);
|
||||
}
|
||||
|
||||
|
||||
$("#source-info p").hide();
|
||||
$("#source-info ul").show();
|
||||
});
|
||||
@@ -73,7 +73,7 @@
|
||||
});
|
||||
$("#fetch-data").trigger("click");
|
||||
}
|
||||
|
||||
|
||||
Danbooru.Upload.initialize_image = function() {
|
||||
var $image = $("#image");
|
||||
if ($image.size() > 0) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Danbooru.meta = function(key) {
|
||||
return $("meta[name=" + key + "]").attr("content");
|
||||
}
|
||||
|
||||
|
||||
Danbooru.scroll_to = function(element) {
|
||||
var top = null;
|
||||
if (typeof(element) === "number") {
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
Danbooru.is_subset = function(array, subarray) {
|
||||
var all = true;
|
||||
|
||||
|
||||
$.each(subarray, function(i, val) {
|
||||
if ($.inArray(val, array) === -1) {
|
||||
all = false;
|
||||
@@ -73,7 +73,7 @@
|
||||
});
|
||||
return filtered;
|
||||
}
|
||||
|
||||
|
||||
$.fn.selectRange = function(start, end) {
|
||||
return this.each(function() {
|
||||
if (this.setSelectionRange) {
|
||||
@@ -88,7 +88,7 @@
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
$.fn.selectEnd = function(){
|
||||
this.selectRange(this.val().length, this.val().length);
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user