-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (36 loc) · 1.76 KB
/
script.js
File metadata and controls
45 lines (36 loc) · 1.76 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function showMessage(response) {
if (response === "No") {
const noButton = document.getElementById("no-button");
const container = document.querySelector(".container");
const maxWidth = window.innerWidth - noButton.offsetWidth;
const maxHeight = window.innerHeight - noButton.offsetHeight;
// Set button position to absolute
noButton.style.position = "absolute";
// Change image source to "gun.gif"
document.getElementsByClassName("image")[0].src = "images/gun.gif";
// Generate random coordinates within the visible container
const randomX = Math.max(0, Math.floor(Math.random() * maxWidth));
const randomY = Math.max(0, Math.floor(Math.random() * maxHeight));
// Apply new coordinates to the button
noButton.style.left = randomX + "px";
noButton.style.top = randomY + "px";
// Update text content and hide name message
document.getElementById("question").textContent =
"What do you mean No? You have to be my Valntines. There's no other option.";
document.getElementById("name").style.display = "none";
// Optional: You can also add a timeout to reset the position after a few seconds
}
if (response === "Yes") {
// Remove name message and no button
document.getElementById("name").remove();
document.getElementById("no-button").remove();
// Update text content, show message, and change image source to "dance.gif"
const yesMessage = document.getElementById("question");
yesMessage.textContent = "Awww. I knew it. Meri Pukuli Maya😘😘";
yesMessage.style.display = "block";
yesMessage.style.fontStyle = "normal";
document.getElementsByClassName("image")[0].src = "images/dance.gif";
// Remove yes button
document.getElementById("yesButton").remove();
}
}