.
This commit is contained in:
@@ -134,21 +134,6 @@
|
||||
|
||||
el = evt.target;
|
||||
|
||||
$(el).find(".temp-thumb").remove();
|
||||
if (el.files.length > 0) {
|
||||
extra_class = " image-ident-loading";
|
||||
if ($(el).hasClass("image-ident-warning")) {
|
||||
extra_class = " image-ident-warning";
|
||||
} else if ($(el).hasClass("image-ident-ok")) {
|
||||
extra_class = " image-ident-ok";
|
||||
}
|
||||
n = el.id.split("-")[1];
|
||||
$(`#drop-filenames span[data-input-id='${el.id}']`).remove();
|
||||
$("#drop-filenames").append(
|
||||
`<span data-input-id='${el.id}'><span>${n}: ${el.files[0].name}</span><img class='uploading${extra_class}' data-input-id='${el.id}' src=${URL.createObjectURL(el.files[0])}></span>`
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
//readFileAndProcess();
|
||||
readFileAndProcess2(el);
|
||||
@@ -452,11 +437,11 @@
|
||||
}
|
||||
|
||||
async function blobToBase64(blob) {
|
||||
return new Promise((resolve, _) => {
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = () => resolve(reader.result);
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
return new Promise((resolve, _) => {
|
||||
const reader = new FileReader();
|
||||
reader.onloadend = () => resolve(reader.result);
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
}
|
||||
|
||||
async function readFileAndProcess2(el) {
|
||||
@@ -465,26 +450,44 @@
|
||||
|
||||
//file_set.each(async (n, el) => {
|
||||
|
||||
if (el.files.length > 0) {
|
||||
filename = el.files[0].name;
|
||||
// Probably no need to await here anymore
|
||||
//await readFile(el.files[0], el);
|
||||
if (el.files.length > 0) {
|
||||
filename = el.files[0].name;
|
||||
// Probably no need to await here anymore
|
||||
//await readFile(el.files[0], el);
|
||||
|
||||
|
||||
console.log(el.files[0])
|
||||
|
||||
$(el).parent().parent().find(".temp-thumb").remove();
|
||||
|
||||
let imageId;
|
||||
if (el.files[0].type.startsWith("image")) {
|
||||
base = await blobToBase64(el.files[0]);
|
||||
imageId = "base64://" + base.split(",")[1];
|
||||
imageId2 = base;
|
||||
} else {
|
||||
let url = URL.createObjectURL(el.files[0])
|
||||
imageId = `wadouri:${url}`;
|
||||
imageId2 = imageId
|
||||
}
|
||||
console.log(el.files[0])
|
||||
|
||||
$(el).parent().parent().find(".temp-thumb").remove();
|
||||
|
||||
let url = URL.createObjectURL(el.files[0])
|
||||
|
||||
extra_class = " image-ident-loading";
|
||||
if ($(el).hasClass("image-ident-warning")) {
|
||||
extra_class = " image-ident-warning";
|
||||
} else if ($(el).hasClass("image-ident-ok")) {
|
||||
extra_class = " image-ident-ok";
|
||||
}
|
||||
n = el.id.split("-")[1];
|
||||
$(`#drop-filenames span[data-input-id='${el.id}']`).remove();
|
||||
|
||||
let imageId;
|
||||
if (el.files[0].type.startsWith("image")) {
|
||||
base = await blobToBase64(el.files[0]);
|
||||
imageId = "base64://" + base.split(",")[1];
|
||||
imageId2 = base;
|
||||
const element = $(`<img class='temp-thumb' src=${url}></div>`).get(0)
|
||||
$(el).parent().parent().prepend(element);
|
||||
|
||||
$("#drop-filenames").append(
|
||||
`<span data-input-id='${el.id}'><span>${n}: ${el.files[0].name}</span><div class='uploading${extra_class}' data-input-id='${el.id}' src=${url}></div></span>`
|
||||
)
|
||||
} else {
|
||||
imageId = `wadouri:${url}`;
|
||||
imageId2 = imageId
|
||||
|
||||
console.log(imageId)
|
||||
const element = $(`<div class='temp-thumb' src=${imageId2}></div>`).get(0)
|
||||
$(el).parent().parent().prepend(element);
|
||||
@@ -495,14 +498,26 @@
|
||||
|
||||
});
|
||||
|
||||
const element2 = $(`#drop-filenames div[data-input-id='${el.id}']`).get(0);
|
||||
cornerstone.enable(element2);
|
||||
cornerstone.loadAndCacheImage(imageId).then(function (image) {
|
||||
cornerstone.displayImage(element2, image);
|
||||
cornerstone.resize(element2)
|
||||
|
||||
});
|
||||
|
||||
active_file_inputs.delete(el)
|
||||
console.log("active", active_file_inputs)
|
||||
// Only load once all queued files have been processed
|
||||
if (active_file_inputs.size < 1) {
|
||||
loadViewer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
active_file_inputs.delete(el)
|
||||
console.log("active", active_file_inputs)
|
||||
// Only load once all queued files have been processed
|
||||
if (active_file_inputs.size < 1) {
|
||||
loadViewer();
|
||||
}
|
||||
}
|
||||
//})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user