new_drawing_game

pull/5/head
Dev 1 2023-08-30 21:30:02 +05:30
parent b48a2e2fdf
commit 35c4c21b30
11 changed files with 620 additions and 36 deletions

13
course.txt Normal file
View File

@ -0,0 +1,13 @@
Main Headingd;
*Add "or Pre-Primary school";
Our Courses:
Computer Course,
Vocational Course,
ITI Course,
Pre-Primary Franchises,
Heritage English Medium School
Mordern Heritage Academy,
StarLight Academy,

BIN
public/assets/cow.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
public/assets/rose.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -0,0 +1 @@
<svg fill="#000000" height="200px" width="200px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 512 512" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g> <g> <path d="M474.984,206.267c-3.018-1.346-6.477-1.346-9.495,0c-6.175,2.774-37.016,17.736-37.016,40.753 c0,0.536,0.013,1.07,0.032,1.602h-22.458c-1.508-4.585-3.627-8.863-6.252-12.755c15.875-2.018,30.052-10.906,38.816-24.631 c10.051-15.741,11.355-35.262,3.488-52.224c-15.562-33.521-42.588-60.543-76.118-76.096c-0.045-0.021-0.092-0.039-0.137-0.06 c-1.014-19.127-8.42-37.181-21.316-51.57c-3.262-3.645-6.918-7.057-10.841-10.156c-2.426-1.904-5.513-2.774-8.578-2.403 c-3.053,0.371-5.85,1.938-7.754,4.376c-5.459,6.971-9.743,14.708-12.752,22.914c-4.008-2.657-8.238-4.989-12.697-6.94 c-4.536-1.99-9.292-3.588-14.135-4.752c-6.231-1.501-12.491,2.332-13.995,8.557c-1.57,6.497-2.368,13.155-2.368,19.792 c0,23.737,10.254,46.562,27.747,62.423c-0.305,2.346-0.458,4.713-0.458,7.082v11.964l-47.444,47.444 c-15.443-31.791-38.681-59.051-67.991-79.51C138.325,87.688,97.27,74.792,54.52,74.792c-19.21,0-37.341,7.382-51.037,20.789 c-3.331,3.273-4.388,8.218-2.67,12.559c1.718,4.341,5.862,7.243,10.528,7.347c17.399,0.395,31.56,14.915,31.56,32.35 c0,0.174,0,0.348,0.012,0.511v137.349c0,114.506,93.149,207.483,207.655,207.483v-0.015c2.123,0.117,4.254,0.193,6.397,0.193 h150.797c18.878,0,34.237-15.359,34.237-34.238c0-18.879-15.359-34.237-34.237-34.237h-45.284 c6.569-14.701,9.982-30.651,9.982-47.02c0-22.237-6.324-43.023-17.258-60.663h93.839c17.596,0,32.129-13.321,34.063-30.408 C499.994,281.415,512,265.735,512,247.02C512,224.003,481.159,209.041,474.984,206.267z M328.732,48.5 c7.042,8.477,11.569,18.56,13.261,29.321c-2.862,0.056-5.719,0.332-8.548,0.848c-2.671-5.374-5.907-10.433-9.679-15.141 C324.758,58.321,326.424,53.266,328.732,48.5z M66.128,285.696v-137.86c0-0.197,0-0.383-0.012-0.58 c-0.151-14.405-5.757-27.985-15.844-38.293c-3.285-3.355-6.93-6.256-10.841-8.636c4.817-1.532,9.889-2.321,15.09-2.321 c37.968,0,74.438,11.445,105.452,33.104c28.271,19.735,50.21,46.584,63.804,77.952l-40.057,40.057 c-47.655,47.656-59.194,120.897-28.821,182.443c0.222,0.671,7.744,13.285,11.82,18.384 C107.055,419.359,66.128,357.221,66.128,285.696z M449.042,293.983H336.274c-20.704-19.586-48.627-31.616-79.309-31.616 c-6.411,0-11.607,5.198-11.607,11.607c0,6.411,5.197,11.607,11.607,11.607c50.883,0,92.28,41.396,92.28,92.279 c0,18.689-5.566,36.693-16.097,52.068c-2.434,3.553-2.7,8.161-0.692,11.972c2.008,3.81,5.961,6.195,10.268,6.195h65.037 c6.078,0,11.022,4.945,11.022,11.022s-4.945,11.023-11.022,11.023H256.965c-33.384,0-64.155-18.053-80.506-47.156 c-0.15-0.41-0.317-0.817-0.517-1.216c-26.262-52.716-16.539-115.501,24.192-156.235l108.379-108.378 c2.176-2.178,3.4-5.129,3.4-8.208v-16.771c0-2.867,0.39-5.726,1.157-8.498c1.271-4.588-0.39-9.489-4.189-12.358 c-15.188-11.475-24.256-29.661-24.256-48.647c0-0.463,0.005-0.929,0.016-1.392c6.918,3.335,13.071,7.908,18.309,13.612 c5.746,6.267,10.059,13.521,12.818,21.563c1.04,3.03,3.285,5.496,6.205,6.814c2.919,1.316,6.254,1.371,9.214,0.144 c6.439-2.665,13.359-3.107,20.024-1.271c1.682,0.46,3.378,1.084,5.021,1.842c28.54,13.239,51.557,36.253,64.811,64.799 c4.514,9.734,3.768,20.933-1.996,29.96c-5.823,9.119-15.37,14.349-26.195,14.349h-34.752c-6.411,0-11.607,5.198-11.607,11.607 c0,6.218,4.895,11.281,11.04,11.578l-0.001,0.016h0.163c14.045,0.499,25.908,11.387,27.579,25.327 c0.708,5.827,5.653,10.214,11.526,10.214h52.245c2.96,0,5.641,1.258,7.812,3.227c3.262,2.959,3.262,6.895,3.262,7.846 C460.115,289.015,455.147,293.983,449.042,293.983z M477.644,264c-1.264-1.909-2.723-3.703-4.367-5.351 c-5.835-5.815-13.381-9.272-21.494-9.912c-0.052-0.569-0.095-1.14-0.095-1.719c0-4.028,8.508-11.712,18.572-17.202 c10.737,5.792,18.525,13.511,18.525,17.202C488.785,254.539,484.178,261.114,477.644,264z"></path> </g> </g> <g> <g> <path d="M224.491,400.94c-12.503-23.256-13.021-51.306-1.386-75.032c2.823-5.756,0.445-12.71-5.31-15.533 c-5.755-2.821-12.709-0.446-15.533,5.31c-14.925,30.432-14.258,66.412,1.783,96.247c2.095,3.898,6.097,6.114,10.233,6.114 c1.855,0,3.738-0.447,5.487-1.386C225.41,413.625,227.527,406.586,224.491,400.94z"></path> </g> </g> <g> <g> <circle cx="359.618" cy="150.976" r="11.607"></circle> </g> </g> </g></svg>

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -0,0 +1,97 @@
---
import Layout from '../layouts/Layout.astro';
---
<Layout title='Drawing Game'>
<main>
<div>
<p>Drawing Game</p>
<div id="game-container"></div>
</div>
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
</main>
</Layout>
<script is:inline>
// Create a new Phaser game
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
scene: {
preload: preload,
create: create,
update: update
}
};
var game = new Phaser.Game(config);
// Declare global variables
var graphics;
var lastPointer;
var color = 0xff0000;
var thickness = 5;
// Load assets
function preload() {
// Preload any assets you need for the game, such as images or sounds
}
// Create the game world
function create() {
// Create the graphics object
graphics = this.add.graphics();
// Set up the input events for the game
this.input.on('pointerdown', function(pointer) {
lastPointer = pointer;
});
this.input.on('pointermove', function(pointer) {
if (lastPointer) {
graphics.lineStyle(thickness, color);
graphics.beginPath();
graphics.moveTo(lastPointer.x, lastPointer.y);
graphics.lineTo(pointer.x, pointer.y);
graphics.strokePath();
lastPointer = pointer;
}
});
this.input.on('pointerup', function(pointer) {
lastPointer = null;
});
// Set up the UI for the game
var colorPicker = this.add.rectangle(50, 50, 40, 40, color);
colorPicker.setInteractive();
colorPicker.on('pointerdown', function() {
// Open a color picker dialog to select a color
var input = document.createElement('input');
input.type = 'color';
input.oninput = function() {
color = Phaser.Display.Color.ValueToColor(input.value).color;
colorPicker.fillColor = color;
};
input.click();
});
var thicknessText = this.add.text(150, 50, 'Thickness: ' + thickness, { font: '24px Arial', fill: '#ffffff' });
var increaseButton = this.add.text(150, 100, '+', { font: '24px Arial', fill: '#ffffff' });
increaseButton.setInteractive();
increaseButton.on('pointerdown', function() {
thickness++;
thicknessText.setText('Thickness: ' + thickness);
});
var decreaseButton = this.add.text(200, 100, '-', { font: '24px Arial', fill: '#ffffff' });
decreaseButton.setInteractive();
decreaseButton.on('pointerdown', function() {
if (thickness > 1) {
thickness--;
thicknessText.setText('Thickness: ' + thickness);
}
});
}
// Update the game world
function update() {
// Update any game logic or animations here
}
</script>

View File

@ -0,0 +1,258 @@
---
import Layout from '../../layouts/Layout.astro';
---
<Layout title='Drawing Game'>
<main>
<div>
</div>
<script is:inline src="/assets/js/phaser_3.60.0.js"></script>
</main>
</Layout>
<script is:inline>
const config = {
type: Phaser.AUTO,
width: window.innerWidth,
height: window.innerHeight,
backgroundColor: '#05b3a4',
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
},
scene: {
preload: preload,
create: create,
update: update,
},
};
const game = new Phaser.Game(config);
const displayW = window.innerWidth;
const displayH = window.innerHeight;
let graphics;
let outlineImage;
let isDrawing = false;
let selectedColor = '#ff0000'; // Default color
let brushSize = 5; // Default brush size
function preload() {
this.load.image('outline', '/assets/cow.png');
}
function create() {
outlineImage = this.add.image(displayW / 2, displayH / 2, 'outline');
graphics = this.add.graphics();
// Create a color picker using HTML input type color
const colorPicker = document.createElement('input');
colorPicker.type = 'color';
colorPicker.value = selectedColor;
colorPicker.className = 'color-picker';
colorPicker.addEventListener('input', (event) => {
selectedColor = event.target.value;
});
document.body.appendChild(colorPicker);
// Create a brush size slider using HTML input type range
const sliderContainer = document.createElement('div');
sliderContainer.className = 'slider-container';
document.body.appendChild(sliderContainer);
const slider = document.createElement('input');
slider.type = 'range';
slider.min = '2';
slider.max = '20';
slider.value = brushSize.toString(); // Set initial value to brushSize
slider.className = 'slider';
sliderContainer.appendChild(slider);
slider.addEventListener('input', (event) => {
brushSize = parseInt(event.target.value);
slider.style.backgroundSize = `calc(${(brushSize - 2) * 100 / 18}% + 20px) 100%`;
});
const clearButton = document.createElement('button');
clearButton.textContent = 'Clear';
clearButton.className = 'clear-button';
clearButton.addEventListener('click', () => {
clearDrawing();
});
document.body.appendChild(clearButton);
this.input.on('pointerdown', () => {
isDrawing = true;
startDrawing(this.input.x, this.input.y);
});
this.input.on('pointermove', () => {
if (isDrawing) {
continueDrawing(this.input.x, this.input.y);
}
});
this.input.on('pointerup', () => {
if (isDrawing) {
finishDrawing();
}
isDrawing = false;
});
}
function startDrawing(x, y) {
graphics.lineStyle(brushSize * 2, Phaser.Display.Color.HexStringToColor(selectedColor).color);
graphics.beginPath();
graphics.moveTo(x, y);
}
function continueDrawing(x, y) {
graphics.lineTo(x, y);
graphics.strokePath();
}
function finishDrawing() {
// No need for additional actions here
}
function clearDrawing() {
graphics.clear();
}
function update() {
// Update the slider position based on the pointer's movement
const slider = document.querySelector('input[type="range"]');
if (slider && !isDrawing) {
const sliderValue = parseInt(slider.value);
const max = parseInt(slider.max);
const width = slider.offsetWidth;
const offsetX = (sliderValue - 2) / (max - 2) * width;
slider.style.background = `linear-gradient(to right, #000 0%, #000 ${offsetX}px, #fff ${offsetX}px, #fff 100%)`;
}
}
// const config = {
// type: Phaser.AUTO,
// width: window.innerWidth,
// height: window.innerHeight,
// backgroundColor: '#05b3a4',
// scale: {
// mode: Phaser.Scale.FIT,
// autoCenter: Phaser.Scale.CENTER_HORIZONTALLY,
// },
// scene: {
// preload: preload,
// create: create,
// update: update
// }
// };
// const game = new Phaser.Game(config);
// const displayW = window.innerWidth;
// const displayH = window.innerHeight;
// let graphics;
// let outlineImage;
// let isDrawing = false;
// let selectedColor = 0xff0000; // Default color
// let brushSize = 5; // Default brush size
// function preload() {
// this.load.image('outline', '/assets/cow.png');
// }
// function create() {
// outlineImage = this.add.image(displayW / 2, displayH / 2, 'outline');
// graphics = this.add.graphics();
// // Create color palette buttons
// const colorPalette = [0xff0000, 0x00ff00, 0x0000ff]; // Example colors
// colorPalette.forEach((color, index) => {
// const button = this.add.rectangle(50 + index * 70, 500, 50, 50, color);
// button.setInteractive();
// button.on('pointerdown', () => {
// selectedColor = color;
// });
// });
// // Create a brush size slider using HTML input type range
// const sliderContainer = document.createElement('div');
// sliderContainer.className = 'slider-container';
// document.body.appendChild(sliderContainer);
// const slider = document.createElement('input');
// slider.type = 'range';
// slider.min = '2';
// slider.max = '20';
// slider.value = brushSize.toString(); // Set initial value to brushSize
// slider.className = 'slider';
// sliderContainer.appendChild(slider);
// slider.addEventListener('input', (event) => {
// brushSize = parseInt(event.target.value);
// slider.style.backgroundSize = `calc(${(brushSize - 2) * 100 / 18}% + 20px) 100%`;
// });
// const clearButton = document.createElement('button');
// clearButton.textContent = 'Clear';
// clearButton.className = 'clear-button';
// clearButton.addEventListener('click', () => {
// clearDrawing();
// });
// document.body.appendChild(clearButton);
// this.input.on('pointerdown', () => {
// isDrawing = true;
// startDrawing(this.input.x, this.input.y);
// });
// this.input.on('pointermove', () => {
// if (isDrawing) {
// continueDrawing(this.input.x, this.input.y);
// }
// });
// this.input.on('pointerup', () => {
// if (isDrawing) {
// finishDrawing();
// }
// isDrawing = false;
// });
// }
// function startDrawing(x, y) {
// graphics.lineStyle(brushSize * 2, selectedColor);
// graphics.beginPath();
// graphics.moveTo(x, y);
// }
// function continueDrawing(x, y) {
// graphics.lineTo(x, y);
// graphics.strokePath();
// }
// function finishDrawing() {
// // No need for additional actions here
// }
// function clearDrawing() {
// graphics.clear();
// }
// function update() {
// // Update the slider position based on the pointer's movement
// const slider = document.querySelector('input[type="range"]');
// if (slider && !isDrawing) {
// const sliderValue = parseInt(slider.value);
// const max = parseInt(slider.max);
// const width = slider.offsetWidth;
// const offsetX = (sliderValue - 2) / (max - 2) * width;
// slider.style.background = `linear-gradient(to right, #000 0%, #000 ${offsetX}px, #fff ${offsetX}px, #fff 100%)`;
// }
// }
</script>
<style>
.clear-button {
background-color: blue;
}
/* .clearButton */
</style>

View File

View File

@ -1,25 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>Checkbox Example</title>
<title>Checkbox Array</title>
</head>
<body>
<label>
<input type="checkbox" id="myCheckbox"> Check me
</label>
<script>
const checkbox = document.getElementById('myCheckbox');
<input type="checkbox" class="myCheckbox" value="Value 1"> Checkbox 1
<input type="checkbox" class="myCheckbox" value="Value 2"> Checkbox 2
<input type="checkbox" class="myCheckbox" value="Value 3"> Checkbox 3
<input type="checkbox" class="myCheckbox" value="Value 4"> Checkbox 4
<input type="checkbox" class="myCheckbox" value="Value 5"> Checkbox 5
<input type="checkbox" class="myCheckbox" value="Value 6"> Checkbox 6
<button id="saveButton">Save</button>
checkbox.addEventListener('change', function() {
if (checkbox.checked) {
console.log('Checkbox is checked - true');
// Do something when the checkbox is checked
} else {
console.log('Checkbox is not checked - false');
// Do something when the checkbox is not checked
}
});
</script>
<script>
// Get a reference to the "Save" button
const saveButton = document.getElementById('saveButton');
// Add a click event listener to the "Save" button
saveButton.addEventListener('click', function() {
// Get all checkboxes with the class "myCheckbox"
const checkboxes = document.querySelectorAll('.myCheckbox');
// Create an array to store the values of checked checkboxes
const checkedValues = [];
// Loop through the checkboxes and check if they are checked
checkboxes.forEach(function(checkbox) {
if (checkbox.checked) {
// If checked, push the value to the array
checkedValues.push(checkbox.value);
}
});
// Log the array of checked values
console.log('Checked Values:', checkedValues);
});
</script>
</body>
</html>

View File

@ -12,26 +12,26 @@
<div id="itemForm" class="flex flex-row place-content-between">
<div class="flex flex-col gap-6 place-items-center">
<img id="image1" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a1" class="round-checkbox-input" value="a1"/>
<input type="checkbox" id="a1" class="round-checkbox-input myCheckbox" value="a1"/>
<label for="a1" class="round-checkbox-label"></label>
<img id="image2" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a2" class="round-checkbox-input" value="a2"/>
<input type="checkbox" id="a2" class="round-checkbox-input myCheckbox" value="a2"/>
<label for="a2" class="round-checkbox-label"></label>
</div>
<div class="flex flex-col gap-6 place-items-center">
<img id="image3" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a3" class="round-checkbox-input" value="a3"/>
<input type="checkbox" id="a3" class="round-checkbox-input myCheckbox" value="a3"/>
<label for="a3" class="round-checkbox-label"></label>
<img id="image4" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a4" class="round-checkbox-input" value="a4"/>
<input type="checkbox" id="a4" class="round-checkbox-input myCheckbox" value="a4"/>
<label for="a4" class="round-checkbox-label"></label>
</div>
<div class="flex flex-col gap-6 place-items-center">
<img id="image5" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a5" class="round-checkbox-input" value="a5"/>
<input type="checkbox" id="a5" class="round-checkbox-input myCheckbox" value="a5"/>
<label for="a5" class="round-checkbox-label"></label>
<img id="image6" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a6" class="round-checkbox-input" value="a6"/>
<input type="checkbox" id="a6" class="round-checkbox-input myCheckbox" value="a6"/>
<label for="a6" class="round-checkbox-label"></label>
</div>
</div>
@ -60,25 +60,39 @@
document.getElementById("image5").src = assetsURL + gameData.image5;
document.getElementById("image6").src = assetsURL + gameData.image6;
});
// const saveButton = document.getElementById('saveButton');
// saveButton.addEventListener('click', function() {
// const checkboxes = document.querySelectorAll('.myCheckbox');
// const checkedValues = [];
// console.log(checkedValues)
// if(checkedValues == gameData.a1){
// console.log(gameData.a1)
// }
// checkboxes.forEach(function(checkbox) {
// if (checkbox.checked) {
// checkedValues.push(checkbox.value);
// // console.log(checkedValues);
// // console.log(gameData.a1)
// // let value1 = checkedValues = 'a1';
// }
// });
// // if(checkedValues == gameData.a1) {
// // console.log("Matched")
// // }
// // console.log('Checked Values:', checkedValues);
// });
var checkBoxes = itemForm.querySelectorAll('input[type="checkbox"]');
function getData() { // this function will get called when the save button is clicked
result = [];
// console.log(result)
console.log(result);
checkBoxes.forEach(item => { // loop all the checkbox item
if (item.checked) { //if the check box is checked
let data = { // create an object
item: item.value,
selected: item.checked
}
console.log(data)
let data1 = gameData.a1 = true;
let input1 = data.item = 'a1';
if(input1 = data1){
console.log("its Matched")
} else {
console.log("Its Unmatched")
}
item: item.value,
selected: item.checked
}
console.log(data.selected);
result.push(data); //stored the objects to result array
}
})

View File

@ -0,0 +1,185 @@
<main>
<div>
<!-- bg-[url('/assets/background.jpg')] -->
<section class="bg-white bg-center bg-no-repeat bg-cover h-screen">
<div class="container mx-auto px-4">
<div class="flex flex-row place-content-between pt-6">
<p class="text-5xl text-[#5ac6c8] font-bold select-none">Tick</p>
<img src="/assets/top_logo.png" alt="" draggable="false" class="select-none">
</div>
<p class="text-4xl text-center font-[600] text-[#7c4c23] my-16 select-none" id="gameDescription"></p>
<form id="contactForm">
<div id="itemForm" class="flex flex-row place-content-between">
<div class="flex flex-col gap-6 place-items-center">
<img id="image1" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a1" class="round-checkbox-input myCheckbox" value="a1"/>
<label for="a1" class="round-checkbox-label"></label>
<img id="image2" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a2" class="round-checkbox-input myCheckbox" value="a2"/>
<label for="a2" class="round-checkbox-label"></label>
<img id="image3" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a3" class="round-checkbox-input myCheckbox" value="a3"/>
<label for="a3" class="round-checkbox-label"></label>
</div>
<div class="flex flex-col gap-6 place-items-center">
<img id="image4" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a4" class="round-checkbox-input myCheckbox" value="a4"/>
<label for="a4" class="round-checkbox-label"></label>
<img id="image5" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a5" class="round-checkbox-input myCheckbox" value="a5"/>
<label for="a5" class="round-checkbox-label"></label>
<img id="image6" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a6" class="round-checkbox-input myCheckbox" value="a6"/>
<label for="a6" class="round-checkbox-label"></label>
</div>
<div class="flex flex-col gap-6 place-items-center">
<img id="image7" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a4" class="round-checkbox-input myCheckbox" value="a7"/>
<label for="a4" class="round-checkbox-label"></label>
<img id="image8" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a5" class="round-checkbox-input myCheckbox" value="a8"/>
<label for="a5" class="round-checkbox-label"></label>
<img id="image9" src="" alt="" draggable="false" class="select-none" />
<input type="checkbox" id="a6" class="round-checkbox-input myCheckbox" value="a9"/>
<label for="a6" class="round-checkbox-label"></label>
</div>
</div>
<div class="flex justify-center pt-8">
<input onclick="getData()" class="bg-blue-700 px-8 py-2 rounded-lg shadow-lg font-bold text-white cursor-pointer" type="submit" value="Save">
</div>
</form>
</div>
</section>
</div>
</main>
<script is:inline>
const params = new URLSearchParams(window.location.search);
const paramsID = params.get('id');
fetch(`https://management.beanstalkedu.com/items/game_tick_variant2/${encodeURIComponent(paramsID)}?filter[status][_eq]=published`)
.then(res => res.json())
.then(data => {
gameData = data.data;
// console.log(gameData);
document.getElementById("gameDescription").innerHTML = gameData.description;
const assetsURL = 'https://management.beanstalkedu.com/assets/';
document.getElementById("image1").src = assetsURL + gameData.image1;
document.getElementById("image2").src = assetsURL + gameData.image2;
document.getElementById("image3").src = assetsURL + gameData.image3;
document.getElementById("image4").src = assetsURL + gameData.image4;
document.getElementById("image5").src = assetsURL + gameData.image5;
document.getElementById("image6").src = assetsURL + gameData.image6;
document.getElementById("image7").src = assetsURL + gameData.image7;
document.getElementById("image8").src = assetsURL + gameData.image8;
document.getElementById("image9").src = assetsURL + gameData.image9;
});
// const saveButton = document.getElementById('saveButton');
// saveButton.addEventListener('click', function() {
// const checkboxes = document.querySelectorAll('.myCheckbox');
// const checkedValues = [];
// console.log(checkedValues)
// if(checkedValues == gameData.a1){
// console.log(gameData.a1)
// }
// checkboxes.forEach(function(checkbox) {
// if (checkbox.checked) {
// checkedValues.push(checkbox.value);
// // console.log(checkedValues);
// // console.log(gameData.a1)
// // let value1 = checkedValues = 'a1';
// }
// });
// // if(checkedValues == gameData.a1) {
// // console.log("Matched")
// // }
// // console.log('Checked Values:', checkedValues);
// });
var checkBoxes = itemForm.querySelectorAll('input[type="checkbox"]');
function getData() { // this function will get called when the save button is clicked
result = [];
console.log(result);
checkBoxes.forEach(item => { // loop all the checkbox item
if (item.checked) { //if the check box is checked
let data = { // create an object
item: item.value,
selected: item.checked
}
console.log(data.selected);
result.push(data); //stored the objects to result array
}
})
};
document.addEventListener('DOMContentLoaded', function () {
const contactForm = document.getElementById('contactForm');
contactForm.addEventListener('submit', async function (event) {
event.preventDefault();
// const formData = {
// f1: result[0],
// f2: result[1],
// f3: result[2],
// f4: result[3],
// f5: result[4],
// f6: result[5]
// };
// console.log("Form Data", formData)
// try {
// const response = await fetch('https://management.beanstalkedu.com/items/game_result', {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json'
// },
// body: JSON.stringify(formData)
// });
// if (response.ok) {
// console.log('Form data submitted successfully');
// } else {
// console.error('Failed to submit form data');
// }
// } catch (error) {
// console.error('An error occurred:', error);
// }
});
});
</script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Lobster&family=Quicksand:wght@500;700&display=swap');
body{
font-family: quicksand;
}
#image1, #image2, #image3, #image4, #image5, #image6, #image7, #image8, #image9{
width: 200px;
/* border: 4px solid red;
border-radius: 5%; */
}
.round-checkbox-input {
display: none;
}
.round-checkbox-label {
display: inline-block;
width: 30px;
height: 30px;
border-radius: 10%;
background-color: #ccc;
border: 2px solid #007bff;
cursor: pointer;
position: relative;
transition: background-color 0.3s, border-color 0.3s, transform 0.3s;
}
.round-checkbox-input:checked + .round-checkbox-label {
background-color: #007bff;
border-color: #007bff;
transform: scale(1.2);
border-radius: 30%;
}
.round-checkbox-input:checked + .round-checkbox-label::after {
content: '\2713';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 40px;
color: white;
display: block;
}
</style>