-
Notifications
You must be signed in to change notification settings - Fork 34
/
index.html
525 lines (519 loc) · 13.4 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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
<!DOCTYPE html>
<html>
<head>
<script async src="https://arc.io/widget.min.js#HEPCFa3K"></script>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<title>ayunEaglerConfig</title>
<script type="text/javascript" src="long.js"></script>
<script src="jsoneditor.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
<link href="https://fonts.googleapis.com/css2?family=Nunito&display=swap" rel="stylesheet"/>
<link href="style.css" rel="stylesheet"/>
</head>
<body>
<sub><a href="old.html">Legacy NBT version</a></sub>
<h1>ayunEaglerConfig</h1>
<p>Configure & customize your Eaglercraft client here!</p>
<button onclick="saveOpts();">Export eaglercraftOpts variable...</button>
<br/>
<textarea id="output" readonly rows="16" cols="9"></textarea>
<br/>
<div id="editor"></div>
<script type="text/javascript">
const relayId = Math.floor(Math.random() * 3);
const startJson = {
container: "game_frame",
assetsURI: "assets.epk",
serverWorkerURI: "worker_bootstrap.js",
worldsFolder: "MAIN",
servers: [
{
serverName: "placeholder",
serverAddress: "address here",
hideAddress: false
}
],
relays: [
{
addr: "wss://relay.deev.is/",
name: "lax1dude relay #1",
primary: relayId == 0
},
{
addr: "wss://relay.lax1dude.net/",
name: "lax1dude relay #2",
primary: relayId == 1
},
{
addr: "wss://relay.shhnowisnottheti.me/",
name: "ayunami relay #1",
primary: relayId == 2
}
],
mainMenu: {
splashes: [
"Darviglet!",
"eaglerenophile!",
"You Eagler!",
"Yeeeeeee!",
"yeee",
"EEEEEEEEE!",
"You Darvig!",
"You Vigg!",
":>",
"|>",
"You Yumpster!"
],
eaglerLogo: false
}
};
const editor = new JSONEditor(document.getElementById('editor'), {
startval: startJson,
no_additional_properties: true,
schema: {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "http://example.com/example.json",
"type": "object",
"default": {},
"title": "Eaglercraft Client Settings",
"required": [
"container",
"assetsURI"
],
"properties": {
"container": {
"type": "string",
"default": "",
"title": "Element where Eaglercraft will be placed",
"examples": [
"game_frame"
]
},
"assetsURI": {
"type": "string",
"default": "",
"title": "URI to assets.epk",
"examples": [
"assets.epk"
]
},
"serverWorkerURI": {
"type": "string",
"default": "",
"title": "URI to worker_bootstrap.js for singleplayer's web worker",
"examples": [
"worker_bootstrap.js"
]
},
"worldsFolder": {
"type": "string",
"default": "",
"title": "Internal folder name for worlds",
"examples": [
"MAIN"
]
},
"servers": {
"type": "array",
"default": [],
"title": "Default servers to show in server list",
"items": {
"type": "object",
"default": {},
"title": "Server entry",
"required": [
"serverName",
"serverAddress"
],
"properties": {
"serverName": {
"type": "string",
"default": "",
"title": "Name of server",
"examples": [
"server name"
]
},
"serverAddress": {
"type": "string",
"default": "",
"title": "Address of server",
"examples": [
"ws://localhost:25565/"
]
},
"hideAddress": {
"type": "boolean",
"default": false,
"title": "Hide server address",
"examples": [
false
]
}
},
"examples": [{
"serverName": "server name",
"serverAddress": "ws://localhost:25565/",
"hideAddress": false
}]
},
"examples": [
[{
"serverName": "server name",
"serverAddress": "ws://localhost:25565/",
"hideAddress": false
}]
]
},
"hideDownServers": {
"type": "boolean",
"default": false,
"title": "Hide servers that seem to be down",
"examples": [
false
]
},
"joinServer": {
"type": "string",
"default": "",
"title": "Automatically join this server on client load",
"examples": [
"wss://sus.shhnowisnottheti.me/"
]
},
"assetOverrides": {
"type": "object",
"default": {},
"title": "Map asset paths to URLs here",
"required": [
],
"examples": [{
"title/no-pano-blur.flag": "",
"sounds/gta.mp3": "https://real.shhnowisnottheti.me/menu.mp3",
"records/mellohi.mp3": "https://stream.nightride.fm/chillsynth.m4a"
}],
"additionalProperties": true,
"patternProperties": {
"^.*$": {
"type": "string"
}
}
},
"profanity": {
"type": "boolean",
"default": false,
"title": "Allow username profanity",
"examples": [
false
]
},
"serverListTitle": {
"type": "string",
"default": "",
"title": "Title for link at the top of multiplayer",
"examples": [
"My cool link"
]
},
"serverListLink": {
"type": "string",
"default": "",
"title": "Link at the top of multiplayer",
"examples": [
"https://example.com"
]
},
"relays": {
"type": "array",
"default": [],
"title": "Default LAN Relays",
"items": {
"type": "object",
"title": "LAN Relay",
"required": [
"addr",
"name"
],
"properties": {
"addr": {
"type": "string",
"title": "Relay address",
"examples": [
"wss://relay.deev.is/",
"wss://relay.lax1dude.net/",
"wss://relay.shhnowisnottheti.me/"
]
},
"name": {
"type": "string",
"title": "Relay name",
"examples": [
"lax1dude relay #1",
"lax1dude relay #2",
"ayunami relay #1"
]
},
"primary": {
"type": "boolean",
"title": "Use this relay by default",
"examples": [
true,
false
]
}
},
"examples": [{
"addr": "wss://relay.deev.is/",
"name": "lax1dude relay #1",
"primary": true
},
{
"addr": "wss://relay.lax1dude.net/",
"name": "lax1dude relay #2",
"primary": false
},
{
"addr": "wss://relay.shhnowisnottheti.me/",
"name": "ayunami relay #1",
"primary": false
}]
},
"examples": [
[{
"addr": "wss://relay.deev.is/",
"name": "lax1dude relay #1",
"primary": true
},
{
"addr": "wss://relay.lax1dude.net/",
"name": "lax1dude relay #2",
"primary": false
},
{
"addr": "wss://relay.shhnowisnottheti.me/",
"name": "ayunami relay #1",
"primary": false
}]
]
},
"mainMenu": {
"type": "object",
"default": {},
"title": "Title screen options",
"required": [
],
"properties": {
"splashes": {
"type": "array",
"default": [],
"title": "Title screen splash texts",
"items": {
"type": "string",
"title": "Splash text",
"examples": [
"Darviglet!",
"eaglerenophile!",
"You Eagler!",
"Yeeeeeee!",
"yeee",
"EEEEEEEEE!",
"You Darvig!",
"You Vigg!",
":\u003e",
"|\u003e",
"You Yumpster!"
]
},
"examples": [
["Darviglet!",
"eaglerenophile!",
"You Eagler!",
"Yeeeeeee!",
"yeee",
"EEEEEEEEE!",
"You Darvig!",
"You Vigg!",
":\u003e",
"|\u003e",
"You Yumpster!"
]
]
},
"eaglerLogo": {
"type": "boolean",
"default": false,
"title": "Use Eaglercraft logo instead",
"examples": [
false
]
},
"itemLink": {
"type": "string",
"default": "",
"title": "Link for item on title screen",
"examples": [
"https://totalfreedom.me"
]
},
"itemLine0": {
"type": "string",
"default": "",
"title": "First line for item on title screen",
"examples": [
"Hello..."
]
},
"itemLine1": {
"type": "string",
"default": "",
"title": "Second line for item on title screen",
"examples": [
"...Please click this!"
]
},
"itemLine2": {
"type": "string",
"default": "",
"title": "Last line for item on title screen",
"examples": [
"It's very cool!"
]
}
},
"examples": [{
"splashes": [
"Darviglet!",
"eaglerenophile!",
"You Eagler!",
"Yeeeeeee!",
"yeee",
"EEEEEEEEE!",
"You Darvig!",
"You Vigg!",
":\u003e",
"|\u003e",
"You Yumpster!"
],
"eaglerLogo": false,
"itemLink": "https://totalfreedom.me",
"itemLine0": "First line for item on title screen",
"itemLine1": "Second line for item on title screen",
"itemLine2": "Last line for item on title screen"
}]
}
},
"examples": [{
"container": "game_frame",
"assetsURI": "assets.epk",
"serverWorkerURI": "worker_bootstrap.js",
"worldsFolder": "MAIN",
"servers": [{
"serverName": "server name",
"serverAddress": "ws://localhost:25565/",
"hideAddress": false
}],
"hideDownServers": false,
"joinServer": "wss://sus.shhnowisnottheti.me/",
"assetOverrides": {
"title/no-pano-blur.flag": "",
"sounds/gta.mp3": "https://real.shhnowisnottheti.me/menu.mp3",
"records/mellohi.mp3": "https://stream.nightride.fm/chillsynth.m4a"
},
"profanity": false,
"serverListTitle": "My cool link",
"serverListLink": "https://example.com",
"relays": [{
"addr": "wss://relay.deev.is/",
"name": "lax1dude relay #1",
"primary": true
},
{
"addr": "wss://relay.lax1dude.net/",
"name": "lax1dude relay #2",
"primary": false
},
{
"addr": "wss://relay.shhnowisnottheti.me/",
"name": "ayunami relay #1",
"primary": false
}],
"mainMenu": {
"splashes": [
"Darviglet!",
"eaglerenophile!",
"You Eagler!",
"Yeeeeeee!",
"yeee",
"EEEEEEEEE!",
"You Darvig!",
"You Vigg!",
":\u003e",
"|\u003e",
"You Yumpster!"
],
"eaglerLogo": false,
"itemLink": "https://totalfreedom.me",
"itemLine0": "First line for item on title screen",
"itemLine1": "Second line for item on title screen",
"itemLine2": "Last line for item on title screen"
}
}]
}
});
const ta = document.getElementById('output');
function relaysEqual(obj1, obj2) {
if (obj1 == null || obj2 == null) {
return obj1 == obj2;
}
if (obj1 == obj2) return true;
if (obj1.length != obj2.length) return false;
let good = 0;
for (const i in obj1) {
for (const ii in obj2) {
if (obj1[i] == obj2[ii]) {
++good;
break;
}
if (obj1[i].addr == obj2[ii].addr && obj1[i].name == obj2[ii].name) {
if (('primary' in obj1[i] && 'primary' in obj2[ii] && obj1[i].primary == obj2[ii].primary) || (!('primary' in obj1[i]) && !('primary' in obj2[ii]))) {
++good;
break;
}
}
}
}
if (good == obj1.length) return true;
}
function saveOpts() {
const errors = editor.validate();
if (errors.length) {
for (const error of errors) {
console.error(error);
}
} else {
const outJson = JSON.parse(JSON.stringify(editor.getValue()));
if (outJson == null) return;
const uniqueId = Array.from(Array(20), () => Math.floor(Math.random() * 36).toString(36)).join('');
const setRelays = relaysEqual(outJson.relays, startJson.relays);
if (setRelays && 'relays' in outJson) {
for (const relay of outJson.relays) {
relay.primary = uniqueId;
}
}
ta.value = 'window.eaglercraftOpts = ' + JSON.stringify(outJson, null, 4) + ';';
if (setRelays) {
let h = -1;
ta.value = 'const relayId = Math.floor(Math.random() * ' + outJson.relays.length + ');\n' + ta.value.replaceAll('"' + uniqueId + '"', function() {
return 'relayId == ' + (++h);
});
}
ta.select();
ta.setSelectionRange(0, ta.value.length);
window.navigator.clipboard.writeText(ta.value);
}
}
</script>
</body>
</html>