-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
196 lines (150 loc) · 6.2 KB
/
script.js
File metadata and controls
196 lines (150 loc) · 6.2 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
const heartsContainer = document.querySelector('.hearts-container');
const heartsContainerRejection = document.querySelector('.hearts-container-rejection');
// List of all heart images in the folder
const heartImages = [
'yellow_hearts/heart1.png',
'yellow_hearts/heart2.png',
'yellow_hearts/heart3.png',
'yellow_hearts/heart4.png'
];
function createHeart(container) {
const heart = document.createElement('img');
// Pick a random image from the list
const randomImage = heartImages[Math.floor(Math.random() * heartImages.length)];
heart.src = randomImage;
heart.classList.add('heart');
// Random position
heart.style.left = Math.random() * 100 + 'vw';
heart.style.top = Math.random() * 100 + 'vh';
// Random size
const size = Math.random() * 50 + 30 + 'px';
heart.style.width = size;
heart.style.height = 'auto';
// Random rotation for variety
heart.style.transform = `rotate(${Math.random() * 360}deg)`;
// Random animation delay
heart.style.animationDelay = Math.random() * 5 + 's';
container.appendChild(heart);
}
// Create 40 random hearts for main page
for (let i = 0; i < 40; i++) {
createHeart(heartsContainer);
}
// Create 40 random hearts for rejection page
for (let i = 0; i < 40; i++) {
createHeart(heartsContainerRejection);
}
// Yes button -> open Google Form
document.getElementById('yesBtn').addEventListener('click', function() {
window.open('https://forms.gle/YTETJWAaUNQWsvU2A', '_blank');
});
// No button -> show modal
document.getElementById('noBtn').addEventListener('click', function() {
document.getElementById('modal').classList.add('visible');
});
// Modal "No, go back" -> hide modal
document.getElementById('modalNo').addEventListener('click', function() {
document.getElementById('modal').classList.remove('visible');
});
// Modal "Yes, I'm sure" -> show rejection screen and send email notification
document.getElementById('modalYes').addEventListener('click', function() {
document.getElementById('modal').classList.remove('visible');
document.getElementById('rejection-screen').classList.add('visible');
// Send email notification via EmailJS
emailjs.init('4nvc3xqpANDBzlqjw');
const message = `Hey Jack,
Lei clicked "Yes, I'm sure" on the rejection modal.
Time: ${new Date().toLocaleString()}
Double check:
- Did she answer the Google Form?
- Was she just messing with the website?
- Did she truly mean no?
Good luck! 💛`;
emailjs.send('service_vex0zgu', 'template_4s5knkk', {
message: message
}).then(function() {
console.log('Email notification sent!');
}).catch(function(error) {
console.log('Email failed to send:', error);
});
});
// No button escape logic
const noBtn = document.getElementById('noBtn');
const detectionRadius = 50; // Detection radius in pixels
const escapeDistance = 80; // How far to teleport
const edgePadding = 10; // Keep away from screen edges
let escapeCount = 0;
const maxEscapes = 11; // Button can be clicked after 11 escapes
let isEscaping = false; // Cooldown flag
// Track total offset from original position
let offsetX = 0;
let offsetY = 0;
let originalRect = null;
document.addEventListener('mousemove', function(event) {
// If already escaped 7 times, button is now clickable
if (escapeCount >= maxEscapes) return;
// If currently in cooldown, skip
if (isEscaping) return;
// Get current visual position using getBoundingClientRect (always accurate)
const rect = noBtn.getBoundingClientRect();
// Store original position on first run
if (originalRect === null) {
originalRect = {
left: rect.left,
top: rect.top,
width: rect.width,
height: rect.height
};
}
const buttonCenterX = rect.left + rect.width / 2;
const buttonCenterY = rect.top + rect.height / 2;
const mouseX = event.clientX;
const mouseY = event.clientY;
// Calculate distance between mouse and button center
const distance = Math.sqrt(
Math.pow(mouseX - buttonCenterX, 2) +
Math.pow(mouseY - buttonCenterY, 2)
);
// If mouse enters detection radius
if (distance < detectionRadius) {
// Set cooldown
isEscaping = true;
// Calculate direction from mouse to button (this is the escape direction)
let directionX = buttonCenterX - mouseX;
let directionY = buttonCenterY - mouseY;
// Handle edge case: mouse exactly on button center
if (directionX === 0 && directionY === 0) {
directionX = 1;
directionY = 0;
}
// Normalize to get unit vector
const length = Math.sqrt(directionX * directionX + directionY * directionY);
const normalizedX = directionX / length;
const normalizedY = directionY / length;
// Calculate new offset
offsetX += normalizedX * escapeDistance;
offsetY += normalizedY * escapeDistance;
// Calculate where button would be with this offset
let newLeft = originalRect.left + offsetX;
let newTop = originalRect.top + offsetY;
// Screen bounds with padding
const minX = edgePadding;
const minY = edgePadding;
const maxX = window.innerWidth - originalRect.width - edgePadding;
const maxY = window.innerHeight - originalRect.height - edgePadding;
// Clamp to screen bounds and adjust offset accordingly
if (newLeft < minX) { offsetX = minX - originalRect.left; }
if (newLeft > maxX) { offsetX = maxX - originalRect.left; }
if (newTop < minY) { offsetY = minY - originalRect.top; }
if (newTop > maxY) { offsetY = maxY - originalRect.top; }
// Apply using transform (more reliable than left/top)
noBtn.style.transform = `translate(${offsetX}px, ${offsetY}px)`;
// Increment escape count
escapeCount++;
console.log('Escape count:', escapeCount, '/', maxEscapes);
// Release cooldown after a short delay
setTimeout(function() {
isEscaping = false;
}, 100);
}
});