number 4 complete start from 5 tomorow

This commit is contained in:
dev sp
2023-12-05 15:34:40 +00:00
parent 1253dd5911
commit dfa0499ab0
70 changed files with 1289 additions and 264 deletions

View File

@@ -32,17 +32,24 @@ import Layout from '../../layouts/Layout.astro';
var snapshotButton;
let submitButton;
let formattedDateTime;
let shortUniqueID;
gameResult = [];
window.onload = function() {
// Get the current date and time
currentDate = new Date();
// Format the date and time as a string
formattedDateTime = currentDate.toLocaleString();
// Log the formatted date and time to the console
formattedDateTime = currentDate.toLocaleString();
console.log("Page loaded on: " + formattedDateTime);
};
function generateShortUniqueID(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let result = '';
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
result += characters.charAt(randomIndex);
}
return result;
}
// shortUniqueID = generateShortUniqueID(10); // Change 10 to the desired length
// console.log(shortUniqueID);
const params = new URLSearchParams(window.location.search);
const paramsID = params.get('id');
@@ -104,23 +111,25 @@ import Layout from '../../layouts/Layout.astro';
});
const URL = window.location.href;
const gameName = URL.split('/');
var gameResult = {
'f1' : gameName[3],
'f2' : formattedDateTime,
}
let userData = {
'status' : 'published',
'user_id': 'drawing@beanstalkedu.com',
'game_name': gameName[3],
'game_open': formattedDateTime,
};
function submitUserData() {
fetch(`https://management.beanstalkedu.com/items/game_result`, {
method: 'POST',
headers: {
'Content-Type' : 'application/json'
},
body: JSON.stringify(gameResult)
body: JSON.stringify(userData)
})
.then(response => {
if(response.ok){
console.log('Data Saved', response)
// console.log('Data Saved', response)
} else{
console.log('Something Wrong', response)
// console.log('Something Wrong', response)
}
})
.catch(error => {
@@ -142,6 +151,7 @@ import Layout from '../../layouts/Layout.astro';
submitButton.setVisible(true);
submitButton.setInteractive().on('pointerdown', () => {
console.log('Clicked');
submitButton.setVisible(false);
submitNotic.setVisible(true);
// windowLoad();
submitUserData();