From 01e38be408b4bd40792c3cf86d353ecad60f7ea2 Mon Sep 17 00:00:00 2001 From: city-unit <140349364+city-unit@users.noreply.github.com> Date: Mon, 4 Sep 2023 13:09:47 -0400 Subject: [PATCH] Expose importing dropped images for consistent import --- public/script.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/public/script.js b/public/script.js index 02626d6ae..5b3ca34d0 100644 --- a/public/script.js +++ b/public/script.js @@ -6765,6 +6765,22 @@ function connectAPISlash(_, text) { toastr.info(`API set to ${text}, trying to connect..`); } +export function processDroppedFiles(files) { + const allowedMimeTypes = [ + 'application/json', + 'image/png', + 'image/webp', + ]; + + for (const file of files) { + if (allowedMimeTypes.includes(file.type)) { + importCharacter(file); + } else { + toastr.warning('Unsupported file type: ' + file.name); + } + } +} + function importCharacter(file) { const ext = file.name.match(/\.(\w+)$/); if ( @@ -8810,21 +8826,6 @@ jQuery(async function () { processDroppedFiles(files); }); - function processDroppedFiles(files) { - const allowedMimeTypes = [ - 'application/json', - 'image/png', - 'image/webp', - ]; - - for (const file of files) { - if (allowedMimeTypes.includes(file.type)) { - importCharacter(file); - } else { - toastr.warning('Unsupported file type: ' + file.name); - } - } - } $("#charListGridToggle").on('click', async () => { doCharListDisplaySwitch();