fix some helper / viewer issues

This commit is contained in:
Ross
2020-08-16 13:38:08 +01:00
parent c5c39bb223
commit 03c88f811e
3 changed files with 20 additions and 14 deletions
-10
View File
@@ -19,16 +19,6 @@ export function shuffleArray(array) {
return array;
}
export function urltoFile(url, filename, mimeType) {
return fetch(url)
.then(function (res) {
return res.arrayBuffer();
})
.then(function (buf) {
return new File([buf], filename, { type: mimeType });
});
}
export function formatBytes(bytes, decimals = 2) {
if (bytes === 0) return "0 Bytes";
+9 -3
View File
@@ -88,7 +88,10 @@ async function loadPacketList(data) {
}
});
window.packet_list = data.packets;
if (data != null) {
window.packet_list = data.packets;
}
$("#packet-list").empty();
window.packet_list.forEach(function (packet) {
let c = "";
if (packets_started.indexOf(packet) > -1) {
@@ -469,7 +472,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
// otherwise try to load it as a dicom
} else {
// convert the data url to a file
helper
viewer
.urltoFile(based_img, "dicom", "application/dicom")
.then(function (dfile) {
// load the file using cornerstoneWADO file loader
@@ -956,6 +959,7 @@ $("#review-button").click(function (evt) {
});
$("#options-button").click(function (evt) {
loadPacketList(null);
$("#options-panel").toggle();
});
@@ -1075,8 +1079,10 @@ function submitAnswers() {
* Displays the review question panel with a summary of marks
*/
function reviewQuestions() {
// Stop timer
// Stop timer (if it's running)
if (window.timer != null) {
window.timer.stop();
}
const cid = window.cid;
const eid = window.eid;
+11 -1
View File
@@ -503,7 +503,7 @@ export function openMainImage(current_question, t, source) {
} else if (data_url.startsWith("data:application/dicom")) {
// stack = stack.split(";")[1];
const dfile = await helper.urltoFile(
const dfile = await urltoFile(
data_url,
"dicom",
"application/dicom"
@@ -566,3 +566,13 @@ export function openMainImage(current_question, t, source) {
load(images);
}
}
export function urltoFile(url, filename, mimeType) {
return fetch(url)
.then(function (res) {
return res.arrayBuffer();
})
.then(function (buf) {
return new File([buf], filename, { type: mimeType });
});
}