From 8251f8ed3e337c0fc0f94440758fd4f9726d5e91 Mon Sep 17 00:00:00 2001 From: codexsit Date: Sat, 25 Jan 2025 09:52:58 +0530 Subject: [PATCH] feat: added PC number rotation --- src/pages/Bug2Bot/index.jsx | 64 +++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/src/pages/Bug2Bot/index.jsx b/src/pages/Bug2Bot/index.jsx index 969b519..4606e35 100644 --- a/src/pages/Bug2Bot/index.jsx +++ b/src/pages/Bug2Bot/index.jsx @@ -62,6 +62,13 @@ export default function Bug2Bot() { minutes: 0, seconds: 0, }); + const [currentIndex, setCurrentIndex] = useState(0); + const [spanContents, setSpanContents] = useState([ + "unlock", + "team", + "15", + "race", + ]); const updateCountdown = () => { const now = new Date(); @@ -89,6 +96,35 @@ export default function Bug2Bot() { return () => clearInterval(interval); }, []); + useEffect(() => { + const PCs = ["4", "8", "17", "28"]; + const revealElements = document.querySelectorAll(".reveal"); + + const updateIndex = () => { + const now = new Date(); + const minutes = now.getMinutes(); + const hours = now.getHours(); + const totalMinutes = hours * 60 + minutes; + const newIndex = Math.floor(totalMinutes / 15) % PCs.length; + setCurrentIndex(newIndex); + }; + + revealElements.forEach((element, i) => { + element.addEventListener("click", (event) => { + event.preventDefault(); + updateIndex(); + if (i === currentIndex) { + setSpanContents((prevContents) => { + const newContents = [...prevContents]; + newContents[i] = btoa(PCs[i]); + return newContents; + }); + alert(`PC Number: ${btoa(PCs[i])}`); + } + }); + }); + }, [currentIndex]); + const gradientFontSize = 100; return ( @@ -155,9 +191,13 @@ export default function Bug2Bot() {
Unleash your tech prowess in this ultimate challenge where coding precision meets hands-on ingenuity. Teams will tackle - gripping puzzles to unlock a path toward an innovative and - competitive build. Navigate through tasks designed to test - your creativity, strategy, and teamwork! + gripping puzzles to{" "} + + {spanContents[0]} + {" "} + a path toward an innovative and competitive build. Navigate + through tasks designed to test your creativity, strategy, and + teamwork!
{/* Col 2 */} @@ -189,7 +229,11 @@ export default function Bug2Bot() {
  1. - Form a team of 3 - 4. + Form a{" "} + + {spanContents[1]} + {" "} + of 3 - 4.
  2. Find Qr, scan it. @@ -223,7 +267,11 @@ export default function Bug2Bot() { Assemble the RC car and race!!
  3. - Total Time - 15 Minutes. + Total Time -{" "} + + {spanContents[2]} + {" "} + Minutes.
@@ -239,7 +287,11 @@ export default function Bug2Bot() {
  1. - Navigate through the race track. + Navigate through the{" "} + + {spanContents[3]} + {" "} + track.
  2. Outsmart the traps.