js: fix eslint warnings.

This commit is contained in:
evazion
2019-08-18 03:50:43 -05:00
parent f2937e3d27
commit 6019a9fdc4
3 changed files with 18 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ env:
extends: 'eslint:recommended' extends: 'eslint:recommended'
parserOptions: parserOptions:
sourceType: module sourceType: module
ecmaVersion: 2017
globals: globals:
$: false $: false
require: false require: false

View File

@@ -107,7 +107,7 @@ PostTooltip.on_disable_tooltips = function (event) {
$(event.target).parents(".qtip").qtip("hide"); $(event.target).parents(".qtip").qtip("hide");
if (Utility.meta("current-user-id") === "") { if (Utility.meta("current-user-id") === "") {
Danbooru.notice('<a href="/session/new">Login</a> to disable tooltips permanently'); Utility.notice('<a href="/session/new">Login</a> to disable tooltips permanently');
return; return;
} }
@@ -115,7 +115,7 @@ PostTooltip.on_disable_tooltips = function (event) {
method: "PUT", method: "PUT",
data: { "user[disable_post_tooltips]": "true" }, data: { "user[disable_post_tooltips]": "true" },
}).then(function() { }).then(function() {
Danbooru.notice("Tooltips disabled; check your account settings to re-enable."); Utility.notice("Tooltips disabled; check your account settings to re-enable.");
location.reload(); location.reload();
}); });
}; };

View File

@@ -69,7 +69,7 @@ Post.initialize_gestures = function() {
if (hasPrev) { if (hasPrev) {
hammer.on("swiperight", async function(e) { hammer.on("swiperight", async function(e) {
$("body").css({"transition-timing-function": "ease", "transition-duration": "0.2s", "opacity": "0", "transform": "translateX(150%)"}); $("body").css({"transition-timing-function": "ease", "transition-duration": "0.2s", "opacity": "0", "transform": "translateX(150%)"});
await Danbooru.Utility.delay(200); await Utility.delay(200);
Post.swipe_prev(e); Post.swipe_prev(e);
}); });
} }
@@ -77,7 +77,7 @@ Post.initialize_gestures = function() {
if (hasNext) { if (hasNext) {
hammer.on("swipeleft", async function(e) { hammer.on("swipeleft", async function(e) {
$("body").css({"transition-timing-function": "ease", "transition-duration": "0.2s", "opacity": "0", "transform": "translateX(-150%)"}); $("body").css({"transition-timing-function": "ease", "transition-duration": "0.2s", "opacity": "0", "transform": "translateX(-150%)"});
await Danbooru.Utility.delay(200); await Utility.delay(200);
Post.swipe_next(e); Post.swipe_next(e);
}); });
} }
@@ -251,15 +251,15 @@ Post.initialize_links = function() {
other_post_id: other_post_id other_post_id: other_post_id
}, },
success: function(data) { success: function(data) {
Danbooru.notice("Successfully copied notes to <a href='" + other_post_id + "'>post #" + other_post_id + "</a>"); Utility.notice("Successfully copied notes to <a href='" + other_post_id + "'>post #" + other_post_id + "</a>");
}, },
error: function(data) { error: function(data) {
if (data.status === 404) { if (data.status === 404) {
Danbooru.error("Error: Invalid destination post"); Utility.error("Error: Invalid destination post");
} else if (data.responseJSON && data.responseJSON.reason) { } else if (data.responseJSON && data.responseJSON.reason) {
Danbooru.error("Error: " + data.responseJSON.reason); Utility.error("Error: " + data.responseJSON.reason);
} else { } else {
Danbooru.error("There was an error copying notes to <a href='" + other_post_id + "'>post #" + other_post_id + "</a>"); Utility.error("There was an error copying notes to <a href='" + other_post_id + "'>post #" + other_post_id + "</a>");
} }
} }
}); });
@@ -467,14 +467,14 @@ Post.resize_ugoira_controls = function() {
Post.notice_update = function(x) { Post.notice_update = function(x) {
if (x === "inc") { if (x === "inc") {
Post.pending_update_count += 1; Post.pending_update_count += 1;
Danbooru.notice("Updating posts (" + Post.pending_update_count + " pending)...", true); Utility.notice("Updating posts (" + Post.pending_update_count + " pending)...", true);
} else { } else {
Post.pending_update_count -= 1; Post.pending_update_count -= 1;
if (Post.pending_update_count < 1) { if (Post.pending_update_count < 1) {
Danbooru.notice("Posts updated"); Utility.notice("Posts updated");
} else { } else {
Danbooru.notice("Updating posts (" + Post.pending_update_count + " pending)...", true); Utility.notice("Updating posts (" + Post.pending_update_count + " pending)...", true);
} }
} }
} }
@@ -493,7 +493,7 @@ Post.update_data = function(data) {
} }
Post.vote = function(score, id) { Post.vote = function(score, id) {
Danbooru.notice("Voting..."); Utility.notice("Voting...");
$.post("/posts/" + id + "/votes.js", { $.post("/posts/" + id + "/votes.js", {
score: score score: score
@@ -518,7 +518,7 @@ Post.update = function(post_id, params) {
}, },
error: function(data) { error: function(data) {
Post.notice_update("dec"); Post.notice_update("dec");
Danbooru.error(`There was an error updating <a href="/posts/${post_id}">post #${post_id}</a>`); Utility.error(`There was an error updating <a href="/posts/${post_id}">post #${post_id}</a>`);
} }
}); });
} }
@@ -534,7 +534,7 @@ Post.ban = function(post_id) {
$("#post_" + post_id).remove(); $("#post_" + post_id).remove();
}, },
error: function(data) { error: function(data) {
Danbooru.error(`There was an error updating <a href="/posts/${post_id}">post #${post_id}</a>`); Utility.error(`There was an error updating <a href="/posts/${post_id}">post #${post_id}</a>`);
} }
}); });
} }
@@ -545,13 +545,13 @@ Post.approve = function(post_id) {
{"post_id": post_id} {"post_id": post_id}
).fail(function(data) { ).fail(function(data) {
var message = $.map(data.responseJSON.errors, function(msg, attr) { return msg; }).join("; "); var message = $.map(data.responseJSON.errors, function(msg, attr) { return msg; }).join("; ");
Danbooru.error("Error: " + message); Utility.error("Error: " + message);
}).done(function(data) { }).done(function(data) {
var $post = $("#post_" + post_id); var $post = $("#post_" + post_id);
if ($post.length) { if ($post.length) {
$post.data("flags", $post.data("flags").replace(/pending/, "")); $post.data("flags", $post.data("flags").replace(/pending/, ""));
$post.removeClass("post-status-pending"); $post.removeClass("post-status-pending");
Danbooru.notice("Approved post #" + post_id); Utility.notice("Approved post #" + post_id);
} }
}); });
} }
@@ -616,7 +616,7 @@ Post.update_tag_count = function(event) {
let tags = [...new Set($(event.target).val().match(/\S+/g))]; let tags = [...new Set($(event.target).val().match(/\S+/g))];
if (tags) { if (tags) {
count = tags.length; count = tags.length;
string = (count == 1) ? (count + " tag") : (count + " tags") string = (count === 1) ? (count + " tag") : (count + " tags")
} }
} }
$("#tags-container .count").html(string); $("#tags-container .count").html(string);