diff --git a/express/asset/frontend.min.js b/express/asset/frontend.min.js new file mode 100644 index 0000000..daa3d12 --- /dev/null +++ b/express/asset/frontend.min.js @@ -0,0 +1 @@ +let a;let b;function c(){return (Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15))}async function d(){try {var A=await fetch('/getNextAnimal');var _=await A.json();document.getElementById('animal-name').textContent=_.animalName} catch (B) {console.error('Error fetching data:',B)}}function e(){var A=document.cookie.replace(/(?:(?:^|.*;\s*)sessionId\s*=\s*([^;]*).*$)|^.*$/,'$1');if(!A){var _=c();document.cookie=`sessionId=${_}`;return _}return A}function f(){var A=c();document.cookie=`sessionId=${A}`;g();e()}function g(){a=new Date()}function h(){if(a&&b){var A=b-a;console.log(`Time since session start: ${A} milliseconds`)}}document.getElementById('isCritterButton').addEventListener('click',()=>i('is critter',e()));document.getElementById('isNotCritterButton').addEventListener('click',()=>i('is not critter',e()));document.getElementById('startOverButton').addEventListener('click',()=>{f();d()});async function i(A,_){try {var B=new Date();if(b){var C=B-b,_b=document.getElementById('animal-name').textContent,_c=JSON.stringify({animal:_b,button:A,session:_,difference:C,time:a});await fetch('/recordButtonClick',{method:'POST',headers:{'Content-Type':'application/json'},body:_c})}b=B;h();d()} catch (_a) {console.error('Error recording button click:',_a)}}d();g(); diff --git a/express/index.html b/express/index.html index 997aff4..895eb64 100644 --- a/express/index.html +++ b/express/index.html @@ -21,7 +21,7 @@ - +