Expose importing dropped images for consistent import

This commit is contained in:
city-unit 2023-09-04 13:09:47 -04:00
parent f69aa07ec1
commit 01e38be408
1 changed files with 16 additions and 15 deletions

View File

@ -6765,6 +6765,22 @@ function connectAPISlash(_, text) {
toastr.info(`API set to ${text}, trying to connect..`); 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) { function importCharacter(file) {
const ext = file.name.match(/\.(\w+)$/); const ext = file.name.match(/\.(\w+)$/);
if ( if (
@ -8810,21 +8826,6 @@ jQuery(async function () {
processDroppedFiles(files); 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 () => { $("#charListGridToggle").on('click', async () => {
doCharListDisplaySwitch(); doCharListDisplaySwitch();