Commit 0fedb4b3 by Daniel Bawag

Merge branch 'feature-WG-66' into 'development'

SVI - Web-GDE - beta 2 See merge request !5
parents d1eff105 ca50c024
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
<script src="./src/XMLWriter/XML_Saver.js" language="javascript"></script> <script src="./src/XMLWriter/XML_Saver.js" language="javascript"></script>
<script src="./src/submit/submit.js" language="javascript"></script> <script src="./src/submit/submit.js" language="javascript"></script>
<script src="./src/fetchConfig/fetchConfig.js"></script> <script src="./src/fetchConfig/fetchConfig.js"></script>
<script src="./src/init/init.js"></script>
</head> </head>
<script> <script>
...@@ -54,7 +55,7 @@ ...@@ -54,7 +55,7 @@
<button id='pause'>Pause</button> <button id='pause'>Pause</button>
</div> </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> </aside>
<!-- Embed viewer --> <!-- Embed viewer -->
<main id="viewer"> <main id="viewer">
...@@ -119,17 +120,7 @@ ...@@ -119,17 +120,7 @@
noConfig.style.display = "block"; noConfig.style.display = "block";
} }
} else { } else {
let started_flag = false; init();
displayFields("fields");
accessFile();
window.onkeydown = (key) => {
if(!started_flag) {
started_flag = true;
startMetricCapture();
}
}
} }
</script> </script>
<script src="./src/endSession/endSession.js"></script> <script src="./src/endSession/endSession.js"></script>
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title> Login Page </title> <title> Login Page </title>
<link rel="stylesheet" href="./login.css"> <link rel="stylesheet" href="./login.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="./src/fetchConfig/fetchConfig.js"></script> <script src="./src/fetchConfig/fetchConfig.js"></script>
<script>fetchConfig()</script>
</head> </head>
<body> <body>
<div class="main-div"> <div class="main-div">
......
const ALLOWED_KPH = 8000;
const ALLOWED_DIMENSION_WIDTH = 1366;
const ALLOWED_DIMENSION_HEIGHT = 768;
const ALLOWED_BROWSERS = "Chrome";
\ No newline at end of file
...@@ -13,9 +13,9 @@ console.log(getBrowserName()); ...@@ -13,9 +13,9 @@ console.log(getBrowserName());
function validateForm() { function validateForm() {
const reqWindowWidth = 1366; const reqWindowWidth = ALLOWED_DIMENSION_WIDTH;
const reqWindowHeight = 768; const reqWindowHeight = ALLOWED_DIMENSION_HEIGHT;
const reqBrowser = 'Chrome'; const reqBrowser = ALLOWED_BROWSERS;
var windowWidth = getWindowWidth(); var windowWidth = getWindowWidth();
var windowHeight = getWindowHeight(); var windowHeight = getWindowHeight();
......
...@@ -69,8 +69,6 @@ function accessFile() { ...@@ -69,8 +69,6 @@ function accessFile() {
const blob = await res.blob(); const blob = await res.blob();
status('download completed'); status('download completed');
const request = indexedDB.open("ImageDatabase", 1); const request = indexedDB.open("ImageDatabase", 1);
request.onsuccess = async function () { request.onsuccess = async function () {
// console.log("Database opened successfully " + val ); // console.log("Database opened successfully " + val );
...@@ -215,7 +213,7 @@ function accessFile() { ...@@ -215,7 +213,7 @@ function accessFile() {
function Input_files() { function Input_files() {
//Dirfiles from dir.php //Dirfiles from dir.php
var urls = Dirfiles; //from config var urls = Object.assign(new Array(), Dirfiles); //from config
var count; var count;
if((localStorage.length) == 0){ if((localStorage.length) == 0){
count = 0; count = 0;
......
...@@ -11,7 +11,7 @@ const ctrl_shift_shortcuts = ['v', 'h', 'V', 'H'] ...@@ -11,7 +11,7 @@ const ctrl_shift_shortcuts = ['v', 'h', 'V', 'H']
const shortcut_triggers = ['Shift', 'Control'] const shortcut_triggers = ['Shift', 'Control']
let shortcut_flag = false let shortcut_flag = false
const csv_header = ['filename', 'speed', 'avg_speed']; const csv_header = ['record_no', 'filename', 'speed', 'eoe_timestamp', 'avg_speed'];
const startMetricCapture = () => { const startMetricCapture = () => {
// reset key strokes // reset key strokes
...@@ -77,24 +77,27 @@ const stopMetricCapture = () => { ...@@ -77,24 +77,27 @@ const stopMetricCapture = () => {
} }
} }
let interval;
const showMetricCapture = () => { const showMetricCapture = () => {
const obj = document.getElementById("counter"); const obj = document.getElementById("counter");
if(key_strokes != 0) { if(key_strokes != 0) {
let time_spent = ((Date.now() - time_start) / 1000) - time_pause_spent; let time_spent = ((Date.now() - time_start) / 1000) - time_pause_spent;
let rate = ((key_strokes/time_spent) * 3600).toFixed(0); 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 obj.innerHTML = rate + " kph"; // immediately apply start value
} }
setTimeout(showMetricCapture, 1000); interval = setTimeout(showMetricCapture, 1000);
} }
const saveMetrics = (metrics) => { const saveMetrics = (metrics, eoe_ts) => {
try try
{ {
eoe_ts = formatDate(eoe_ts);
let rows = new Array(); let rows = new Array();
if (sessionStorage.getItem('csv') === null) { if (sessionStorage.getItem('csv') === null) {
rows.push(csv_header); rows.push(csv_header);
rows.push([escapeCSV(File_Path.replace(/^.*[\\\/]/, '')), metrics.rate, metrics.rate]); rows.push([1, escapeCSV(File_Path.replace(/^.*[\\\/]/, '')), metrics.rate, eoe_ts, metrics.rate]);
} else { } else {
rows = JSON.parse(sessionStorage.getItem('csv')); rows = JSON.parse(sessionStorage.getItem('csv'));
let size = rows.length - 1; let size = rows.length - 1;
...@@ -103,7 +106,7 @@ const saveMetrics = (metrics) => { ...@@ -103,7 +106,7 @@ const saveMetrics = (metrics) => {
let newAvg = ((avg * size) + metrics.rate) / (size + 1); let newAvg = ((avg * size) + metrics.rate) / (size + 1);
rows.push([escapeCSV(File_Path.replace(/^.*[\\\/]/, '')), metrics.rate, newAvg]); rows.push([(size + 1), escapeCSV(File_Path.replace(/^.*[\\\/]/, '')), metrics.rate, eoe_ts, newAvg]);
} }
var myFile = new File( var myFile = new File(
...@@ -121,7 +124,7 @@ const saveMetrics = (metrics) => { ...@@ -121,7 +124,7 @@ const saveMetrics = (metrics) => {
sessionStorage.setItem('csv', JSON.stringify(rows)); sessionStorage.setItem('csv', JSON.stringify(rows));
} catch(Err){ } catch(Err){
alert("Error: " + Err.description); console.log("Error: " + Err.description);
} }
} }
...@@ -138,4 +141,8 @@ const pauseMetricCapture = () => { ...@@ -138,4 +141,8 @@ const pauseMetricCapture = () => {
const unpauseMetricCapture = () => { const unpauseMetricCapture = () => {
time_pause_spent += (Date.now() - time_pause) / 1000; time_pause_spent += (Date.now() - time_pause) / 1000;
time_pause = 0; time_pause = 0;
}
const formatDate = (date) => {
return date.replace(",", "");
} }
\ No newline at end of file
...@@ -2,18 +2,27 @@ var found = true; //variable to return ...@@ -2,18 +2,27 @@ var found = true; //variable to return
var embed = 0; //checker if which file is using the function var embed = 0; //checker if which file is using the function
const fetchConfig = () => { const fetchConfig = () => {
$.ajax({ //locates the config file $.ajax({ //locates the config file
url: './config.js', url: './config.js',
async: false, async: false,
success: function(data){}, success: function (data) { },
error: function(data){ error: function (data) {
handleError(); handleError("application config");
}, },
}) })
$.ajax({ //locates the project config file
url: './project_config.js',
async: false,
success: function (data) { },
error: function (data) {
handleError("project config");
},
})
} }
const handleError = () => { const handleError = (file) => {
if (embed == 0) {//to ensure the prompt appears only once if (embed == 0) {//to ensure the prompt appears only once
if (confirm("config.js not found, application will not commence")) {} if (confirm(`${file} not found, application will not commence`)) { }
} }
found = false; found = false;
} }
const init = () => {
let started_flag = false;
displayFields("fields");
accessFile();
window.onkeydown = (key) => {
if(!started_flag) {
started_flag = true;
startMetricCapture();
}
}
}
const submitForm = (e) => { const submitForm = (e) => {
try { try {
let eoe_ts = new Date().toLocaleString();
const Form = Settings.SrcElement(e); const Form = Settings.SrcElement(e);
const { elements } = Form const { elements } = Form
let error = false let error = false
...@@ -38,7 +39,23 @@ const submitForm = (e) => { ...@@ -38,7 +39,23 @@ const submitForm = (e) => {
else { else {
const metrics = stopMetricCapture(); const metrics = stopMetricCapture();
WriteForm(e, metrics); 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 return true
} }
} catch(err) { } 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