/uploads: fix manually clicking 'Similar' button.
Manually clicking Similar called `/iqdb_queries` instead of `/iqdb_queries.js`, which caused it to update the page incorrectly.
This commit is contained in:
@@ -5,6 +5,8 @@ import SparkMD5 from 'spark-md5';
|
||||
let Upload = {};
|
||||
|
||||
Upload.MAX_FILE_SIZE = <%= Danbooru.config.max_file_size.to_json %> / (1024 * 1024);
|
||||
Upload.IQDB_LIMIT = 5;
|
||||
Upload.IQDB_SIMILARITY = 20;
|
||||
|
||||
Upload.initialize_all = function() {
|
||||
if ($("#c-uploads,#c-posts").length) {
|
||||
@@ -26,6 +28,7 @@ Upload.initialize_all = function() {
|
||||
}
|
||||
this.initialize_similar();
|
||||
this.initialize_submit();
|
||||
$("#similar-button").click();
|
||||
|
||||
$("#toggle-artist-commentary").on("click.danbooru", function(e) {
|
||||
Upload.toggle_commentary();
|
||||
@@ -36,10 +39,6 @@ Upload.initialize_all = function() {
|
||||
if ($("#c-uploads #a-new").length) {
|
||||
this.initialize_dropzone();
|
||||
}
|
||||
|
||||
if ($("#iqdb-similar").length) {
|
||||
this.initialize_iqdb_source();
|
||||
}
|
||||
}
|
||||
|
||||
Upload.initialize_submit = function() {
|
||||
@@ -66,12 +65,6 @@ Upload.validate_upload = function (e) {
|
||||
}
|
||||
}
|
||||
|
||||
Upload.initialize_iqdb_source = function() {
|
||||
if (/^https?:\/\//.test($("#upload_source").val())) {
|
||||
$.get("/iqdb_queries.js", { url: $("#upload_source").val(), limit: 5, similarity: 20 });
|
||||
}
|
||||
}
|
||||
|
||||
Upload.initialize_enter_on_tags = function() {
|
||||
var $textarea = $("#upload_tag_string, #post_tag_string");
|
||||
var $submit = $textarea.parents("form").find('input[type="submit"]');
|
||||
@@ -84,8 +77,12 @@ Upload.initialize_enter_on_tags = function() {
|
||||
|
||||
Upload.initialize_similar = function() {
|
||||
$("#similar-button").on("click.danbooru", function(e) {
|
||||
$.get("/iqdb_queries", {"url": $("#upload_source").val()}).done(function(html) {$("#iqdb-similar").html(html).show()});
|
||||
e.preventDefault();
|
||||
|
||||
let source = $("#upload_source").val();
|
||||
if (/^https?:\/\//.test(source)) {
|
||||
$.get("/iqdb_queries.js", { url: source, limit: Upload.IQDB_LIMIT, similarity: Upload.IQDB_SIMILARITY });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user