forked from ynoproject/ynohome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
235 lines (203 loc) · 8.75 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
<!doctype html>
<html lang="en">
<head>
<title>Yume Nikki Online Project</title>
<meta charset="utf-8">
<meta name="description" content="Play Yume Nikki and Yume Nikki fangames in multiplayer with your friends, no account or downloads required.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="nexus.css">
</head>
<body>
<div id="nexus">
<div id="siteLogo" class="fade fadeUp fadeSlow">
<img src="images/logo_yno.png" />
</div>
<div id="doors"></div>
</div>
<div id="background" class="fade fadeSlow"></div>
<template>
<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
<path d="M 9 4 A 1 1 90 0 0 9 9 A 1 1 90 0 0 9 4 M 5 17 C 5 12 6 10 9 10 C 12 10 13 12 13 17 Q 9 19 5 17 M 5 0 A 1 1 90 0 0 5 5 A 1 1 90 0 0 5 0 M 1 13 C 1 8 2 6 5 6 C 5.375 6 5.5 6 6.25 6.125 C 6 7.75 7.5 9.25 8.75 9.25 Q 8.875 9.5 8.875 9.75 C 7.125 9.75 5.25 10.75 5 13.875 Q 2.625 13.875 1 13 M 13 0 A 1 1 90 0 1 13 5 A 1 1 90 0 1 13 0 M 17 13 C 17 8 16 6 13 6 C 12.625 6 12.5 6 11.75 6.125 C 12 7.75 10.5 9.25 9.25 9.25 Q 9.125 9.5 9.125 9.75 C 10.875 9.75 12.75 10.75 13 13.875 Q 15.375 13.875 17 13" />
</svg>
</template>
<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0">
<defs>
<linearGradient id="baseGradient" x1="0%" y1="0%" x2="0%" y2="100%">
<stop stop-color="rgba(217, 179, 228, 1)" offset="0%"></stop>
<stop stop-color="rgba(205, 163, 214, 1)" offset="43.75%"></stop>
<stop stop-color="rgba(194, 146, 200, 1)" offset="56.25%"></stop>
<stop stop-color="rgba(182, 130, 186, 1)" offset="68.75%"></stop>
<stop stop-color="rgba(172, 115, 173, 1)" offset="81.25%"></stop>
<stop stop-color="rgba(159, 98, 158, 1)" offset="87.5%"></stop>
<stop stop-color="rgba(148, 87, 144, 1)" offset="93.75%"></stop>
<stop stop-color="rgba(137, 87, 131, 1)" offset="100%"></stop>
</linearGradient>
<linearGradient id="altGradient" x1="0%" y1="0%" x2="0%" y2="100%">
<stop stop-color="rgba(123, 82, 134, 1)" offset="0%"></stop>
<stop stop-color="rgba(110, 65, 120, 1)" offset="43.75%"></stop>
<stop stop-color="rgba(99, 48, 105, 1)" offset="56.25%"></stop>
<stop stop-color="rgba(86, 30, 91, 1)" offset="68.75%"></stop>
<stop stop-color="rgba(75, 12, 76, 1)" offset="81.25%"></stop>
<stop stop-color="rgba(62, 0, 61, 1)" offset="87.5%"></stop>
<stop stop-color="rgba(50, 0, 45, 1)" offset="93.75%"></stop>
<stop stop-color="rgba(37, 0, 31, 1)" offset="100%"></stop>
</linearGradient>
<filter id="dropShadow">
<feDropShadow dx="1" dy="1" stdDeviation="0.2" flood-color="rgba(0, 0, 0, 1)"></feDropShadow>
</filter>
</defs>
</svg>
<svg id="zoom" xmlns="http://www.w3.org/2000/svg">
<rect id="bg" width="100%" height="100%" fill="black" mask="url(#zoomMask)" />
<mask id="zoomMask">
<rect id="maskBg" width="100%" height="100%" fill="black" />
<circle id="circle" fill="black" />
</mask>
</svg>
<script>
const gameIds = [
'yume',
'2kki',
'flow',
'unevendream',
'deepdreams',
'prayers',
'someday',
'amillusion',
'braingirl',
'muma',
'genie'
];
const nexus = document.getElementById('nexus');
const doorsContainer = document.getElementById('doors');
setTimeout(() => {
document.getElementById('siteLogo').classList.add('fadeIn');
document.getElementById('background').classList.add('fadeIn');
}, 0);
gameIds.forEach((gameId, g) => {
const door = document.createElement('div');
door.classList.add('door');
door.classList.add('fade');
door.dataset.gameId = gameId;
const playerCountContainer = document.createElement('div');
playerCountContainer.classList.add('playerCountContainer');
const doorImgContainer = document.createElement('div');
doorImgContainer.classList.add('doorImgContainer');
const doorImg = document.createElement('img');
doorImg.classList.add('doorImg');
doorImg.src = `images/door_${gameId}.gif`;
const doorShadowImg = document.createElement('img');
doorShadowImg.classList.add('doorShadowImg');
doorShadowImg.src = 'images/door_shadow.png';
doorImgContainer.append(doorImg);
doorImgContainer.append(doorShadowImg);
const logoContainer = document.createElement('div');
logoContainer.classList.add('logoContainer');
const logo = document.createElement('img');
logo.classList.add('logo');
logo.src = `images/logo_${gameId}.png`;
logoContainer.append(logo);
door.append(playerCountContainer);
door.append(doorImgContainer);
door.append(logoContainer);
doorsContainer.append(door);
setTimeout(() => door.classList.add('fadeIn'), 75 * g + 750);
});
const doors = document.querySelectorAll('.door');
for (let door of doors) {
const playerCountContainer = door.querySelector('.playerCountContainer');
const playerCountLabel = document.createElement('label');
playerCountLabel.classList.add('unselectable');
playerCountLabel.textContent = '?';
fetchAndUpdatePlayerCount(door.dataset.gameId, playerCountLabel);
playerCountContainer.appendChild(document.getElementsByTagName('template')[0].content.cloneNode(true));
playerCountContainer.appendChild(playerCountLabel);
door.onclick = function () {
if (!this.classList.contains('active')) {
door.classList.add('active');
doDoorAnim(nexus, door);
}
};
}
window.setInterval(() => doors.forEach(door => fetchAndUpdatePlayerCount(door.dataset.gameId, door.querySelector('.playerCountContainer label'))), 60000);
function fetchAndUpdatePlayerCount(gameId, playerCountLabel) {
fetch(`connect/${gameId}/api/players`)
.then(response => response.text())
.then(count => !isNaN(count) && (playerCountLabel.textContent = count))
.catch(err => console.error(err));
}
window.onresize = function () { setTimeout(onResize, 0); };
function onResize() {
document.getElementById('zoom').style.height = document.body.offsetHeight;
}
setTimeout(onResize, 0);
function doDoorAnim(nexus, door) {
const zoom = document.getElementById('zoom');
const circle = document.getElementById('circle');
const initialRadius = Math.max(nexus.offsetWidth, nexus.offsetHeight) * 0.75;
const rect = door.getBoundingClientRect();
const centerX = ((rect.x + door.offsetWidth / 2) / nexus.offsetWidth) * 100;
const centerY = ((rect.y + door.offsetHeight / 2) / nexus.offsetHeight) * 100;
circle.setAttribute('r', initialRadius);
circle.setAttribute('cx', `${centerX}%`);
circle.setAttribute('cy', `${centerY}%`);
circle.style.transformOrigin = `calc(${centerX}% + 64px) calc(${centerY}% + 8px)`;
const cssAnim = document.createElement('style');
cssAnim.type = 'text/css';
const rules = document.createTextNode(`
@keyframes maskAnim {
from {
fill: black;
}
to {
fill: white;
}
}
@keyframes zoomAnim {
from {
r: ${initialRadius};
transform: rotate(0deg);
}
to {
r: 128px;
transform: rotate(360deg);
}
}
`);
cssAnim.appendChild(rules);
document.querySelector('head').appendChild(cssAnim);
zoom.classList.add('active');
playAudio('door_effect.wav');
const gameId = door.dataset.gameId;
window.setTimeout(() => {
playAudio(`door_${gameId}.wav`, 0.5);
const doorImg = door.querySelector('.doorImg');
doorImg.src = doorImg.src.replace('door_', 'door_open_');
window.setTimeout(() => {
// wait for page navigation
window.onpagehide = () => {
// wait for document to be hidden
// must be done here to not respond to switching tabs
window.onpagehide = null;
document.onvisibilitychange = () => {
// make sure the document is being hidden
if (document.visibilityState != 'hidden') return;
document.onvisibilitychange = null;
zoom.classList.remove('active');
cssAnim.remove();
doorImg.src = doorImg.src.replace('_open', '');
door.classList.remove('active');
};
};
window.location.href = `/${gameId}/`;
}, 1500);
}, 1000);
}
function playAudio(filename, volume) {
const audio = new Audio(`audio/${filename}`);
audio.volume = volume || 1;
audio.play();
}
</script>
</body>
</html>