expliciting declare a few more global variables

This commit is contained in:
Ross
2021-03-06 11:08:44 +00:00
parent 7fcebe56af
commit 2f22c3750b
4 changed files with 109 additions and 88 deletions
+3 -2
View File
@@ -179,10 +179,11 @@
<script src="lib/jq-ajax-progress.min.js" type="text/javascript"></script> <script src="lib/jq-ajax-progress.min.js" type="text/javascript"></script>
<script src="lib/easytimer.min.js" type="module"></script> <script src="lib/easytimer.min.js" type="module"></script>
<script src="lib/hammer.js"></script> <script src="lib/hammer.js"></script>
<script src="lib/cornerstone.js"></script> <script src="https://unpkg.com/cornerstone-core/dist/cornerstone.js"></script>
<script src="lib/dicomParser.min.js"></script> <script src="lib/dicomParser.min.js"></script>
<script src="lib/cornerstoneMath.min.js"></script> <script src="lib/cornerstoneMath.min.js"></script>
<script src="lib/cornerstoneTools.min.js"></script> <!-- <script src="lib/cornerstoneTools.min.js"></script> -->
<script src="https://www.unpkg.com/cornerstone-tools@5.1.3/dist/cornerstoneTools.js"></script>
<script src="lib/cornerstoneWebImageLoader.min.js"></script> <script src="lib/cornerstoneWebImageLoader.min.js"></script>
<script src="lib/cornerstoneWADOImageLoader.js"></script> <script src="lib/cornerstoneWADOImageLoader.js"></script>
<script src="lib/cornerstone-base64-image-loader.umd.js"></script> <script src="lib/cornerstone-base64-image-loader.umd.js"></script>
+8 -8
View File
@@ -2,11 +2,11 @@ import * as helper from "./helpers.js";
/** /**
* Submits answers * Submits answers
*/ */
export function submitAnswers(window, db) { export function submitAnswers(exam_details, db) {
console.log( console.log(
getJsonAnswers(window, db).then((a) => { getJsonAnswers(exam_details, db).then((a) => {
let json = { let json = {
eid: window.eid, eid: exam_details.eid,
answers: JSON.stringify(a), answers: JSON.stringify(a),
}; };
postAnswers(json); postAnswers(json);
@@ -18,9 +18,9 @@ export function submitAnswers(window, db) {
* Gets a json representation of answers * Gets a json representation of answers
* @return {JSON} - answers * @return {JSON} - answers
*/ */
export function getJsonAnswers(window, db) { export function getJsonAnswers(exam_details, db) {
const cid = window.cid; const cid = exam_details.cid;
const eid = window.eid; const eid = exam_details.eid;
return db.answers.where({ aid: aid, cid: cid, eid: eid }).toArray(); return db.answers.where({ aid: aid, cid: cid, eid: eid }).toArray();
// .then(function(ans) { // .then(function(ans) {
// console.log(ans); // console.log(ans);
@@ -52,8 +52,8 @@ export function postAnswers(ans) {
if (config.exam_results_url != "") { if (config.exam_results_url != "") {
let url = config.exam_results_url; let url = config.exam_results_url;
if (window.cid != "") { if (window.exam_details.cid != "") {
url = url + window.cid; url = url + window.exam_details.cid;
} }
$("#options-link") $("#options-link")
.empty() .empty()
+82 -65
View File
@@ -6,11 +6,19 @@ import * as config from "./config.js";
// const { v4: uuidv4 } = require('uuid'); // const { v4: uuidv4 } = require('uuid');
// cid = null; // cid = null;
window.aid = null; //window.aid = null;
window.cid = ""; //window.cid = "";
window.eid = 5678; //window.eid = 5678;
window.exam_mode = false; window.exam_details = {
aid: null,
cid: "",
eid: 5678,
exam_mode: false,
}
//window.exam_mode = false;
window.packet_list = []; window.packet_list = [];
window.exams = []; window.exams = [];
@@ -257,6 +265,7 @@ function loadPacketFromAjax(path) {
$.ajax({ $.ajax({
dataType: "json", dataType: "json",
url: path, url: path,
cache: true,
progress: function (e) { progress: function (e) {
if (e.lengthComputable) { if (e.lengthComputable) {
console.log("1") console.log("1")
@@ -316,7 +325,7 @@ function setUpQuestions(load_previous) {
window.question_type = window.question_type =
window.questions[Object.keys(window.questions)[0]].type; window.questions[Object.keys(window.questions)[0]].type;
if (window.exam_mode) { if (window.exam_details.exam_mode) {
$("#options-button, #review-overlay-button").hide(); $("#options-button, #review-overlay-button").hide();
} else { } else {
$("#submit-button").hide(); $("#submit-button").hide();
@@ -344,12 +353,12 @@ function setUpQuestions(load_previous) {
window.exam_time = $(".exam-time").val() * 60; window.exam_time = $(".exam-time").val() * 60;
}); });
if (window.exam_mode) { if (window.exam_details.exam_mode) {
// NOTE: changing the CID when restoring a session will not affect the time left // NOTE: changing the CID when restoring a session will not affect the time left
$("#candidate-number2") $("#candidate-number2")
.val(window.cid) .val(window.exam_details.cid)
.change(() => { .change(() => {
window.cid = parseInt($("#candidate-number2").val()); window.exam_details.cid = parseInt($("#candidate-number2").val());
}); });
$("#start-dialog").addClass("no-close"); $("#start-dialog").addClass("no-close");
@@ -417,7 +426,7 @@ function setUpPacket(data, path) {
window.packet_name = packet_name; window.packet_name = packet_name;
if (data.hasOwnProperty("eid")) { if (data.hasOwnProperty("eid")) {
window.eid = data.eid; window.exam_details.eid = data.eid;
} }
if (data.hasOwnProperty("type")) { if (data.hasOwnProperty("type")) {
@@ -425,7 +434,7 @@ function setUpPacket(data, path) {
} }
if (data.hasOwnProperty("exam_mode")) { if (data.hasOwnProperty("exam_mode")) {
window.exam_mode = data.exam_mode; window.exam_details.exam_mode = data.exam_mode;
} }
if (data.hasOwnProperty("questions")) { if (data.hasOwnProperty("questions")) {
@@ -470,6 +479,13 @@ function setUpPacket(data, path) {
console.log("error loading question"); console.log("error loading question");
data["questions"][n] = {}; data["questions"][n] = {};
}); });
if (question_json.hasOwnProperty("cached") && question_json["cached"]) { console.log("loading cached packet")}
//requests.push(request)
//request_numbers.push(n)
data["questions"][n] = question_json;
} catch (error) { } catch (error) {
console.log(error); console.log(error);
console.log("error loading question ", question_url); console.log("error loading question ", question_url);
@@ -479,14 +495,12 @@ function setUpPacket(data, path) {
question_number, question_number,
question_total question_total
) )
data["questions"][n] = question_json;
} finally {
} }
if (question_json.hasOwnProperty("cached") && question_json["cached"]) { console.log("loading cached packet")}
//requests.push(request)
//request_numbers.push(n)
data["questions"][n] = question_json;
} }
// Once all questions have been downloaded we carry on loading // Once all questions have been downloaded we carry on loading
loadSession(); loadSession();
@@ -499,8 +513,9 @@ function setUpPacket(data, path) {
} }
function loadSession() { function loadSession() {
console.log("load session")
// Either continue session or create a new one // Either continue session or create a new one
db.session window.db.session
// .where("status") // .where("status")
// .equals("active") // .equals("active")
.where("[packet+aid]") .where("[packet+aid]")
@@ -524,11 +539,11 @@ function loadSession() {
// Start new session if no session found // Start new session if no session found
if (sessions.length < 1) { if (sessions.length < 1) {
window.aid = uuidv4(); window.exam_details.aid = uuidv4();
window.date_started = Date.now(); window.date_started = Date.now();
} else { } else {
let text = "Select session to continue (leave blank to create new):"; let text = "Select session to continue (leave blank to create new):";
if (window.exam_mode) { if (window.exam_details.exam_mode) {
text = "Session will be continued"; text = "Session will be continued";
} }
console.log(sessions.date); console.log(sessions.date);
@@ -559,7 +574,7 @@ function loadSession() {
// If in exam mode we don't want to allow multiple sessions // If in exam mode we don't want to allow multiple sessions
let s; let s;
if (window.exam_mode) { if (window.exam_details.exam_mode) {
s = "0"; s = "0";
alert(text); alert(text);
} else { } else {
@@ -569,8 +584,8 @@ function loadSession() {
if (s != null && s != "") { if (s != null && s != "") {
load_previous = true; load_previous = true;
window.aid = sessions[parseInt(s)].aid; window.exam_details.aid = sessions[parseInt(s)].aid;
window.cid = sessions[parseInt(s)].cid; window.exam_details.cid = sessions[parseInt(s)].cid;
window.date_started = sessions[parseInt(s)].date; window.date_started = sessions[parseInt(s)].date;
let time_left = sessions[parseInt(s)].time_left; let time_left = sessions[parseInt(s)].time_left;
@@ -584,7 +599,7 @@ function loadSession() {
} }
} else { } else {
// If cancel is pressed or input is blank // If cancel is pressed or input is blank
window.aid = uuidv4(); window.exam_details.aid = uuidv4();
window.date_started = Date.now(); window.date_started = Date.now();
console.log("new date", window.date_started); console.log("new date", window.date_started);
} }
@@ -601,9 +616,9 @@ function loadSession() {
* @param {boolean} force_reload - Force question to be reloaded if already loaded * @param {boolean} force_reload - Force question to be reloaded if already loaded
*/ */
function loadQuestion(n, section = 1, force_reload = false) { function loadQuestion(n, section = 1, force_reload = false) {
const aid = window.aid; const aid = window.exam_details.aid;
const cid = window.cid; const cid = window.exam_details.cid;
const eid = window.eid; const eid = window.exam_details.eid;
// Make sure we have an integer // Make sure we have an integer
n = parseInt(n); n = parseInt(n);
@@ -781,7 +796,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
} else { } else {
$("#rapid-text").css("display", "none"); $("#rapid-text").css("display", "none");
} }
db.answers.put({ window.db.answers.put({
aid: aid, aid: aid,
cid: cid, cid: cid,
eid: eid, eid: eid,
@@ -797,14 +812,14 @@ function loadQuestion(n, section = 1, force_reload = false) {
$(".long-answer").change(function (evt) { $(".long-answer").change(function (evt) {
// ignore blank text and delete any stored value // ignore blank text and delete any stored value
if (evt.target.value.length < 1) { if (evt.target.value.length < 1) {
db.answers.delete([aid, cid, eid, qid, "2"]); window.db.answers.delete([aid, cid, eid, qid, "2"]);
$( $(
"#question-list-item-" + window.question_order.indexOf(qid) + "-2" "#question-list-item-" + window.question_order.indexOf(qid) + "-2"
).removeClass("question-saved-localdb"); ).removeClass("question-saved-localdb");
return; return;
} }
// db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value}); // db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value});
db.answers.put({ window.db.answers.put({
aid: aid, aid: aid,
cid: cid, cid: cid,
eid: eid, eid: eid,
@@ -824,7 +839,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
// We chain our db requests as we can only check answers once // We chain our db requests as we can only check answers once
// they have been loaded (should probably use then or after) // they have been loaded (should probably use then or after)
db.answers window.db.answers
.get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "1" }) .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "1" })
.then(function (answer) { .then(function (answer) {
if (answer != undefined) { if (answer != undefined) {
@@ -844,7 +859,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
console.log("error-", error); console.log("error-", error);
}) })
.then( .then(
db.answers window.db.answers
.get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "2" }) .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "2" })
.then(function (answer) { .then(function (answer) {
if (answer != undefined) { if (answer != undefined) {
@@ -878,14 +893,14 @@ function loadQuestion(n, section = 1, force_reload = false) {
$(".long-answer").change(function (evt) { $(".long-answer").change(function (evt) {
// ignore blank text and delete any stored value // ignore blank text and delete any stored value
if (evt.target.value.length < 1) { if (evt.target.value.length < 1) {
db.answers.delete([aid, cid, eid, qid, "1"]); window.db.answers.delete([aid, cid, eid, qid, "1"]);
$( $(
"#question-list-item-" + window.question_order.indexOf(qid) + "-1" "#question-list-item-" + window.question_order.indexOf(qid) + "-1"
).removeClass("question-saved-localdb"); ).removeClass("question-saved-localdb");
return; return;
} }
// db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value}); // db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value});
db.answers.put({ window.db.answers.put({
aid: aid, aid: aid,
cid: cid, cid: cid,
eid: eid, eid: eid,
@@ -901,7 +916,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
updateQuestionListPanel(); updateQuestionListPanel();
}); });
db.answers window.db.answers
.get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "1" }) .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: "1" })
.then(function (answer) { .then(function (answer) {
if (answer != undefined) { if (answer != undefined) {
@@ -962,7 +977,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
// ignore blank text and delete any stored value // ignore blank text and delete any stored value
if (evt.target.value.length < 1) { if (evt.target.value.length < 1) {
db.answers.delete([aid, cid, eid, qid, qidn]); window.db.answers.delete([aid, cid, eid, qid, qidn]);
$( $(
"#question-list-item-" + "#question-list-item-" +
window.question_order.indexOf(qid) + window.question_order.indexOf(qid) +
@@ -972,7 +987,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
return; return;
} }
// db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value}); // db.answers.put({aid: [cid, eid, qidn], ans: evt.target.value});
db.answers.put({ window.db.answers.put({
aid: aid, aid: aid,
cid: cid, cid: cid,
eid: eid, eid: eid,
@@ -997,7 +1012,7 @@ function loadQuestion(n, section = 1, force_reload = false) {
// //
for (let qidn_count = 1; qidn_count < 6; qidn_count++) { for (let qidn_count = 1; qidn_count < 6; qidn_count++) {
db.answers window.db.answers
.get({ .get({
aid: aid, aid: aid,
cid: cid, cid: cid,
@@ -1068,12 +1083,13 @@ function setFocus(section) {
* if it gets slow...) * if it gets slow...)
*/ */
function updateQuestionListPanel() { function updateQuestionListPanel() {
const cid = window.cid; const aid = window.exam_details.aid;
const eid = window.eid; const cid = window.exam_details.cid;
const eid = window.exam_details.eid;
console.log("UP"); console.log("UP");
// Reset all classes // Reset all classes
db.answers window.db.answers
.where({ aid: aid, cid: cid, eid: eid }) .where({ aid: aid, cid: cid, eid: eid })
.toArray() .toArray()
.then(function (answers) { .then(function (answers) {
@@ -1110,7 +1126,7 @@ function updateQuestionListPanel() {
console.log("error - ", error); console.log("error - ", error);
}); });
db.flags window.db.flags
.where({ aid: aid, cid: cid, eid: eid }) .where({ aid: aid, cid: cid, eid: eid })
.toArray() .toArray()
.then(function (answers) { .then(function (answers) {
@@ -1317,8 +1333,8 @@ function reviewQuestions() {
window.timer.stop(); window.timer.stop();
} }
const cid = window.cid; const cid = window.exam_details.cid;
const eid = window.eid; const eid = window.exam_details.eid;
$("#review-overlay").show(); $("#review-overlay").show();
$("#review-answer-list").empty(); $("#review-answer-list").empty();
$("#review-answer-table").empty(); $("#review-answer-table").empty();
@@ -1327,7 +1343,7 @@ function reviewQuestions() {
loadQuestion(0, 0, true); loadQuestion(0, 0, true);
db.answers window.db.answers
.where({ aid: aid, cid: cid, eid: eid }) .where({ aid: aid, cid: cid, eid: eid })
.toArray() .toArray()
.then(function (answers) { .then(function (answers) {
@@ -1424,7 +1440,7 @@ function reviewQuestions() {
$("#review-overlay").hide(); $("#review-overlay").hide();
}); });
db.user_answers window.db.user_answers
.get({ qid: qid }) .get({ qid: qid })
.then(function (answers) { .then(function (answers) {
// Merge the question answers with the user saved answers // Merge the question answers with the user saved answers
@@ -1674,7 +1690,7 @@ function markAnswer(qid, current_question) {
let user_answer = textarea.val(); let user_answer = textarea.val();
// Load user saved answers // Load user saved answers
db.user_answers window.db.user_answers
.get({ qid: qid }) .get({ qid: qid })
.then(function (saved_user_answers) { .then(function (saved_user_answers) {
// check if given answer matches a user saved answer // check if given answer matches a user saved answer
@@ -1755,7 +1771,7 @@ function markCorrect(qid, user_answer) {
return; return;
} }
db.user_answers window.db.user_answers
.get({ qid: qid }) .get({ qid: qid })
.then(function (answers) { .then(function (answers) {
let new_answers = []; let new_answers = [];
@@ -1764,7 +1780,7 @@ function markCorrect(qid, user_answer) {
} }
new_answers.push(user_answer); new_answers.push(user_answer);
db.user_answers.put({ qid: qid, ans: new_answers }); window.db.user_answers.put({ qid: qid, ans: new_answers });
}) })
.catch(function (error) { .catch(function (error) {
console.log("error-", error); console.log("error-", error);
@@ -1792,9 +1808,9 @@ function answerInArray(arr, ans) {
} }
function addFlagEvents() { function addFlagEvents() {
const aid = window.aid; const aid = window.exam_details.aid;
const cid = window.cid; const cid = window.exam_details.cid;
const eid = window.eid; const eid = window.exam_details.eid;
// Bind flag change events // Bind flag change events
$("button.flag").click(function (event) { $("button.flag").click(function (event) {
@@ -1810,22 +1826,23 @@ function addFlagEvents() {
"visibility", "visibility",
"hidden" "hidden"
); );
db.flags.delete([aid, cid, eid, qid, qidn]); window.db.flags.delete([aid, cid, eid, qid, qidn]);
} else { } else {
$("#question-list-item-" + nqid + "-" + qidn + " span").css( $("#question-list-item-" + nqid + "-" + qidn + " span").css(
"visibility", "visibility",
"visible" "visible"
); );
db.flags.put({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: qidn }); window.db.flags.put({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: qidn });
} }
updateQuestionListPanel(); updateQuestionListPanel();
}); });
} }
function loadFlagsFromDb(qid, n) { function loadFlagsFromDb(qid, n) {
const cid = window.cid; const aid = window.exam_details.aid;
const eid = window.eid; const cid = window.exam_details.cid;
db.flags const eid = window.exam_details.eid;
window.db.flags
.get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: n }) .get({ aid: aid, cid: cid, eid: eid, qid: qid, qidn: n })
.then(function (answer) { .then(function (answer) {
if (answer != undefined) { if (answer != undefined) {
@@ -1844,12 +1861,12 @@ function showLoginDialog() {
} }
$("#start-exam-button").click(function (evt) { $("#start-exam-button").click(function (evt) {
window.cid = parseInt($("#candidate-number").val()); window.exam_details.cid = parseInt($("#candidate-number").val());
$.modal.close(); $.modal.close();
}); });
$(".start-packet-button").click(function (evt) { $(".start-packet-button").click(function (evt) {
if (window.exam_mode) { if (window.exam_details.exam_mode) {
if (!Number.isInteger(parseInt($("#candidate-number2").val()))) { if (!Number.isInteger(parseInt($("#candidate-number2").val()))) {
alert("Please enter a valid candidate number."); alert("Please enter a valid candidate number.");
return; return;
@@ -1868,7 +1885,7 @@ $(".start-packet-button").click(function (evt) {
$("#timer").html("Time left: " + timer.getTimeValues().toString()); $("#timer").html("Time left: " + timer.getTimeValues().toString());
}); });
timer.addEventListener("targetAchieved", function (e) { timer.addEventListener("targetAchieved", function (e) {
if (window.exam_mode == true) { if (window.exam_details.exam_mode == true) {
$( $(
"#dialog-submit-button, #time-up-review-button, #time-up-continue-button" "#dialog-submit-button, #time-up-review-button, #time-up-continue-button"
).toggle(); ).toggle();
@@ -1932,7 +1949,7 @@ $("#btn-delete-databases").click(function (evt) {
"This will delete ALL saved answers (including saved correct answers)!" "This will delete ALL saved answers (including saved correct answers)!"
); );
if (r == true) { if (r == true) {
db.delete() window.db.delete()
.then(() => { .then(() => {
$.notify("Database successfully deleted", "success"); $.notify("Database successfully deleted", "success");
$.notify("The page will now reload", "warn"); $.notify("The page will now reload", "warn");
@@ -1958,7 +1975,7 @@ $("#btn-delete-current").click(function (evt) {
return; return;
} }
db.flags window.db.flags
.where("qid") .where("qid")
.anyOf(window.question_order) .anyOf(window.question_order)
.delete() .delete()
@@ -1970,7 +1987,7 @@ $("#btn-delete-current").click(function (evt) {
$.notify("You may have to delete all answers this time", "info"); $.notify("You may have to delete all answers this time", "info");
}); });
db.answers window.db.answers
.where("qid") .where("qid")
.anyOf(window.question_order) .anyOf(window.question_order)
.delete() .delete()
@@ -1996,7 +2013,7 @@ $("#btn-delete-current-saved-answers").click(function (evt) {
return; return;
} }
db.user_answers window.db.user_answers
.where("qid") .where("qid")
.anyOf(window.question_order) .anyOf(window.question_order)
.delete() .delete()
@@ -2030,10 +2047,10 @@ function saveSession() {
time_values.hours * 60 * 60 + time_values.hours * 60 * 60 +
time_values.minutes * 60 + time_values.minutes * 60 +
time_values.seconds; time_values.seconds;
db.session.put({ window.db.session.put({
packet: window.packet_name, packet: window.packet_name,
aid: window.aid, aid: window.exam_details.aid,
cid: window.cid, cid: window.exam_details.cid,
status: status, status: status,
date: window.date_started, date: window.date_started,
score: window.score, score: window.score,
+16 -13
View File
@@ -20,17 +20,17 @@ export function loadMainImage(image, stack) {
cornerstoneTools.addStackStateManager(element, ["stack"]); cornerstoneTools.addStackStateManager(element, ["stack"]);
cornerstoneTools.addToolState(element, "stack", stack); cornerstoneTools.addToolState(element, "stack", stack);
cornerstoneTools.addTool(PanTool); cornerstoneTools.addToolForElement(element, PanTool);
cornerstoneTools.addTool(ZoomTool, { cornerstoneTools.addToolForElement(element, ZoomTool, {
configuration: { configuration: {
invert: true, invert: true,
}, },
}); });
cornerstoneTools.addTool(WwwcTool); cornerstoneTools.addToolForElement(element, WwwcTool);
cornerstoneTools.addTool(RotateTool); cornerstoneTools.addToolForElement(element, RotateTool);
cornerstoneTools.addTool(StackScrollTool); cornerstoneTools.addToolForElement(element, StackScrollTool);
cornerstoneTools.addTool(ArrowAnnotateTool, { cornerstoneTools.addToolForElement(element, ArrowAnnotateTool, {
configuration: { configuration: {
getTextCallback: () => {}, getTextCallback: () => {},
changeTextCallback: () => {}, changeTextCallback: () => {},
@@ -41,8 +41,8 @@ export function loadMainImage(image, stack) {
}, },
}); });
cornerstoneTools.setToolActive("Pan", { mouseButtonMask: 1 }); cornerstoneTools.setToolActiveForElement(element, "Pan", { mouseButtonMask: 1 });
cornerstoneTools.setToolEnabled("ArrowAnnotate"); cornerstoneTools.setToolEnabledForElement(element, "ArrowAnnotate");
//cornerstoneTools.keyboardInput.enable(element); //cornerstoneTools.keyboardInput.enable(element);
@@ -269,25 +269,25 @@ export function changeControlSelection() {
const dicom_element = document.getElementById("dicom-image"); const dicom_element = document.getElementById("dicom-image");
switch (sel.options[sel.selectedIndex].value) { switch (sel.options[sel.selectedIndex].value) {
case "pan": { case "pan": {
cornerstoneTools.setToolActive("Pan", { mouseButtonMask: 1 }); cornerstoneTools.setToolActiveForElement(dicom_element, "Pan", { mouseButtonMask: 1 });
break; break;
} }
case "zoom": { case "zoom": {
cornerstoneTools.setToolActive("Zoom", { mouseButtonMask: 1 }); cornerstoneTools.setToolActiveForElement(dicom_element, "Zoom", { mouseButtonMask: 1 });
break; break;
} }
case "rotate": { case "rotate": {
cornerstoneTools.setToolActive("Rotate", { mouseButtonMask: 1 }); cornerstoneTools.setToolActiveForElement(dicom_element, "Rotate", { mouseButtonMask: 1 });
break; break;
} }
case "scroll": { case "scroll": {
cornerstoneTools.setToolActive("StackScroll", { mouseButtonMask: 1 }); cornerstoneTools.setToolActiveForElement(dicom_element, "StackScroll", { mouseButtonMask: 1 });
// _this.left.onstart = _this.scroll_start; // _this.left.onstart = _this.scroll_start;
// _this.selected_control = t.selectedIndex; // _this.selected_control = t.selectedIndex;
break; break;
} }
case "window": { case "window": {
cornerstoneTools.setToolActive("Wwwc", { mouseButtonMask: 1 }); cornerstoneTools.setToolActiveForElement(dicom_element, "Wwwc", { mouseButtonMask: 1 });
break; break;
} }
case "abdomen": { case "abdomen": {
@@ -533,6 +533,7 @@ export function openMainImage(current_question, t, source) {
toolStateManager.restoreToolState(tool_state); toolStateManager.restoreToolState(tool_state);
} }
async function load(images, annotations) { async function load(images, annotations) {
console.log("Load function", images)
const imageIds = []; const imageIds = [];
for (let i = 0; i < images.length; i++) { for (let i = 0; i < images.length; i++) {
const data_url = images[i]; const data_url = images[i];
@@ -587,6 +588,8 @@ export function openMainImage(current_question, t, source) {
el = document.getElementById("dicom-image"); el = document.getElementById("dicom-image");
if (el != undefined) { if (el != undefined) {
cornerstone.disable(el); cornerstone.disable(el);
// Explicitly remove the dicom-image element
el.remove();
$(".canvas-panel").remove(); $(".canvas-panel").remove();
} }
} }