Commit 95605193 by Jorem Magcawas

latest hr

parent c1b7986d
......@@ -11,7 +11,7 @@
// const SCHEMA_FILE = "./src/sample_schema/missing_fields.json"
// schema with 20 fields
const SCHEMA_FILE = "./src/sample_schema/20_field_schema.json"
// const SCHEMA_FILE = "./src/sample_schema/20_field_schema.json"
// schema with 15 fields
// const SCHEMA_FILE = "./src/sample_schema/15_field_schema.json"
......@@ -20,7 +20,9 @@ const SCHEMA_FILE = "./src/sample_schema/20_field_schema.json"
// const SCHEMA_FILE = "./src/sample_schema/10_field_schema.json"
// schema with 5 fields and all possible collections
// const SCHEMA_FILE = "./src/sample_schema/5_field_schema.json"
//const SCHEMA_FILE = "./src/sample_schema/5_field_schema.json"
const SCHEMA_FILE = "./src/sample_schema/Accounting Speed Test schema.json"
// const SCHEMA_FILE = "./src/sample_schema/Sample_Schema.json"
......@@ -40,3 +42,5 @@ const CONTEXTROOT = "gfs-explorer-ws"
const FOLDER_URL = DOMAIN + "/" + CONTEXTROOT + "/svc/gfs-rest/get-folder?parentPath="
const DOWNLOAD_URL = DOMAIN + "/" + CONTEXTROOT + "/svc/gfs-rest/get-download-link"
const IS_RETRIEVE_FROM_GFS = "Y"
const INVALID_KEYS = "F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,PrintScreen,ScrollLock,Pause,PageUp,PageDown,Insert,Delete,Control"
......@@ -9,6 +9,7 @@
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="./config.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://cdn.rawgit.com/seikichi/tiff.js/master/tiff.min.js"></script>
......@@ -109,7 +110,7 @@
</body>
<!--body onload-->
<script src="./config.js"></script>
<script src='dir.php'></script>
<script src="./src/captureMetrics/captureMetrics.js"></script>
<!-- fetch the schema -->
......
record_no,filename,speed,eoe_timestamp,avg_speed
1,0001SVI_0016_accounting.tif,8209.854661467565,9/29/2022 3:18:05 PM,8209.854661467565
2,0001SVI_0006_accounting.tif,8773.925194163714,9/29/2022 3:19:45 PM,8491.889927815639
3,SPEED TEST_031_accounting.tif,7092.418372993913,9/29/2022 3:20:34 PM,8025.39940954173
4,SPEED TEST_032_accounting.tif,5130.180249576337,9/29/2022 3:21:32 PM,7301.594619550382
5,SPEED TEST_035_accounting.tif,6683.48645689532,9/29/2022 3:22:16 PM,7177.97298701937
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Image_Source_Path>./input/0001SVI_0006_accounting.tif</Image_Source_Path>
<No_of_Keystrokes>225</No_of_Keystrokes>
<Processing_Time_Seconds>92.319</Processing_Time_Seconds>
<Payee>Pldt inc</Payee>
<Particulars>To Payment of Internet Services of POOI CAGAYAN with telephone number 783961731 for the period August 16-Sept-15-2020 as per supporting papers hereto attached in the amount</Particulars>
<Account_No>4311-12-369753</Account_No>
<Transaction_Date>2013-04-15</Transaction_Date>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Image_Source_Path>./input/0001SVI_0016_accounting.tif</Image_Source_Path>
<No_of_Keystrokes>193</No_of_Keystrokes>
<Processing_Time_Seconds>84.63</Processing_Time_Seconds>
<Payee>Alexander</Payee>
<Particulars>To payment of travelling expenses incurred during the household assessment for the month of july 2020</Particulars>
<Account_No>2020-06-500258</Account_No>
<Transaction_Date>1998-01-15</Transaction_Date>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Image_Source_Path>./input/SPEED TEST_031_accounting.tif</Image_Source_Path>
<No_of_Keystrokes>89</No_of_Keystrokes>
<Processing_Time_Seconds>45.175</Processing_Time_Seconds>
<Payee>Anthony P Cervantes</Payee>
<Particulars>BILL PERIOD FROM OCTBER 1 to 31, 1996</Particulars>
<Account_No>00103600357</Account_No>
<Transaction_Date>1996-11-02</Transaction_Date>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Image_Source_Path>./input/SPEED TEST_032_accounting.tif</Image_Source_Path>
<No_of_Keystrokes>74</No_of_Keystrokes>
<Processing_Time_Seconds>51.928</Processing_Time_Seconds>
<Payee>Mr Marcelo H pangilinan</Payee>
<Particulars>Monthly Bill</Particulars>
<Account_No>0036978520</Account_No>
<Transaction_Date>1997-09-01</Transaction_Date>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Image_Source_Path>./input/SPEED TEST_035_accounting.tif</Image_Source_Path>
<No_of_Keystrokes>78</No_of_Keystrokes>
<Processing_Time_Seconds>42.014</Processing_Time_Seconds>
<Payee>Ms Christina T Pangilinan</Payee>
<Particulars>Monthly Bill</Particulars>
<Account_No>0068941231</Account_No>
<Transaction_Date>1998-05-15</Transaction_Date>
\ No newline at end of file
......@@ -15,6 +15,8 @@ const csv_header = ['record_no', 'filename', 'speed', 'eoe_timestamp', 'avg_spee
let temp;
const keyArray = INVALID_KEYS.split(",");
const startMetricCapture = () => {
// reset key strokes
key_strokes = 0
......@@ -28,37 +30,41 @@ const startMetricCapture = () => {
window.onkeyup = (key) => {
const onfocus = document.activeElement
if(shortcut_flag && shortcut_triggers.includes(key.key)) {
if (shortcut_flag && shortcut_triggers.includes(key.key)) {
if (!key.ctrlKey && !key.shiftKey) { // will disregard key up event on shift or ctrl right after a short cut key combination
console.log('Shortcut trigger lifted') // for demonstration purposes
shortcut_flag = false
}
return
}
if((key.shiftKey && shift_shortcuts.includes(key.key)) || // shift shortcut
(key.ctrlKey && ctrl_shortcuts.includes(key.key))) { // ctrl shortcut
if(onfocus.nodeName !== 'INPUT' ||
!conflicts.includes(key.key)) { // ignore shortcuts with conflict if triggered inside input field
if ((key.shiftKey && shift_shortcuts.includes(key.key)) || // shift shortcut
(key.ctrlKey && ctrl_shortcuts.includes(key.key))) { // ctrl shortcut
if (onfocus.nodeName !== 'INPUT' ||
!conflicts.includes(key.key)) { // ignore shortcuts with conflict if triggered inside input field
console.log('Shortcut Triggered') // for demonstration purposes
shortcut_flag = true
return
}
}
if(key.shiftKey && key.ctrlKey && ctrl_shift_shortcuts.includes(key.key)) {
if (key.shiftKey && key.ctrlKey && ctrl_shift_shortcuts.includes(key.key)) {
console.log('Shortcut Triggered') // for demonstration purposes
shortcut_flag = true
return
}
key_strokes++
if (searchStringInArray(`${key.key}`, keyArray) == true || key.ctrlKey && key.key) {
console.log('key invalid');
} else {
key_strokes++
}
console.log(`key: ${key.key}; key_strokes: ${key_strokes}; time_spent: ${((Date.now()-time_start)/1000)-time_pause_spent}`) // for demonstration purposes
console.log(`key: ${key.key}; key_strokes: ${key_strokes}; time_spent: ${((Date.now() - time_start) / 1000) - time_pause_spent}`) // for demonstration purposes
}
window.onclick = (event) => {
if(event.path[0].id == 'pause') {
if (event.path[0].id == 'pause') {
console.log("im paused");
pauseMetricCapture();
}
......@@ -66,12 +72,20 @@ const startMetricCapture = () => {
showMetricCapture();
}
function searchStringInArray(str, strArray) {
for (var j = 0; j < strArray.length; j++) {
if (strArray[j] == str) return true;
}
return false;
}
const stopMetricCapture = () => {
const time_end = Date.now()
time_spent = (time_end-time_start)/1000 // time spend in seconds
const rate = (key_strokes/time_spent)*3600 // key strokes made per hour
time_spent = (time_end - time_start) / 1000 // time spend in seconds
const rate = (key_strokes / time_spent) * 3600 // key strokes made per hour
return {
key_strokes,
......@@ -84,20 +98,19 @@ let interval = null;
const showMetricCapture = () => {
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 rate = ((key_strokes/time_spent) * 3600).toFixed(0);
let rate = ((key_strokes / time_spent) * 3600).toFixed(0);
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
}
interval = setTimeout(showMetricCapture, 1000);
interval = setTimeout(showMetricCapture, 1000);
}
const saveMetrics = (metrics, eoe_ts) => {
try
{
try {
eoe_ts = formatDate(eoe_ts);
let rows = new Array();
if (sessionStorage.getItem('csv') === null) {
......@@ -115,30 +128,30 @@ const saveMetrics = (metrics, eoe_ts) => {
}
var myFile = new File(
[(rows.map(e => e.join(",")).join("\n"))],
sessionStorage.getItem('user_id') + '_Metrics_' + (new Date()).toISOString().slice(0,10).replace(/-/g,"") + ".csv",
{type: "text/plain;charset=utf-8"}
[(rows.map(e => e.join(",")).join("\n"))],
sessionStorage.getItem('user_id') + '_Metrics_' + (new Date()).toISOString().slice(0, 10).replace(/-/g, "") + ".csv",
{ type: "text/plain;charset=utf-8" }
);
let formData = new FormData();
let formData = new FormData();
formData.append("file", myFile);
formData.append("data", JSON.stringify({"metrics_dir": METRIC_FILES}));
formData.append("data", JSON.stringify({ "metrics_dir": METRIC_FILES }));
fetch('./src/captureMetrics/saveMetrics.php', {
method: "POST",
method: "POST",
body: formData
});
});
sessionStorage.setItem('csv', JSON.stringify(rows));
} catch(Err){
sessionStorage.setItem('csv', JSON.stringify(rows));
} catch (Err) {
console.log("Error: " + Err.description);
}
}
}
const escapeCSV = (filename) => {
return filename.includes(",") ? '"' + filename + '"' : filename;
}
const pauseMetricCapture = () => {
time_pause = Date.now();
time_pause = Date.now();
hideImage();
disableForm();
promptPaused();
......@@ -159,7 +172,7 @@ const unpauseMetricCapture = () => {
const hideImage = () => {
var tiffbody = document.getElementById("TiffModalBody");
tiffbody.style.opacity = 0;
tiffbody.style.opacity = 0;
}
const unhideImage = () => {
......@@ -170,7 +183,7 @@ const unhideImage = () => {
function promptPaused(){
function promptPaused() {
var viewer = document.getElementById('viewer');
var promptMain = document.createElement('div');
promptMain.setAttribute("id", "prompt");
......@@ -186,43 +199,43 @@ function promptPaused(){
promptMain.style.padding = '10px';
promptMain.style.display = 'block';
var message = document.createElement('p');
var message = document.createElement('p');
message.innerHTML = 'Session Paused';
var okButton = document.createElement('button');
okButton.innerHTML = 'continue';
okButton.onclick = function() {
okButton.onclick = function () {
promptMain.style.display = 'none';
unpauseMetricCapture();
};
promptMain.appendChild(message);
promptMain.appendChild(okButton);
viewer.appendChild(promptMain);
}
function disableForm(){
function disableForm() {
var pbutton = document.getElementById("pause");
pbutton.disabled = true;
var form = document.getElementById("fields");
var elements = form.elements;
for (var i = 0, len = elements.length; i < len; ++i) {
elements[i].disabled = true;
// elements[i].style.backgroundColor = "gray";
elements[i].disabled = true;
// elements[i].style.backgroundColor = "gray";
}
}
function enableForm(){
function enableForm() {
var pbutton = document.getElementById("pause");
pbutton.disabled = false;
var form = document.getElementById("fields");
var elements = form.elements;
for (var i = 0, len = elements.length; i < len; ++i) {
elements[i].disabled = false;
// elements[i].style.backgroundColor = "white";
elements[i].disabled = false;
// elements[i].style.backgroundColor = "white";
}
}
......
const init = () => {
let started_flag = false;
let started_flag = false;
displayFields("fields");
accessFile();
window.onkeydown = (key) => {
if(!started_flag) {
displayFields("fields");
accessFile();
window.onkeydown = (key) => {
if (!started_flag) {
if (searchStringInArray(`${key.key}`, keyArray) == true || key.ctrlKey && key.key) {
console.log('Invalid key cannot Start');
} else {
started_flag = true;
startMetricCapture();
}
}
}
}
function searchStringInArray(str, strArray) {
for (var j = 0; j < strArray.length; j++) {
if (strArray[j] == str) return true;
}
return false;
}
{
"SECTION":
{
"Payee":
{
"fieldLabel": "Payee",
"page": 1,
"validation":
{
"fieldLength": 50,
"collection": "alphanumeric",
"invalidchar": "`~!@#&$%^*._={}[]:;/\"|\\<>",
"mandatory": true
}
},
"Particulars":
{
"fieldLabel": "Particulars",
"validation":
{
"fieldLength": 200,
"collection": "alphanumeric",
"mandatory": true
}
},
"Account_No":
{
"fieldLabel": "Account No",
"validation":
{
"fieldLength": 30,
"collection": "alphanumeric",
"invalidchar": "`~!@#&$%^*_={}[]:;/\"|\\<>",
"mandatory": true
}
},
"Transaction_Date":
{
"fieldLabel": "Transaction Date",
"validation":
{
"fieldLength": 10,
"collection": "datepicker",
"mandatory": true
}
}
}
}
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