diff --git a/js/interact.js b/js/interact.js
index d74e8c1..884ccda 100644
--- a/js/interact.js
+++ b/js/interact.js
@@ -1,3 +1,4 @@
+import * as helper from "./helpers.js";
/**
* Submits answers
*/
@@ -67,7 +68,7 @@ export function postAnswers(ans) {
alert(`${data.question_count} answers sucessfully submitted.`);
}
} else {
- submissionError(data, ans);
+ submissionError(data, ans);
}
})
.fail((e) => {
@@ -108,3 +109,29 @@ function submissionError(data, ans) {
"z-index": 5000,
});
}
+
+// TODO: async request
+export function getQuestion(url, question_number, question_total) {
+ console.log("Downloading ", url, question_number, question_total);
+ return $.ajax({
+ dataType: "json",
+ url: url,
+ progress: function (e) {
+ console.log(e);
+ if (e.lengthComputable) {
+ var completedPercentage = Math.round((e.loaded * 100) / e.total);
+
+ $("#progress").html(
+ `Downloading [${question_number}/${question_total}]${completedPercentage}%
${helper.formatBytes(
+ e.total
+ )}`
+ );
+ }
+ },
+ //success: function (data) {
+ // strReturn = data;
+ //},
+ //async: false,
+ });
+
+}
diff --git a/js/main.js b/js/main.js
index 4753842..ca37c29 100644
--- a/js/main.js
+++ b/js/main.js
@@ -53,13 +53,18 @@ function retrievePacketList() {
url = window.config.exam_query_url;
}
- $.ajax({dataType: "json", cache: false, url: url, success : function (data) {
- if (data.hasOwnProperty("exams")) {
- loadExamList(data);
- } else {
- loadPacketList(data);
- }
- },})
+ $.ajax({
+ dataType: "json",
+ cache: false,
+ url: url,
+ success: function (data) {
+ if (data.hasOwnProperty("exams")) {
+ loadExamList(data);
+ } else {
+ loadPacketList(data);
+ }
+ },
+ })
.done(function () {})
.fail(function () {
$.getJSON("packets/packets.json", function (data) {
@@ -133,12 +138,14 @@ async function loadExamList(data) {
if ($(`#packet-list .${exam.type}`).length) {
list = $(`#packet-list .${exam.type}`);
} else {
- list = $("#packet-list").append(`