From d82e6fcb9df207a335dc182f6c7cee601a38a175 Mon Sep 17 00:00:00 2001 From: Suvodip Date: Sat, 15 Jun 2024 20:33:43 +0530 Subject: [PATCH] s2 --- public/saveGameData.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/public/saveGameData.js b/public/saveGameData.js index 8ac6170..475aa0e 100644 --- a/public/saveGameData.js +++ b/public/saveGameData.js @@ -4,6 +4,23 @@ const userId = urlParams.get('userid'); const gameId = urlParams.get('id'); +// Get the current time +let startTime = new Date(); + +// Simulate some process with a delay +setTimeout(() => { + // Get the current time again + let endTime = new Date(); + + // Calculate the difference in milliseconds + let timeDifference = endTime - startTime; + + // Convert milliseconds to seconds + let timeDifferenceInSeconds = timeDifference / 1000; + + console.log(`Time difference: ${timeDifferenceInSeconds} seconds`); +}, 3000); // 3-second delay + const url = window.location.href; const gameName = url.split('/'); const gameType = gameName[3].split('?id='); @@ -31,16 +48,18 @@ function submitUserData(drawingZone) { let userData = { - 'gameType': gameVersion, + 'gameName': gameVersion, 'gameID': gameId, 'screenShot': imageCode, - 'userId' : userId + 'userId' : userId, + 'gameTime' : '10', + 'score' : '100' // 'starts': formattedDateTime, // 'game_start' : gameStartTime, }; console.log(userData); - fetch(`https://save-game-data.teachertrainingchennai.in/saveGameData`, { + fetch(`http://192.168.0.166:3000/save-data`, { method: 'POST', headers: { 'Content-Type' : 'application/json'