-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·274 lines (255 loc) · 7.86 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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<!doctype html>
<html>
<head>
<title>WEmulator - Arcade</title>
<meta name="viewport" content="width = device-width, initial-scale = 1" />
<link rel="icon" type="image/png" href="apple-touch-icon.png" />
<link rel="apple-touch-icon" href="apple-touch-icon.png" />
<link rel="manifest" href="manifest.json" />
<link rel="shortcut icon" href="favicon.ico" />
<meta name="apple-mobile-web-app-title" content="WEmu" />
<meta name="application-name" content="WEmu" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="theme-color" content="#000000" />
<style>
body,
html {
height: 100%;
margin: 0;
background-color: black;
color: white;
}
#navigation {
position: sticky;
display: block;
margin: 0 auto;
top: 0px;
width: fit-content;
}
input {
display: inline-block;
width: 300px;
max-width: calc(50% - 35px);
margin: 14px;
appearance: none;
/* safari */
-webkit-appearance: none;
font-size: 16px;
padding: 7px;
background-color: #333333ee;
border: 0px solid transparent;
border-radius: 0.25rem;
color: white;
cursor: pointer;
}
select {
appearance: none;
/* safari */
-webkit-appearance: none;
width: 100%;
/* other styles for aesthetics */
font-size: 16px;
padding: 7px 32px 7px 7px;
background-color: #333333ee;
border: 0px solid transparent;
border-radius: 0.25rem;
color: white;
cursor: pointer;
}
#systems {
margin: 14px;
width: 300px;
max-width: calc(50% - 35px);
position: relative;
display: inline-block;
}
#systems::before,
#systems::after {
--size: 0.3rem;
content: "";
position: absolute;
right: 1rem;
pointer-events: none;
}
#systems::before {
border-left: var(--size) solid transparent;
border-right: var(--size) solid transparent;
border-bottom: var(--size) solid white;
top: 40%;
}
#systems::after {
border-left: var(--size) solid transparent;
border-right: var(--size) solid transparent;
border-top: var(--size) solid white;
top: 55%;
}
#arcade {
width: 100%;
height: calc(100% - 64px);
display: block;
overflow: scroll;
margin-top: -64px;
padding-top: 64px;
text-align: center;
}
#arcade a {
width: calc((100% / 4) - (8 * 7px));
height: calc((100% / 3) - (6 * 7px));
min-height: 250px;
min-width: 250px;
display: inline-block;
border-radius: 14px;
overflow: hidden;
margin: 7px;
}
/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {
#arcade a {
width: calc((100% / 1) - (2 * 7px));
height: calc((100% / 2) - (4 * 7px));
}
}
/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {
#arcade a {
width: calc((100% / 2) - (4 * 7px));
height: calc((100% / 2) - (4 * 7px));
}
}
/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {
#arcade a {
width: calc((100% / 4) - (8 * 7px));
height: calc((100% / 3) - (6 * 7px));
}
}
/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {
#arcade a {
width: calc((100% / 5) - (10 * 7px));
height: calc((100% / 4) - (8 * 7px));
}
}
/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {
#arcade a {
width: calc((100% / 6) - (12 * 7px));
height: calc((100% / 5) - (10 * 7px));
}
}
#arcade a img {
object-fit: contain;
max-width: 100%;
max-height: 100%;
border-radius: 14px;
display: block;
overflow: hidden;
margin: 0 auto;
}
</style>
</head>
<body>
<div id="navigation">
<div id="systems">
<select id="system" onchange="filterArcade(this)">
<option value="all">All</option>
<option value="gb">Game Boy</option>
<option value="gbc">Game Boy Color</option>
<option value="gba">Game Boy Advance</option>
<option value="nes">Nintendo Entertainment System</option>
<option value="snes">Super Nintendo Entertainment System</option>
<option value="n64">Nintendo 64</option>
<option value="nds">Nintendo DS</option>
<option value="psx">Playstation One</option>
<option value="segaMD">Sega Genesis</option>
</select>
</div>
<input
id="search"
type="search"
placeholder="Search ..."
oninput="search(this)"
/>
</div>
<div id="arcade"></div>
<script>
function basename(path) {
return path.split("/").reverse()[0];
}
function append(selector, html) {
document.querySelector(selector).innerHTML += html;
}
function clear(selector) {
document.querySelector(selector).innerHTML = "";
}
function system() {
let current = window.location.hash.substr(1);
if (current.length == 0) {
current = "all";
window.location.hash = current;
}
return current;
}
fetch("roms/map.json")
.then((response) => {
return response.json();
})
.then((data) => {
window.gameList = {};
data[0]["contents"].forEach((gamedir) => {
window.gameList[basename(gamedir["name"])] = [];
(gamedir["contents"] ?? []).forEach((game) => {
window.gameList[basename(gamedir["name"])].push(
basename(game["name"]),
);
});
});
buildArcade(window.gameList);
})
.catch((err) => {
console.error(err);
window.location.href = "play.html";
console.log(
"No Game List available. Be sure to run the mapper to set the list of your games for the arcade to load properly.",
);
});
document.getElementById("system").value = system();
window.onhashchange = function () {
document.getElementById("system").value = system();
};
function filterArcade(selectObject) {
window.location.hash = selectObject.value;
buildArcade(window.gameList);
}
function buildArcade() {
clear("#arcade");
Object.entries(window.gameList).forEach(([systemDir, games]) => {
if (system() !== "all" && systemDir !== system()) {
return;
}
games.forEach((game) => {
const gamePath = `roms/${systemDir}/${game}`;
const gameTitle = game.split(".")[0];
if (
(window.searchCriteria ?? "").length > 2 &&
!gameTitle
.toLowerCase()
.includes(window.searchCriteria.toLowerCase())
) {
return;
}
append(
"#arcade",
`<a href="play.html?game=${gamePath}" title="${gameTitle}"><img loading="lazy" src="${gamePath.replace(".zip", "")}.jpg" alt="${gameTitle}" /></a>`,
);
});
});
}
function search(e) {
window.searchCriteria = e.value;
buildArcade();
}
</script>
</body>
</html>