Kill trailing whitespaces in javascript files

This commit is contained in:
小太
2013-03-19 23:09:22 +11:00
parent 35f1304157
commit c107f96cec
25 changed files with 128 additions and 128 deletions

View File

@@ -1,12 +1,12 @@
(function() { (function() {
Danbooru.Artist = {}; Danbooru.Artist = {};
Danbooru.Artist.initialize_all = function() { Danbooru.Artist.initialize_all = function() {
if ($("#c-artists").length) { if ($("#c-artists").length) {
Danbooru.Artist.initialize_check_name_link(); Danbooru.Artist.initialize_check_name_link();
} }
} }
Danbooru.Artist.initialize_check_name_link = function() { Danbooru.Artist.initialize_check_name_link = function() {
$("#check-name-link").click(function(e) { $("#check-name-link").click(function(e) {
var artist_name = $("#artist_name").val(); var artist_name = $("#artist_name").val();

View File

@@ -57,12 +57,12 @@
} }
}); });
} }
Danbooru.Blacklist.update_sidebar = function() { Danbooru.Blacklist.update_sidebar = function() {
if (this.blacklists.length > 0) { if (this.blacklists.length > 0) {
this.blacklists.unshift({"tags": "~all~", "hits": -1}); this.blacklists.unshift({"tags": "~all~", "hits": -1});
} }
$.each(this.blacklists, function(i, blacklist) { $.each(this.blacklists, function(i, blacklist) {
if (blacklist.hits === 0) { if (blacklist.hits === 0) {
return; return;
@@ -71,7 +71,7 @@
var item = $("<li/>"); var item = $("<li/>");
var link = $("<a/>"); var link = $("<a/>");
var count = $("<span/>"); var count = $("<span/>");
if (blacklist.tags === "~all~") { if (blacklist.tags === "~all~") {
link.html("All"); link.html("All");
link.click(Danbooru.Blacklist.toggle_all); link.click(Danbooru.Blacklist.toggle_all);
@@ -85,7 +85,7 @@
item.append(" "); item.append(" ");
item.append(count); item.append(count);
} }
$("#blacklist-list").append(item); $("#blacklist-list").append(item);
}); });

View File

@@ -1,23 +1,23 @@
(function() { (function() {
Danbooru.Comment = {}; Danbooru.Comment = {};
Danbooru.Comment.initialize_all = function() { Danbooru.Comment.initialize_all = function() {
if ($("#c-posts").length || $("#c-comments").length) { if ($("#c-posts").length || $("#c-comments").length) {
this.initialize_response_link(); this.initialize_response_link();
this.initialize_reply_links(); this.initialize_reply_links();
this.initialize_expand_links(); this.initialize_expand_links();
} }
if ($("#c-posts").length && $("#a-show").length) { if ($("#c-posts").length && $("#a-show").length) {
Danbooru.Comment.highlight_threshold_comments(Danbooru.meta("post-id")); Danbooru.Comment.highlight_threshold_comments(Danbooru.meta("post-id"));
} }
} }
Danbooru.Comment.quote_message = function(data) { Danbooru.Comment.quote_message = function(data) {
var stripped_body = data["body"].replace(/\[quote\](?:.|\n|\r)+?\[\/quote\](?:\r\n|\r|\n)*/gm, ""); 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"; return "[quote]\n" + data["creator_name"] + " said:\n" + stripped_body + "\n[/quote]\n\n";
} }
Danbooru.Comment.quote = function(e) { Danbooru.Comment.quote = function(e) {
$.get( $.get(
"/comments/" + $(e.target).data('comment-id') + ".json", "/comments/" + $(e.target).data('comment-id') + ".json",
@@ -36,11 +36,11 @@
); );
e.preventDefault(); e.preventDefault();
} }
Danbooru.Comment.initialize_reply_links = function() { Danbooru.Comment.initialize_reply_links = function() {
$(".reply-link").click(Danbooru.Comment.quote); $(".reply-link").click(Danbooru.Comment.quote);
} }
Danbooru.Comment.initialize_expand_links = function() { Danbooru.Comment.initialize_expand_links = function() {
$(".comment-section form").hide(); $(".comment-section form").hide();
$(".comment-section input.expand-comment-response").click(function(e) { $(".comment-section input.expand-comment-response").click(function(e) {
@@ -50,7 +50,7 @@
e.preventDefault(); e.preventDefault();
}); });
} }
Danbooru.Comment.initialize_response_link = function() { Danbooru.Comment.initialize_response_link = function() {
$("a.expand-comment-response").click(function(e) { $("a.expand-comment-response").click(function(e) {
$(e.target).hide(); $(e.target).hide();
@@ -59,10 +59,10 @@
Danbooru.scroll_to($form); Danbooru.scroll_to($form);
e.preventDefault(); e.preventDefault();
}); });
$("div.new-comment form").hide(); $("div.new-comment form").hide();
} }
Danbooru.Comment.highlight_threshold_comments = function(post_id) { Danbooru.Comment.highlight_threshold_comments = function(post_id) {
var threshold = parseInt(Danbooru.meta("user-comment-threshold")); var threshold = parseInt(Danbooru.meta("user-comment-threshold"));
var articles = $("article.comment[data-post-id=" + post_id + "]"); var articles = $("article.comment[data-post-id=" + post_id + "]");
@@ -73,7 +73,7 @@
} }
}) })
} }
Danbooru.Comment.hide_threshold_comments = function(post_id) { Danbooru.Comment.hide_threshold_comments = function(post_id) {
var threshold = parseInt(Danbooru.meta("user-comment-threshold")); var threshold = parseInt(Danbooru.meta("user-comment-threshold"));
var articles = $("article.comment[data-post-id=" + post_id + "]"); var articles = $("article.comment[data-post-id=" + post_id + "]");

View File

@@ -2,14 +2,14 @@ $(function() {
// Table striping // Table striping
$(".striped tbody tr:even").addClass("even"); $(".striped tbody tr:even").addClass("even");
$(".striped tbody tr:odd").addClass("odd"); $(".striped tbody tr:odd").addClass("odd");
// Account notices // Account notices
$("#hide-sign-up-notice").click(function(e) { $("#hide-sign-up-notice").click(function(e) {
$("#sign-up-notice").hide(); $("#sign-up-notice").hide();
Danbooru.Cookie.put("hide_sign_up_notice", "1", 7); Danbooru.Cookie.put("hide_sign_up_notice", "1", 7);
e.preventDefault(); e.preventDefault();
}); });
$("#hide-upgrade-account-notice").click(function(e) { $("#hide-upgrade-account-notice").click(function(e) {
$("#upgrade-account-notice").hide(); $("#upgrade-account-notice").hide();
Danbooru.Cookie.put('hide_upgrade_account_notice', '1', 7); Danbooru.Cookie.put('hide_upgrade_account_notice', '1', 7);

View File

@@ -1,6 +1,6 @@
(function() { (function() {
Danbooru.Cookie = {}; Danbooru.Cookie = {};
Danbooru.Cookie.put = function(name, value, days) { Danbooru.Cookie.put = function(name, value, days) {
if (days == null) { if (days == null) {
days = 365; days = 365;
@@ -11,7 +11,7 @@
var expires = "; expires=" + date.toGMTString(); var expires = "; expires=" + date.toGMTString();
document.cookie = name + "=" + encodeURIComponent(value) + expires + "; path=/"; document.cookie = name + "=" + encodeURIComponent(value) + expires + "; path=/";
} }
Danbooru.Cookie.raw_get = function(name) { Danbooru.Cookie.raw_get = function(name) {
var nameEq = name + "="; var nameEq = name + "=";
var ca = document.cookie.split(";"); var ca = document.cookie.split(";");
@@ -30,11 +30,11 @@
return ""; return "";
} }
Danbooru.Cookie.get = function(name) { Danbooru.Cookie.get = function(name) {
return this.unescape(this.raw_get(name)); return this.unescape(this.raw_get(name));
} }
Danbooru.Cookie.remove = function(name) { Danbooru.Cookie.remove = function(name) {
this.put(name, "", -1); this.put(name, "", -1);
} }
@@ -45,7 +45,7 @@
Danbooru.Cookie.initialize = function() { Danbooru.Cookie.initialize = function() {
var loc = location.href; var loc = location.href;
if (loc.match(/^http/)) { if (loc.match(/^http/)) {
loc = loc.replace(/^https?:\/\/[^\/]+/, "") loc = loc.replace(/^https?:\/\/[^\/]+/, "")
} }

View File

@@ -1,11 +1,11 @@
(function() { (function() {
Danbooru.Dtext = {}; Danbooru.Dtext = {};
Danbooru.Dtext.initialize_links = function() { Danbooru.Dtext.initialize_links = function() {
$(".simple_form .dtext-preview").hide(); $(".simple_form .dtext-preview").hide();
$(".simple_form input[value=Preview]").click(Danbooru.Dtext.click_button); $(".simple_form input[value=Preview]").click(Danbooru.Dtext.click_button);
} }
Danbooru.Dtext.call_preview = function(e, $button, $input, $preview) { Danbooru.Dtext.call_preview = function(e, $button, $input, $preview) {
$.ajax({ $.ajax({
type: "post", type: "post",
@@ -20,18 +20,18 @@
} }
}); });
} }
Danbooru.Dtext.call_edit = function(e, $button, $input, $preview) { Danbooru.Dtext.call_edit = function(e, $button, $input, $preview) {
$button.val("Preview"); $button.val("Preview");
$preview.hide(); $preview.hide();
$input.slideDown("fast"); $input.slideDown("fast");
} }
Danbooru.Dtext.click_button = function(e) { Danbooru.Dtext.click_button = function(e) {
var $button = $(e.target); var $button = $(e.target);
var $input = $("#" + $button.data("input-id")); var $input = $("#" + $button.data("input-id"));
var $preview = $("#" + $button.data("preview-id")); var $preview = $("#" + $button.data("preview-id"));
if ($button.val().match(/preview/i)) { if ($button.val().match(/preview/i)) {
Danbooru.Dtext.call_preview(e, $button, $input, $preview); Danbooru.Dtext.call_preview(e, $button, $input, $preview);
} else { } else {

View File

@@ -1,12 +1,12 @@
(function() { (function() {
Danbooru.Favorite = {}; Danbooru.Favorite = {};
Danbooru.Favorite.initialize_all = function() { Danbooru.Favorite.initialize_all = function() {
if ($("#c-posts").length) { if ($("#c-posts").length) {
this.hide_or_show_add_to_favorites_link(); this.hide_or_show_add_to_favorites_link();
} }
} }
Danbooru.Favorite.hide_or_show_add_to_favorites_link = function() { Danbooru.Favorite.hide_or_show_add_to_favorites_link = function() {
var favorites = Danbooru.meta("favorites"); var favorites = Danbooru.meta("favorites");
var current_user_id = Danbooru.meta("current-user-id"); var current_user_id = Danbooru.meta("current-user-id");
@@ -19,13 +19,13 @@
if ((favorites != undefined) && (favorites.match(regexp))) { if ((favorites != undefined) && (favorites.match(regexp))) {
$("#add-to-favorites").hide(); $("#add-to-favorites").hide();
} else { } else {
$("#remove-from-favorites").hide(); $("#remove-from-favorites").hide();
} }
} }
Danbooru.Favorite.create = function(post_id) { Danbooru.Favorite.create = function(post_id) {
Danbooru.Post.notice_update("inc"); Danbooru.Post.notice_update("inc");
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/favorites", url: "/favorites",
@@ -40,10 +40,10 @@
} }
}); });
} }
Danbooru.Favorite.destroy = function(post_id) { Danbooru.Favorite.destroy = function(post_id) {
Danbooru.Post.notice_update("inc"); Danbooru.Post.notice_update("inc");
$.ajax({ $.ajax({
type: "DELETE", type: "DELETE",
url: "/favorites/" + post_id, url: "/favorites/" + post_id,

View File

@@ -18,7 +18,7 @@
}); });
e.preventDefault(); e.preventDefault();
}); });
} }
} }
})(); })();

View File

@@ -1,11 +1,11 @@
$(function() { $(function() {
var $sidebar = $("#sidebar"); var $sidebar = $("#sidebar");
var $content = $("#content"); var $content = $("#content");
if (!$sidebar.length || !$content.length) { if (!$sidebar.length || !$content.length) {
return; return;
} }
var sidebar_offset = $sidebar.offset().top + $sidebar.height(); var sidebar_offset = $sidebar.offset().top + $sidebar.height();
var content_offset = $content.offset().top + $content.height(); var content_offset = $content.offset().top + $content.height();
var offset = null; var offset = null;

View File

@@ -1,6 +1,6 @@
(function() { (function() {
Danbooru.ModQueue = {}; Danbooru.ModQueue = {};
Danbooru.ModQueue.initialize_approve_all_button = function() { Danbooru.ModQueue.initialize_approve_all_button = function() {
$("#approve-all-button").click(function(e) { $("#approve-all-button").click(function(e) {
if (!confirm("Are you sure you want to approve every post on this page?")) { if (!confirm("Are you sure you want to approve every post on this page?")) {
@@ -11,7 +11,7 @@
e.preventDefault(); e.preventDefault();
}); });
} }
Danbooru.ModQueue.initialize_hide_all_button = function() { Danbooru.ModQueue.initialize_hide_all_button = function() {
$("#hide-all-button").click(function(e) { $("#hide-all-button").click(function(e) {
if (!confirm("Are you sure you want to hide every post on this page?")) { if (!confirm("Are you sure you want to hide every post on this page?")) {
@@ -22,7 +22,7 @@
e.preventDefault(); e.preventDefault();
}); });
} }
Danbooru.ModQueue.initialize_hilights = function() { Danbooru.ModQueue.initialize_hilights = function() {
$.each($("article.post"), function(i, v) { $.each($("article.post"), function(i, v) {
var $post = $(v); var $post = $(v);

View File

@@ -1,19 +1,19 @@
(function() { (function() {
Danbooru.NewsUpdate = {}; Danbooru.NewsUpdate = {};
Danbooru.NewsUpdate.initialize = function() { Danbooru.NewsUpdate.initialize = function() {
var key = $("#news-updates").data("updated-at"); var key = $("#news-updates").data("updated-at");
if (Danbooru.Cookie.get("news-ticker") === key) { if (Danbooru.Cookie.get("news-ticker") === key) {
$("#news-updates").hide(); $("#news-updates").hide();
} else { } else {
$("#close-news-ticker-link").click(function(e) { $("#close-news-ticker-link").click(function(e) {
$("#news-updates").hide(); $("#news-updates").hide();
Danbooru.Cookie.put("news-ticker", key); Danbooru.Cookie.put("news-ticker", key);
// need to reset the more link // 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; return false;
}); });
} }

View File

@@ -383,14 +383,14 @@ Danbooru.Note = {
TranslationMode: { TranslationMode: {
active: false, active: false,
start: function(e) { start: function(e) {
e.preventDefault(); e.preventDefault();
if (Danbooru.Note.TranslationMode.active) { if (Danbooru.Note.TranslationMode.active) {
return; return;
} }
Danbooru.Note.TranslationMode.active = true; Danbooru.Note.TranslationMode.active = true;
$("#original-file-link").click(); $("#original-file-link").click();
$("#image").one("click", Danbooru.Note.TranslationMode.create_note); $("#image").one("click", Danbooru.Note.TranslationMode.create_note);

View File

@@ -1,6 +1,6 @@
(function() { (function() {
Danbooru.Paginator = {}; Danbooru.Paginator = {};
Danbooru.Paginator.next_page = function() { Danbooru.Paginator.next_page = function() {
var href = $(".paginator a[rel=next]").attr("href"); var href = $(".paginator a[rel=next]").attr("href");
if (href) { if (href) {

View File

@@ -1,19 +1,19 @@
(function() { (function() {
Danbooru.Pool = {}; Danbooru.Pool = {};
Danbooru.Pool.initialize_all = function() { Danbooru.Pool.initialize_all = function() {
if ($("#c-posts").length && $("#a-show").length) { if ($("#c-posts").length && $("#a-show").length) {
this.initialize_add_to_pool_link(); this.initialize_add_to_pool_link();
} }
if ($("#c-pool-orders").length) { if ($("#c-pool-orders").length) {
this.initialize_simple_edit(); this.initialize_simple_edit();
} }
} }
Danbooru.Pool.initialize_add_to_pool_link = function() { Danbooru.Pool.initialize_add_to_pool_link = function() {
$("#add-to-pool-dialog").dialog({autoOpen: false}); $("#add-to-pool-dialog").dialog({autoOpen: false});
$("#c-pool-elements #a-new input[type=text]").autocomplete({ $("#c-pool-elements #a-new input[type=text]").autocomplete({
source: function(req, resp) { source: function(req, resp) {
$.getJSON( $.getJSON(
@@ -25,24 +25,24 @@
}, },
minLength: 2, minLength: 2,
}); });
$("#pool").click(function(e) { $("#pool").click(function(e) {
e.preventDefault(); e.preventDefault();
$("#add-to-pool-dialog").dialog("open"); $("#add-to-pool-dialog").dialog("open");
}); });
$("#recent-pools li").click(function(e) { $("#recent-pools li").click(function(e) {
e.preventDefault(); e.preventDefault();
$("#pool_name").val($(this).html()); $("#pool_name").val($(this).html());
}); });
} }
Danbooru.Pool.initialize_simple_edit = function() { Danbooru.Pool.initialize_simple_edit = function() {
$("#sortable").sortable({ $("#sortable").sortable({
placeholder: "ui-state-placeholder" placeholder: "ui-state-placeholder"
}); });
$("#sortable").disableSelection(); $("#sortable").disableSelection();
$("#ordering-form").submit(function(e) { $("#ordering-form").submit(function(e) {
$.ajax({ $.ajax({
type: "put", type: "put",

View File

@@ -1,22 +1,22 @@
(function() { (function() {
Danbooru.PostAppeal = {}; Danbooru.PostAppeal = {};
Danbooru.PostAppeal.initialize_all = function() { Danbooru.PostAppeal.initialize_all = function() {
if ($("#c-posts").length && $("#a-show").length) { if ($("#c-posts").length && $("#a-show").length) {
this.initialize_appeal(); this.initialize_appeal();
this.hide_or_show_appeal_link(); this.hide_or_show_appeal_link();
} }
} }
Danbooru.PostAppeal.hide_or_show_appeal_link = function() { Danbooru.PostAppeal.hide_or_show_appeal_link = function() {
if (Danbooru.meta("post-is-flagged") !== "true") { if (Danbooru.meta("post-is-flagged") !== "true") {
$("#appeal").hide(); $("#appeal").hide();
} }
} }
Danbooru.PostAppeal.initialize_appeal = function() { Danbooru.PostAppeal.initialize_appeal = function() {
$("#appeal-dialog").dialog({ $("#appeal-dialog").dialog({
autoOpen: false, autoOpen: false,
width: 700, width: 700,
modal: true, modal: true,
buttons: { buttons: {

View File

@@ -1,22 +1,22 @@
(function() { (function() {
Danbooru.PostFlag = {}; Danbooru.PostFlag = {};
Danbooru.PostFlag.initialize_all = function() { Danbooru.PostFlag.initialize_all = function() {
if ($("#c-posts").length && $("#a-show").length) { if ($("#c-posts").length && $("#a-show").length) {
this.initialize_flag(); this.initialize_flag();
this.hide_or_show_flag_link(); this.hide_or_show_flag_link();
} }
} }
Danbooru.PostFlag.hide_or_show_flag_link = function() { Danbooru.PostFlag.hide_or_show_flag_link = function() {
if (Danbooru.meta("post-is-deleted") === "true") { if (Danbooru.meta("post-is-deleted") === "true") {
$("#flag").hide(); $("#flag").hide();
} }
} }
Danbooru.PostFlag.initialize_flag = function() { Danbooru.PostFlag.initialize_flag = function() {
$("#flag-dialog").dialog({ $("#flag-dialog").dialog({
autoOpen: false, autoOpen: false,
width: 700, width: 700,
modal: true, modal: true,
buttons: { buttons: {

View File

@@ -1,6 +1,6 @@
(function() { (function() {
Danbooru.PostModeMenu = {}; Danbooru.PostModeMenu = {};
Danbooru.PostModeMenu.initialize = function() { Danbooru.PostModeMenu.initialize = function() {
if ($("#c-posts").length || $("#c-favorites").length || $("#c-pools").length) { if ($("#c-posts").length || $("#c-favorites").length || $("#c-pools").length) {
this.initialize_selector(); this.initialize_selector();
@@ -9,7 +9,7 @@
Danbooru.PostModeMenu.change(); Danbooru.PostModeMenu.change();
} }
} }
Danbooru.PostModeMenu.initialize_selector = function() { Danbooru.PostModeMenu.initialize_selector = function() {
if (Danbooru.Cookie.get("mode") === "") { if (Danbooru.Cookie.get("mode") === "") {
Danbooru.Cookie.put("mode", "view"); Danbooru.Cookie.put("mode", "view");
@@ -20,18 +20,18 @@
$("#mode-box select").change(Danbooru.PostModeMenu.change); $("#mode-box select").change(Danbooru.PostModeMenu.change);
} }
Danbooru.PostModeMenu.initialize_preview_link = function() { Danbooru.PostModeMenu.initialize_preview_link = function() {
$(".post-preview a").click(Danbooru.PostModeMenu.click); $(".post-preview a").click(Danbooru.PostModeMenu.click);
} }
Danbooru.PostModeMenu.initialize_edit_form = function() { Danbooru.PostModeMenu.initialize_edit_form = function() {
$("#quick-edit-div").hide(); $("#quick-edit-div").hide();
$("#quick-edit-form input[value=Cancel]").click(function(e) { $("#quick-edit-form input[value=Cancel]").click(function(e) {
$("#quick-edit-div").slideUp("fast"); $("#quick-edit-div").slideUp("fast");
e.preventDefault(); e.preventDefault();
}); });
$("#quick-edit-form").submit(function(e) { $("#quick-edit-form").submit(function(e) {
$.ajax({ $.ajax({
type: "put", type: "put",
@@ -47,11 +47,11 @@
Danbooru.notice("Post #" + data.id + " updated"); Danbooru.notice("Post #" + data.id + " updated");
} }
}); });
e.preventDefault(); e.preventDefault();
}); });
} }
Danbooru.PostModeMenu.change = function(e) { Danbooru.PostModeMenu.change = function(e) {
$("#quick-edit-div").slideUp("fast"); $("#quick-edit-div").slideUp("fast");
var s = $("#mode-box select").val(); var s = $("#mode-box select").val();
@@ -62,11 +62,11 @@
$body.removeClass(); $body.removeClass();
$body.addClass("mode-" + s); $body.addClass("mode-" + s);
Danbooru.Cookie.put("mode", s, 1); Danbooru.Cookie.put("mode", s, 1);
if (s === "edit-tag-script") { if (s === "edit-tag-script") {
var script = Danbooru.Cookie.get("tag-script"); var script = Danbooru.Cookie.get("tag-script");
script = prompt("Enter a tag script", script); script = prompt("Enter a tag script", script);
if (script) { if (script) {
Danbooru.Cookie.put("tag-script", script); Danbooru.Cookie.put("tag-script", script);
$("#mode-box select").val("apply-tag-script"); $("#mode-box select").val("apply-tag-script");
@@ -77,18 +77,18 @@
Danbooru.PostModeMenu.change(e); Danbooru.PostModeMenu.change(e);
} }
} }
Danbooru.PostModeMenu.open_edit = function(post_id) { Danbooru.PostModeMenu.open_edit = function(post_id) {
var $post = $("#post_" + post_id); var $post = $("#post_" + post_id);
$("#quick-edit-div").slideDown("fast"); $("#quick-edit-div").slideDown("fast");
$("#quick-edit-form").attr("action", "/posts/" + post_id + ".json"); $("#quick-edit-form").attr("action", "/posts/" + post_id + ".json");
$("#post_tag_string").val($post.data("tags")).focus(); $("#post_tag_string").val($post.data("tags")).focus();
} }
Danbooru.PostModeMenu.click = function(e) { Danbooru.PostModeMenu.click = function(e) {
var s = $("#mode-box select").val(); var s = $("#mode-box select").val();
var post_id = $(e.target).closest("article").data("id"); var post_id = $(e.target).closest("article").data("id");
if (s === "add-fav") { if (s === "add-fav") {
Danbooru.Favorite.create(post_id); Danbooru.Favorite.create(post_id);
} else if (s === "remove-fav") { } else if (s === "remove-fav") {
@@ -117,7 +117,7 @@
} else { } else {
return; return;
} }
e.preventDefault(); e.preventDefault();
} }
})(); })();

View File

@@ -1,20 +1,20 @@
(function() { (function() {
Danbooru.PostModeration = {}; Danbooru.PostModeration = {};
Danbooru.PostModeration.initialize_all = function() { Danbooru.PostModeration.initialize_all = function() {
if ($("#c-posts").length && $("#a-show").length) { if ($("#c-posts").length && $("#a-show").length) {
this.hide_or_show_approve_and_disapprove_links(); this.hide_or_show_approve_and_disapprove_links();
this.hide_or_show_delete_and_undelete_links(); this.hide_or_show_delete_and_undelete_links();
} }
} }
Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() { Danbooru.PostModeration.hide_or_show_approve_and_disapprove_links = function() {
if (Danbooru.meta("post-is-approvable") !== "true") { if (Danbooru.meta("post-is-approvable") !== "true") {
$("#approve").hide(); $("#approve").hide();
$("#disapprove").hide(); $("#disapprove").hide();
} }
} }
Danbooru.PostModeration.hide_or_show_delete_and_undelete_links = function() { Danbooru.PostModeration.hide_or_show_delete_and_undelete_links = function() {
if (Danbooru.meta("post-is-deleted") === "true") { if (Danbooru.meta("post-is-deleted") === "true") {
$("#delete").hide(); $("#delete").hide();

View File

@@ -9,7 +9,7 @@
} }
} }
} }
Danbooru.PostPopular.nav_next = function() { Danbooru.PostPopular.nav_next = function() {
if ($("#popular-nav-links").length) { if ($("#popular-nav-links").length) {
var href = $("#popular-nav-links a[rel=next]").attr("href"); var href = $("#popular-nav-links a[rel=next]").attr("href");

View File

@@ -29,7 +29,7 @@
} }
} }
} }
Danbooru.Post.initialize_similar = function() { Danbooru.Post.initialize_similar = function() {
$("#similar-button").click(function(e) { $("#similar-button").click(function(e) {
var old_source_name = $("#post_source").attr("name"); var old_source_name = $("#post_source").attr("name");
@@ -44,11 +44,11 @@
$("#post_source").attr("name", old_source_name); $("#post_source").attr("name", old_source_name);
$("#form").attr("target", ""); $("#form").attr("target", "");
$("#form").attr("action", old_action); $("#form").attr("action", old_action);
e.preventDefault(); e.preventDefault();
}); });
} }
Danbooru.Post.nav_prev = function() { Danbooru.Post.nav_prev = function() {
if ($("#search-seq-nav").length) { if ($("#search-seq-nav").length) {
var href = $("#search-seq-nav a[rel=prev]").attr("href"); var href = $("#search-seq-nav a[rel=prev]").attr("href");
@@ -62,7 +62,7 @@
} }
} }
} }
Danbooru.Post.nav_next = function() { Danbooru.Post.nav_next = function() {
if ($("#search-seq-nav").length) { if ($("#search-seq-nav").length) {
var href = $("#search-seq-nav a[rel=next]").attr("href"); var href = $("#search-seq-nav a[rel=next]").attr("href");
@@ -74,7 +74,7 @@
} }
} }
} }
Danbooru.Post.nav_scroll_down = function() { Danbooru.Post.nav_scroll_down = function() {
var scroll_top = $(window).scrollTop() + ($(window).height() * 0.85); var scroll_top = $(window).scrollTop() + ($(window).height() * 0.85);
Danbooru.scroll_to(scroll_top); Danbooru.scroll_to(scroll_top);
@@ -316,7 +316,7 @@
} }
}); });
} }
Danbooru.Post.approve = function(post_id) { Danbooru.Post.approve = function(post_id) {
$.ajax({ $.ajax({
type: "POST", type: "POST",

View File

@@ -1,6 +1,6 @@
(function() { (function() {
Danbooru.RelatedTag = {}; Danbooru.RelatedTag = {};
Danbooru.RelatedTag.initialize_all = function() { Danbooru.RelatedTag.initialize_all = function() {
if ($("#c-posts").length || $("#c-uploads").length) { if ($("#c-posts").length || $("#c-uploads").length) {
this.initialize_buttons(); this.initialize_buttons();
@@ -8,7 +8,7 @@
$("#artist-tags-container").hide(); $("#artist-tags-container").hide();
} }
} }
Danbooru.RelatedTag.initialize_buttons = function() { Danbooru.RelatedTag.initialize_buttons = function() {
this.common_bind("#related-tags-button", ""); this.common_bind("#related-tags-button", "");
this.common_bind("#related-artists-button", "artist"); this.common_bind("#related-artists-button", "artist");
@@ -22,7 +22,7 @@
} }
} }
} }
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>"); $("#related-tags").html("<em>Loading...</em>");
@@ -35,7 +35,7 @@
e.preventDefault(); e.preventDefault();
}); });
} }
Danbooru.RelatedTag.current_tag = function() { Danbooru.RelatedTag.current_tag = function() {
// 1. abc def | -> def // 1. abc def | -> def
// 2. abc def| -> def // 2. abc def| -> def
@@ -45,7 +45,7 @@
// 6. ab|c def -> abc // 6. ab|c def -> abc
// 7. |abc def -> abc // 7. |abc def -> abc
// 8. | abc def -> abc -- not supported by this code but a pretty rare case // 8. | abc def -> abc -- not supported by this code but a pretty rare case
var $field = $("#upload_tag_string,#post_tag_string"); var $field = $("#upload_tag_string,#post_tag_string");
var string = $field.val().trim(); var string = $field.val().trim();
var n = string.length; var n = string.length;
@@ -55,7 +55,7 @@
if ((a > 0) && (a < (n - 1)) && (string[a] !== " ") && (string[a - 1] === " ")) { 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 // 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. // can drag a backwards, and then drag b forwards.
while ((b < n) && (string[b] !== " ")) { while ((b < n) && (string[b] !== " ")) {
b++; b++;
} }
@@ -64,39 +64,39 @@
a--; a--;
b--; b--;
} }
while ((a > 0) && (string[a - 1] !== " ")) { while ((a > 0) && (string[a - 1] !== " ")) {
a--; a--;
b--; b--;
} }
while ((b < (n - 1)) && (string[b] !== " ")) { while ((b < (n - 1)) && (string[b] !== " ")) {
b++; b++;
} }
} }
b++; b++;
return string.slice(a, b); return string.slice(a, b);
} }
Danbooru.RelatedTag.process_response = function(data) { Danbooru.RelatedTag.process_response = function(data) {
Danbooru.RelatedTag.recent_search = data; Danbooru.RelatedTag.recent_search = data;
Danbooru.RelatedTag.build_all(); Danbooru.RelatedTag.build_all();
} }
Danbooru.RelatedTag.build_all = function() { Danbooru.RelatedTag.build_all = function() {
if (Danbooru.RelatedTag.recent_search === null || Danbooru.RelatedTag.recent_search === undefined) { if (Danbooru.RelatedTag.recent_search === null || Danbooru.RelatedTag.recent_search === undefined) {
return; return;
} }
$("#related-tags").show(); $("#related-tags").show();
var query = Danbooru.RelatedTag.recent_search.query; var query = Danbooru.RelatedTag.recent_search.query;
var related_tags = Danbooru.RelatedTag.recent_search.tags.sort(); var related_tags = Danbooru.RelatedTag.recent_search.tags.sort();
var wiki_page_tags = Danbooru.RelatedTag.recent_search.wiki_page_tags; var wiki_page_tags = Danbooru.RelatedTag.recent_search.wiki_page_tags;
var $dest = $("#related-tags"); var $dest = $("#related-tags");
$dest.empty(); $dest.empty();
if (Danbooru.Cookie.get("recent_tags")) { if (Danbooru.Cookie.get("recent_tags")) {
$dest.append(Danbooru.RelatedTag.build_html("recent", Danbooru.RelatedTag.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)); $dest.append(Danbooru.RelatedTag.build_html("wiki:" + query, wiki_page_tags));
} }
} }
Danbooru.RelatedTag.favorite_tags = function() { Danbooru.RelatedTag.favorite_tags = function() {
var string = Danbooru.meta("favorite-tags"); var string = Danbooru.meta("favorite-tags");
if (string) { if (string) {
@@ -119,7 +119,7 @@
return []; return [];
} }
} }
Danbooru.RelatedTag.recent_tags = function() { Danbooru.RelatedTag.recent_tags = function() {
var string = Danbooru.Cookie.get("recent_tags"); var string = Danbooru.Cookie.get("recent_tags");
if (string && string.length) { if (string && string.length) {
@@ -130,7 +130,7 @@
return []; return [];
} }
} }
Danbooru.RelatedTag.build_html = function(query, related_tags) { Danbooru.RelatedTag.build_html = function(query, related_tags) {
if (query === null || query === "") { if (query === null || query === "") {
return ""; return "";
@@ -146,7 +146,7 @@
) )
) )
); );
$.each(related_tags, function(i, tag) { $.each(related_tags, function(i, tag) {
var $link = $("<a/>"); var $link = $("<a/>");
$link.html(tag[0].replace(/_/g, " ")); $link.html(tag[0].replace(/_/g, " "));
@@ -160,11 +160,11 @@
$("<li/>").append($link) $("<li/>").append($link)
); );
}); });
$div.append($ul); $div.append($ul);
return $div; return $div;
} }
Danbooru.RelatedTag.toggle_tag = function(e) { Danbooru.RelatedTag.toggle_tag = function(e) {
var $field = $("#upload_tag_string,#post_tag_string"); var $field = $("#upload_tag_string,#post_tag_string");
var tags = $field.val().match(/\S+/g) || []; var tags = $field.val().match(/\S+/g) || [];
@@ -180,7 +180,7 @@
Danbooru.RelatedTag.build_all(); Danbooru.RelatedTag.build_all();
e.preventDefault(); e.preventDefault();
} }
Danbooru.RelatedTag.find_artist = function(e) { Danbooru.RelatedTag.find_artist = function(e) {
$("#artist-tags").html("<em>Loading...</em>"); $("#artist-tags").html("<em>Loading...</em>");
Danbooru.RelatedTag.recent_search = null; Danbooru.RelatedTag.recent_search = null;
@@ -188,12 +188,12 @@
$.get("/artists.json", {"search[name]": url.val()}).success(Danbooru.RelatedTag.process_artist); $.get("/artists.json", {"search[name]": url.val()}).success(Danbooru.RelatedTag.process_artist);
e.preventDefault(); e.preventDefault();
} }
Danbooru.RelatedTag.process_artist = function(data) { Danbooru.RelatedTag.process_artist = function(data) {
$("#artist-tags-container").show(); $("#artist-tags-container").show();
var $dest = $("#artist-tags"); var $dest = $("#artist-tags");
$dest.empty(); $dest.empty();
if (data.length === 0) { if (data.length === 0) {
$dest.html("No artists found"); $dest.html("No artists found");
return; return;
@@ -201,7 +201,7 @@
$dest.html("Too many matching artists found"); $dest.html("Too many matching artists found");
return; return;
} }
$.each(data, function(i, json) { $.each(data, function(i, json) {
if (!json.other_names) { if (!json.other_names) {
json.other_names = ""; json.other_names = "";

View File

@@ -1,6 +1,6 @@
(function() { (function() {
Danbooru.Sources = {}; Danbooru.Sources = {};
Danbooru.Sources.get = function(url) { Danbooru.Sources.get = function(url) {
$.get("/sources.json", { $.get("/sources.json", {
url: url url: url

View File

@@ -4,7 +4,7 @@
Danbooru.TagScript.parse = function(script) { Danbooru.TagScript.parse = function(script) {
return script.match(/\[.+?\]|\S+/g); return script.match(/\[.+?\]|\S+/g);
} }
Danbooru.TagScript.test = function(tags, predicate) { Danbooru.TagScript.test = function(tags, predicate) {
var split_pred = predicate.match(/\S+/g); var split_pred = predicate.match(/\S+/g);
var is_true = true; var is_true = true;
@@ -46,7 +46,7 @@
var commands = Danbooru.TagScript.parse(tag_script); var commands = Danbooru.TagScript.parse(tag_script);
var $post = $("#post_" + post_id); var $post = $("#post_" + post_id);
var old_tags = $post.data("tags"); var old_tags = $post.data("tags");
$.each(commands, function(i, x) { $.each(commands, function(i, x) {
var array = String($post.data("tags")).match(/\S+/g); var array = String($post.data("tags")).match(/\S+/g);
$post.data("tags", Danbooru.TagScript.process(array, x).join(" ")); $post.data("tags", Danbooru.TagScript.process(array, x).join(" "));

View File

@@ -1,11 +1,11 @@
(function() { (function() {
Danbooru.Upload = {}; Danbooru.Upload = {};
Danbooru.Upload.initialize_all = function() { Danbooru.Upload.initialize_all = function() {
if ($("#c-uploads,#c-posts").length) { if ($("#c-uploads,#c-posts").length) {
this.initialize_enter_on_tags(); this.initialize_enter_on_tags();
} }
if ($("#c-uploads").length) { if ($("#c-uploads").length) {
this.initialize_image(); this.initialize_image();
this.initialize_info(); this.initialize_info();
@@ -15,7 +15,7 @@
} }
} }
} }
Danbooru.Upload.initialize_enter_on_tags = function() { Danbooru.Upload.initialize_enter_on_tags = function() {
$("#upload_tag_string,#post_tag_string").bind("keydown.return", function(e) { $("#upload_tag_string,#post_tag_string").bind("keydown.return", function(e) {
$("#form").trigger("submit"); $("#form").trigger("submit");
@@ -41,11 +41,11 @@
$("#upload_file").attr("name", old_file_name); $("#upload_file").attr("name", old_file_name);
$("#form").attr("target", ""); $("#form").attr("target", "");
$("#form").attr("action", old_action); $("#form").attr("action", old_action);
e.preventDefault(); e.preventDefault();
}); });
} }
Danbooru.Upload.initialize_info = function() { Danbooru.Upload.initialize_info = function() {
$("#source-info ul").hide(); $("#source-info ul").hide();
$("#fetch-data").click(function(e) { $("#fetch-data").click(function(e) {
@@ -54,10 +54,10 @@
$.each(data.tags, function(i, v) { $.each(data.tags, function(i, v) {
tag_html += ('<a href="' + v[1] + '">' + v[0] + '</a> '); tag_html += ('<a href="' + v[1] + '">' + v[0] + '</a> ');
}); });
$("#source-artist").html('<a href="' + data.profile_url + '">' + data.artist_name + '</a>'); $("#source-artist").html('<a href="' + data.profile_url + '">' + data.artist_name + '</a>');
$("#source-tags").html(tag_html); $("#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>'; 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) { if (data.danbooru_id) {
@@ -65,7 +65,7 @@
} else { } else {
$("#source-record").html(new_artist_link); $("#source-record").html(new_artist_link);
} }
$("#source-info p").hide(); $("#source-info p").hide();
$("#source-info ul").show(); $("#source-info ul").show();
}); });
@@ -73,7 +73,7 @@
}); });
$("#fetch-data").trigger("click"); $("#fetch-data").trigger("click");
} }
Danbooru.Upload.initialize_image = function() { Danbooru.Upload.initialize_image = function() {
var $image = $("#image"); var $image = $("#image");
if ($image.size() > 0) { if ($image.size() > 0) {

View File

@@ -2,7 +2,7 @@
Danbooru.meta = function(key) { Danbooru.meta = function(key) {
return $("meta[name=" + key + "]").attr("content"); return $("meta[name=" + key + "]").attr("content");
} }
Danbooru.scroll_to = function(element) { Danbooru.scroll_to = function(element) {
var top = null; var top = null;
if (typeof(element) === "number") { if (typeof(element) === "number") {
@@ -26,7 +26,7 @@
Danbooru.is_subset = function(array, subarray) { Danbooru.is_subset = function(array, subarray) {
var all = true; var all = true;
$.each(subarray, function(i, val) { $.each(subarray, function(i, val) {
if ($.inArray(val, array) === -1) { if ($.inArray(val, array) === -1) {
all = false; all = false;
@@ -73,7 +73,7 @@
}); });
return filtered; return filtered;
} }
$.fn.selectRange = function(start, end) { $.fn.selectRange = function(start, end) {
return this.each(function() { return this.each(function() {
if (this.setSelectionRange) { if (this.setSelectionRange) {
@@ -88,7 +88,7 @@
} }
}); });
}; };
$.fn.selectEnd = function(){ $.fn.selectEnd = function(){
this.selectRange(this.val().length, this.val().length); this.selectRange(this.val().length, this.val().length);
return this; return this;