-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgamePatch.js
2249 lines (2144 loc) · 87.1 KB
/
gamePatch.js
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
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
((h, c, d, P) => {
let Y = 28,
z = 57,
U = 51,
n = [Y, z, U],
H = 0,
B = 1,
_ = 2,
G = 5,
K = 0,
F = 1,
V = 2,
j = 3,
Z = 4,
X = 5,
J = 6,
Q = 7,
ee = 1,
te = 2,
ne = {
LANG: 0,
SLOTS: 1,
DRAWTIME: 2,
ROUNDS: 3,
WORDCOUNT: 4,
HINTCOUNT: 5,
WORDMODE: 6,
CUSTOMWORDSONLY: 7
},
ae = {
NORMAL: 0,
HIDDEN: 1,
COMBINATION: 2
}
// TYPOMOD
// desc: create re-useable functions
, typo = {
messagePort: (()=>{
const channel = new MessageChannel();
window.postMessage("skribblMessagePort", "*", [channel.port2]);
return channel.port1;
})(),
emitPort: (()=>{
const channel = new MessageChannel();
window.postMessage("skribblEmitPort", "*", [channel.port2]);
return channel.port1;
})(),
joinLobby: undefined,
createFakeUser: (id = 0, name = "", avatar = [], score = 0, guessed = false) => {
// IDENTIFY x.value.split: #home .container-name-lang input -> Kn
// IDENTIFY x.avatar: [Math.round(100 * Math.random()) % -> l
return {
id: id,
name: name.length != 0 ? name : (Kn.value.split("#")[0] != "" ? Kn.value.split("#")[0] : "Player"),
avatar: avatar.length == 0 ? l.avatar : avatar,
score: score,
guessed: guessed
};
},
createFakeLobbyData: (
settings = ["PRACTISE", "en", 1, 1, 80, 3, 3, 2, 0, false],
id = null,
me = 0,
owner = 0,
users = [],
state = { id: 4, type: 0, time: 0, data: { id: 0, word: "Anything" } }) => {
if (users.length == 0) users = [typo.createFakeUser()];
return {
settings: settings,
id: id,
me: me,
owner: owner,
round: 0,
users: users,
state: state
};
},
disconnect: undefined,
lastConnect: 0,
initListeners: (() => {
let abort = false;
document.addEventListener("clearDrawing", () => Vt());
document.addEventListener("abortJoin", () => abort = true);
document.addEventListener("joinLobby", (e) => {
abort = false;
let timeoutdiff = Date.now() - (typo.lastConnect == 0 ? Date.now() : typo.lastConnect);
// Xn(true);
setTimeout(() => {
if (abort) return;
typo.lastConnect = Date.now();
// Vn.dispatchEvent(new Event("click"));
// IDENTIFY x.dispatchEvent: querySelector("#home .panel .button-play") -> BTNPLAY
// ##PRIVATELBBY## = !1
// IDENTIFY: x: = !1
if (e.detail) window.history.pushState({path: window.location.origin + '?' + e.detail}, '', window.location.origin + '?' + e.detail);
// ##JOINLOBBY##(e.detail?.join ? e.detail.join : "");
// IDENTIFY x(e.det..): ? "id=" + -> JOINLOBBY
typo.joinLobby();
window.history.pushState({path: window.location.origin}, '', window.location.origin);
// Jn(false);
// IDENTIFY x(false): querySelector("#load").style.display -> LOADING
document.dispatchEvent(new Event("joinedLobby"));
}, timeoutdiff < 2000 ? 2000 - timeoutdiff : 0);
});
document.addEventListener("leaveLobby", () => {
if (typo.disconnect) typo.disconnect();
else ua() | document.dispatchEvent(new Event("leftLobby"));
// IDENTIFY x(): querySelector("#home").style.display = "" -> GOHOME
});
document.addEventListener("setColor", (e) => {
let rgb = typo.hexToRgb((e.detail.code - 10000).toString(16).padStart(6, "0"));
let match = wt.findIndex(color => color[0] == rgb[0] && color[1] == rgb[1] && color[2] == rgb[2]);
// IDENTIFY [0, 59, 120], -> COLORS
let code = match >= 0 ? match : e.detail.code;
if (e.detail.secondary) Ot(code);
// IDENTIFY x(e.detail.code): querySelector("#color-preview-secondary").style.fill -> SECFILL
else Wt(code);
// IDENTIFY x(e.detail.code): querySelector("#color-preview-primary").style.fill -> PRIMFILL
});
document.addEventListener("performDrawCommand", (e) => {
v.push(e.detail);
// IDENTIFY x.push(e.detail): .getContext("2d"), x = [] -> PUSHCMD
Kt(Zt(e.detail));
// IDENTIFY: x(y(e.detail)): bounds: AND Math.floor(Math.ceil -> PERFOUTER, PERFINNER
});
document.addEventListener("addTypoTooltips", () => {
[...document.querySelectorAll("[data-typo-tooltip]")].forEach(elem => {
elem.setAttribute("data-tooltip", elem.getAttribute("data-typo-tooltip"));
elem.removeAttribute("data-typo-tooltip");
elem.addEventListener("mouseenter", (e) => Oe(e.target));
// IDENTIFY: x(e.target):
elem.addEventListener("mouseleave", (e) => Pe());
// IDENTIFY: (e) => x():
});
});
})(),
hexToRgb: (hex) => {
let arrBuff = new ArrayBuffer(4);
let vw = new DataView(arrBuff);
vw.setUint32(0, parseInt(hex, 16), false);
let arrByte = new Uint8Array(arrBuff);
return [arrByte[1], arrByte[2], arrByte[3]];
},
rgbToHex: (r, g, b) => {
return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
}
// TYPOEND,
oe = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if (h.localStorageAvailable = !1, void 0 !== d) try {
d.setItem("feature_test", "yes"), "yes" === d.getItem("feature_test") && (d.removeItem("feature_test"), h.localStorageAvailable = !0)
} catch (e) {}
var u = [];
function re(e) {
for (var t = 0; t < u.length; t++)
if (u[t].name == e) return u[t]
}
function ie(e, t, n, a, o) {
var r, i, l = t,
s = (h.localStorageAvailable && (r = d.getItem("hotkey_" + e)) && (t = r), re(e));
return s ? (s.key = t, s.def = l, s.desc = n) : (s = {
name: e,
desc: n,
key: t,
def: l,
listing: $("item"),
changed: [],
cb: []
}, u.push(s), je(r = $("key", s.name), "text"), s.listing.appendChild(r), (i = c.createElement("input")).value = s.key, s.listing.appendChild(i), D(i, "keydown", function(e) {
for (var t = e.key, n = 0; n < u.length; n++)
if (u[n].key == t) return void e.preventDefault();
i.value = t, s.key = t;
for (n = 0; n < s.changed.length; n++) s.changed[n](s);
return le(), e.preventDefault(), !1
}), g[p].querySelector("#hotkey-list").appendChild(s.listing)), a && s.cb.push(a), o && s.changed.push(o), s
}
function le() {
if (h.localStorageAvailable)
for (var e = 0; e < u.length; e++) h.localStorage.setItem("hotkey_" + u[e].name, u[e].key)
}
var l = {
avatar: [Math.round(100 * Math.random()) % Y, Math.round(100 * Math.random()) % z, Math.round(100 * Math.random()) % U, -1],
volume: 100,
dark: 0,
filterChat: 1,
pressureSensitivity: 1,
displayLang: "en",
undefined,
mobileChatLayout: "bottom"
};
function a(e, t) {
e = d.getItem(e);
return null == e ? t : e
}
function se() {
h.localStorageAvailable ? (d.setItem("name", Kn.value), d.setItem("lang", Fn.value), d.setItem("displaylang", l.displayLang), d.setItem("volume", l.volume), d.setItem("dark", 1 == l.dark ? 1 : 0), d.setItem("filter", 1 == l.filterChat ? 1 : 0), d.setItem("pressure", 1 == l.pressureSensitivity ? 1 : 0), d.setItem("ava", JSON.stringify(l.avatar)), d.setItem("mobileChatLayout", l.mobileChatLayout), d.setItem("keyboard", ze.value), d.setItem("keyboardlayout", Ue.value), console.log("Settings saved.")) : console.log("Settings not saved. LocalStorage unavailable.")
}
function D(e, t, n) {
for (var a, o = e, r = ("string" == typeof e ? o = c.querySelectorAll(e) : "[object Array]" !== (a = Object.prototype.toString.call(e)) && "[object NodeList]" !== a && "[object HTMLCollection]" !== a && (o = [e]), t.split(" ")), i = 0; i < o.length; i++)
for (var l = 0; l < r.length; l++) o[i].addEventListener(r[l], n)
}
function $(e, t) {
var n = c.createElement("div");
if (void 0 !== e)
for (var a = e.split(" "), o = 0; o < a.length; o++) n.classList.add(a[o]);
return void 0 !== t && (n.textContent = t), n
}
function ce(e, t, n) {
var a = c.createElement(e);
if (void 0 !== t)
for (var o = t.split(" "), r = 0; r < o.length; r++) a.classList.add(o[r]);
return void 0 !== n && (a.textContent = n), a
}
function de(e) {
for (; e.firstChild;) e.removeChild(e.firstChild)
}
function ue(e, t) {
var n = $("avatar"),
a = $("color"),
o = $("eyes"),
r = $("mouth"),
i = $("special"),
l = $("owner");
return l.style.display = t ? "block" : "none", n.appendChild(a), n.appendChild(o), n.appendChild(r), n.appendChild(i), n.appendChild(l), n.parts = [a, o, r], he(n, e), n
}
function he(e, t) {
function n(e, t, n) {
var a = -t % n * 100,
t = 100 * -Math.floor(t / n);
e.style.backgroundPosition = a + "% " + t + "%"
}
var a = t[0] % Y,
o = t[1] % z,
r = t[2] % U,
t = t[3],
a = (n(e.querySelector(".color"), a, 10), n(e.querySelector(".eyes"), o, 10), n(e.querySelector(".mouth"), r, 10), e.querySelector(".special"));
0 <= t ? (a.style.display = "", n(a, t, 10)) : a.style.display = "none"
}
function pe(e, t) {
e.querySelector(".owner").style.display = t ? "block" : "none"
}
function me(e, t) {
e.className = "avatar";
for (var n of t) e.classList.add("filter-" + n)
}
function ge(e, t, n, a) {
var o = {
element: $("dots"),
dots: [],
selected: 0,
change: a
};
return e.appendChild(o.element), n.push(o.element), D(n, "DOMMouseScroll wheel", function(e) {
var t;
1 < o.dots.length && (t = -e.deltaY || e.wheelDeltaY, t = Math.sign(t), ye(o, Math.min(o.dots.length - 1, Math.max(0, o.selected - t)), !0), e.preventDefault(), e.stopPropagation())
}), fe(o, t), o
}
function fe(e, t) {
de(e.element), e.dots = [];
for (var n = 0; n < t; n++) {
var a = $("dot");
a.index = n, a.appendChild($("inner")), D(a, "click", function() {
ye(e, this.index, !0)
}), e.element.appendChild(a), e.dots.push(a)
}
e.selected < 0 && (e.selected = 0), t <= e.selected && (e.selected = t - 1), ye(e, e.selected, !1)
}
function ye(e, t, n) {
if (0 <= t && t < e.dots.length) {
e.selected = t;
for (var a = 0; a < e.dots.length; a++) e.dots[a].classList.remove("active");
e.dots[t].classList.add("active"), e.change(e, t, n)
}
}
let s = 0,
ve = 1,
be = 2,
Se = 3,
p = 4,
ke = 5;
var m = c.querySelector("#modal"),
we = m.querySelector(".modal-title .text"),
Ce = m.querySelector(".modal-content"),
g = [];
function qe(e) {
g[s].querySelector(".buttons button.mute").textContent = E(e ? "Unmute" : "Mute")
}
function xe(e, t) {
m.style.display = "block";
for (var n = 0; n < g.length; n++) g[n].style.display = "none";
g[e].style.display = "flex";
var a = g[e];
switch (e) {
case ve:
we.textContent = E("Something went wrong!"), a.querySelector(".message").textContent = t;
break;
case be:
we.textContent = E("Disconnected!"), a.querySelector(".message").textContent = t;
break;
case s:
we.textContent = t.id == x ? E("$ (You)", t.name) : t.name;
var o = (O(x).flags & k) == k,
r = (t.flags & k) == k,
i = a.querySelector(".buttons"),
r = (i.style.display = t.id == x || r ? "none" : "flex", i.querySelector(".button-pair").style.display = x == R || o ? "flex" : "none", i.querySelector("button.report").style.display = t.reported ? "none" : "", qe(t.muted), a.querySelector(".report-menu").style.display = "none", a.querySelector(".invite").style.display = x == t.id ? "flex" : "none", Ce.querySelector(".player")),
o = (r.style.display = "", de(r), ue(t.avatar));
pe(o, R == t.id), me(o, Ya(t)), r.appendChild(o);
break;
case ke:
we.textContent = E("Rooms"), roomsUpdate(t);
break;
case Se:
we.textContent = E("Invite your friends!");
break;
case p:
we.textContent = E("Settings"), a.querySelector("#select-pressure-sensitivity").value = l.pressureSensitivity
}
}
function Me() {
m.style.display = "none"
}
g[s] = m.querySelector(".modal-container-player"), g[ve] = m.querySelector(".modal-container-info"), g[be] = m.querySelector(".modal-container-info"), g[Se] = m.querySelector(".modal-container-room"), g[p] = m.querySelector(".modal-container-settings"), D([m.querySelector(".close"), g[ve].querySelector("button.ok")], "click", Me);
let Le = 0,
De = 2,
$e = 3,
Ee = 4,
Ae = 5,
Ie = 6,
Re = 7,
Te = ["BASE", "GUESSED", "CLOSE", "DRAWING", "JOIN", "LEAVE", "OWNER", "GUESSCHAT"];
function f(e) {
return "var(--COLOR_CHAT_TEXT_" + Te[e] + ")"
}
function Ne(e, t, n, a) {
var o = c.createElement("p"),
r = c.createElement("b"),
a = (r.textContent = a ? e : e + ": ", o.appendChild(r), o.style.color = n, c.createElement("span"));
return a.textContent = t, o.appendChild(a), o
}
function y(e, t, n, a) {
var o = Ne(e, t, n, a),
r = Gn.scrollHeight - Gn.scrollTop - Gn.clientHeight <= 20;
if (Gn.appendChild(o), r && (Gn.scrollTop = Gn.scrollHeight + 100), 0 < l.chatDeleteQuota)
for (; Gn.childElementCount > l.chatDeleteQuota;) Gn.firstElementChild.remove();
var i = Ne(e, t, n, a);
return c.querySelector("#game-canvas .bubbles").appendChild(i), setTimeout(function() {
i.remove()
}, 2500), o
}
var i = void 0,
We = void 0;
function Oe(e) {
Pe();
for (var t = (We = e).dataset.tooltip, n = e.dataset.tooltipdir || "N", a = ((i = $("tooltip")).appendChild($("tooltip-arrow")), i.appendChild($("tooltip-content", E(t))), !1), o = e; o;) {
if ("fixed" == h.getComputedStyle(o).position) {
a = !0;
break
}
o = o.parentElement
}
i.style.position = a ? "fixed" : "absolute";
var t = e.getBoundingClientRect(),
e = ("E" == (n = "W" == (n = "S" == (n = "N" == n && t.top - h.scrollY < 48 ? "S" : n) && t.bottom - h.scrollY > c.documentElement.clientHeight - 48 ? "N" : n) && t.left - h.scrollX < 48 ? "E" : n) && t.right - h.scrollX > c.documentElement.clientWidth - 48 && (n = "W"), t.left),
r = t.top;
"N" == n && (e = (t.left + t.right) / 2), "S" == n && (e = (t.left + t.right) / 2, r = t.bottom), "E" == n && (e = t.right, r = (t.top + t.bottom) / 2), "W" == n && (r = (t.top + t.bottom) / 2), a || (e += h.scrollX, r += h.scrollY), i.classList.add(n), i.style.left = e + "px", i.style.top = r + "px", c.body.appendChild(i)
}
function Pe() {
i && (i.remove(), We = i = void 0)
}
let Ye = [{
code: "en",
name: "English",
layout: [
["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"],
["A", "S", "D", "F", "G", "H", "J", "K", "L"],
["Z", "X", "C", "V", "B", "N", "M"]
]
}, {
code: "fr",
name: "French",
layout: [
["A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P"],
["Q", "S", "D", "F", "G", "H", "J", "K", "L", "M"],
["W", "X", "C", "V", "B", "N", "É", "È", "Ç", "À", "'"]
]
}, {
code: "de",
name: "German",
layout: [
["Q", "W", "E", "R", "T", "Z", "U", "I", "O", "P", "Ü"],
["A", "S", "D", "F", "G", "H", "J", "K", "L", "Ö", "Ä"],
["Y", "X", "C", "V", "B", "N", "M"]
]
}, {
code: "tr",
name: "Turkish",
layout: [
["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "Ğ", "Ü"],
["A", "S", "D", "F", "G", "H", "J", "K", "L", "Ş", "İ"],
["Z", "X", "C", "V", "B", "N", "M", "Ö", "Ç"]
]
}, {
code: "ru",
name: "Russian",
layout: [
["Й", "Ц", "У", "К", "Е", "Н", "Г", "Ш", "Щ", "З", "Х", "Ъ"],
["Ф", "Ы", "В", "А", "П", "Р", "О", "Л", "Д", "Ж", "Э"],
["Я", "Ч", "С", "М", "И", "Т", "Ь", "Б", "Ю", "Ё"]
]
}, {
code: "es",
name: "Spanish",
layout: [
["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"],
["A", "S", "D", "F", "G", "H", "J", "K", "L", "Ñ"],
["Z", "X", "C", "V", "B", "N", "M"]
]
}];
var ze = c.querySelector("#select-mobile-keyboard-enabled"),
Ue = c.querySelector("#select-mobile-keyboard-layout"),
He = {
elements: {
main: c.querySelector("#game-keyboard"),
input: c.querySelector("#game-keyboard .input"),
rows: c.querySelector("#game-keyboard .keys"),
caps: 0,
keys: []
},
lang: 0,
form: void 0,
input: void 0,
caps: !1,
keys: [],
rows: [],
columns: 0,
isOpen: !1,
getKeyLowercase: function(e) {
return e.toLocaleLowerCase(this.lang)
},
getKeyUppercase: function(e) {
return e.toLocaleUpperCase(this.lang)
},
init: function(e) {
this.lang = e.code, this.caps = !1, this.columns = 0, this.elements.keys = [], this.form = c.querySelector("#game-chat-input-mobile form"), this.input = this.form.querySelector("input"), de(this.elements.rows);
var t = e.layout,
i = this;
function n(e, t, n) {
var a, o = ce("button", "key"),
r = "PointerEvent" in h ? "pointerdown" : "click";
return Be.has(t) ? (a = Be.get(t), o.classList.add(a.class), o.appendChild(ce("span", "material-icons", a.icon)), D(o, r, function(e) {
a.callback(i), e.preventDefault()
})) : (o.textContent = i.getKeyLowercase(t), D(o, r, function(e) {
i.inputAdd(t), e.preventDefault()
}), i.elements.keys.push(o)), n ? e.insertBefore(o, e.firstChild) : e.appendChild(o), o
}
for (var a = 0; a < t.length; a++) {
current_row = i.addRow();
for (var o = 0; o < t[a].length; o++) {
var r = t[a][o];
n(current_row, r)
}
}
this.elements.caps = n(current_row, "caps", !0), n(current_row, "backspace"), current_row = i.addRow();
for (var l = ["-", "space", ".", "enter"], o = 0; o < l.length; o++) n(current_row, l[o])
},
addRow: function() {
var e = $("row");
return this.elements.rows.appendChild(e), this.rows.push(e), e
},
inputChanged: function() {
this.input.dispatchEvent(new Event("input", {
bubbles: !0
}))
},
inputAdd: function(e) {
this.input.value += this.caps ? this.getKeyUppercase(e) : this.getKeyLowercase(e), this.inputChanged(), this.caps && this.toggleCaps()
},
enter: function() {
0 < this.input.value.length && (this.form.requestSubmit(), this.input.value = "", this.inputChanged())
},
toggleCaps: function() {
this.caps = !this.caps;
for (var e = 0; e < this.elements.keys.length; e++) {
var t = this.elements.keys[e];
t.textContent = this.caps ? this.getKeyUppercase(t.textContent) : this.getKeyLowercase(t.textContent)
}
this.elements.caps.classList.toggle("enabled", this.caps)
}
};
let Be = new Map;
function _e() {
1 == ze.value ? (_n[1].setAttribute("readonly", ""), c.documentElement.dataset.mobileKeyboard = "") : (_n[1].removeAttribute("readonly"), delete c.documentElement.dataset.mobileKeyboard)
}
Be.set("backspace", {
class: "wide",
icon: "backspace",
callback: function(e) {
0 < e.input.value.length && (e.input.value = e.input.value.slice(0, -1), e.inputChanged())
}
}), Be.set("caps", {
class: "wide",
icon: "keyboard_capslock",
callback: function(e) {
e.toggleCaps()
}
}), Be.set("enter", {
class: "wide",
icon: "keyboard_return",
callback: function(e) {
e.enter()
}
}), Be.set("space", {
class: "extra-wide",
icon: "space_bar",
callback: function(e) {
e.input.value += " ", e.inputChanged()
}
});
for (var e = 0; e < Ye.length; e++) {
var Ge = ce("option");
Ge.textContent = Ye[e].name, Ge.value = Ye[e].code, Ue.appendChild(Ge)
}
D(Ue, "change", function(e) {
for (var t = void 0, n = 0; n < Ye.length; n++) Ye[n].code == this.value && (t = Ye[n]);
null != t && He.init(t)
}), D([ze, Ue], "change", function(e) {
se(), _e()
}), D(He.elements.main, "gesturestart gesturechange gestureend drag scroll", function(e) {
return e.preventDefault(), !1
}), He.init(Ye[0]);
var Ke = {},
Fe = [];
function Ve(e, t) {
e = e[t];
return null != e && "" != e ? e : t
}
function E(e, t) {
var n = Ve(Ke[l.displayLang], e),
a = "",
o = 0;
Array.isArray(t) || (t = [t]);
for (var r = 0; r < n.length; r++) {
var i = n.charAt(r);
"$" == i ? (a += t[o], o++) : a += i
}
return a
}
function je(e, t) {
if ("children" == t)
for (var n = 0; n < e.children.length; n++) {
var a = e.children[n].dataset.translate;
je(e.children[n], null == a ? "text" : a)
} else {
var o = "";
"text" == t && (o = e.textContent), 0 < (o = "placeholder" == t ? e.placeholder : o).length ? Fe.push({
key: o,
element: e,
type: t
}) : (console.log("Empty key passed to translate with!"), console.log(e))
}
}
Ke.en = {}, Ke.de = {
"You have been kicked!": "Du wurdest gekickt!",
"You have been banned!": "Du wurdest gebannt!",
"You muted '$'!": "Du hast '$' stummgeschalten!",
"You unmuted '$'!": "Du hast die Stummschaltung für '$' aufgehoben!",
"You are on a kick cooldown!": "Du bist noch in der Kick Abklingzeit!",
"You are banned from this room!": "Du bist von diesem Raum gebannt!",
"You need at least 2 players to start the game!": "Du brauchst mind. 2 Spieler um das Spiel zu starten!",
"Server restarting in about $ seconds!": "Server Neustart in ungefähr $ Sekunden!",
"Spam detected! You're sending messages too quickly.": "Spam erkannt! Du sendest Nachrichten zu schnell.",
"You can not votekick the lobby owner!": "Du kannst den Raumbesitzer nicht kicken!",
"The word was '$'": "Das Wort war '$'",
"$ is drawing now!": "$ zeichnet nun!",
"$ is now the room owner!": "$ ist nun der Raumeigentümer!",
"$ is voting to kick $ ($/$)": "$ möchte $ kicken ($/$)!",
"$ joined the room!": "$ ist dem Raum beigetreten!",
"$ left the room!": "$ hat den Raum verlassen!",
"$ has been kicked!": "$ wurde gekickt!",
"$ has been banned!": "$ wurde gebannt!",
"$ guessed the word!": "$ hat das Wort erraten!",
"$ liked the drawing!": "$ mag die Zeichnung!",
"$ disliked the drawing!": "$ mag die Zeichnung nicht!",
"$ is close!": "$ ist nah dran!",
"$ is choosing a word!": "$ wählt ein Wort!",
"$ won with a score of $!": "$ hat mit einem Punktestand von $ gewonnen!",
"$ and $ won with a score of $!": "$ und $ haben mit einem Punktestand von $ gewonnen!",
WAITING: "WARTEN",
"DRAW THIS": "ZEICHNE",
"WORD HIDDEN": "WORT VERSTECKT",
"GUESS THIS": "RATE",
"$ (You)": "$ (Du)",
"$ points": "$ Punkte",
"Room not found!": "Raum nicht gefunden!",
"Room is full!": "Raum ist voll!",
"No rooms found!": "Keine Räume gefunden!",
"An unknown error ('$')": "Unbekannter Fehler ('$')",
"Something went wrong!": "Etwas ist schief gelaufen!",
"Disconnected!": "Verbindung getrennt!",
"Connection lost!": "Verbindung verloren!",
"Servers are currently undergoing maintenance!": "Server werden derzeit gewartet",
"Please try again later!": "Bitte versuch es später noch einmal!",
"An unknown error occurred ('$')": "Ein unbekannter Fehler ist aufgetreten ('$')",
Unmute: "Stumm. aufheben",
Mute: "Stummschalten",
Rooms: "Räume",
Settings: "Einstellungen",
"Not started": "Nicht gestartet",
Round: "Runde",
Rounds: "Runden",
"Round $": "Runde $",
"Round $ of $": "Runde $ von $",
"Waiting for players...": "Auf Spieler warten...",
"Game starting in a few seconds...": "Das Spiel beginnt in wenigen Sekunden...",
"is the winner!": "hat gewonnen!",
"are the winners!": "haben gewonnen!",
"Nobody won!": "Niemand hat gewonnen!",
"Choose a word": "Wähle ein Wort",
"The word was": "Das Wort war",
User: "Spieler",
Play: "Spielen",
"Create Room": "Raum erstellen",
"View Rooms": "Räume ansehen",
"How to play": "Wie gespielt wird",
About: "Über",
News: "Neuigkeiten",
"When it's your turn, choose a word you want to draw!": "Wähle ein Wort, das du zeichnen willst, wenn du dran bist!",
"Try to draw your choosen word! No spelling!": "Versuche nun dein Wort zu zeichnen. Kein Schreiben!",
"Let other players try to guess your drawn word!": "Lass andere Mitspieler dein gezeichnetes Wort erraten!",
"When it's not your turn, try to guess what other players are drawing!": "Wenn du nicht dran bist mit Zeichnen, versuche die Zeichnungen anderer zu erraten!",
"Score the most points and be crowned the winner at the end!": "Sammel die meisten Punkte und werde zum Gewinner!",
"is a free online multiplayer drawing and guessing pictionary game.": "ist ein kostenloses Mehrspieler-Zeichnen und Raten- / Montagsmaler-Spiel.",
"A normal game consists of a few rounds, where every round a player has to draw their chosen word and others have to guess it to gain points!": "Ein normales Spiel besteht aus drei Runden, in welcher jeder Spieler sein gewähltes Wort zeichnen muss, während die Anderen es für Punkte erraten müssen!",
"The person with the most points at the end of the game, will then be crowned as the winner!": "Die Person mit dem höchsten Punktestand am Ende des Spiels wird als Sieger gekrönt!",
"Have fun!": "Viel Spaß!",
"Invite your friends!": "Lad deine Freunde ein!",
Copy: "Kopieren",
"Hover over me to see the Invite link!": "Einladungslink hier anschauen!",
"Click to copy the link to this room!": "Klicke um den Einladungslink zu kopieren!",
Visibility: "Sichtbarkeit",
Name: "Name",
Players: "Spieler",
Drawtime: "Zeit",
Language: "Sprache",
"Word Mode": "Wort-Modus",
"Word Count ": "Wort-Anzahl",
Hints: "Hinweise",
"Custom words": "Eigene Wörter",
"Minimum of 10 words. 1-32 characters per word! 10000 characters maximum. Separated by a , (comma)": "Minimum von 10 Wörtern. 1-32 Buchstaben pro Wort. 10000 Buchstaben maximal. Getrennt durch ein , (Komma)",
"Use custom words only": "Nur eigene Wörter benutzen",
"Start!": "Starten!",
All: "Alle",
Custom: "Benutzerdefiniert",
Public: "Öffentlich",
Private: "Privat",
Mode: "Modus",
Normal: "Normal",
Hidden: "Versteckt",
Combination: "Kombination",
"Please select the reasons for your report": "Bitte wählen Sie die Gründe für Ihre Meldung",
"Inappropriate Messages / Drawings": "Unangemessene Nachrichten / Zeichnungen",
Spam: "Spam",
"Botting / Cheating": "Botting / Cheating",
"Your report for '$' has been sent!": "Deine Meldung für '$' wurde abgesendet!",
"Enter your name": "Gib dein Namen ein",
"Filter rooms by name here...": "Suche nach Räume hier...",
"Type your guess here...": "Rate das gesuchte Wort hier...",
"Everyone guessed the word!": "Jeder hat das Wort erraten!",
"The drawer left the game!": "Der Zeichner hat das Spiel verlassen!",
"Time is up!": "Die Zeit ist abgelaufen!",
Kick: "Kicken",
Ban: "Bannen",
Votekick: "Votekicken",
Report: "Melden",
"Randomize your Avatar!": "Zufälliger Avatar!",
Brush: "Stift",
Colorpick: "Pipette",
Fill: "Füllen",
Undo: "Rückgängig",
Clear: "Löschen",
"Mute audio": "Stummschalten",
"Unmute audio": "Stumm. aufheben",
"Turn the lights off": "Lichter ausmachen",
"Turn the lights on": "Lichter anmachen",
"Hotkeys & Misc.": "Tastenkürzel & Sonstiges",
Hotkeys: "Tastenkürzel",
Miscellaneous: "Sonstiges",
"Display Language": "Anzeigesprache",
"Filter bad words in chat": "Schlechte Wörter im Chat filtern",
"Brush Pressure Sensitivity": "Stiftdruckempfindlichkeit",
Reset: "Zurücksetzen",
"Reset hotkeys to default": "Tastenkürzel zurücksetzen",
On: "An",
Off: "Aus"
};
let Ze = 0,
Xe = 1,
Je = 0,
Qe = 4,
et = 40;
var tt = [4, 10, 20, 32, 40],
nt = c.querySelector("#game-toolbar"),
at = nt.querySelector(".toolbar-group-tools"),
ot = nt.querySelector(".toolbar-group-actions"),
t = c.querySelector("#game-toolbar .sizes .size-preview"),
rt = c.querySelector("#game-toolbar .sizes .container"),
it = c.querySelector("#game-toolbar .colors");
function lt(e, t) {
var n, a, o, r = $("tool clickable"),
i = (r.appendChild($("icon")), r.appendChild($("key")), t),
l = (i.id = e, (i.element = r).toolIndex = e, r.querySelector(".icon").style.backgroundImage = "url(/img/" + t.graphic + ")", o = t.name, a = "S", (n = r).dataset.tooltip = o, n.dataset.tooltipdir = a, D(n, "pointerenter", function(e) {
Oe(e.target)
}), D(n, "pointerleave", function(e) {
Pe()
}), o = t.isAction ? (r.addEventListener("click", function(e) {
Tt(this.toolIndex)
}), ot.appendChild(r), ct[e] = i, ie(t.name, t.keydef, "", function() {
Tt(e)
}, function(e) {
l.textContent = e.key
})) : (r.addEventListener("click", function(e) {
Nt(this.toolIndex)
}), at.appendChild(r), st[e] = i, ie(t.name, t.keydef, "", function() {
Nt(i.id)
}, function(e) {
l.textContent = e.key
})), r.querySelector(".key"));
l.textContent = o.key, t.hide && (r.style.display = "none")
}
var st = [],
ct = (lt(Je, {
isAction: !1,
name: "Brush",
keydef: "B",
graphic: "pen.gif",
cursor: 0
}), lt(1, {
isAction: !1,
name: "Fill",
keydef: "F",
graphic: "fill.gif",
cursor: "url(/img/fill_cur.png) 7 38, default"
}), []),
C = (lt(0, {
isAction: !0,
name: "Undo",
keydef: "U",
graphic: "undo.gif",
action: function() {
{
var e;
M == x && 0 < mt.length && (mt.pop(), 0 < mt.length ? (Bt(e = mt[mt.length - 1]), S && S.emit("data", {
id: Ta,
data: e
})) : Vt())
}
}
}), lt(1, {
isAction: !0,
name: "Clear",
keydef: "C",
graphic: "clear.gif",
action: Vt
})
/*TYPOMOD DESC: add tool for pipette*/
,
lt(3, {
isAction: !1,
name: "Pipette",
graphic: "",
keydef: 'P',
})
/*TYPOEND*/
/* TYPOMOD DESC: add action for colorswitch */
/*
,
lt(2, {
isAction: !0,
name: "Switcher",
graphic: "",
action: () => {
document.dispatchEvent(new Event("toggleColor"));
}
})
*/
/* TYPOEND */
/*TYPOMOD DESC: add action for brushlab*/
,
lt(3, {
isAction: !0,
name: "Lab",
graphic: "",
keydef: 'L',
action: () => {
document.dispatchEvent(new Event("openBrushLab"));
}
})
/*TYPOEND*/, c.querySelector("#game-canvas canvas")),
dt = C.getContext("2d", {
willReadFrequently: !0
}),
v = [],
ut = 0,
ht = 0,
pt = [],
r = [0, 9999, 9999, 0, 0],
mt = [],
b = [0, 0],
gt = [0, 0],
ft = 0,
yt = c.createElement("canvas"),
o = (yt.width = et + 2, yt.height = et + 2, yt.getContext("2d"));
function vt() {
var e = st[bt].cursor;
if (L.id == Z && M == x) {
if (bt == Je) {
var t = yt.width,
n = qt;
if (n <= 0) return;
o.clearRect(0, 0, t, t);
// TYPOMOD
// desc: cursor with custom color
var a = St < 10000 ? wt[St] : typo.hexToRgb((St - 10000).toString(16).padStart(6, "0"));
// TYPOEND
a = [(a = 1 == l.dark ? [Math.floor(.75 * a[0]), Math.floor(.75 * a[1]), Math.floor(.75 * a[2])] : a)[0], a[1], a[2], .8];
o.fillStyle = "rgba(" + a[0] + "," + a[1] + "," + a[2] + "," + a[3] + ")", o.beginPath(), o.arc(t / 2, t / 2, n / 2 - 1, 0, 2 * Math.PI), o.fill(), o.strokeStyle = "#FFF", o.beginPath(), o.arc(t / 2, t / 2, n / 2 - 1, 0, 2 * Math.PI), o.stroke(), o.strokeStyle = "#000", o.beginPath(), o.arc(t / 2, t / 2, n / 2, 0, 2 * Math.PI), o.stroke();
a = t / 2, e = "url(" + yt.toDataURL() + ")" + a + " " + a + ", default"
}
} else e = "default";
C.style.cursor = e
}
var bt = 0,
St = 0,
kt = 0,
wt = [
[255, 255, 255],
[0, 0, 0],
[193, 193, 193],
[80, 80, 80],
[239, 19, 11],
[116, 11, 7],
[255, 113, 0],
[194, 56, 0],
[255, 228, 0],
[232, 162, 0],
[0, 204, 0],
[0, 70, 25],
[0, 255, 145],
[0, 120, 93],
[0, 178, 255],
[0, 86, 158],
[35, 31, 211],
[14, 8, 101],
[163, 0, 186],
[85, 0, 105],
[223, 105, 167],
[135, 53, 84],
[255, 172, 142],
[204, 119, 77],
[160, 82, 45],
[99, 48, 13]
],
Ct = ["White", "Black", "Light Gray", "Gray", "Red", "Dark Red", "Orange", "Dark Orange", "Yellow", "Dark Yellow", "Green", "Dark Green", "Mint", "Dark Mint", "Skyblue", "Dark Skyblue", "Seablue", "Dark Seablue", "Purple", "Dark Purple", "Pink", "Dark Pink", "Beige", "Dark Beige", "Brown", "Dark Brown"],
qt = 0,
xt = -1,
Mt = [];
function Lt(e) {
return 20 + (e - Qe) / (et - Qe) * 80
}
for (e = 0; e < tt.length; e++) {
var Dt = $("size clickable"),
$t = $("icon"),
Et = ($t.style.backgroundSize = Lt(tt[e]) + "%", {
id: e,
size: tt[e],
element: Dt,
elementIcon: $t
});
Dt.appendChild($t), rt.appendChild(Dt), Dt.size = Et, Mt.push(Et)
}
for (var At = [$("top"), $("bottom")], e = 0; e < wt.length / 2; e++) At[0].appendChild(zt(2 * e)), At[1].appendChild(zt(2 * e + 1));
for (e = 0; e < At.length; e++) it.appendChild(At[e]);
function It(e) {
qt = q(e, Qe, et);
for (var t = Mt[Mt.length - 1], n = t.size, a = 0; a < Mt.length; a++) {
var o = Mt[a],
r = Math.abs(qt - o.size);
r <= n && (n = r, t = o, 0), o.element.classList.remove("selected")
}
t.element.classList.add("selected"), nt.querySelector(".size-preview .icon").style.backgroundSize = Lt(qt) + "%", vt()
}
function Rt(e) {
e.classList.remove("clicked"), e.offsetWidth, e.classList.add("clicked")
}
function Tt(e) {
Rt(ct[e].element), ct[e].action()
}
function Nt(e, t) {
Rt(st[e].element), e == bt && !t || (st[bt].element.classList.remove("selected"), st[e].element.classList.add("selected"), bt = e, vt())
}
function Wt(e) {
var t =
e > 10000 ? Ut(typo.hexToRgb((e - 10000).toString(16).padStart(6, "0"))) : Ut(wt[e]);
St = e, c.querySelector("#color-preview-primary").style.fill = t, c.querySelector("#game-toolbar .color-preview-mobile").style.backgroundColor = t, vt()
}
function Ot(e) {
var t =
e > 10000 ? Ut(typo.hexToRgb((e - 10000).toString(16).padStart(6, "0"))) : Ut(wt[e]);
kt = e, c.querySelector("#color-preview-secondary").style.fill = t, vt()
}
function Pt() {
var e = St;
Wt(kt), Ot(e)
}
function Yt() {
rt.classList.remove("open")
}
function zt(e) {
var t = $("color");
return t.style.backgroundColor = Ut(wt[e]), t.colorIndex = e, t
}
function Ut(e) {
return "rgb(" + e[0] + "," + e[1] + "," + e[2] + ")"
}
function Ht(e) {
/*TYPOMOD
desc: if color code > 1000 -> customcolor*/if(e < 1000)
e = q(e, 0, wt.length), e = wt[e];
else e = typo.hexToRgb((e - 10000).toString(16).padStart(6, "0"));/* TYPOEND */
return {
r: e[0],
g: e[1],
b: e[2]
}
}
function Bt(e) {
if (v = v.slice(0, e), !(x != M && ht < e)) {
/* TYPOMOD
desc: replace draw commands because of redo*/ const keepCommands = v;
/* TYPOEND*/
r = Gt();
e = Math.floor(v.length / _t);
pt = pt.slice(0, e), Qt();
for (var t = 0; t < pt.length; t++) {
var n = pt[t];
dt.putImageData(n.data, n.bounds[1], n.bounds[2])
}
for (t = pt.length * _t; t < v.length; t++) Kt(Zt(v[t]), v[t]);
ut = Math.min(v.length, ut), ht = Math.min(v.length, ht)
/* TYPOMOD
log kept commands*/
document.dispatchEvent(new CustomEvent("logRedo", { detail: keepCommands }));
/* TYPOEND*/}
}