Merge pull request 'b6' (#1) from b6 into fetch2

Reviewed-on: #1
pull/16/head
Kar 2023-08-22 18:50:48 +00:00
commit 92188a3548
5 changed files with 203 additions and 6 deletions

BIN
public/assets/top_logo.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -134,7 +134,6 @@ class MyGame extends Phaser.Scene {
super();
}
preload() {
var progressBar = this.add.graphics();
var progressBox = this.add.graphics();
progressBox.fillStyle(0x222222, 0.8);
@ -152,7 +151,6 @@ class MyGame extends Phaser.Scene {
}
});
loadingText.setOrigin(0.5, 0.5);
var percentText = this.make.text({
x: width / 2,
y: height / 2 - 5,
@ -392,23 +390,35 @@ const displayResult = (droppedBlocks) => {
};
let score = 0;
let counter = 0;
const isMatch = (blockName, targetName) => {
if(isMatch){
counter++;
// console.log(counter)
if(counter === 4){
const overlap = document.getElementById("overlap");
overlap.style.display = "block";
// console.log("Done")
}
}
const match = blockMatches.find((m) => m.blockName === blockName && m.targetName === targetName);
console.log(match)
let scoreTotal=0;
if(match){
scoreTotal++;
// console.log(scoreTotal)
}
console.log(scoreTotal)
// console.log(match)
if(match){
score++;
console.log(score)
let day;
switch (score) {
case 1:
case 0:
day = "Points - 1";
break;
case 2:
@ -416,7 +426,9 @@ if(isMatch){
break;
case 4:
day = "Points - 4";
}
console.log(day)
finalDom = document.getElementById("good");
finalDom.classList.add("good");
document.getElementById("good").innerHTML = day;
@ -448,6 +460,8 @@ if(isMatch){
// // console.log("Losttttt")
// }
} else{
score = score
}
return match !== undefined;
};

View File

@ -10,8 +10,8 @@ import Footer from '../components/Footer.astro';
<main>
<h1>Welcome to <span class="text-gradient">Astro</span></h1>
<p class="instructions">
To get started, open the directory <code>src/pages</code> in your project.<br />
<strong>Code Challenge: Tweak the "Welcome to Astro" message above.</strong>
<code>To get started, open the directory src/pages</code> in your project.<br />
<code>Code Challenge: Tweak the "Welcome to Astro" message above.</code>
</p>
<ul role="list" class="link-card-grid">
<Card

158
src/pages/tick/index.astro Normal file
View File

@ -0,0 +1,158 @@
<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" 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"/>
<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"/>
<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"/>
<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"/>
<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"/>
<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_tick6/${encodeURIComponent(paramsID)}?filter[status][_eq]=published`)
.then(res => res.json())
.then(data => {
gameData = data.data;
// console.log(gameData);
document.getElementById("gameDescription").innerHTML = gameData.game_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;
});
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)
let data1 = gameData.a1 = true;
let input1 = data.item = 'a1';
if(input1 = data1){
console.log("its Matched")
} else {
console.log("Its Unmatched")
}
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{
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>

25
src/pages/tick/temp.astro Normal file
View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<title>Checkbox Example</title>
</head>
<body>
<label>
<input type="checkbox" id="myCheckbox"> Check me
</label>
<script>
const checkbox = document.getElementById('myCheckbox');
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>
</body>
</html>