-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
257 lines (212 loc) · 8.88 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Name Generator</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #2c3e50;
font-family: Arial, sans-serif;
color: #ecf0f1;
transition: opacity 1s ease;
overflow: hidden; /* Prevent scroll during transition */
}
.name-container {
display: inline-block;
width: 180px;
height: 60px;
overflow: hidden;
border: 4px solid #ecf0f1;
border-radius: 10px;
margin: 20px;
position: relative;
background: linear-gradient(135deg, #34495e, #2c3e50);
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
transition: transform 0.2s ease;
}
.name-slot {
position: absolute;
width: 100%;
transition: transform 3s ease-out;
}
.name-text {
font-size: 2em;
text-align: center;
height: 60px;
line-height: 60px;
color: #ecf0f1;
font-weight: bold;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
}
.button {
padding: 15px 30px;
margin: 10px;
font-size: 1.2em;
cursor: pointer;
background: #e74c3c;
border: none;
border-radius: 10px;
color: #ecf0f1;
font-weight: bold;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
transition: transform 0.2s ease;
}
.button:hover {
background: #c0392b;
}
.button:active {
transform: translateY(4px);
}
.plus-button {
font-size: 1.5em; /* Reduced font size */
padding: 5px 10px; /* Reduced padding */
background: #3498db;
display: none; /* Hidden by default */
}
.fade-out {
opacity: 0;
transition: opacity 1s ease; /* Ensure opacity transition */
}
.fade-in {
opacity: 1;
transition: opacity 1s ease; /* Ensure opacity transition */
}
.result-container {
text-align: center;
font-size: 0.8em; /* Smaller font size for the result message */
opacity: 0; /* Start hidden */
transition: opacity 1s ease; /* Transition for fading in */
}
.jojo {
font-size: 3em; /* Larger font size for "JoJo" */
font-weight: bold; /* Make it bold */
opacity: 0; /* Initially hidden */
transform: scale(0); /* Start scaled down */
transition: opacity 0.5s ease, transform 0.5s ease; /* Transition for pop-up effect */
}
.jojo.show {
font-size: 10em;
opacity: 1; /* Make visible */
transform: scale(1); /* Scale to normal size */
color: gold;
}
</style>
</head>
<body>
<div class="name-container" id="firstNameContainer">
<div class="name-slot" id="firstNameSlot">
<div class="name-text">-</div>
</div>
</div>
<button class="button plus-button" id="plusButton">+</button>
<div class="name-container" id="lastNameContainer">
<div class="name-slot" id="lastNameSlot">
<div class="name-text">-</div>
</div>
</div>
<br>
<button class="button" id="firstNameBtn">Generate First Name</button>
<button class="button" id="lastNameBtn">Generate Last Name</button>
<div class="result-container" id="resultContainer">
<h1 id="resultText"></h1>
<span class="jojo" id="jojoText">JOJO</span> <!-- Separate span for "JoJo" -->
</div>
<script>
const firstNames = ["Johnathan", "Joseph", "Jolene", "Joanna", "Josiah",
"Jota", "Joestrella", "Geoffrey", "Jotaro", "Joe", "Josuke", "Jordan",
"Jorou", "Joroku", "Jiomoto", "Giorgos", "Giolios"];
const lastNames = ["Johnson", "Jordan", "Jones", "Johansson", "Joestar", "Jomama", "Giovanna", "Giorno", "Jiosuke",
"Jiotake", "Giomelos", "Jokalos", "Jopoulos", "Giorgio"];
let firstNameFinished = false;
let lastNameFinished = false;
function getRandomName(names) {
return names[Math.floor(Math.random() * names.length)];
}
function checkPlusButtonVisibility() {
const firstName = document.getElementById('firstNameSlot').innerText;
const lastName = document.getElementById('lastNameSlot').innerText;
if (firstName !== '-' && lastName !== '-') {
document.getElementById('plusButton').style.display = 'inline-block';
} else {
document.getElementById('plusButton').style.display = 'none';
}
}
function slotMachineEffect(slotId, names, containerId) {
const slot = document.getElementById(slotId);
const container = document.getElementById(containerId);
let randomNames = [];
for (let i = 0; i < 30; i++) {
randomNames.push(getRandomName(names));
}
const finalName = getRandomName(names);
randomNames.push(finalName);
slot.innerHTML = randomNames.map(name => `<div class="name-text">${name}</div>`).join('');
slot.style.transition = 'none';
slot.style.transform = 'translateY(0)';
void slot.offsetWidth;
slot.style.transition = 'transform 3s ease-out';
slot.style.transform = `translateY(-${60 * randomNames.length - 60}px)`;
slot.addEventListener('transitionend', () => {
slot.style.transition = 'none';
slot.innerHTML = `<div class="name-text">${finalName}</div>`;
slot.style.transform = 'translateY(0)';
container.classList.add('pop-effect');
setTimeout(() => {
container.classList.remove('pop-effect');
}, 300);
if (containerId === 'firstNameContainer') {
firstNameFinished = true;
} else if (containerId === 'lastNameContainer') {
lastNameFinished = true;
}
if (firstNameFinished && lastNameFinished) {
document.getElementById('firstNameContainer').classList.add('pop-effect');
document.getElementById('lastNameContainer').classList.add('pop-effect');
firstNameFinished = false;
lastNameFinished = false;
}
checkPlusButtonVisibility();
}, { once: true });
}
document.getElementById('firstNameBtn').addEventListener('click', () => {
slotMachineEffect('firstNameSlot', firstNames, 'firstNameContainer');
});
document.getElementById('lastNameBtn').addEventListener('click', () => {
slotMachineEffect('lastNameSlot', lastNames, 'lastNameContainer');
});
document.getElementById('plusButton').addEventListener('click', () => {
const firstName = document.getElementById('firstNameSlot').innerText;
const lastName = document.getElementById('lastNameSlot').innerText;
// Fade out current content
document.body.classList.add('fade-out');
setTimeout(() => {
// Clear current content except for resultContainer
document.querySelectorAll('.name-container, .button').forEach(el => el.style.display = 'none');
// Update and show the result container with the message
const resultContainer = document.getElementById('resultContainer');
const resultText = document.getElementById('resultText');
resultText.innerHTML = `My name is ${firstName} ${lastName}, but people call me `;
const jojoText = document.getElementById('jojoText');
jojoText.classList.remove('show'); // Ensure JoJo is hidden initially
resultContainer.style.opacity = 0; // Start hidden
resultContainer.style.display = 'block'; // Make it visible
// Fade in the result container
setTimeout(() => {
resultContainer.style.opacity = 1; // Fade in
// Show "JoJo" after a delay
setTimeout(() => {
jojoText.classList.add('show'); // Apply the pop-up effect
}, 1000); // Increase the delay before showing "JoJo"
document.body.classList.remove('fade-out'); // Remove fade-out class
}, 100); // Slight delay before fading in
}, 1000); // Delay before showing the result to allow fade-out
});
</script>
</body>
</html>