trying out uglify-js, even though it is deprecated
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
20e560c55c
commit
02a17489c7
3 changed files with 16 additions and 2 deletions
1
express/asset/frontend.min.js
vendored
Normal file
1
express/asset/frontend.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
let sessionStartTime;let lastButtonClickTime;function generateSessionId(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}async function getNextAnimal(){try{const response=await fetch("/getNextAnimal");const data=await response.json();document.getElementById("animal-name").textContent=data.animalName}catch(error){console.error("Error fetching data:",error)}}function getSessionId(){const sessionId=document.cookie.replace(/(?:(?:^|.*;\s*)sessionId\s*=\s*([^;]*).*$)|^.*$/,"$1");if(!sessionId){const newSessionId=generateSessionId();document.cookie=`sessionId=${newSessionId}`;return newSessionId}return sessionId}function clearSessionId(){const newSessionId=generateSessionId();document.cookie=`sessionId=${newSessionId}`;setSessionStartTime();getSessionId()}function setSessionStartTime(){sessionStartTime=new Date}function displayTimeDifference(){if(sessionStartTime&&lastButtonClickTime){const timeDifference=lastButtonClickTime-sessionStartTime;console.log(`Time since session start: ${timeDifference} milliseconds`)}}document.getElementById("isCritterButton").addEventListener("click",()=>{recordButtonClick("is critter",getSessionId())});document.getElementById("isNotCritterButton").addEventListener("click",()=>{recordButtonClick("is not critter",getSessionId())});document.getElementById("startOverButton").addEventListener("click",()=>{clearSessionId();getNextAnimal()});async function recordButtonClick(buttonName,sessionId){try{const currentTime=new Date;if(lastButtonClickTime){const timeDifference=currentTime-lastButtonClickTime;const animal=document.getElementById("animal-name").textContent;const bodyData=JSON.stringify({animal:animal,button:buttonName,session:sessionId,difference:timeDifference,time:sessionStartTime});await fetch("/recordButtonClick",{method:"POST",headers:{"Content-Type":"application/json"},body:bodyData})}lastButtonClickTime=currentTime;displayTimeDifference();getNextAnimal()}catch(error){console.error("Error recording button click:",error)}}getNextAnimal();setSessionStartTime();
|
14
express/package-lock.json
generated
14
express/package-lock.json
generated
|
@ -12,7 +12,8 @@
|
||||||
"body-parser": "^1.20.2",
|
"body-parser": "^1.20.2",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"sqlite3": "^5.1.6"
|
"sqlite3": "^5.1.6",
|
||||||
|
"uglify-js": "^3.17.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@gar/promisify": {
|
"node_modules/@gar/promisify": {
|
||||||
|
@ -1716,6 +1717,17 @@
|
||||||
"node": ">= 0.6"
|
"node": ">= 0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/uglify-js": {
|
||||||
|
"version": "3.17.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz",
|
||||||
|
"integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==",
|
||||||
|
"bin": {
|
||||||
|
"uglifyjs": "bin/uglifyjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/unique-filename": {
|
"node_modules/unique-filename": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz",
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"body-parser": "^1.20.2",
|
"body-parser": "^1.20.2",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"sqlite3": "^5.1.6"
|
"sqlite3": "^5.1.6",
|
||||||
|
"uglify-js": "^3.17.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue