Start extracting server communications to seperate module

This commit is contained in:
Ross
2020-10-20 11:35:38 +01:00
parent 5dfd0c4ff3
commit 6f70c5ed34
2 changed files with 29 additions and 26 deletions
+3 -26
View File
@@ -1,6 +1,7 @@
/* global Dexie, cornerstone, cornerstoneTools, cornerstoneBase64ImageLoader, cornerstoneWebImageLoader, cornerstoneWADOImageLoader */
import * as helper from "./helpers.js";
import * as viewer from "./viewer.js";
import * as interact from "./viewer.js";
// const { v4: uuidv4 } = require('uuid');
// cid = null;
@@ -92,6 +93,7 @@ async function loadPacketList(data) {
if (data != null) {
window.packet_list = data.packets;
}
$("#packet-list").empty();
window.packet_list.forEach(function (packet) {
let c = "";
@@ -968,7 +970,7 @@ $("#btn-local-file-load").click(function (evt) {
});
$("#submit-button").click(function (evt) {
submitAnswers();
interact.submitAnswers();
});
$("#review-button").click(function (evt) {
@@ -1032,21 +1034,6 @@ function getJsonAnswers() {
// });
}
/**
* Posts answers to url
* @param {*} ans - json representation of answers
*/
function postAnswers(ans) {
console.log(ans);
// ans = {"test" : 1}
$.post("http://localhost:8000/submit_answers", JSON.stringify(ans)).done(
(data) => {
console.log(data);
}
);
// $.post( "http://localhost:8000/submit_answers", JSON.stringify(ans));
}
/**
* Loads a local question set (from a file)
* This is call in index.html
@@ -1089,16 +1076,6 @@ function loadLocalQuestionSet() {
}
}
/**
* Submits answers
*/
function submitAnswers() {
console.log(
getJsonAnswers().then((a) => {
postAnswers(a);
})
);
}
/**
* Displays the review question panel with a summary of marks