-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
56 lines (47 loc) · 1.97 KB
/
script.js
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
46
47
48
49
50
51
52
53
54
55
56
let currentQuestionIndex = 0;
const questions = document.querySelectorAll(".question-block");
// Different alert messages for each question
const alertMessages = [
"But I like you 🥰",
"I don't want, but situation are not in my favour 😓",
"Thankyou.. 🥰",
// Add more messages corresponding to additional questions
];
function showQuestion(index) {
questions.forEach((question, i) => {
question.classList.toggle("active", i === index);
});
}
document.querySelectorAll(".yesButton").forEach(function(button, index) {
button.addEventListener("click", function() {
alert(alertMessages[index]); // Show the specific alert message
nextQuestion();
});
});
document.querySelectorAll(".noButton").forEach(function(button) {
button.addEventListener("click", function() {
const emojis = ["🙅", "🚫", "🙅♂️", "🙅♀️", "❌", "😠"];
const randomEmoji = emojis[Math.floor(Math.random() * emojis.length)];
this.innerHTML = `NO ${randomEmoji}`;
const container = button.parentElement;
const containerWidth = container.offsetWidth;
const containerHeight = container.offsetHeight;
const buttonWidth = button.offsetWidth;
const buttonHeight = button.offsetHeight;
const newLeft = Math.random() * (containerWidth - buttonWidth) * 0.8; // Ensures larger repositioning
const newTop = Math.random() * (containerHeight - buttonHeight) * 0.8; // Ensures larger repositioning
button.style.position = 'absolute';
button.style.left = `${newLeft}px`;
button.style.top = `${newTop}px`;
});
});
function nextQuestion() {
currentQuestionIndex++;
if (currentQuestionIndex < questions.length) {
showQuestion(currentQuestionIndex);
} else {
alert("Have a nice day.... Bye.. 🥰!");
}
}
// Show the first question initially
showQuestion(currentQuestionIndex);