-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
168 lines (140 loc) Β· 4.71 KB
/
Copy pathscript.js
File metadata and controls
168 lines (140 loc) Β· 4.71 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
const questionContainer = document.querySelector(".question-container");
const resultContainer = document.querySelector(".result-container");
const gifResult = document.querySelector(".gif-result");
const heartLoader = document.querySelector(".cssload-main");
const yesBtn = document.querySelector(".js-yes-btn");
const noBtn = document.querySelector(".js-no-btn");
const videoContainer = document.querySelector(".video-container");
const youtubeVideo = document.querySelector("#youtube-video");
const cuteMessages = [
"Are you sure? π₯Ί",
"Really really sure? π",
"Think again! π",
"You don't mean that! π’",
"Please say yes! π",
"I'll be so sad! π",
"Don't break my heart! π",
"Just kidding, right? π
",
"You're teasing me! π€",
"I know you miss me! π"
];
let messageIndex = 0;
function moveNoButton() {
// Get button dimensions
const buttonWidth = noBtn.offsetWidth;
const buttonHeight = noBtn.offsetHeight;
// Calculate safe boundaries (keeping button fully visible)
const maxX = window.innerWidth - buttonWidth - 50;
const maxY = window.innerHeight - buttonHeight - 50;
const minX = 50;
const minY = 50;
// Generate random position within safe bounds
const newX = Math.floor(Math.random() * (maxX - minX)) + minX;
const newY = Math.floor(Math.random() * (maxY - minY)) + minY;
// Set fixed positioning and new coordinates
noBtn.style.position = "fixed";
noBtn.style.left = `${newX}px`;
noBtn.style.top = `${newY}px`;
noBtn.style.right = "auto";
noBtn.style.bottom = "auto";
noBtn.style.zIndex = "1000";
// Change button text to cute messages
noBtn.textContent = cuteMessages[messageIndex % cuteMessages.length];
messageIndex++;
// Add a cute shake animation
noBtn.style.animation = "shake 0.5s ease-in-out";
setTimeout(() => {
noBtn.style.animation = "";
}, 500);
}
// Mouse events for desktop
noBtn.addEventListener("mouseover", moveNoButton);
// Touch events for mobile
noBtn.addEventListener("touchstart", (e) => {
e.preventDefault();
moveNoButton();
});
noBtn.addEventListener("touchend", (e) => {
e.preventDefault();
});
// Additional mobile event listeners
noBtn.addEventListener("touchmove", (e) => {
e.preventDefault();
moveNoButton();
});
// Fallback for any interaction
noBtn.addEventListener("click", (e) => {
e.preventDefault();
moveNoButton();
});
const style = document.createElement('style');
style.textContent = `
@keyframes shake {
0%, 100% { transform: translateX(0) scale(1.05); }
25% { transform: translateX(-5px) scale(1.05); }
75% { transform: translateX(5px) scale(1.05); }
}
`;
document.head.appendChild(style);
yesBtn.addEventListener("click", () => {
yesBtn.style.transform = "scale(0.95)";
setTimeout(() => {
yesBtn.style.transform = "scale(1.05)";
}, 100);
questionContainer.style.opacity = "0";
questionContainer.style.transform = "translate(-50%, -50%) scale(0.9)";
setTimeout(() => {
questionContainer.style.display = "none";
heartLoader.style.display = "inherit";
}, 300);
const timeoutId = setTimeout(() => {
heartLoader.style.display = "none";
resultContainer.style.display = "inherit";
resultContainer.style.opacity = "0";
resultContainer.style.transform = "translate(-50%, -50%) scale(0.8)";
setTimeout(() => {
resultContainer.style.opacity = "1";
resultContainer.style.transform = "translate(-50%, -50%) scale(1)";
resultContainer.style.transition = "all 0.5s ease";
// Show video container and play immediately after result appears
videoContainer.classList.add("show");
// Play the YouTube video immediately
const videoSrc = youtubeVideo.src;
youtubeVideo.src = videoSrc + "&autoplay=1";
}, 100);
if (gifResult) {
gifResult.play();
}
}, 3000);
});
function createFloatingHeart() {
const heart = document.createElement('div');
heart.innerHTML = 'π';
heart.style.position = 'fixed';
heart.style.left = Math.random() * window.innerWidth + 'px';
heart.style.top = window.innerHeight + 'px';
heart.style.fontSize = (Math.random() * 20 + 15) + 'px';
heart.style.opacity = '0.6';
heart.style.pointerEvents = 'none';
heart.style.zIndex = '-1';
heart.style.animation = `floatUp ${Math.random() * 3 + 4}s linear`;
document.body.appendChild(heart);
setTimeout(() => {
heart.remove();
}, 7000);
}
const floatStyle = document.createElement('style');
floatStyle.textContent = `
@keyframes floatUp {
0% {
transform: translateY(0) rotate(0deg);
opacity: 0.6;
}
100% {
transform: translateY(-100vh) rotate(360deg);
opacity: 0;
}
}
`;
document.head.appendChild(floatStyle);
setInterval(createFloatingHeart, 2000);