Commit ca50c024 by Daniel Bawag

WG-69 - Removed the reloading of page after submitting

parent 862870cc
......@@ -23,6 +23,7 @@
<script src="./src/XMLWriter/XML_Saver.js" language="javascript"></script>
<script src="./src/submit/submit.js" language="javascript"></script>
<script src="./src/fetchConfig/fetchConfig.js"></script>
<script src="./src/init/init.js"></script>
</head>
<script>
......@@ -54,7 +55,7 @@
<button id='pause'>Pause</button>
</div>
<form id='fields' style="display: flex; flex-direction:column;" onsubmit="return submitForm(event);"></form>
<form id='fields' style="display: flex; flex-direction:column;" onsubmit="submitForm(event);return false"></form>
</aside>
<!-- Embed viewer -->
<main id="viewer">
......@@ -119,17 +120,7 @@
noConfig.style.display = "block";
}
} else {
let started_flag = false;
displayFields("fields");
accessFile();
window.onkeydown = (key) => {
if(!started_flag) {
started_flag = true;
startMetricCapture();
}
}
init();
}
</script>
<script src="./src/endSession/endSession.js"></script>
......
......@@ -69,8 +69,6 @@ function accessFile() {
const blob = await res.blob();
status('download completed');
const request = indexedDB.open("ImageDatabase", 1);
request.onsuccess = async function () {
// console.log("Database opened successfully " + val );
......@@ -215,7 +213,7 @@ function accessFile() {
function Input_files() {
//Dirfiles from dir.php
var urls = Dirfiles; //from config
var urls = Object.assign(new Array(), Dirfiles); //from config
var count;
if((localStorage.length) == 0){
count = 0;
......
......@@ -77,15 +77,17 @@ const stopMetricCapture = () => {
}
}
let interval;
const showMetricCapture = () => {
const obj = document.getElementById("counter");
if(key_strokes != 0) {
let time_spent = ((Date.now() - time_start) / 1000) - time_pause_spent;
let rate = ((key_strokes/time_spent) * 3600).toFixed(0);
rate >= 8000 ? obj.className = "green" : obj.className = "red";
rate >= ALLOWED_KPH ? obj.className = "green" : obj.className = "red";
obj.innerHTML = rate + " kph"; // immediately apply start value
}
setTimeout(showMetricCapture, 1000);
interval = setTimeout(showMetricCapture, 1000);
}
const saveMetrics = (metrics, eoe_ts) => {
......
const init = () => {
let started_flag = false;
displayFields("fields");
accessFile();
window.onkeydown = (key) => {
if(!started_flag) {
started_flag = true;
startMetricCapture();
}
}
}
......@@ -39,8 +39,23 @@ const submitForm = (e) => {
else {
const metrics = stopMetricCapture();
WriteForm(e, metrics);
saveMetrics(metrics);
saveMetrics(metrics, eoe_ts);
[...document.getElementsByClassName("TiffModalContent")].forEach(el => {
while (el.children[1].hasChildNodes()) {
el.children[1].removeChild(el.children[1].firstChild);
}
while (el.children[2].hasChildNodes()) {
el.children[2].removeChild(el.children[2].firstChild);
}
while (el.children[3].hasChildNodes()) {
el.children[3].removeChild(el.children[3].firstChild);
}
});
document.getElementById("counter").innerHTML = "";
clearTimeout(interval);
init();
return true
}
} catch(err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment