File size: 798 Bytes
e1f88bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const yesBtn = document.querySelector(".yes__btn");
const noBtn = document.querySelector(".no__btn");

const themeSound = new Audio("/assets/sounds/main.mp3");

noBtn.addEventListener("click", () => {
  themeSound.play();
  themeSound.loop = true;
  noBtn.style.position = "absolute";
  let i = Math.floor(Math.random() * 500) + 1;
  let j = Math.floor(Math.random() * 500) + 1;
  noBtn.style.top = `${i}px`;
  noBtn.style.left = `${j}px`;
});

yesBtn.addEventListener("click", () => {
  // Retrieve the user's name from localStorage
  const userName = localStorage.getItem('userName');

  // Log the button click and the user's name
  if (userName) {
    console.log("Yes Button Clicked");
    console.log("User Name:", userName);
  }

  // Redirect to yes.html
  location.href = "./yes.html";
});