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 @@
<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>
......
......@@ -4,7 +4,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> Login Page </title>
<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>fetchConfig()</script>
</head>
<body>
<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());
function validateForm() {
const reqWindowWidth = 1366;
const reqWindowHeight = 768;
const reqBrowser = 'Chrome';
const reqWindowWidth = ALLOWED_DIMENSION_WIDTH;
const reqWindowHeight = ALLOWED_DIMENSION_HEIGHT;
const reqBrowser = ALLOWED_BROWSERS;
var windowWidth = getWindowWidth();
var windowHeight = getWindowHeight();
......
......@@ -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;
......
......@@ -11,7 +11,7 @@ const ctrl_shift_shortcuts = ['v', 'h', 'V', 'H']
const shortcut_triggers = ['Shift', 'Control']
let shortcut_flag = false
const csv_header = ['filename', 'speed', 'avg_speed'];
const csv_header = ['record_no', 'filename', 'speed', 'eoe_timestamp', 'avg_speed'];
const startMetricCapture = () => {
// reset key strokes
......@@ -77,24 +77,27 @@ 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) => {
const saveMetrics = (metrics, eoe_ts) => {
try
{
eoe_ts = formatDate(eoe_ts);
let rows = new Array();
if (sessionStorage.getItem('csv') === null) {
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 {
rows = JSON.parse(sessionStorage.getItem('csv'));
let size = rows.length - 1;
......@@ -103,7 +106,7 @@ const saveMetrics = (metrics) => {
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(
......@@ -121,7 +124,7 @@ const saveMetrics = (metrics) => {
sessionStorage.setItem('csv', JSON.stringify(rows));
} catch(Err){
alert("Error: " + Err.description);
console.log("Error: " + Err.description);
}
}
......@@ -138,4 +141,8 @@ const pauseMetricCapture = () => {
const unpauseMetricCapture = () => {
time_pause_spent += (Date.now() - time_pause) / 1000;
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
var embed = 0; //checker if which file is using the function
const fetchConfig = () => {
$.ajax({ //locates the config file
url: './config.js',
url: './config.js',
async: false,
success: function(data){},
error: function(data){
handleError();
success: function (data) { },
error: function (data) {
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 (confirm("config.js not found, application will not commence")) {}
}
if (confirm(`${file} not found, application will not commence`)) { }
}
found = false;
}
const init = () => {
let started_flag = false;
displayFields("fields");
accessFile();
window.onkeydown = (key) => {
if(!started_flag) {
started_flag = true;
startMetricCapture();
}
}
}
const submitForm = (e) => {
try {
let eoe_ts = new Date().toLocaleString();
const Form = Settings.SrcElement(e);
const { elements } = Form
let error = false
......@@ -38,7 +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