This commit is contained in:
Ross
2021-11-11 21:29:10 +00:00
parent bf08ca0e3b
commit 1c4a8d9166
+5 -49
View File
@@ -452,54 +452,6 @@
}
async function readFileAndProcess2(callback) {
//$("#single-dicom-viewer").empty()
//images = []
//Function that returns a promise to read the file
const reader = (file) => {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.onload = () => resolve(fileReader);
fileReader.readAsDataURL(file);
});
}
// Add file to the process list
active_file_inputs.add(el)
const readFile = (file, el) => {
reader(file).then(reader => {
console.log("12345", reader)
$(el).parent().parent().find(".temp-thumb").remove();
if (reader.result.startsWith("data:application/octet-stream;base64")) {
const element = $(`<div class='temp-thumb' src=${reader.result}></div>`).get(0)
$(el).parent().parent().prepend(element);
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(
file
);
cornerstone.enable(element);
cornerstone.loadAndCacheImage(imageId).then(function (image) {
cornerstone.displayImage(element, image);
cornerstone.resize(element)
});
} else {
var image = new Image();
image.title = file.name;
image.src = reader.result;
image.className = "temp-thumb";
$(el).parent().parent().prepend(image);
//images.push(reader.result);
}
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();
}
});
}
file_set = $("#image_form_set input[type=file]");
@@ -513,7 +465,11 @@
$(el).parent().parent().find(".temp-thumb").remove();
const imageId = `wadouri:${url}`;
if (el.files[0].type.startsWith("image")) {
const imageId = `${url}`;
} else {
const imageId = `wadouri:${url}`;
}
const element = $(`<div class='temp-thumb' src=${url}></div>`).get(0)
$(el).parent().parent().prepend(element);
cornerstone.enable(element);