express: ready for voting, but the /results display is not good
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
e3150bd53b
commit
5c4e28e2de
4 changed files with 83 additions and 5 deletions
|
@ -30,7 +30,10 @@ function getSessionId() {
|
|||
}
|
||||
|
||||
function clearSessionId() {
|
||||
document.cookie = ``;
|
||||
const newSessionId = generateSessionId();
|
||||
document.cookie = `sessionId=${newSessionId}`;
|
||||
setSessionStartTime();
|
||||
getSessionId();
|
||||
}
|
||||
|
||||
// Function to set session start time
|
||||
|
@ -58,6 +61,7 @@ document.getElementById('isNotCritterButton').addEventListener('click', () => {
|
|||
|
||||
document.getElementById('startOverButton').addEventListener('click', () => {
|
||||
clearSessionId();
|
||||
getNextAnimal();
|
||||
});
|
||||
|
||||
// Function to record button clicks on the server
|
||||
|
@ -68,12 +72,14 @@ async function recordButtonClick(buttonName, sessionId) {
|
|||
const timeDifference = currentTime - lastButtonClickTime;
|
||||
// Include the time difference in the POST request data
|
||||
const animal = document.getElementById('animal-name').textContent;
|
||||
const bodyData = JSON.stringify({ "animal": animal, "button": buttonName, "session": sessionId, "difference": timeDifference, "time": sessionStartTime });
|
||||
console.log(bodyData);
|
||||
await fetch('/recordButtonClick', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ "animal": animal, "button": buttonName, "session": sessionId, "difference": timeDifference, "time": sessionStartTime }),
|
||||
body: bodyData,
|
||||
});
|
||||
}
|
||||
lastButtonClickTime = currentTime; // Record the timestamp of the button click
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue