-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathscript.js
More file actions
291 lines (253 loc) · 8.3 KB
/
script.js
File metadata and controls
291 lines (253 loc) · 8.3 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
document.addEventListener("DOMContentLoaded", function () {
let audio = document.getElementById("bg-music");
// Start music after user interaction (for autoplay restrictions)
document.body.addEventListener("click", function () {
if (audio.paused) {
audio.play().catch(error => console.error("Autoplay blocked:", error));
}
}, { once: true });
// Replace content when button is clicked
document.getElementById("startButton").addEventListener("click", function () {
let content = document.getElementById("content");
// Clear everything inside the div and replace it with full content
content.innerHTML = `
<div class="envelope-wrapper">
<div id="envelope" class="close">
<div class="front flap"></div>
<div class="front pocket"></div>
<div class="letter">
<p class="words line1">I'm vvv lucky to have you in my life :D</p>
<p class="words line2">Can't wait to celebrate valentine's wt you!</p>
<p class="words line3">I love you more than you’ll ever know!</p>
<p class="words line4">- your loving bf</p>
</div>
</div>
</div>
<div class="continue">
<button id="continue">Continue</button>
</div>
<style>
@font-face {
font-family: 'Caveat';
src: url('fonts/Caveat-Regular.ttf') format('truetype');
}
body {
background-color: #ffc3da;
font-family: 'Caveat', sans-serif;
}
.envelope-wrapper {
height: 380px;
}
#envelope {
position: relative;
height: 180px;
width: 280px;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
margin-left: auto;
margin-right: auto;
top: 50%;
background-color: #FF6863;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
cursor: pointer;
}
.front {
position: absolute;
width: 0;
height: 0;
z-index: 3;
}
.flap {
border-top: 98px solid #FF6863;
border-left: 140px solid transparent;
border-right: 140px solid transparent;
border-bottom: 82px solid transparent;
transform-origin: top;
}
.pocket {
border-left: 140px solid #FF8BA0;
border-right: 140px solid #FF8BA0;
border-bottom: 90px solid #FFA8B5;
border-top: 90px solid transparent;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
}
.letter {
position: relative;
background-color: white;
width: 90%;
height: 95%;
top: 0%;
border-radius: 10px;
box-shadow: 0 2px 26px rgba(0, 0, 0, .12);
margin-left: auto;
margin-right: auto;
}
.letter:after {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
position: absolute;
left: 10%;
width: 80%;
height: 14%;
font-size: 1px;
font-family: 'Caveat', sans-serif;
color: black;
}
.line1 { top: 15%; }
.line2 { top: 25%; }
.line3 { top: 45%; text-align: center; }
.line4 { top: 55%; text-align: center; }
.open .flap {
transform: rotatex(180deg);
transition: transform 0.4s ease, z-index 0.6s;
z-index: 1;
}
.close .flap {
transform: rotatex(0deg);
transition: transform 0.4s 0.6s ease, z-index 1s;
z-index: 5;
}
.open .letter {
transform: translatey(-80px);
transition: transform 0.4s 0.6s ease, z-index 0.6s;
z-index: 2;
}
.close .letter {
transform: translatey(0deg);
transition: transform 0.4s ease, z-index 1s;
z-index: 1;
}
.continue {
text-align: center;
}
.continue button {
font-weight: 800;
font-style: normal;
transition: all 0.1s linear;
background-color: transparent;
color: #FFFFFF;
display: inline-block;
font-size: 14px;
text-transform: uppercase;
margin: 20px;
margin-top: 100px;
padding: 10px;
line-height: 2em;
text-decoration: none;
min-width: 150px;
outline: none;
}
.continue button:hover {
background-color: #FFFFFF;
cursor: pointer;
color: white;
}
.question {
text-align: center;
margin-top: 100px;
}
.question p {
font-size: 20px;
font-weight: bold;
color: #FF6863;
}
.question button {
background-color: #FF6863;
color: white;
padding: 10px 20px;
border: none;
font-size: 18px;
margin: 10px;
cursor: pointer;
border-radius: 5px;
font-weight: bold;
}
.question button:hover {
background-color: #FF8BA0;
}
.surprise {
text-align: center;
margin-top: 50px;
}
.itinerary-img {
width: 70%;
max-width: 500px;
border-radius: 10px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
margin-bottom: 20px;
}
#downloadBtn {
display: inline-block;
padding: 12px 25px;
background-color: #FF6863;
color: white;
border-radius: 5px;
text-decoration: none;
font-size: 18px;
font-weight: bold;
transition: 0.3s;
}
#downloadBtn:hover {
background-color: #FF8BA0;
transform: scale(1.05);
}
</style>
`;
// Adding event listeners to Open and Continue buttons after content is loaded
const envelope = document.getElementById("envelope");
const btnContinue = document.getElementById("continue");
// Open the envelope when clicked
envelope.addEventListener("click", function () {
envelope.classList.add("open");
envelope.classList.remove("close");
});
// Continue button functionality to show question
btnContinue.addEventListener("click", function () {
content.innerHTML = `
<img src="pictures/what.gif" alt="asking tonton">
<div class="question">
<p style="font-size: 24px;">Will you be my Valentine?</p>
<button id="yesBtn">Yes</button>
<button id="noBtn">No</button>
</div>
`;
// Yes and No button event listeners
const yesBtn = document.getElementById("yesBtn");
const noBtn = document.getElementById("noBtn");
// "Yes" button functionality
document.getElementById("yesBtn").addEventListener("click", function () {
content.innerHTML = `
<div style="text-align: center;">
<img src="pictures/love.gif" alt="Love GIF" style="display: block; margin: 0 auto;">
<p style="font-size: 24px;">Yaaaaaay! I love you!</p>
</div>
<div style="text-align: center; margin-top: 50px;">
<button id="surpriseBtn" style="padding: 12px 25px; font-size: 18px; background: #ffa500; color: white; border: none; cursor: pointer; border-radius: 5px;">Click for a Surprise</button>
</div>
`;
// Surprise button functionality
document.getElementById("surpriseBtn").addEventListener("click", function () {
content.innerHTML = `
<div style="text-align: center; margin-top: 20px;">
<img src="pictures/itinerary.png" alt="Itinerary Image" style="width: 70%; max-width: 500px; border-radius: 10px; box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2); margin-bottom: 20px;">
<br>
<a id="downloadBtn" href="pictures/itinerary.png" download style="display: inline-block; padding: 12px 25px; background: #FF6863; color: white; border-radius: 5px; text-decoration: none; font-size: 18px; font-weight: bold; transition: 0.3s;">Download Itinerary</a>
</div>
`;
});
});
noBtn.addEventListener("click", function () {
content.innerHTML = "<div style='text-align: center;'>" +
"<img src='pictures/sad.gif' alt='Sad GIF' style='display: block; margin: 0 auto;'>" +
"<p style='font-size: 24px;'>Next time nalang :(</p>" +
"</div>";
});
});
});
});