diff --git a/info.txt b/info.txt new file mode 100644 index 0000000..1d7ca1a --- /dev/null +++ b/info.txt @@ -0,0 +1 @@ +1. Auto brake line Drag v4 Left & Right Heading. \ No newline at end of file diff --git a/public/assets/color_button.png b/public/assets/color_button.png new file mode 100644 index 0000000..6d11e5c Binary files /dev/null and b/public/assets/color_button.png differ diff --git a/public/saveGameData.js b/public/saveGameData.js index 99d83a4..1069d54 100644 --- a/public/saveGameData.js +++ b/public/saveGameData.js @@ -1,7 +1,7 @@ const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); const userId = urlParams.get('userid'); -const gameId = urlParams.get('id'); +let gameId; let startTime = Date.now(); @@ -9,9 +9,20 @@ let startTime = Date.now(); const url = window.location.href; const gameName = url.split('/'); const gameType = gameName[3].split('?id='); -const gameVersion = gameType[0] + '-' + gameName[4]; +let gameVersion; +if(gameType[0] == "guided-tracing"){ + gameVersion = gameType[0].split('?')[0]; + gameId = gameName[4]; +} else if(gameName.length == 5){ + gameVersion = gameName[3]; + gameId = urlParams.get('id'); +}else if(gameName.length == 6){ + gameVersion = gameType[0] + '-' + gameName[4]; + gameId = urlParams.get('id'); +} + function submitUserData(drawingZone) { @@ -22,7 +33,7 @@ function submitUserData(drawingZone) { let imageCode; let gameScore; - let scoreTotal=0; + if(scoreTotal){ gameScore = scoreTotal; }else{ @@ -45,6 +56,21 @@ function submitUserData(drawingZone) { link.click(); document.body.removeChild(image); imageCode = image.src; + }else if( gameType[0] == "guided-tracing"){ + // submitButton.setVisible(true); + // snapshotButton.setVisible(true); + // customCursor.setVisible(true); + image.style.width = '160px'; + image.style.height = '120px'; + image.style.paddingLeft = '2px'; + document.body.appendChild(image); + // Download the snapshot as an image + const link = document.createElement('a'); + link.href = image.src; + link.download = `guided-tracing-${gameId}.png`; + link.click(); + document.body.removeChild(image); + imageCode = image.src; } @@ -59,9 +85,9 @@ function submitUserData(drawingZone) { // 'starts': formattedDateTime, // 'game_start' : gameStartTime, }; - console.log(userData); + // console.log(userData); - fetch(`http://192.168.0.166:3000/save-data`, { + fetch(`https://phaser-game-api.s38.siliconpin.com/save-data`, { method: 'POST', headers: { 'Content-Type' : 'application/json' @@ -70,7 +96,7 @@ function submitUserData(drawingZone) { }) .then(response => { if(response.ok){ - console.log('Data Saved', response) + // console.log('Data Saved', response) } else{ // console.log('Something Wrong', response) } diff --git a/src/pages/cross/cross_phonics_v1.astro b/src/pages/cross/cross_phonics_v1.astro index 482b675..b8681f2 100644 --- a/src/pages/cross/cross_phonics_v1.astro +++ b/src/pages/cross/cross_phonics_v1.astro @@ -10,7 +10,7 @@ import Layout from "../../layouts/Layout.astro";