From e73fc55e2833a9435366a2cc084a862b6d866fb3 Mon Sep 17 00:00:00 2001 From: tobeh Date: Sun, 27 Oct 2024 20:50:32 +0100 Subject: [PATCH] update game patch --- gamePatch.js | 1855 +++++++++++++++++++++++++++---------------------- manifest.json | 2 +- 2 files changed, 1011 insertions(+), 846 deletions(-) diff --git a/gamePatch.js b/gamePatch.js index 71a6743..70e5484 100644 --- a/gamePatch.js +++ b/gamePatch.js @@ -1,16 +1,16 @@ -((h, u, c, P) => { - let z = 28, - Y = 57, - H = 51, - n = [z, Y, H], - U = 0, +((h, c, d, P) => { + let Y = 28, + z = 57, + U = 51, + n = [Y, z, U], + H = 0, B = 1, - G = 2, - F = 5, - _ = 0, - j = 1, + _ = 2, + G = 5, + K = 0, + F = 1, V = 2, - K = 3, + j = 3, Z = 4, X = 5, J = 6, @@ -32,7 +32,7 @@ HIDDEN: 1, COMBINATION: 2 } -// TYPOMOD +// TYPOMOD // desc: create re-useable functions , typo = { messagePort: (()=>{ @@ -47,12 +47,12 @@ })(), joinLobby: undefined, createFakeUser: (id = 0, name = "", avatar = [], score = 0, guessed = false) => { - // IDENTIFY x.value.split: #home .container-name-lang input -> Pn - // IDENTIFY x.avatar: [Math.round(100 * Math.random()) % -> p + // 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 : (Pn.value.split("#")[0] != "" ? Pn.value.split("#")[0] : "Player"), - avatar: avatar.length == 0 ? p.avatar : avatar, + 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 }; @@ -79,7 +79,7 @@ lastConnect: 0, initListeners: (() => { let abort = false; - document.addEventListener("clearDrawing", () => Bt()); + document.addEventListener("clearDrawing", () => Vt()); document.addEventListener("abortJoin", () => abort = true); document.addEventListener("joinLobby", (e) => { abort = false; @@ -88,7 +88,7 @@ setTimeout(() => { if (abort) return; typo.lastConnect = Date.now(); - // Yn.dispatchEvent(new Event("click")); + // Vn.dispatchEvent(new Event("click")); // IDENTIFY x.dispatchEvent: querySelector("#home .panel .button-play") -> BTNPLAY // ##PRIVATELBBY## = !1 // IDENTIFY: x: = !1 @@ -97,39 +97,39 @@ // IDENTIFY x(e.det..): ? "id=" + -> JOINLOBBY typo.joinLobby(); window.history.pushState({path: window.location.origin}, '', window.location.origin); - // Bn(false); + // 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 na() | document.dispatchEvent(new Event("leftLobby")); + 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 = yt.findIndex(color => color[0] == rgb[0] && color[1] == rgb[1] && color[2] == rgb[2]); + 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) At(code); + if (e.detail.secondary) Ot(code); // IDENTIFY x(e.detail.code): querySelector("#color-preview-secondary").style.fill -> SECFILL - else Et(code); + else Wt(code); // IDENTIFY x(e.detail.code): querySelector("#color-preview-primary").style.fill -> PRIMFILL }); document.addEventListener("performDrawCommand", (e) => { - S.push(e.detail); + v.push(e.detail); // IDENTIFY x.push(e.detail): .getContext("2d"), x = [] -> PUSHCMD - Ht(Ft(e.detail)); + 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) => Pe(e.target)); + elem.addEventListener("mouseenter", (e) => Oe(e.target)); // IDENTIFY: x(e.target): - elem.addEventListener("mouseleave", (e) => ze()); + elem.addEventListener("mouseleave", (e) => Pe()); // IDENTIFY: (e) => x(): }); }); @@ -146,21 +146,20 @@ } } // TYPOEND, - oe = ["Normal", "Hidden", "Combination"], - re = ["English", "German", "Bulgarian", "Czech", "Danish", "Dutch", "Finnish", "French", "Estonian", "Greek", "Hebrew", "Hungarian", "Italian", "Japanese", "Korean", "Latvian", "Macedonian", "Norwegian", "Portuguese", "Polish", "Romanian", "Russian", "Serbian", "Slovakian", "Spanish", "Swedish", "Tagalog", "Turkish"]; - if (h.localStorageAvailable = !1, void 0 !== c) try { - c.setItem("feature_test", "yes"), "yes" === c.getItem("feature_test") && (c.removeItem("feature_test"), h.localStorageAvailable = !0) + a = /^((?!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 d = []; + var u = []; - function ie(e) { - for (var t = 0; t < d.length; t++) - if (d[t].name == e) return d[t] + function oe(e) { + for (var t = 0; t < u.length; t++) + if (u[t].name == e) return u[t] } - function le(e, t, n, a, o) { + function re(e, t, n, a, o) { var r, i, l = t, - s = (h.localStorageAvailable && (r = c.getItem("hotkey_" + e)) && (t = r), ie(e)); + s = (h.localStorageAvailable && (r = d.getItem("hotkey_" + e)) && (t = r), oe(e)); return s ? (s.key = t, s.def = l, s.desc = n) : (s = { name: e, desc: n, @@ -169,21 +168,21 @@ listing: $("item"), changed: [], cb: [] - }, d.push(s), Be(r = $("key", s.name), "text"), s.listing.appendChild(r), (i = u.createElement("input")).value = s.key, s.listing.appendChild(i), D(i, "keydown", function(e) { - for (var t = e.key, n = 0; n < d.length; n++) - if (d[n].key == t) return void e.preventDefault(); + }, 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 se(), e.preventDefault(), !1 - }), y[g].querySelector("#hotkey-list").appendChild(s.listing)), a && s.cb.push(a), o && s.changed.push(o), s + return ie(), e.preventDefault(), !1 + }), g[p].querySelector("#hotkey-list").appendChild(s.listing)), a && s.cb.push(a), o && s.changed.push(o), s } - function se() { + function ie() { if (h.localStorageAvailable) - for (var e = 0; e < d.length; e++) h.localStorage.setItem("hotkey_" + d[e].name, d[e].key) + for (var e = 0; e < u.length; e++) h.localStorage.setItem("hotkey_" + u[e].name, u[e].key) } - var p = { - avatar: [Math.round(100 * Math.random()) % z, Math.round(100 * Math.random()) % Y, Math.round(100 * Math.random()) % H, -1], + 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, @@ -193,72 +192,72 @@ mobileChatLayout: "bottom" }; - function a(e, t) { - e = c.getItem(e); + function le(e, t) { + e = d.getItem(e); return null == e ? t : e } - function ce() { - h.localStorageAvailable ? (c.setItem("name", Pn.value), c.setItem("lang", zn.value), c.setItem("displaylang", p.displayLang), c.setItem("volume", p.volume), c.setItem("dark", 1 == p.dark ? 1 : 0), c.setItem("filter", 1 == p.filterChat ? 1 : 0), c.setItem("pressure", 1 == p.pressureSensitivity ? 1 : 0), c.setItem("ava", JSON.stringify(p.avatar)), c.setItem("mobileChatLayout", p.mobileChatLayout), console.log("Settings saved.")) : console.log("Settings not saved. LocalStorage unavailable.") + 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 = u.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 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 = u.createElement("div"); + 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 de(e, t, n) { - var a = u.createElement(e); + 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 ue(e) { + function de(e) { for (; e.firstChild;) e.removeChild(e.firstChild) } - function he(e, t) { + 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], pe(n, e), n + 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 pe(e, t) { + 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] % z, - o = t[1] % Y, - r = t[2] % H, + 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 me(e, t) { + function pe(e, t) { e.querySelector(".owner").style.display = t ? "block" : "none" } - function ge(e, t) { + function me(e, t) { e.className = "avatar"; for (var n of t) e.classList.add("filter-" + n) } - function fe(e, t, n, a) { + function ge(e, t, n, a) { var o = { element: $("dots"), dots: [], @@ -267,126 +266,115 @@ }; 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), ve(o, Math.min(o.dots.length - 1, Math.max(0, o.selected - t)), !0), e.preventDefault(), e.stopPropagation()) - }), ye(o, t), o + 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 ye(e, t) { - ue(e.element), e.dots = []; + 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() { - ve(e, this.index, !0) + 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), ve(e, e.selected, !1) + e.selected < 0 && (e.selected = 0), t <= e.selected && (e.selected = t - 1), ye(e, e.selected, !1) } - function ve(e, t, n) { + 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 m = 0, - be = 1, - Se = 2, - ke = 3, - g = 4, - we = 5; - var f = u.querySelector("#modal"), - Ce = f.querySelector(".modal-title .text"), - qe = f.querySelector(".modal-content"), - y = []; - - function xe(e) { - y[m].querySelector(".buttons button.mute").textContent = R(e ? "Unmute" : "Mute") - } - - function Me(e, t) { - f.style.display = "block"; - for (var n = 0; n < y.length; n++) y[n].style.display = "none"; - y[e].style.display = "flex"; - var a = y[e]; + 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 be: - Ce.textContent = R("Something went wrong!"), a.querySelector(".message").textContent = t; + case ve: + we.textContent = E("Something went wrong!"), a.querySelector(".message").textContent = t; break; - case Se: - Ce.textContent = R("Disconnected!"), a.querySelector(".message").textContent = t; + case be: + we.textContent = E("Disconnected!"), a.querySelector(".message").textContent = t; break; - case m: - Ce.textContent = t.id == M ? R("$ (You)", t.name) : t.name; - var o = (O(M).flags & w) == w, - r = (t.flags & w) == w, + 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 == M || r ? "none" : "flex", i.querySelector(".button-pair").style.display = M == I || o ? "flex" : "none", i.querySelector("button.report").style.display = t.reported ? "none" : "", xe(t.muted), a.querySelector(".report-menu").style.display = "none", a.querySelector(".invite").style.display = M == t.id ? "flex" : "none", qe.querySelector(".player")), - o = (r.style.display = "", ue(r), he(t.avatar)); - me(o, I == t.id), ge(o, Ra(t)), r.appendChild(o); - break; - case we: - Ce.textContent = R("Rooms"), roomsUpdate(t); + 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: - Ce.textContent = 0 == xn ? "Public Room" : "Private Room", ue(a); - for (var l = ["Language", "Players", "Drawtime", "Rounds", "Word count", "Hint count", "Word mode", "Custom words only"], s = $("settings"), n = 0; n < qn.length; n++) { - var c = $("setting"), - d = de("img", "icon"), - d = (d.src = "/img/setting_" + n + ".gif", c.appendChild(d), c.appendChild(de("span", "name", l[n] + ":")), qn[n]); - n == ne.CUSTOMWORDSONLY && (d = d ? "Yes" : "No"), n == ne.SLOTS && (d = x.length + "/" + d), n == ne.LANG && (d = re[d]), n == ne.WORDMODE && (d = oe[d]), n == ne.DRAWTIME && (d += "s"), c.appendChild(de("span", "value", d)), s.appendChild(c) - } - a.appendChild(s); - i = u.querySelector("#game-invite").cloneNode(!0); - D(i.querySelector("#copy-invite"), "click", no), a.appendChild(i); + we.textContent = E("Rooms"), roomsUpdate(t); + break; + case Se: + we.textContent = E("Invite your friends!"); break; - case g: - Ce.textContent = R("Settings"), a.querySelector("#select-pressure-sensitivity").value = p.pressureSensitivity + case p: + we.textContent = E("Settings"), a.querySelector("#select-pressure-sensitivity").value = l.pressureSensitivity } } - function Le() { - f.style.display = "none" + function Me() { + m.style.display = "none" } - y[m] = f.querySelector(".modal-container-player"), y[be] = f.querySelector(".modal-container-info"), y[Se] = f.querySelector(".modal-container-info"), y[ke] = f.querySelector(".modal-container-room"), y[g] = f.querySelector(".modal-container-settings"), D(h, "click", function(e) { - e.target == f && Le() - }), D([f.querySelector(".close"), y[be].querySelector("button.ok")], "click", Le); - let De = 0, - $e = 2, - Re = 3, + 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, - Te = 7, - Ne = ["BASE", "GUESSED", "CLOSE", "DRAWING", "JOIN", "LEAVE", "OWNER", "GUESSCHAT"]; + Re = 7, + Te = ["BASE", "GUESSED", "CLOSE", "DRAWING", "JOIN", "LEAVE", "OWNER", "GUESSCHAT"]; - function v(e) { - return "var(--COLOR_CHAT_TEXT_" + Ne[e] + ")" + function f(e) { + return "var(--COLOR_CHAT_TEXT_" + Te[e] + ")" } - function We(e, t, n, a) { - var o = u.createElement("p"), - r = u.createElement("b"), - a = (r.textContent = a ? e : e + ": ", o.appendChild(r), o.style.color = n, u.createElement("span")); + 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 b(e, t, n, a) { - var o = We(e, t, n, a), - r = On.scrollHeight - On.scrollTop - On.clientHeight <= 20; - if (On.appendChild(o), r && (On.scrollTop = On.scrollHeight + 100), 0 < p.chatDeleteQuota) - for (; On.childElementCount > p.chatDeleteQuota;) On.firstElementChild.remove(); - var i = We(e, t, n, a); - return u.querySelector("#game-canvas .bubbles").appendChild(i), setTimeout(function() { + 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, - Oe = void 0; + We = void 0; - function Pe(e) { - ze(); - for (var t = (Oe = e).dataset.tooltip, n = e.dataset.tooltipdir || "N", a = ((i = $("tooltip")).appendChild($("tooltip-arrow")), i.appendChild($("tooltip-content", R(t))), !1), o = e; o;) { + 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 @@ -395,24 +383,187 @@ } 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 > u.documentElement.clientHeight - 48 ? "N" : n) && t.left - h.scrollX < 48 ? "E" : n) && t.right - h.scrollX > u.documentElement.clientWidth - 48 && (n = "W"), t.left), + 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", u.body.appendChild(i) - } + "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 ze() { - i && (i.remove(), Oe = i = void 0) + function _e() { + 1 == ze.value ? (_n[1].setAttribute("readonly", ""), c.documentElement.dataset.mobileKeyboard = "") : (_n[1].removeAttribute("readonly"), delete c.documentElement.dataset.mobileKeyboard) } - var Ye = {}, - He = []; + 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 Ue(e, t) { + function Ve(e, t) { e = e[t]; return null != e && "" != e ? e : t } - function R(e, t) { - var n = Ue(Ye[p.displayLang], e), + function E(e, t) { + var n = Ve(Ke[l.displayLang], e), a = "", o = 0; Array.isArray(t) || (t = [t]); @@ -423,21 +574,21 @@ return a } - function Be(e, t) { + function je(e, t) { if ("children" == t) for (var n = 0; n < e.children.length; n++) { var a = e.children[n].dataset.translate; - Be(e.children[n], null == a ? "text" : a) + je(e.children[n], null == a ? "text" : a) } else { var o = ""; - "text" == t && (o = e.textContent), 0 < (o = "placeholder" == t ? e.placeholder : o).length ? He.push({ + "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)) } } - Ye.en = {}, Ye.de = { + Ke.en = {}, Ke.de = { "You have been kicked!": "Du wurdest gekickt!", "You have been banned!": "Du wurdest gebannt!", "You muted '$'!": "Du hast '$' stummgeschalten!", @@ -571,56 +722,56 @@ On: "An", Off: "Aus" }; - let Ge = 0, - Fe = 1, - _e = 0, - je = 4, - Ve = 40; - var Ke = [4, 10, 20, 32, 40], - Ze = u.querySelector("#game-toolbar"), - Xe = Ze.querySelector(".toolbar-group-tools"), - Je = Ze.querySelector(".toolbar-group-actions"), - Qe = u.querySelector("#game-toolbar .sizes .size-preview"), - et = u.querySelector("#game-toolbar .sizes .container"), - tt = u.querySelector("#game-toolbar .colors"); - - function nt(e, t) { + 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) { - Pe(e.target) + Oe(e.target) }), D(n, "pointerleave", function(e) { - ze() + Pe() }), o = t.isAction ? (r.addEventListener("click", function(e) { - $t(this.toolIndex) - }), Je.appendChild(r), ot[e] = i, le(t.name, t.keydef, "", function() { - $t(e) + Tt(this.toolIndex) + }), ot.appendChild(r), ct[e] = i, re(t.name, t.keydef, "", function() { + Tt(e) }, function(e) { l.textContent = e.key })) : (r.addEventListener("click", function(e) { - Rt(this.toolIndex) - }), Xe.appendChild(r), at[e] = i, le(t.name, t.keydef, "", function() { - Rt(i.id) + Nt(this.toolIndex) + }), at.appendChild(r), st[e] = i, re(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 at = [], - ot = (nt(_e, { + var st = [], + ct = (lt(Je, { isAction: !1, name: "Brush", keydef: "B", graphic: "pen.gif", cursor: 0 - }), nt(1, { + }), lt(1, { isAction: !1, name: "Fill", keydef: "F", graphic: "fill.gif", cursor: "url(/img/fill_cur.png) 7 38, default" }), []), - C = (nt(0, { + C = (lt(0, { isAction: !0, name: "Undo", keydef: "U", @@ -628,22 +779,22 @@ action: function() { { var e; - L == M && 0 < ct.length && (ct.pop(), 0 < ct.length ? (Pt(e = ct[ct.length - 1]), l && l.emit("data", { - id: xa, + M == x && 0 < mt.length && (mt.pop(), 0 < mt.length ? (Bt(e = mt[mt.length - 1]), S && S.emit("data", { + id: Ta, data: e - })) : Bt()) + })) : Vt()) } } - }), nt(1, { + }), lt(1, { isAction: !0, name: "Clear", keydef: "C", graphic: "clear.gif", - action: Bt + action: Vt }) /*TYPOMOD DESC: add tool for pipette*/ , - nt(3, { + lt(3, { isAction: !1, name: "Pipette", graphic: "", @@ -653,7 +804,7 @@ /* TYPOMOD DESC: add action for colorswitch */ /* , - nt(2, { + lt(2, { isAction: !0, name: "Switcher", graphic: "", @@ -665,7 +816,7 @@ /* TYPOEND */ /*TYPOMOD DESC: add action for brushlab*/ , - nt(3, { + lt(3, { isAction: !0, name: "Lab", graphic: "", @@ -674,46 +825,46 @@ document.dispatchEvent(new Event("openBrushLab")); } }) - /*TYPOEND*/, u.querySelector("#game-canvas canvas")), - rt = C.getContext("2d", { + /*TYPOEND*/, c.querySelector("#game-canvas canvas")), + dt = C.getContext("2d", { willReadFrequently: !0 }), - S = [], - it = 0, - lt = 0, - st = [], - r = [0, 9999, 9999, 0, 0], - ct = [], - k = [0, 0], - dt = [0, 0], + v = [], ut = 0, - ht = u.createElement("canvas"), - o = (ht.width = Ve + 2, ht.height = Ve + 2, ht.getContext("2d")); - - function pt() { - var e = at[mt].cursor; - if (T.id == Z && L == M) { - if (mt == _e) { - var t = ht.width, - n = bt; + 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 = gt < 10000 ? yt[gt] : typo.hexToRgb((gt - 10000).toString(16).padStart(6, "0")); + var a = St < 10000 ? wt[St] : typo.hexToRgb((St - 10000).toString(16).padStart(6, "0")); // TYPOEND - a = [(a = 1 == p.dark ? [Math.floor(.75 * a[0]), Math.floor(.75 * a[1]), Math.floor(.75 * a[2])] : a)[0], a[1], a[2], .8]; + 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(" + ht.toDataURL() + ")" + a + " " + a + ", default" + a = t / 2, e = "url(" + yt.toDataURL() + ")" + a + " " + a + ", default" } } else e = "default"; C.style.cursor = e } - var mt = 0, - gt = 0, - ft = 0, - yt = [ + var bt = 0, + St = 0, + kt = 0, + wt = [ [255, 255, 255], [0, 0, 0], [193, 193, 193], @@ -741,84 +892,84 @@ [160, 82, 45], [99, 48, 13] ], - vt = ["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"], - bt = 0, - St = -1, - kt = []; - - function wt(e) { - return 20 + (e - je) / (Ve - je) * 80 - } - for (var e = 0; e < Ke.length; e++) { - var Ct = $("size clickable"), - qt = $("icon"), - xt = (qt.style.backgroundSize = wt(Ke[e]) + "%", { + 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: Ke[e], - element: Ct, - elementIcon: qt + size: tt[e], + element: Dt, + elementIcon: $t }); - Ct.appendChild(qt), et.appendChild(Ct), Ct.size = xt, kt.push(xt) + Dt.appendChild($t), rt.appendChild(Dt), Dt.size = Et, Mt.push(Et) } - for (var Mt = [$("top"), $("bottom")], e = 0; e < yt.length / 2; e++) Mt[0].appendChild(Nt(2 * e)), Mt[1].appendChild(Nt(2 * e + 1)); - for (e = 0; e < Mt.length; e++) tt.appendChild(Mt[e]); + 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 Lt(e) { - bt = q(e, je, Ve); - for (var t = kt[kt.length - 1], n = t.size, a = 0; a < kt.length; a++) { - var o = kt[a], - r = Math.abs(bt - o.size); + 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"), Ze.querySelector(".size-preview .icon").style.backgroundSize = wt(bt) + "%", pt() + t.element.classList.add("selected"), nt.querySelector(".size-preview .icon").style.backgroundSize = Lt(qt) + "%", vt() } - function Dt(e) { + function Rt(e) { e.classList.remove("clicked"), e.offsetWidth, e.classList.add("clicked") } - function $t(e) { - Dt(ot[e].element), ot[e].action() + function Tt(e) { + Rt(ct[e].element), ct[e].action() } - function Rt(e, t) { - Dt(at[e].element), e == mt && !t || (at[mt].element.classList.remove("selected"), at[e].element.classList.add("selected"), mt = e, pt()) + 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 Et(e) { + function Wt(e) { var t = - e > 10000 ? Wt(typo.hexToRgb((e - 10000).toString(16).padStart(6, "0"))) : Wt(yt[e]); - gt = e, u.querySelector("#color-preview-primary").style.fill = t, u.querySelector("#game-toolbar .color-preview-mobile").style.backgroundColor = t, pt() + 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 At(e) { + function Ot(e) { var t = - e > 10000 ? Wt(typo.hexToRgb((e - 10000).toString(16).padStart(6, "0"))) : Wt(yt[e]); - ft = e, u.querySelector("#color-preview-secondary").style.fill = t, pt() + 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 It() { - var e = gt; - Et(ft), At(e) + function Pt() { + var e = St; + Wt(kt), Ot(e) } - function Tt() { - et.classList.remove("open") + function Yt() { + rt.classList.remove("open") } - function Nt(e) { + function zt(e) { var t = $("color"); - return t.style.backgroundColor = Wt(yt[e]), t.colorIndex = e, t + return t.style.backgroundColor = Ut(wt[e]), t.colorIndex = e, t } - function Wt(e) { + function Ut(e) { return "rgb(" + e[0] + "," + e[1] + "," + e[2] + ")" } - function Ot(e) { + function Ht(e) { /*TYPOMOD desc: if color code > 1000 -> customcolor*/if(e < 1000) - e = q(e, 0, yt.length), e = yt[e]; + 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], @@ -827,78 +978,78 @@ } } - function Pt(e) { - if (S = S.slice(0, e), !(M != L && lt < e)) { + function Bt(e) { + if (v = v.slice(0, e), !(x != M && ht < e)) { /* TYPOMOD - desc: replace draw commands because of redo*/ const keepCommands = S; + desc: replace draw commands because of redo*/ const keepCommands = v; /* TYPOEND*/ - r = Yt(); - e = Math.floor(S.length / zt); - st = st.slice(0, e), Vt(); - for (var t = 0; t < st.length; t++) { - var n = st[t]; - rt.putImageData(n.data, n.bounds[1], n.bounds[2]) + 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 = st.length * zt; t < S.length; t++) Ht(Ft(S[t]), S[t]); - it = Math.min(S.length, it), lt = Math.min(S.length, lt) + 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*/} } - let zt = 50; + let _t = 50; - function Yt() { + function Gt() { return [0, 9999, 9999, 0, 0] } - function Ht(e) { + function Kt(e) { var t, n, a, o; - r[0] += 1, r[1] = Math.min(r[1], e[0]), r[2] = Math.min(r[2], e[1]), r[3] = Math.max(r[3], e[2]), r[4] = Math.max(r[4], e[3]), r[0] >= zt && (t = r[1], n = r[2], a = r[3], o = r[4], (a - t <= 0 || o - n <= 0) && (t = e[0], n = e[1], a = e[2], o = e[3]), e = rt.getImageData(t, n, a - t, o - n), st.push({ + r[0] += 1, r[1] = Math.min(r[1], e[0]), r[2] = Math.min(r[2], e[1]), r[3] = Math.max(r[3], e[2]), r[4] = Math.max(r[4], e[3]), r[0] >= _t && (t = r[1], n = r[2], a = r[3], o = r[4], (a - t <= 0 || o - n <= 0) && (t = e[0], n = e[1], a = e[2], o = e[3]), e = dt.getImageData(t, n, a - t, o - n), pt.push({ data: e, bounds: r - }), r = Yt()) + }), r = Gt()) } - function Ut(e) { - return (e || 0 < S.length || 0 < ct.length || 0 < it || 0 < lt) && (S = [], ct = [], it = lt = 0, r = Yt(), st = [], Vt(), 1) + function Ft(e) { + return (e || 0 < v.length || 0 < mt.length || 0 < ut || 0 < ht) && (v = [], mt = [], ut = ht = 0, r = Gt(), pt = [], Qt(), 1) } - function Bt() { - L == M && Ut() && l && l.emit("data", { - id: qa + function Vt() { + M == x && Ft() && S && S.emit("data", { + id: Ra }) } - function Gt(e) { + function jt(e) { var t, n, a, o, r, i; - ((t = e)[0] != Ge ? t[0] == Fe && 0 <= t[2] && t[2] < C.width && 0 <= t[3] && t[3] < C.height : (a = t[3], o = t[4], r = t[5], i = t[6], t = Math.ceil(t[2] / 2), n = (a + r) / 2, o = (o + i) / 2, r = Math.abs(r - a) / 2, a = Math.abs(i - i) / 2, (i = { + ((t = e)[0] != Ze ? t[0] == Xe && 0 <= t[2] && t[2] < C.width && 0 <= t[3] && t[3] < C.height : (a = t[3], o = t[4], r = t[5], i = t[6], t = Math.ceil(t[2] / 2), n = (a + r) / 2, o = (o + i) / 2, r = Math.abs(r - a) / 2, a = Math.abs(i - i) / 2, (i = { x1: -(t + r), y1: -(t + r), x2: C.width + t + r, y2: C.height + t + a - }).x1 < n && n < i.x2 && i.y1 < o && o < i.y2)) ? (S.push(e), M == L && Ht(Ft(e))) + }).x1 < n && n < i.x2 && i.y1 < o && o < i.y2)) ? (v.push(e), x == M && Kt(Zt(e))) /* TYPOMOD log draw commands */ & document.dispatchEvent(new CustomEvent("logDrawCommand", { detail: e })) /* TYPOEND */: console.log("IGNORED COMMAND OUT OF CANVAS BOUNDS") } - function Ft(e) { + function Zt(e) { var t = [0, 0, C.width, C.height]; switch (e[0]) { - case Ge: - var n = q(Math.floor(e[2]), je, Ve), + case Ze: + var n = q(Math.floor(e[2]), Qe, et), a = Math.ceil(n / 2), o = q(Math.floor(e[3]), -a, C.width + a), r = q(Math.floor(e[4]), -a, C.height + a), i = q(Math.floor(e[5]), -a, C.width + a), a = q(Math.floor(e[6]), -a, C.height + a), - l = Ot(e[1]); - t[0] = q(o - n, 0, C.width), t[1] = q(r - n, 0, C.height), t[2] = q(i + n, 0, C.width), t[3] = q(a + n, 0, C.height), jt(o, r, i, a, n, l.r, l.g, l.b); + l = Ht(e[1]); + t[0] = q(o - n, 0, C.width), t[1] = q(r - n, 0, C.height), t[2] = q(i + n, 0, C.width), t[3] = q(a + n, 0, C.height), Jt(o, r, i, a, n, l.r, l.g, l.b); break; - case Fe: - var l = Ot(e[1]), + case Xe: + var l = Ht(e[1]), o = q(Math.floor(e[2]), 0, C.width), r = q(Math.floor(e[3]), 0, C.height), i = o, @@ -906,7 +1057,7 @@ s = l.r, c = l.g, d = l.b, - u = rt.getImageData(0, 0, C.width, C.height), + u = dt.getImageData(0, 0, C.width, C.height), h = [ [i, a] ], @@ -919,9 +1070,9 @@ return (t != s || n != c || e != d) && (t = Math.abs(t - p[0]), n = Math.abs(n - p[1]), e = Math.abs(e - p[2]), t < 3) && n < 3 && e < 3 }, k = u.height, w = u.width; h.length;) { for (m = h.pop(), g = m[0], y = 4 * ((f = m[1]) * w + g); 0 <= f-- && S(y);) y -= 4 * w; - for (y += 4 * w, ++f, b = v = !1; f++ < k - 1 && S(y);) _t(u, y, s, c, d), 0 < g && (S(y - 4) ? v || (h.push([g - 1, f]), v = !0) : v = v && !1), g < w - 1 && (S(y + 4) ? b || (h.push([g + 1, f]), b = !0) : b = b && !1), y += 4 * w + for (y += 4 * w, ++f, b = v = !1; f++ < k - 1 && S(y);) Xt(u, y, s, c, d), 0 < g && (S(y - 4) ? v || (h.push([g - 1, f]), v = !0) : v = v && !1), g < w - 1 && (S(y + 4) ? b || (h.push([g + 1, f]), b = !0) : b = b && !1), y += 4 * w } - rt.putImageData(u, 0, 0) + dt.putImageData(u, 0, 0) } } return t @@ -931,11 +1082,11 @@ return e < t ? t : n < e ? n : e } - function _t(e, t, n, a, o) { + function Xt(e, t, n, a, o) { 0 <= t && t < e.data.length && (e.data[t] = n, e.data[t + 1] = a, e.data[t + 2] = o, e.data[t + 3] = 255) } - function jt(e, t, n, a, o, r, i, l) { + function Jt(e, t, n, a, o, r, i, l) { function s(e, t) { for (var n = -c; n <= c; n++) for (var a, o = -c; o <= c; o++) n * n + o * o < d && 0 <= (a = 4 * ((t + o) * m.width + e + n)) && a < m.data.length && (m.data[a] = r, m.data[1 + a] = i, m.data[2 + a] = l, m.data[3 + a] = 255) @@ -946,7 +1097,7 @@ u = Math.min(t, a) - c, h = Math.max(e, n) + c, p = Math.max(t, a) + c, - m = (e -= o, t -= u, n -= o, a -= u, rt.getImageData(o, u, h - o, p - u)); + m = (e -= o, t -= u, n -= o, a -= u, dt.getImageData(o, u, h - o, p - u)); if (e == n && t == a) s(e, t); else { s(e, t), s(n, a); @@ -959,29 +1110,29 @@ var S = b << 1; - f < S && (b -= f, e += y), S < g && (b += g, t += v), s(e, t) } } - rt.putImageData(m, o, u) + dt.putImageData(m, o, u) } - function Vt() { + function Qt() { /* TYPOMOD desc: store data before clear */ const data = document.querySelector("#game-canvas canvas").toDataURL(); /* TYPOEND */ - rt.fillStyle = "#FFF", rt.fillRect(0, 0, C.width, C.height) + dt.fillStyle = "#FFF", dt.fillRect(0, 0, C.width, C.height) /* TYPOMOD desc: dispatch clear event */ ;document.dispatchEvent(new CustomEvent("logCanvasClear", { detail: data })); /* TYPOEND */ } - function Kt(e) { - if (T.id == Z && L == M && -1 != St) { - var t = 0 == St ? gt : ft, + function en(e) { + if (L.id == Z && M == x && -1 != xt) { + var t = 0 == xt ? St : kt, n = null; if (e) { var e = ((e, t) => { - for (var n = (e = rt.getImageData(e, t, 1, 1)).data[0], a = e.data[1], o = e.data[2], r = 0; r < yt.length; r++) { - var i = yt[r]; + for (var n = (e = dt.getImageData(e, t, 1, 1)).data[0], a = e.data[1], o = e.data[2], r = 0; r < wt.length; r++) { + var i = wt[r]; if (0 == i[0] - n && 0 == i[1] - a && 0 == i[2] - o) return r } /* TYPOMOD @@ -989,122 +1140,129 @@ return r = parseInt(typo.rgbToHex(n, a, o), 16) + 10000; /* TYPOEND */ return r - })(k[0], k[1]); - if (1 == mt) { + })(b[0], b[1]); + if (1 == bt) { if (e == t) return; - e = t, l = k[0], s = k[1], n = [Fe, e, l, s] + e = t, l = b[0], s = b[1], n = [Xe, e, l, s] } } - mt == _e && (e = bt, 0 <= ut && (e = (e - je) * q(ut, 0, 1) + je), + bt == Je && (e = qt, 0 <= ft && (e = (e - Qe) * q(ft, 0, 1) + Qe), /* TYPOMOD use typo pressure */ (() => { - if (0 <= ut && localStorage.typoink == 'true') { + if (0 <= ft && localStorage.typoink == 'true') { const calcSkribblSize = (val) => Number(val) * 36 + 4; const calcLevelledSize = (val, level) => Math.pow(Number(val), Math.pow(1.5, (Number(level) - 50) / 10)); const sensitivity = 100 - Number(localStorage.sens); - let levelled = calcLevelledSize(ut, sensitivity); + let levelled = calcLevelledSize(ft, sensitivity); e = Math.round(calcSkribblSize(levelled)); } - })(),l = Math.ceil(.5 * e), s = q(Math.floor(dt[0]), -l, C.width + l), o = q(Math.floor(dt[1]), -l, C.height + l), r = q(Math.floor(k[0]), -l, C.width + l), i = q(Math.floor(k[1]), -l, C.height + l), t = t, e = e, a = s, o = o, r = r, i = i, n = [Ge, t, e, a, o, r, i]), null != n && Gt(n) + })(),l = Math.ceil(.5 * e), s = q(Math.floor(gt[0]), -l, C.width + l), o = q(Math.floor(gt[1]), -l, C.height + l), r = q(Math.floor(b[0]), -l, C.width + l), i = q(Math.floor(b[1]), -l, C.height + l), t = t, e = e, a = s, o = o, r = r, i = i, n = [Ze, t, e, a, o, r, i]), null != n && jt(n) } var a, o, r, i, l, s } - function Zt(e, t, n, a) { + function tn(e, t, n, a) { var o = C.getBoundingClientRect(), e = Math.floor((e - o.left) / o.width * C.width), t = Math.floor((t - o.top) / o.height * C.height); - a ? (ut = n, dt[0] = k[0] = e, dt[1] = k[1] = t) : (dt[0] = k[0], dt[1] = k[1], ut = n, k[0] = e, k[1] = t) + a ? (ft = n, gt[0] = b[0] = e, gt[1] = b[1] = t) : (gt[0] = b[0], gt[1] = b[1], ft = n, b[0] = e, b[1] = t) } - function Xt(e) { + function nn(e) { return 0 == e || 2 == e || 5 == e } - function Jt(e) { - var t = "Left-/Rightclick to choose a color!\n" + vt[this.colorIndex]; - u.querySelector("#game-toolbar .colors").dataset.tooltip = t, i && (i.querySelector(".tooltip-content").textContent = R(Oe.dataset.tooltip)) + function an(e) { + var t = "Left-/Rightclick to choose a color!\n" + Ct[this.colorIndex]; + c.querySelector("#game-toolbar .colors").dataset.tooltip = t, i && (i.querySelector(".tooltip-content").textContent = E(We.dataset.tooltip)) } - function Qt(e) { + function on(e) { var t, n; - t = this.colorIndex, n = 0 == e.button, ((n = e.altKey ? !n : n) ? Et : At)(t) + t = this.colorIndex, n = 0 == e.button, ((n = e.altKey ? !n : n) ? Wt : Ot)(t) } - D(Ze, "contextmenu", function(e) { + D(nt, "contextmenu", function(e) { return e.preventDefault(), !1 }), D("#game-toolbar .sizes .size", "click", function(e) { var t; - t = this.size.id, Dt((t = kt[t]).element), Lt(t.size), Tt() + t = this.size.id, Rt((t = Mt[t]).element), It(t.size), Yt() }), D([C], "DOMMouseScroll wheel", function(e) { e.preventDefault(); e = -e.deltaY || e.wheelDeltaY, e = Math.sign(e); - Lt(bt + 2 * e) - }), le("Swap", "S", "Swap the primary and secondary color.", It), D(Ze.querySelector(".color-preview"), "click", function(e) { - It() - }), D(Ze.querySelector(".color-preview-mobile"), "click", function(e) { - Ze.querySelector(".colors").classList.toggle("open") - }), D(Qe, "click", function(e) { - et.classList.toggle("open") - }), D(u, "keydown", function(e) { - if ("Enter" == e.code) return Wn[0].focus(), 0; - if ("input" == u.activeElement.tagName.toLowerCase() || "textarea" == u.activeElement.tagName.toLowerCase() || -1 != St) return 0; - for (var t = e.key.toLowerCase().replace("key", ""), n = 0; n < d.length; n++) - if (d[n].key.toLowerCase() == t) { - for (var a = 0; a < d[n].cb.length; a++) d[n].cb[a](d[n]); + It(qt + 2 * e) + }), re("Swap", "S", "Swap the primary and secondary color.", Pt), D(nt.querySelector(".color-preview"), "click", function(e) { + Pt() + }), D(nt.querySelector(".color-preview-mobile"), "click", function(e) { + nt.querySelector(".colors").classList.toggle("open") + }), D(t, "click", function(e) { + rt.classList.toggle("open") + }), D(c, "keydown", function(e) { + if ("Enter" == e.code) return _n[0].focus(), 0; + if ("input" == c.activeElement.tagName.toLowerCase() || "textarea" == c.activeElement.tagName.toLowerCase() || -1 != xt) return 0; + for (var t = e.key.toLowerCase().replace("key", ""), n = 0; n < u.length; n++) + if (u[n].key.toLowerCase() == t) { + for (var a = 0; a < u[n].cb.length; a++) u[n].cb[a](u[n]); return void e.preventDefault() } }), D(C, "contextmenu", function(e) { return e.preventDefault(), !1 }); - var l, en = null, - tn = ("PointerEvent" in h ? (D("#game-toolbar .colors * .color", "pointerenter", Jt), D("#game-toolbar .colors * .color", "pointerdown", Qt), D(C, "pointerdown", function(e) { - var t, n, a; - null == en && Xt(e.button) && (a = p.pressureSensitivity && ("pen" == e.pointerType || "touch" == e.pointerType), t = e.clientX, n = e.clientY, a = a ? e.pressure : -1, en = e.pointerId, St = e.button, C.setPointerCapture(e.pointerId), S.length, Zt(t, n, a, !0), Kt(!0)) - }), D(C, "pointermove", function(e) { - var t; - en === e.pointerId && (t = p.pressureSensitivity && ("pen" == e.pointerType || "touch" == e.pointerType), Zt(e.clientX, e.clientY, t ? e.pressure : -1, !1), Kt(!1)) - }), D(C, "pointerup pointercancel", function(e) { - en === e.pointerId && (tn != S.length && (tn = S.length, ct.push(tn)), en = null, St = -1, C.releasePointerCapture(e.pointerId)) - })) : (D("#game-toolbar .colors * .color", "mouseenter", Jt), D("#game-toolbar .colors * .color", "click", Qt), D(C, "mousedown", function(e) { - Xt(e.button) && (St = e.button, S.length, Zt(e.clientX, e.clientY, -1, !0), Kt(!0)) - }), D(u, "mousemove", function(e) { - Zt(e.clientX, e.clientY, -1, !1), Kt(!1) - }), D(u, "mouseup", function(e) { - -1 != St && (tn != S.length && (tn = S.length, ct.push(tn)), St = -1) - })), 0), - nn = (setInterval(function() { - var e, t; - l && T.id == Z && L == M && 0 < S.length - it && (e = it + 8, t = S.slice(it, e), l.emit("data", { - id: Ca, - data: t - }), it = Math.min(e, S.length)) - }, 50), setInterval(function() { - l && T.id == Z && L != M && lt < S.length && (Ht(Ft(S[lt]), S[lt]), lt++) - }, 3), u.querySelector("#game-canvas .overlay")), - an = u.querySelector("#game-canvas .overlay-content"), - E = u.querySelector("#game-canvas .overlay-content .text"), - on = u.querySelector("#game-canvas .overlay-content .words"), - rn = u.querySelector("#game-canvas .overlay-content .reveal"), - A = u.querySelector("#game-canvas .overlay-content .result"), - ln = u.querySelector("#game-canvas .overlay-content .room"), - sn = -100, + var rn = null; + "PointerEvent" in h ? (D("#game-toolbar .colors * .color", "pointerenter", an), D("#game-toolbar .colors * .color", "pointerdown", on), D(C, "pointerdown", function(e) { + var t, n, a, o; + null == rn && nn(e.button) && (t = 1 == l.pressureSensitivity && ("pen" == e.pointerType || "touch" == e.pointerType), n = e.clientX, a = e.clientY, o = -1, t && e.pressure && (o = e.pressure), rn = e.pointerId, xt = e.button, C.setPointerCapture(e.pointerId), v.length, tn(n, a, o, !0), en(!0)) + }), D(C, "pointermove", function(e) { + var t, n; + rn !== e.pointerId || (() => { + var e = performance.now(); + if (e - sn < 1e3 / ln) return 1; + sn = e + })() || (t = 1 == l.pressureSensitivity && ("pen" == e.pointerType || "touch" == e.pointerType), n = -1, tn(e.clientX, e.clientY, n = t && e.pressure ? e.pressure : n, !1), en(!1)) + }), D(C, "pointerup pointercancel", function(e) { + rn === e.pointerId && (cn != v.length && (cn = v.length, mt.push(cn)), rn = null, xt = -1, C.releasePointerCapture(e.pointerId)) + })) : (D("#game-toolbar .colors * .color", "mouseenter", an), D("#game-toolbar .colors * .color", "click", on), D(C, "mousedown", function(e) { + nn(e.button) && (xt = e.button, v.length, tn(e.clientX, e.clientY, -1, !0), en(!0)) + }), D(c, "mousemove", function(e) { + tn(e.clientX, e.clientY, -1, !1), en(!1) + }), D(c, "mouseup", function(e) { + -1 != xt && (cn != v.length && (cn = v.length, mt.push(cn)), xt = -1) + })); + let ln = 90; + var S, sn = 0, cn = 0, - dn = void 0; - - function un(e, a, o) { - var r, i, l = sn, - s = cn, + dn = (setInterval(function() { + var e, t, n; + S && L.id == Z && M == x && 0 < (e = v.length - ut) && (t = ut + 8, n = v.slice(ut, t), S.emit("data", { + id: Ia, + data: n + }), ut = Math.min(t, v.length), console.log(`Sent ${n.length} commands. ${e} remaining.`)) + }, 50), setInterval(function() { + S && L.id == Z && M != x && ht < v.length && (Kt(Zt(v[ht]), v[ht]), ht++) + }, 1), c.querySelector("#game-canvas .overlay")), + un = c.querySelector("#game-canvas .overlay-content"), + A = c.querySelector("#game-canvas .overlay-content .text"), + hn = c.querySelector("#game-canvas .overlay-content .words"), + pn = c.querySelector("#game-canvas .overlay-content .reveal"), + I = c.querySelector("#game-canvas .overlay-content .result"), + mn = c.querySelector("#game-canvas .overlay-content .room"), + gn = -100, + fn = 0, + yn = void 0; + + function vn(e, a, o) { + var r, i, l = gn, + s = fn, c = e.top - l, d = e.opacity - s; - Math.abs(c) < .001 && Math.abs(d) < .001 ? o && o() : (r = void 0, i = 0, dn = h.requestAnimationFrame(function e(t) { + Math.abs(c) < .001 && Math.abs(d) < .001 ? o && o() : (r = void 0, i = 0, yn = h.requestAnimationFrame(function e(t) { var n = t - (r = null == r ? t : r), t = (r = t, (i = Math.min(i + n, a)) / a), n = (n = t) < .5 ? .5 * ((e, t) => e * e * ((t + 1) * e - t))(2 * n, 1.2 * 1.5) : .5 * (((e, t) => e * e * ((t + 1) * e + t))(2 * n - 2, 1.2 * 1.5) + 2); - sn = l + c * n, cn = s + t * t * (3 - 2 * t) * d, an.style.top = sn + "%", nn.style.opacity = cn, i == a ? o && o() : dn = h.requestAnimationFrame(e) + gn = l + c * n, fn = s + t * t * (3 - 2 * t) * d, un.style.top = gn + "%", dn.style.opacity = fn, i == a ? o && o() : yn = h.requestAnimationFrame(e) })) } - function hn(e) { + function bn(e) { e.classList.add("show") } /* TYPOMOD desc: add event handlers for typo features */ @@ -1112,10 +1270,10 @@ const data = typo.createFakeLobbyData(); typo.messagePort.postMessage({ id: 10, data }); //document.dispatchEvent(new CustomEvent("practiceJoined", {detail: data})); - Vn(data); + aa(data); }); - l = new Proxy({},{ + S = new Proxy({},{ emit: (...data) => typo.emitPort.postMessage(data), other: (...data) => void 0, get (target, prop) { @@ -1127,37 +1285,37 @@ }); /* TYPOEND */ - function pn(e) { - for (var t = 0; t < an.children.length; t++) an.children[t].classList.remove("show"); + function Sn(e) { + for (var t = 0; t < un.children.length; t++) un.children[t].classList.remove("show"); switch (e.id) { case Q: - hn(ln); + bn(mn); break; case V: - hn(E), E.textContent = R("Round $", e.data + 1); + bn(A), A.textContent = E("Round $", e.data + 1); break; - case _: - hn(E), E.textContent = R("Waiting for players..."); + case K: + bn(A), A.textContent = E("Waiting for players..."); break; - case j: - hn(E), E.textContent = R("Game starting in a few seconds..."); + case F: + bn(A), A.textContent = E("Game starting in a few seconds..."); break; case X: - hn(rn), rn.querySelector("p span.word").textContent = e.data.word, rn.querySelector(".reason").textContent = (e => { + bn(pn), pn.querySelector("p span.word").textContent = e.data.word, pn.querySelector(".reason").textContent = (e => { switch (e) { - case U: - return R("Everyone guessed the word!"); - case G: - return R("The drawer left the game!"); + case H: + return E("Everyone guessed the word!"); + case _: + return E("The drawer left the game!"); case B: - return R("Time is up!"); - case F: - return R("Drawer got skipped!"); + return E("Time is up!"); + case G: + return E("Drawer got skipped!"); default: return "Error!" } })(e.data.reason); - for (var n = rn.querySelector(".player-container"), a = (ue(n), []), o = 0; o < e.data.scores.length; o += 3) { + for (var n = pn.querySelector(".player-container"), a = (de(n), []), o = 0; o < e.data.scores.length; o += 3) { var r = e.data.scores[o + 0], i = (e.data.scores[o + 1], e.data.scores[o + 2]); (s = O(r)) && a.push({ @@ -1176,8 +1334,8 @@ } break; case J: - hn(A); - for (var d = [A.querySelector(".podest-1"), A.querySelector(".podest-2"), A.querySelector(".podest-3"), A.querySelector(".ranks")], o = 0; o < 4; o++) ue(d[o]); + bn(I); + for (var d = [I.querySelector(".podest-1"), I.querySelector(".podest-2"), I.querySelector(".podest-3"), I.querySelector(".ranks")], o = 0; o < 4; o++) de(d[o]); if (0 < e.data.length) { for (var u = [ [], @@ -1199,61 +1357,61 @@ f = d[h], l = $("avatar-container"), y = (f.appendChild(l), $("border")); - y.appendChild($("rank-place", "#" + (h + 1))), y.appendChild($("rank-name", m)), y.appendChild($("rank-score", R("$ points", g))), f.appendChild(y), 0 == h && l.appendChild($("trophy")); - for (o = 0; o < p.length; o++) ge(b = he((s = p[o]).player.avatar, 0 == h), Ra(s.player)), b.style.left = 15 * -(p.length - 1) + 30 * o + "%", 0 == h && (b.classList.add("winner"), b.style.animationDelay = -2.35 * o + "s"), l.appendChild(b) + y.appendChild($("rank-place", "#" + (h + 1))), y.appendChild($("rank-name", m)), y.appendChild($("rank-score", E("$ points", g))), f.appendChild(y), 0 == h && l.appendChild($("trophy")); + for (o = 0; o < p.length; o++) me(b = ue((s = p[o]).player.avatar, 0 == h), Ya(s.player)), b.style.left = 15 * -(p.length - 1) + 30 * o + "%", 0 == h && (b.classList.add("winner"), b.style.animationDelay = -2.35 * o + "s"), l.appendChild(b) } } for (var v = Math.min(5, u[3].length), o = 0; o < v; o++) { var b, s = u[3][o], f = $("rank"); - ge(b = he(s.player.avatar, !1), Ra(s.player)), f.appendChild(b), f.appendChild($("rank-place", "#" + (s.rank + 1))), f.appendChild($("rank-name", s.player.name)), f.appendChild($("rank-score", R("$ points", s.player.score))), d[3].appendChild(f) + me(b = ue(s.player.avatar, !1), Ya(s.player)), f.appendChild(b), f.appendChild($("rank-place", "#" + (s.rank + 1))), f.appendChild($("rank-name", s.player.name)), f.appendChild($("rank-score", E("$ points", s.player.score))), d[3].appendChild(f) } 0 < u[0].length ? (L = u[0].map(function(e) { return e.player.name - }).join(", "), A.querySelector(".winner-name").textContent = (0 < u[0].length ? L : "") + " ", A.querySelector(".winner-text").textContent = 1 == u[0].length ? R("is the winner!") : R("are the winners!")) : (A.querySelector(".winner-name").textContent = "", A.querySelector(".winner-text").textContent = R("Nobody won!")) - } else A.querySelector(".winner-name").textContent = "", A.querySelector(".winner-text").textContent = R("Nobody won!"); + }).join(", "), I.querySelector(".winner-name").textContent = (0 < u[0].length ? L : "") + " ", I.querySelector(".winner-text").textContent = 1 == u[0].length ? E("is the winner!") : E("are the winners!")) : (I.querySelector(".winner-name").textContent = "", I.querySelector(".winner-text").textContent = E("Nobody won!")) + } else I.querySelector(".winner-name").textContent = "", I.querySelector(".winner-text").textContent = E("Nobody won!"); break; - case K: + case j: if (e.data.words) - if (hn(E), hn(on), ue(on), qn[ne.WORDMODE] == ae.COMBINATION) { - E.textContent = R("Choose the first word"); + if (bn(A), bn(hn), de(hn), An[ne.WORDMODE] == ae.COMBINATION) { + A.textContent = E("Choose the first word"); for (var S = e.data.words.length / 2, k = [], w = [], C = 0, o = 0; o < S; o++) { var q = $("word", e.data.words[o]), x = (q.index = o, $("word", e.data.words[o + S])); x.index = o, x.style.display = "none", x.style.animationDelay = .03 * o + "s", k.push(q), w.push(x), D(q, "click", function() { C = this.index; for (var e = 0; e < S; e++) k[e].style.display = "none", w[e].style.display = ""; - E.textContent = R("Choose the second word") + A.textContent = E("Choose the second word") }), D(x, "click", function() { - aa([C, this.index]) - }), on.appendChild(q), on.appendChild(x) + ha([C, this.index]) + }), hn.appendChild(q), hn.appendChild(x) } } else { - E.textContent = R("Choose a word"); + A.textContent = E("Choose a word"); for (o = 0; o < e.data.words.length; o++) { var M = $("word", e.data.words[o]); M.index = o, D(M, "click", function() { - aa(this.index) - }), on.appendChild(M) + ha(this.index) + }), hn.appendChild(M) } } else { - hn(E); - var L = (s = O(e.data.id)) ? s.name : R("User"), - L = (E.textContent = "", E.appendChild(de("span", void 0, R("$ is choosing a word!", L))), he(s ? s.avatar : [0, 0, 0, 0], e.data.id == I)); - s && ge(L, Ra(s)), L.style.width = "2em", L.style.height = "2em", E.appendChild(L) + bn(A); + var L = (s = O(e.data.id)) ? s.name : E("User"), + L = (A.textContent = "", A.appendChild(ce("span", void 0, E("$ is choosing a word!", L))), ue(s ? s.avatar : [0, 0, 0, 0], e.data.id == R)); + s && me(L, Ya(s)), L.style.width = "2em", L.style.height = "2em", A.appendChild(L) } } } - let mn = 0, - gn = 1, - fn = 2, - yn = 3, - vn = 4, - bn = 5, - Sn = 6; + let kn = 0, + wn = 1, + Cn = 2, + qn = 3, + xn = 4, + Mn = 5, + Ln = 6; - function kn(e, t) { + function Dn(e, t) { this.url = t, this.buffer = null, this.loaded = !1; var n = this, a = new XMLHttpRequest; @@ -1266,68 +1424,70 @@ }, a.send() } - function wn() { + function $n() { this.context = null, this.gain = null, this.sounds = new Map, h.addEventListener("load", this.load.bind(this), !1) } - wn.prototype.addSound = function(e, t) { - this.sounds.set(e, new kn(this, t)) - }, wn.prototype.loadSounds = function() { - this.addSound(mn, "/audio/roundStart.ogg"), this.addSound(gn, "/audio/roundEndSuccess.ogg"), this.addSound(fn, "/audio/roundEndFailure.ogg"), this.addSound(yn, "/audio/join.ogg"), this.addSound(vn, "/audio/leave.ogg"), this.addSound(bn, "/audio/playerGuessed.ogg"), this.addSound(Sn, "/audio/tick.ogg") - }, wn.prototype.playSound = function(e) { + $n.prototype.addSound = function(e, t) { + this.sounds.set(e, new Dn(this, t)) + }, $n.prototype.loadSounds = function() { + this.addSound(kn, "/audio/roundStart.ogg"), this.addSound(wn, "/audio/roundEndSuccess.ogg"), this.addSound(Cn, "/audio/roundEndFailure.ogg"), this.addSound(qn, "/audio/join.ogg"), this.addSound(xn, "/audio/leave.ogg"), this.addSound(Mn, "/audio/playerGuessed.ogg"), this.addSound(Ln, "/audio/tick.ogg") + }, $n.prototype.playSound = function(e) { var t, n; null == this.context ? this.load() : "running" != this.context.state ? this.context.resume().then(function() { this.playSound(e) - }) : null != this.context && 0 < p.volume && this.sounds.has(e) && (t = this.sounds.get(e)).loaded && ((n = this.context.createBufferSource()).buffer = t.buffer, n.connect(this.gain), n.start(0)) - }, wn.prototype.setVolume = function(e) { - y[g].querySelector("#volume .title .icon").classList.toggle("muted", e <= 0), y[g].querySelector("#volume .volume-value").textContent = e <= 0 ? "Muted" : e + "%", this.gain && (this.gain.gain.value = e / 100) - }, wn.prototype.load = function() { + }) : null != this.context && 0 < l.volume && this.sounds.has(e) && (t = this.sounds.get(e)).loaded && ((n = this.context.createBufferSource()).buffer = t.buffer, n.connect(this.gain), n.start(0)) + }, $n.prototype.setVolume = function(e) { + g[p].querySelector("#volume .title .icon").classList.toggle("muted", e <= 0), g[p].querySelector("#volume .volume-value").textContent = e <= 0 ? "Muted" : e + "%", this.gain && (this.gain.gain.value = e / 100) + }, $n.prototype.load = function() { if (null == this.context) try { - h.AudioContext = h.AudioContext || h.webkitAudioContext, this.context = new AudioContext, this.gain = this.context.createGain(), this.gain.connect(this.context.destination), this.setVolume(p.volume), console.log("AudioContext created."), this.loadSounds() + h.AudioContext = h.AudioContext || h.webkitAudioContext, this.context = new AudioContext, this.gain = this.context.createGain(), this.gain.connect(this.context.destination), this.setVolume(l.volume), console.log("AudioContext created."), this.loadSounds() } catch (e) { console.log("Error creating AudioContext.", e), this.context = null } }; - let w = 4, - Cn = "https://skribbl.io/api/play"; - _; - var x = [], - M = 0, - I = -1, - L = -1, - qn = [], - T = { + let k = 4, + En = "https://skribbl.io/api/play"; + K; + var w = [], + x = 0, + R = -1, + M = -1, + An = [], + L = { id: -1, time: 0, data: 0 }, - xn = -1, - Mn = 0, - Ln = void 0, - N = new wn, - s = void 0, - Dn = !1, - $n = !1, - Rn = u.querySelector("#game-wrapper"), - Qe = u.querySelector("#game-canvas .room"), - En = u.querySelector("#game-players"), - An = u.querySelector("#game-players .players-list"), - In = u.querySelector("#game-players-footer"), - Tn = (u.querySelector("#game-board"), u.querySelector("#game-bar"), u.querySelector("#game-round .text")), - W = [u.querySelector("#game-word .description"), u.querySelector("#game-word .word"), u.querySelector("#game-word .hints .container")], - Nn = (u.querySelector("#game-chat"), [u.querySelector("#game-chat form"), u.querySelector("#game-chat-input-mobile form")]), - Wn = [u.querySelector("#game-chat input"), u.querySelector("#game-chat-input-mobile input")], - On = u.querySelector("#game-chat .chat-content"), - Pn = u.querySelector("#home .container-name-lang input"), - zn = u.querySelector("#home .container-name-lang select"), - Yn = u.querySelector("#home .panel .button-play"), - Hn = u.querySelector("#home .panel .button-create"); - let Un = 11 == (t = new Date).getMonth() && 19 <= (t = t.getDate()) && t <= 26; - - function Bn(e) { - Dn = e, u.querySelector("#load").style.display = e ? "block" : "none" - } - - function Gn(e, t, n, a) { + In = -1, + Rn = 0, + Tn = void 0, + T = new $n, + N = void 0, + Nn = !1, + Wn = !1, + On = c.querySelector("#game"), + Pn = c.querySelector("#game-wrapper"), + t = c.querySelector("#game-canvas .room"), + Yn = c.querySelector("#game-players"), + zn = c.querySelector("#game-players .players-list"), + Un = c.querySelector("#game-players-footer"), + Hn = (c.querySelector("#game-board"), c.querySelector("#game-bar"), c.querySelector("#game-round .text")), + W = [c.querySelector("#game-word .description"), c.querySelector("#game-word .word"), c.querySelector("#game-word .hints .container")], + Bn = (c.querySelector("#game-chat"), [c.querySelector("#game-chat form"), c.querySelector("#game-chat-input-mobile form")]), + _n = [c.querySelector("#game-chat input"), c.querySelector("#game-chat-input-mobile input")], + Gn = c.querySelector("#game-chat .chat-content"), + Kn = c.querySelector("#home .container-name-lang input"), + Fn = c.querySelector("#home .container-name-lang select"), + Vn = c.querySelector("#home .panel .button-play"), + jn = c.querySelector("#home .panel .button-create"); + let Zn = 11 == (Xn = new Date).getMonth() && 19 <= (Xn = Xn.getDate()) && Xn <= 26; + var Xn = 9 == (Xn = new Date).getMonth() && 24 <= (Xn = Xn.getDate()) && Xn <= 31; + + function Jn(e) { + Nn = e, c.querySelector("#load").style.display = e ? "block" : "none" + } + + function Qn(e, t, n, a) { var o, r; e = e, t = t, o = function(e, t) { switch (e) { @@ -1338,10 +1498,10 @@ }); case 503: case 0: - a && Me(be, R("Servers are currently undergoing maintenance!") + "\n\r" + R("Please try again later!") + "\n\rStatus: " + e); + a && xe(ve, E("Servers are currently undergoing maintenance!") + "\n\r" + E("Please try again later!") + "\n\rStatus: " + e); break; default: - a && Me(be, R("An unknown error occurred ('$')", e) + "\n\r" + R("Please try again later!")) + a && xe(ve, E("An unknown error occurred ('$')", e) + "\n\r" + E("Please try again later!")) } n({ success: !1, @@ -1351,8 +1511,8 @@ 4 == this.readyState && o(this.status, this.response) }, r.open("POST", e, !0), r.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), r.send(t) } - Un; - var Fn = null; + Zn; + var ea = null; adplayer = null; try { aiptag.cmd.player.push(function() { @@ -1363,10 +1523,10 @@ AD_CENTERPLAYER: !0, LOADING_TEXT: "loading advertisement", PREROLL_ELEM: function() { - return u.getElementById("preroll") + return c.getElementById("preroll") }, AIP_COMPLETE: function(e) { - Fn() + ea() }, AIP_REMOVE: function() {} }) @@ -1375,10 +1535,10 @@ console.log("ad push failed: "), console.log(e) } - function _n(t) { + function ta(t) { var e, n, a = !1; - if (h.localStorageAvailable && (n = c.getItem("lastAd"), e = new Date, c.setItem("lastAd", e.toString()), null == n ? n = e : (n = new Date(Date.parse(n)), a = 1 <= Math.abs(n - e) / 1e3 / 60)), a) try { - aiptag && adplayer && null != adplayer && "undefined" !== adplayer ? (Fn = t, aiptag.cmd.player.push(function() { + if (h.localStorageAvailable && (n = d.getItem("lastAd"), e = new Date, d.setItem("lastAd", e.toString()), null == n ? n = e : (n = new Date(Date.parse(n)), a = 1 <= Math.abs(n - e) / 1e3 / 60)), a) try { + aiptag && adplayer && null != adplayer && "undefined" !== adplayer ? (ea = t, aiptag.cmd.player.push(function() { adplayer.startPreRoll() })) : t() } catch (e) { @@ -1386,190 +1546,190 @@ } else t() } - function jn(e, t, n) { - N.context && N.context.resume && N.context.resume(), l && na(); + function na(e, t, n) { + T.context && T.context.resume && T.context.resume(), S && ua(); var a, o = 0, r = { transports: ["websocket", "polling"], closeOnBeforeunload: !1 }; - "URL" in h && "127.0.0.1" != (a = new URL(e)).hostname && "localhost" != a.hostname && (r.path = "/" + a.port + "/", e = a.protocol + "//" + a.hostname), (l = P(e, r)).on("connect", function() { + "URL" in h && "127.0.0.1" != (a = new URL(e)).hostname && "localhost" != a.hostname && (r.path = "/" + a.port + "/", e = a.protocol + "//" + a.hostname), (S = P(e, r)).on("connect", function() { /* TYPOMOD desc: disconnect socket & leave lobby */ document.addEventListener('socketEmit', event => - l.emit('data', { id: event.detail.id, data: event.detail.data }) + S.emit('data', { id: event.detail.id, data: event.detail.data }) ); typo.disconnect = () => { - if (l) { - l.typoDisconnect = true; - l.on("disconnect", () => { + if (S) { + S.typoDisconnect = true; + S.on("disconnect", () => { typo.disconnect = undefined; document.dispatchEvent(new Event("leftLobby")); }); - l.off("data"); - l.reconnect = false; - l.disconnect(); + S.off("data"); + S.reconnect = false; + S.disconnect(); } else { document.dispatchEvent(new Event("leftLobby")); } } - l.on("data", data => typo.messagePort.postMessage(data)); - typo.messagePort.onmessage = data => l.emit("data", data.data); + S.on("data", data => typo.messagePort.postMessage(data)); + typo.messagePort.onmessage = data => S.emit("data", data.data); - const originalEmit = l.emit.bind(l); - l.emit = function(...data) { + const originalEmit = S.emit.bind(l); + S.emit = function(...data) { typo.emitPort.postMessage(data); originalEmit(...data); }; /* TYPOEND */ - Bn(!1), l.on("joinerr", function(e) { - na(), Me(be, (e => { + Jn(!1), S.on("joinerr", function(e) { + ua(), xe(ve, (e => { switch (e) { case 1: - return R("Room not found!"); + return E("Room not found!"); case 2: - return R("Room is full!"); + return E("Room is full!"); case 3: - return R("You are on a kick cooldown!"); + return E("You are on a kick cooldown!"); case 4: - return R("You are banned from this room!"); + return E("You are banned from this room!"); case 5: - return R("You are joining rooms too quickly!"); + return E("You are joining rooms too quickly!"); case 100: - return R("You are already connected to this room!"); + return E("You are already connected to this room!"); case 200: - return R("Too many users from your IP are connected to this room!"); + return E("Too many users from your IP are connected to this room!"); case 300: - return R("You have been kicked too many times!"); + return E("You have been kicked too many times!"); default: - return R("An unknown error ('$') occured!", e) + return E("An unknown error ('$') occured!", e) } })(e)) - }), l.on("data", $a); - var e = Pn.value.split("#"), + }), S.on("data", Pa); + var e = Kn.value.split("#"), e = { join: t, create: n ? 1 : 0, name: e[0], - lang: zn.value, + lang: Fn.value, code: e[1], - avatar: p.avatar + avatar: l.avatar }; - l.emit("login", e) - }), l.on("reason", function(e) { + S.emit("login", e) + }), S.on("reason", function(e) { o = e - }), l.on("disconnect", function(e) { + }), S.on("disconnect", function(e) { /* TYPOMOD DESC: no msg if disconnect intentionally */ - if(!l.typoDisconnect) + if(!S.typoDisconnect) /*TYPOEND*/ switch (console.log("socket disconnect: " + e), o) { case ee: - Me(Se, R("You have been kicked!")); + xe(be, E("You have been kicked!")); break; case te: - Me(Se, R("You have been banned!")); + xe(be, E("You have been banned!")); break; default: - Me(Se, R("Connection lost!") + "\n" + e) + xe(be, E("Connection lost!") + "\n" + e) } - na() - }), l.on("connect_error", function(e) { - na(), Bn(!1), Me(be, e.message) + ua() + }), S.on("connect_error", function(e) { + ua(), Jn(!1), xe(ve, e.message) }) } - function Vn(e) { - N.playSound(yn), Rt(_e, !0), Lt(12), Et(1), At(0), Ut(!0), ue(On), u.querySelector("#home").style.display = "none", u.querySelector("#game").style.display = "flex", M = e.me, xn = e.type, Ln = e.id, u.querySelector("#input-invite").value = "https://skribbl.io/?" + e.id, qn = e.settings, Kn(), ue(An), x = []; - for (var t = 0; t < e.users.length; t++) Ea(e.users[t], !1); - Wa(), Oa(), Xn(e.round), la(e.owner), Qn(e.state, !0), $n || (setTimeout(function() { + function aa(e) { + T.playSound(qn), Nt(Je, !0), It(12), Wt(1), Ot(0), Ft(!0), de(Gn), c.querySelector("#home").style.display = "none", c.querySelector("#game").style.display = "flex", x = e.me, In = e.type, Tn = e.id, c.querySelector("#input-invite").value = "https://skribbl.io/?" + e.id, An = e.settings, oa(), de(zn), w = []; + for (var t = 0; t < e.users.length; t++) za(e.users[t], !1); + Ga(), Ka(), ia(e.round), fa(e.owner), sa(e.state, !0), Wn || (setTimeout(function() { try { (adsbygoogle = h.adsbygoogle || []).push({}), (adsbygoogle = h.adsbygoogle || []).push({}) } catch (e) { console.log("google ad request failed"), console.log(e) } - }, 1500), $n = !0) + }, 1500), Wn = !0) } - function Kn() { - Xn(Mn); - for (var e, t = 0; t < Ya.length; t++) { - var n = Ya[t]; - n.index && (e = qn[(n = n).index], "checkbox" == n.element.type ? n.element.checked = !!e : n.element.value = e) + function oa() { + ia(Rn); + for (var e, t = 0; t < ja.length; t++) { + var n = ja[t]; + n.index && (e = An[(n = n).index], "checkbox" == n.element.type ? n.element.checked = !!e : n.element.value = e) } } - function Zn(e, t, n) { - qn[e] = t, n && l && l.emit("data", { - id: fa, + function ra(e, t, n) { + An[e] = t, n && S && S.emit("data", { + id: xa, data: { id: e, val: t } - }), Kn() + }), oa() } - function Xn(e) { - var e = (Mn = e) + 1, - t = qn[ne.ROUNDS]; - Tn.textContent = R("Round $ of $", [e, t]) + function ia(e) { + var e = (Rn = e) + 1, + t = An[ne.ROUNDS]; + Hn.textContent = E("Round $ of $", [e, t]) } - function Jn() { - for (var e = 0; e < x.length; e++) x[e].score = 0; - for (e = 0; e < x.length; e++) Pa(x[e], !1), za(x[e], !1); - Oa() + function la() { + for (var e = 0; e < w.length; e++) w[e].score = 0; + for (e = 0; e < w.length; e++) Fa(w[e], !1), Va(w[e], !1); + Ka() } - function Qn(e, t) { + function sa(e, t) { var n, a; - if (n = T = e, null != dn && (h.cancelAnimationFrame(dn), dn = void 0), n.id == Z ? un({ + if (n = L = e, null != yn && (h.cancelAnimationFrame(yn), yn = void 0), n.id == Z ? vn({ top: -100, opacity: 0 }, 600, function() { - nn.classList.remove("show") - }) : nn.classList.contains("show") ? un({ + dn.classList.remove("show") + }) : dn.classList.contains("show") ? vn({ top: -100, opacity: 1 }, 600, function() { - pn(n), un({ + Sn(n), vn({ top: 0, opacity: 1 }, 600) - }) : (nn.classList.add("show"), pn(n), un({ + }) : (dn.classList.add("show"), Sn(n), vn({ top: 0, opacity: 1 - }, 600)), a = e.time, Ka(), Za(a), ja = setInterval(function() { - Za(Math.max(0, Va - 1)); + }, 600)), a = e.time, oo(), ro(a), no = setInterval(function() { + ro(Math.max(0, ao - 1)); var e = -1; - T.id == Z && (e = Ga), T.id == K && (e = Fa), _a.style.animationName = Va < e ? Va % 2 == 0 ? "rot_left" : "rot_right" : "none", Va < e && N.playSound(Sn), Va <= 0 && Ka() - }, 1e3), Rn.classList.add("toolbar-hidden"), pt(), ta(!1), e.id == Q ? (Jn(), Rn.classList.add("room")) : Rn.classList.remove("room"), e.id == V && (Xn(e.data), 0 == e.data) && Jn(), e.id == X) { - M != L && ia(e.data.word); + L.id == Z && (e = Qa), L.id == j && (e = eo), to.style.animationName = ao < e ? ao % 2 == 0 ? "rot_left" : "rot_right" : "none", ao < e && T.playSound(Ln), ao <= 0 && oo() + }, 1e3), Pn.classList.add("toolbar-hidden"), vt(), da(!1), e.id == Q ? (la(), Pn.classList.add("room")) : Pn.classList.remove("room"), e.id == V && (ia(e.data), 0 == e.data) && la(), e.id == X) { + x != M && ga(e.data.word); for (var o = 0; o < e.data.scores.length; o += 3) { var r = e.data.scores[o + 0], i = e.data.scores[o + 1]; e.data.scores[o + 2]; (c = O(r)) && (c.score = i) } - Oa(); - for (var l = !0, o = 0; o < x.length; o++) - if (x[o].guessed) { + Ka(); + for (var l = !0, o = 0; o < w.length; o++) + if (w[o].guessed) { l = !1; break - } l ? N.playSound(fn) : N.playSound(gn), b(R("The word was '$'", e.data.word), "", v(Ee), !0) + } l ? T.playSound(Cn) : T.playSound(wn), y(E("The word was '$'", e.data.word), "", f(Ee), !0) /* TYPOMOD desc: log finished drawing */ ;document.dispatchEvent(new CustomEvent("drawingFinished", { detail: e.data.word })); /* TYPOEND */ - } else e.id != Z && (W[0].textContent = R("WAITING"), W[0].classList.add("waiting"), W[1].style.display = "none", W[2].style.display = "none"); + } else e.id != Z && (W[0].textContent = E("WAITING"), W[0].classList.add("waiting"), W[1].style.display = "none", W[2].style.display = "none"); if (e.id == Z) { - if (L = e.data.id, N.playSound(mn), Ut(!0), e.data.drawCommands && (S = e.data.drawCommands), b(R("$ is drawing now!", O(L).name), "", v(Re), !0), !t) - for (o = 0; o < x.length; o++) Pa(x[o], !1); - W[0].classList.remove("waiting"), L == M ? (a = e.data.word, W[0].textContent = R("DRAW THIS"), W[1].style.display = "", W[2].style.display = "none", W[1].textContent = a, Rn.classList.remove("toolbar-hidden"), pt()) : (ta(!0), oa(e.data.word, !1), ra(e.data.hints)) + if (M = e.data.id, T.playSound(kn), Ft(!0), e.data.drawCommands && (v = e.data.drawCommands), y(E("$ is drawing now!", O(M).name), "", f($e), !0), !t) + for (o = 0; o < w.length; o++) Fa(w[o], !1); + W[0].classList.remove("waiting"), M == x ? (a = e.data.word, W[0].textContent = E("DRAW THIS"), W[1].style.display = "", W[2].style.display = "none", W[1].textContent = a, Pn.classList.remove("toolbar-hidden"), vt()) : (da(!0), pa(e.data.word, !1), ma(e.data.hints)) } else { - L = -1; - for (o = 0; o < x.length; o++) Pa(x[o], !1) + M = -1; + for (o = 0; o < w.length; o++) Fa(w[o], !1) } if (e.id == J && 0 < e.data.length) { for (var s = [], i = 0, o = 0; o < e.data.length; o++) { @@ -1577,47 +1737,47 @@ u = e.data[o][1]; (c = O(d)) && 0 == u && (i = c.score, s.push(c.name)) } - 1 == s.length ? b(R("$ won with a score of $!", [s[0], i]), "", v(Ie), !0) : 1 < s.length && b(R("$ and $ won with a score of $!", [s.slice(0, -1).join(", "), s[s.length - 1], i]), "", v(Ie), !0) + 1 == s.length ? y(E("$ won with a score of $!", [s[0], i]), "", f(Ie), !0) : 1 < s.length && y(E("$ and $ won with a score of $!", [s.slice(0, -1).join(", "), s[s.length - 1], i]), "", f(Ie), !0) } - for (o = 0; o < x.length; o++) za(x[o], x[o].id == L); - Wa() + for (o = 0; o < w.length; o++) Va(w[o], w[o].id == M); + Ga() } - function ea(e) { - l && l.connected && T.id == Z && (l.emit("data", { - id: ua, + function ca(e) { + S && S.connected && L.id == Z && (S.emit("data", { + id: Sa, data: e - }), ta(!1)) + }), da(!1)) } - function ta(e) { - u.querySelector("#game-rate").style.display = e ? "" : "none" + function da(e) { + c.querySelector("#game-rate").style.display = e ? "" : "none" } - function na() { - console.log("lobby left"), l && l.close(), Ut(!(l = void 0)), Ka(), x = [], qn = [], T = { - id: L = I = -1, - time: M = 0, + function ua() { + console.log("lobby left"), S && S.close(), Ft(!(S = void 0)), oo(), w = [], An = [], L = { + id: M = R = -1, + time: x = 0, data: 0 - }, u.querySelector("#home").style.display = "", u.querySelector("#game").style.display = "none" + }, c.querySelector("#home").style.display = "", c.querySelector("#game").style.display = "none" } - function aa(e) { - l && l.connected && T.id == K && l.emit("data", { - id: wa, + function ha(e) { + S && S.connected && L.id == j && S.emit("data", { + id: Aa, data: e }) } - function oa(e, t) { + function pa(e, t) { for (var n = e.length - 1, a = 0; a < e.length; a++) n += e[a]; - var o = !t && 1 == qn[ne.WORDMODE]; - o && (n = 3), W[0].textContent = R(o ? "WORD HIDDEN" : "GUESS THIS"), W[1].style.display = "none", W[2].style.display = "", ue(W[2]), W[2].hints = []; + var o = !t && 1 == An[ne.WORDMODE]; + o && (n = 3), W[0].textContent = E(o ? "WORD HIDDEN" : "GUESS THIS"), W[1].style.display = "none", W[2].style.display = "", de(W[2]), W[2].hints = []; for (a = 0; a < n; a++) W[2].hints[a] = $("hint", o ? "?" : "_"), W[2].appendChild(W[2].hints[a]); o || W[2].appendChild($("word-length", e.join(" "))) } - function ra(e) { + function ma(e) { for (var t = W[2].hints, n = 0; n < e.length; n++) { var a = e[n][0], o = e[n][1]; @@ -1625,137 +1785,137 @@ } } - function ia(e) { - (!W[2].hints || W[2].hints.length < e.length) && oa([e.length], !0); + function ga(e) { + (!W[2].hints || W[2].hints.length < e.length) && pa([e.length], !0); for (var t = [], n = 0; n < e.length; n++) t.push([n, e.charAt(n)]); - ra(t) - } - - function la(e) { - I = e; - for (var t = 0; t < x.length; t++) me(x[t].element, x[t].id == I), Ta(x[t], 0, x[t].id == I); - var n = M != I; - u.querySelector("#button-start-game").disabled = n; - for (var a = 0; a < Ya.length; a++) Ya[a].element.disabled = n; - e = O(I); - e && b(R("$ is now the room owner!", e.name), "", v(Ie), !0) - } - let sa = 1, - ca = 2, - da = 5, - ua = 8, - ha = 9, - pa = 90, - ma = 10, - ga = 11, - fa = 12, - ya = 13, - va = 14, - ba = 15, - Sa = 16, - ka = 17, - wa = 18, - Ca = 19, - qa = 20, - xa = 21, - Ma = 30, - La = 31, - Da = 32; - - function $a(e) { + ma(t) + } + + function fa(e) { + R = e; + for (var t = 0; t < w.length; t++) pe(w[t].element, w[t].id == R), Ba(w[t], 0, w[t].id == R); + var n = x != R; + c.querySelector("#button-start-game").disabled = n; + for (var a = 0; a < ja.length; a++) ja[a].element.disabled = n; + e = O(R); + e && y(E("$ is now the room owner!", e.name), "", f(Ie), !0) + } + let ya = 1, + va = 2, + ba = 5, + Sa = 8, + ka = 9, + wa = 90, + Ca = 10, + qa = 11, + xa = 12, + Ma = 13, + La = 14, + Da = 15, + $a = 16, + Ea = 17, + Aa = 18, + Ia = 19, + Ra = 20, + Ta = 21, + Na = 30, + Wa = 31, + Oa = 32; + + function Pa(e) { var t = e.id, n = e.data; switch (t) { - case ma: + case Ca: /* TYPOMOD desc: send lobbydata*/ document.dispatchEvent(new CustomEvent("lobbyConnected", { detail: n })); /* TYPOEND*/ - Vn(n); + aa(n); break; - case ga: - Qn(n); + case qa: + sa(n); break; - case fa: - Zn(n.id, n.val, !1); + case xa: + ra(n.id, n.val, !1); break; - case ya: - ra(n); + case Ma: + ma(n); break; - case va: - Za(n); + case La: + ro(n); break; - case sa: - var a = Ea(n, !0); - Oa(), a.joinTimeout = setTimeout(() => { - b(R("$ joined the room!", a.name), "", v(Ee), !0), N.playSound(yn), a.joinTimeout = void 0 - }, 0 == xn ? 1e3 : 0); + case ya: + var a = za(n, !0); + Ka(), a.joinTimeout = setTimeout(() => { + y(E("$ joined the room!", a.name), "", f(Ee), !0), T.playSound(qn), a.joinTimeout = void 0 + }, 0 == In ? 1e3 : 0); break; - case ha: - (a = O(n.id)) && (a.avatar = n.avatar, pe(a.element.avatar, a.avatar)); + case ka: + (a = O(n.id)) && (a.avatar = n.avatar, he(a.element.avatar, a.avatar)); break; - case pa: + case wa: (a = O(n.id)) && (a.name = n.name, a.element.querySelector(".player-name").textContent = n.name); break; - case ca: + case va: (a = (e => { - for (var t = 0; t < x.length; t++) { - var n = x[t]; - if (n.id == e) return x.splice(t, 1), n.element.remove(), Oa(), Wa(), n + for (var t = 0; t < w.length; t++) { + var n = w[t]; + if (n.id == e) return w.splice(t, 1), n.element.remove(), Ka(), Ga(), n } - })(n.id)) && (null == a.joinTimeout ? (b(((e, t) => { + })(n.id)) && (null == a.joinTimeout ? (y(((e, t) => { switch (e) { default: - return R("$ left the room!", t); + return E("$ left the room!", t); case ee: - return R("$ has been kicked!", t); + return E("$ has been kicked!", t); case te: - return R("$ has been banned!", t) + return E("$ has been banned!", t) } - })(n.reason, a.name), "", v(Ae), !0), N.playSound(vn)) : (clearTimeout(a.joinTimeout), a.joinTimeout = void 0), n.id != L || n.reason != ee && n.reason != te || Ut(!0)); + })(n.reason, a.name), "", f(Ae), !0), T.playSound(xn)) : (clearTimeout(a.joinTimeout), a.joinTimeout = void 0), n.id != M || n.reason != ee && n.reason != te || Ft(!0)); break; - case da: + case ba: var o = O(n[0]), r = O(n[1]), i = n[2], l = n[3]; - o && r && b(R("$ is voting to kick $ ($/$)", [o.name, r.name, i, l]), "", v($e), !0); + o && r && y(E("$ is voting to kick $ ($/$)", [o.name, r.name, i, l]), "", f(De), !0); break; - case ba: - (a = O(n.id)) && (b(R("$ guessed the word!", a.name), "", v(Ee), !0).classList.add("guessed"), Pa(a, !0), N.playSound(bn), n.id == M) && ia(n.word); + case Da: + (a = O(n.id)) && (y(E("$ guessed the word!", a.name), "", f(Ee), !0).classList.add("guessed"), Fa(a, !0), T.playSound(Mn), n.id == x) && ga(n.word); break; - case ua: - (a = O(n.id)) && (o = a, r = 0 == n.vote ? "thumbsdown.gif" : "thumbsup.gif", (i = $("icon")).style.backgroundImage = "url(/img/" + r + ")", r = Ia(o, i).getBoundingClientRect(), o = .9 * (r.bottom - r.top), i.style.width = o + "px", i.style.height = o + "px", n.vote ? b(R("$ liked the drawing!", a.name), "", v(Ee), !0) : b(R("$ disliked the drawing!", a.name), "", v(Ae), !0)); + case Sa: + (a = O(n.id)) && (o = a, r = 0 == n.vote ? "thumbsdown.gif" : "thumbsup.gif", (i = $("icon")).style.backgroundImage = "url(/img/" + r + ")", r = Ha(o, i).getBoundingClientRect(), o = .9 * (r.bottom - r.top), i.style.width = o + "px", i.style.height = o + "px", n.vote ? y(E("$ liked the drawing!", a.name), "", f(Ee), !0) : y(E("$ disliked the drawing!", a.name), "", f(Ae), !0)); break; - case ka: - la(n); + case Ea: + fa(n); break; - case Sa: - b(R("$ is close!", n), "", v($e), !0); + case $a: + y(E("$ is close!", n), "", f(De), !0); break; - case Ma: - Aa(O(n.id), n.msg); + case Na: + Ua(O(n.id), n.msg); break; - case Da: - b(R("Spam detected! You're sending messages too quickly."), "", v(Ae), !0); + case Oa: + y(E("Spam detected! You're sending messages too quickly."), "", f(Ae), !0); break; - case La: + case Wa: switch (n.id) { case 0: - b(R("You need at least 2 players to start the game!"), "", v(Ae), !0); + y(E("You need at least 2 players to start the game!"), "", f(Ae), !0); break; case 100: - b(R("Server restarting in about $ seconds!", n.data), "", v(Ae), !0) + y(E("Server restarting in about $ seconds!", n.data), "", f(Ae), !0) } break; - case Ca: - for (var s = 0; s < n.length; s++) Gt(n[s]); + case Ia: + for (var s = 0; s < n.length; s++) jt(n[s]); break; - case qa: - Ut(!0); + case Ra: + Ft(!0); break; - case xa: - Pt(n); + case Ta: + Bt(n); break; default: return void console.log("Unimplemented data packed received with id " + t) @@ -1763,17 +1923,17 @@ } function O(e) { - for (var t = 0; t < x.length; t++) { - var n = x[t]; + for (var t = 0; t < w.length; t++) { + var n = w[t]; if (n.id == e) return n } } - function Ra(e) { - return (e.flags & w) == w ? ["glow", "hue-rotate"] : [] + function Ya(e) { + return (e.flags & k) == k ? ["glow", "hue-rotate"] : [] } - function Ea(e, t) { + function za(e, t) { var n = { id: e.id, flags: e.flags, @@ -1789,8 +1949,8 @@ element: $("player"), bubble: void 0 }, - e = (x.push(n), n.id == M ? R("$ (You)", n.name) : n.name), - a = (n.flags & w) == w, + e = (w.push(n), n.id == x ? E("$ (You)", n.name) : n.name), + a = (n.flags & k) == k, o = (a && n.element.classList.add("admin"), $("player-background")), r = (n.element.appendChild(o), a ? 1 : -1); if (1 == r) @@ -1798,11 +1958,11 @@ if (2 == r) for (i = 0; i < 3; i++) o.appendChild($("background-wave")); var r = $("player-avatar-container"), - l = he(n.avatar), - r = (n.element.drawing = $("drawing"), (n.element.avatar = l).appendChild(n.element.drawing), r.appendChild(l), n.element.appendChild(r), An.appendChild(n.element), ge(l, Ra(n)), $("player-info")), + l = ue(n.avatar), + r = (n.element.drawing = $("drawing"), (n.element.avatar = l).appendChild(n.element.drawing), r.appendChild(l), n.element.appendChild(r), zn.appendChild(n.element), me(l, Ya(n)), $("player-info")), l = $("player-name", e), - e = (n.id == M && l.classList.add("me"), r.appendChild(l), r.appendChild($("player-rank", "#" + n.rank)), r.appendChild($("player-score", R("$ points", n.score))), a && r.appendChild($("player-tag", "ADMIN")), n.element.appendChild(r), D(n.element, "click", function() { - s = n, Me(m, n) + e = (n.id == x && l.classList.add("me"), r.appendChild(l), r.appendChild($("player-rank", "#" + n.rank)), r.appendChild($("player-score", E("$ points", n.score))), a && r.appendChild($("player-tag", "ADMIN")), n.element.appendChild(r), D(n.element, "click", function() { + N = n, xe(s, n) }), $("player-icons")), l = $("icon owner"), a = $("icon muted"); @@ -1810,16 +1970,16 @@ desc: set ID to player to identify */ n.element.setAttribute("playerid", n.id); /* TYPOEND */ - return e.appendChild(l), e.appendChild(a), n.element.appendChild(e), n.element.icons = [l, a], Pa(n, n.guessed), t && Wa(), n + return e.appendChild(l), e.appendChild(a), n.element.appendChild(e), n.element.icons = [l, a], Fa(n, n.guessed), t && Ga(), n } - function Aa(e, t) { + function Ua(e, t) { var n, a, o; - !e.muted && (o = ((a = O(M)).flags & w) == w, n = e.id == L || e.guessed, M == L || a.guessed || !n || o) && (a = (e.flags & w) == w, o = De, n && (o = Te), a && (o = Ae), Ia(e, $("text", t)), b(e.name, t, v(o), !1) + !e.muted && (o = ((a = O(x)).flags & k) == k, n = e.id == M || e.guessed, x == M || a.guessed || !n || o) && (a = (e.flags & k) == k, o = Le, n && (o = Re), a && (o = Ae), Ha(e, $("text", t)), y(e.name, t, f(o), !1) .setAttribute("playerid", e.id)) } - function Ia(e, t) { + function Ha(e, t) { e.bubble && (clearTimeout(e.bubble.timeout), e.bubble.remove(), e.bubble = void 0); var n = $("player-bubble"), a = $("content"); @@ -1828,255 +1988,260 @@ }, 1500), n } - function Ta(e, t, n) { + function Ba(e, t, n) { n ? e.element.icons[t].classList.add("visible") : e.element.icons[t].classList.remove("visible") } - var Na = void 0; + var _a = void 0; - function Wa() { - T.id, Q; - for (var e = getComputedStyle(Rn).getPropertyValue("--PLAYERS_PER_PAGE"), t = (e <= 0 && (t = Math.max(48, En.clientHeight), e = Math.floor(t / 48)), Math.ceil(x.length / e)), n = 0; n < x.length; n++) x[n].page = Math.floor(n / e); - null == Na ? Na = fe(In, t, [En], function(e, t, n) { - for (var a = [], o = 0; o < x.length; o++) { - var r = (i = x[o]).page == t; + function Ga() { + L.id, Q; + for (var e = getComputedStyle(Pn).getPropertyValue("--PLAYERS_PER_PAGE"), t = (e <= 0 && (t = Math.max(48, Yn.clientHeight), e = Math.floor(t / 48)), Math.ceil(w.length / e)), n = 0; n < w.length; n++) w[n].page = Math.floor(n / e); + null == _a ? _a = ge(Un, t, [Yn], function(e, t, n) { + for (var a = [], o = 0; o < w.length; o++) { + var r = (i = w[o]).page == t; i.element.style.display = r ? "" : "none", r && a.push(i.element) } if (0 < a.length) { for (var i, o = 0; o < a.length; o++)(i = a[o]).classList.remove("first"), i.classList.remove("last"), o % 2 == 0 ? i.classList.remove("odd") : i.classList.add("odd"); a[0].classList.add("first"), a[a.length - 1].classList.add("last") } - }) : ye(Na, t), Na.element.style.display = 1 < t ? "" : "none" + }) : fe(_a, t), _a.element.style.display = 1 < t ? "" : "none" } - function Oa() { - for (var e = [], t = 0; t < x.length; t++) e.push(x[t]); + function Ka() { + for (var e = [], t = 0; t < w.length; t++) e.push(w[t]); e.sort(function(e, t) { return t.score - e.score }); for (var n, a, o = 1, t = 0; t < e.length; t++) { var r = e[t]; - a = o, (n = r).rank = a, n.element.querySelector(".player-score").textContent = R("$ points", n.score), (n = n.element.querySelector(".player-rank")).textContent = "#" + a, n.classList.remove("first"), n.classList.remove("second"), n.classList.remove("third"), 1 == a && n.classList.add("first"), 2 == a && n.classList.add("second"), 3 == a && n.classList.add("third"), t < e.length - 1 && r.score > e[t + 1].score && o++ + a = o, (n = r).rank = a, n.element.querySelector(".player-score").textContent = E("$ points", n.score), (n = n.element.querySelector(".player-rank")).textContent = "#" + a, n.classList.remove("first"), n.classList.remove("second"), n.classList.remove("third"), 1 == a && n.classList.add("first"), 2 == a && n.classList.add("second"), 3 == a && n.classList.add("third"), t < e.length - 1 && r.score > e[t + 1].score && o++ } } - function Pa(e, t) { + function Fa(e, t) { (e.guessed = t) ? e.element.classList.add("guessed"): e.element.classList.remove("guessed") } - function za(e, t) { + function Va(e, t) { e.element.drawing.style.display = t ? "block" : "none" } - for (var Ya = [], Ha = Qe.querySelectorAll('*[id^="item-"]'), Ua = 0; Ua < Ha.length; Ua++) { - var Ba = { - id: Ha[Ua].id.replace("item-settings-", ""), - element: Ha[Ua], - index: Ha[Ua].dataset.setting + for (var ja = [], Za = t.querySelectorAll('*[id^="item-"]'), Xa = 0; Xa < Za.length; Xa++) { + var Ja = { + id: Za[Xa].id.replace("item-settings-", ""), + element: Za[Xa], + index: Za[Xa].dataset.setting }; - Ha[Ua].item = Ba, Ya.push(Ba), D(Ha[Ua].item.element, "change", function() { + Za[Xa].item = Ja, ja.push(Ja), D(Za[Xa].item.element, "change", function() { var e = this.value; - "checkbox" == this.type && (e = this.checked ? 1 : 0), null != this.item.index && Zn(this.item.index, e, !0) + "checkbox" == this.type && (e = this.checked ? 1 : 0), null != this.item.index && ra(this.item.index, e, !0) }) } - let Ga = 10, - Fa = 4; - var _a = u.querySelector("#game-clock .text"), - ja = null, - Va = 0; + let Qa = 10, + eo = 4; + var to = c.querySelector("#game-clock .text"), + no = null, + ao = 0; - function Ka() { - ja && (clearInterval(ja), ja = null) + function oo() { + no && (clearInterval(no), no = null) } - function Za(e) { - Va = e, _a.textContent = Va + function ro(e) { + ao = e, to.textContent = ao } - var Xa, t = u.querySelector("#tutorial"), - Ja = t.querySelectorAll(".page"), - Qa = fe(t.querySelector(".navigation"), Ja.length, [t.querySelector(".pages")], function(e, t, n) { - n && clearInterval(eo); - for (var a = 0; a < Ja.length; a++) Ja[a].classList.remove("active"); - Ja[t].classList.add("active") + var io, lo = (t = c.querySelector("#tutorial")).querySelectorAll(".page"), + so = ge(t.querySelector(".navigation"), lo.length, [t.querySelector(".pages")], function(e, t, n) { + n && clearInterval(co); + for (var a = 0; a < lo.length; a++) lo[a].classList.remove("active"); + lo[t].classList.add("active") }), - eo = setInterval(function() { - Qa.selected < 4 ? ve(Qa, Qa.selected + 1, !1) : ve(Qa, 0, !1) + co = setInterval(function() { + so.selected < 4 ? ye(so, so.selected + 1, !1) : ye(so, 0, !1) }, 3500), - Qe = u.querySelector("#game-settings"); + t = c.querySelector("#game-settings"); - function to() { - var e = .01 * (e = h.innerHeight, "virtualKeyboard" in navigator && (e -= navigator.virtualKeyboard.boundingRect.height), e); - u.documentElement.style.setProperty("--vh", e + "px") + function uo() { + var e; + e = h.visualViewport ? h.visualViewport.height : h.innerHeight, "virtualKeyboard" in navigator && (e -= navigator.virtualKeyboard.boundingRect.height), c.documentElement.style.setProperty("--vh", e + "px") } - function no() { - b(R("Copied room link to clipboard!"), "", v($e), !0); - var e = "https://skribbl.io/?" + Ln; - if (navigator.clipboard) navigator.clipboard.writeText(e).then(function() { - console.log("Async: Copying to clipboard was successful!") - }, function(e) { - console.error("Async: Could not copy text: ", e) - }); - else { - var t = u.createElement("textarea"); - t.value = e, t.style.top = "0", t.style.left = "0", t.style.position = "fixed", u.body.appendChild(t), t.select(), t.focus(); - try { - var n = u.execCommand("copy"); - console.log("Copying link was " + (n ? "successful" : "unsuccessful")) - } catch (e) { - console.log("Unable to copy link " + e) - } - u.body.removeChild(t) - } + function ho() { + uo(), Ga() } - function ao() { - var e = "top" == p.mobileChatLayout; - Rn.classList.toggle("mobile-input-top", e) + function po() { + var e = "top" == l.mobileChatLayout; + On.classList.toggle("mobile-input-top", e) } - function oo(e, t) { + function mo(e, t) { e = e.querySelector(".characters"); 0 == (e.textContent = t) ? e.classList.remove("visible") : e.classList.add("visible") } - u.querySelector("#audio"), u.querySelector("#lightbulb"), D(Qe, "click", function() { - Me(g) + c.querySelector("#audio"), c.querySelector("#lightbulb"), D(t, "click", function() { + xe(p) }), "virtualKeyboard" in navigator && (navigator.virtualKeyboard.overlaysContent = !0, navigator.virtualKeyboard.addEventListener("geometrychange", e => { - to() - })), D(h, "resize", function() { - to(), Wa() - }), h.onunload = function() { - l && na() - }, D(u, "PointerEvent" in h ? "pointerdown" : "click", function(e) { - u.querySelector("#game-toolbar .sizes").contains(e.target) || Tt(), e.target != u.querySelector("#game-toolbar .color-preview-mobile") && tt.classList.remove("open") - }), D([Pn, zn], "change", ce), D(Yn, "click", + uo() + })), h.visualViewport ? (D(h.visualViewport, "resize", ho), a && D(h.visualViewport, "scroll", ho)) : D(h, "resize", ho), h.onunload = function() { + S && ua() + }, D(c, "PointerEvent" in h ? "pointerdown" : "click", function(e) { + if (e.target == m) return Me(), e.preventDefault(), !1; + He.elements.main.contains(e.target) ? e.preventDefault() : ("1" == ze.value && _n[1].blur(), c.querySelector("#game-toolbar .sizes").contains(e.target) || Yt(), e.target != c.querySelector("#game-toolbar .color-preview-mobile") && it.classList.remove("open")) + }), D([Kn, Fn], "change", se), D(Vn, "click", typo.joinLobby = function() { var t, e, n, a, o; n = h.location.href, - typo.lastConnect = Date.now(), o = "", n = n.split("?"), t = o = 1 < n.length ? (o = "" + n[1]).substring(0, a) : o, Dn || (e = "" != t ? "id=" + t : "lang=" + zn.value, Le(), Bn(!0), _n(function() { - Gn(Cn, e, function(e) { - Bn(!1), e.success && jn(e.data, t) + typo.lastConnect = Date.now(), o = "", n = n.split("?"), t = o = 1 < n.length ? (o = "" + n[1]).substring(0, a) : o, Nn || (e = "" != t ? "id=" + t : "lang=" + Fn.value, Me(), Jn(!0), ta(function() { + Qn(En, e, function(e) { + Jn(!1), e.success && na(e.data, t) }, !0) })) - }), D(Hn, "click", function() { - Dn || (Le(), Bn(!0), _n(function() { - Gn(Cn, "lang=" + zn.value, function(e) { - e.success ? jn(e.data, 0, 1) : Bn(!1) + }), D(jn, "click", function() { + Nn || (Me(), Jn(!0), ta(function() { + Qn(En, "lang=" + Fn.value, function(e) { + e.success ? na(e.data, 0, 1) : Jn(!1) }, !0) })) - }), D(u.querySelector("#game-rate .like"), "click", function() { - ea(1) - }), D(u.querySelector("#game-rate .dislike"), "click", function() { - ea(0) - }), D(u.querySelector("#button-start-game"), "click", function() { - if (l) { - var e = u.querySelector("#item-settings-customwords").value.split(","), + }), D(c.querySelector("#game-rate .like"), "click", function() { + ca(1) + }), D(c.querySelector("#game-rate .dislike"), "click", function() { + ca(0) + }), D(c.querySelector("#button-start-game"), "click", function() { + if (S) { + var e = c.querySelector("#item-settings-customwords").value.split(","), t = ""; if (5 <= e.length) { for (var n = 0; n < e.length; n++) e[n] = e[n].trim(); t = e.join(",") } - l.emit("data", { + S.emit("data", { id: 22, data: t }) } - }), D([u.querySelector("#button-invite"), u.querySelector("#modal-player-button-invite")], "click", no), D(y[m].querySelector("button.kick"), "click", function() { - Le(), null != s && s.id != M && l && l.emit("data", { + }), D([c.querySelector("#button-invite"), c.querySelector("#modal-player-button-invite")], "click", function() { + y(E("Copied room link to clipboard!"), "", f(De), !0); + var e = "https://skribbl.io/?" + Tn; + if (navigator.clipboard) navigator.clipboard.writeText(e).then(function() { + console.log("Async: Copying to clipboard was successful!") + }, function(e) { + console.error("Async: Could not copy text: ", e) + }); + else { + var t = c.createElement("textarea"); + t.value = e, t.style.top = "0", t.style.left = "0", t.style.position = "fixed", c.body.appendChild(t), t.select(), t.focus(); + try { + var n = c.execCommand("copy"); + console.log("Copying link was " + (n ? "successful" : "unsuccessful")) + } catch (e) { + console.log("Unable to copy link " + e) + } + c.body.removeChild(t) + } + }), D(g[s].querySelector("button.kick"), "click", function() { + Me(), null != N && N.id != x && S && S.emit("data", { id: 3, - data: s.id + data: N.id }) - }), D(y[m].querySelector("button.ban"), "click", function() { - Le(), null != s && s.id != M && l && l.emit("data", { + }), D(g[s].querySelector("button.ban"), "click", function() { + Me(), null != N && N.id != x && S && S.emit("data", { id: 4, - data: s.id + data: N.id }) - }), D(y[m].querySelector("button.votekick"), "click", function() { - Le(), null != s && s.id != M && l && (s.id == I ? b(R("You can not votekick the lobby owner!"), "", v(Ae), !0) : l.emit("data", { - id: da, - data: s.id + }), D(g[s].querySelector("button.votekick"), "click", function() { + Me(), null != N && N.id != x && S && (N.id == R ? y(E("You can not votekick the lobby owner!"), "", f(Ae), !0) : S.emit("data", { + id: ba, + data: N.id })) - }), D(y[m].querySelector("button.mute"), "click", function() { - null != s && s.id != M && (s.muted = !s.muted, Ta(s, 1, s.muted), s.muted ? b(R("You muted '$'!", s.name), "", v(Ae), !0) : b(R("You unmuted '$'!", s.name), "", v(Ae), !0), l && l.emit("data", { + }), D(g[s].querySelector("button.mute"), "click", function() { + null != N && N.id != x && (N.muted = !N.muted, Ba(N, 1, N.muted), N.muted ? y(E("You muted '$'!", N.name), "", f(Ae), !0) : y(E("You unmuted '$'!", N.name), "", f(Ae), !0), S && S.emit("data", { id: 7, - data: s.id - }), xe(s.muted)) - }), D(y[m].querySelector("button.report"), "click", function() { - y[m].querySelector(".buttons").style.display = "none", y[m].querySelector(".player").style.display = "none", y[m].querySelector(".report-menu").style.display = ""; - for (var e = y[m].querySelectorAll(".report-menu input"), t = 0; t < e.length; t++) e[t].checked = !1 - }), D(y[m].querySelector("button#report-send"), "click", function() { + data: N.id + }), qe(N.muted)) + }), D(g[s].querySelector("button.report"), "click", function() { + g[s].querySelector(".buttons").style.display = "none", g[s].querySelector(".player").style.display = "none", g[s].querySelector(".report-menu").style.display = ""; + for (var e = g[s].querySelectorAll(".report-menu input"), t = 0; t < e.length; t++) e[t].checked = !1 + }), D(g[s].querySelector("button#report-send"), "click", function() { var e = 0; - y[m].querySelector("#report-reason-toxic").checked && (e |= 1), y[m].querySelector("#report-reason-spam").checked && (e |= 2), y[m].querySelector("#report-reason-bot").checked && (e |= 4), 0 < e && (null != s && s.id != M && (s.reported = !0, l && l.emit("data", { + g[s].querySelector("#report-reason-toxic").checked && (e |= 1), g[s].querySelector("#report-reason-spam").checked && (e |= 2), g[s].querySelector("#report-reason-bot").checked && (e |= 4), 0 < e && (null != N && N.id != x && (N.reported = !0, S && S.emit("data", { id: 6, data: { - id: s.id, + id: N.id, reasons: e } - }), b(R("Your report for '$' has been sent!", s.name), "", v($e), !0)), Le()) - }), D(y[g].querySelector("#volume input"), "change", function(e) { - p.volume = e.target.value, N.setVolume(p.volume), N.playSound(bn), ce() - }), D(y[g].querySelector("#select-pressure-sensitivity"), "change", function(e) { - p.pressureSensitivity = e.target.value, ce() - }), D(y[g].querySelector("#select-mobile-chat-input"), "change", function(e) { - p.mobileChatLayout = e.target.value, ao(), ce() - }), D(y[g].querySelector("button.reset"), "click", function() { - for (var e = 0; e < d.length; e++) { - var t = d[e]; + }), y(E("Your report for '$' has been sent!", N.name), "", f(De), !0)), Me()) + }), D(g[p].querySelector("#volume input"), "change", function(e) { + l.volume = e.target.value, T.setVolume(l.volume), T.playSound(Mn), se() + }), D(g[p].querySelector("#select-pressure-sensitivity"), "change", function(e) { + l.pressureSensitivity = e.target.value, se() + }), D(g[p].querySelector("#select-mobile-chat-input"), "change", function(e) { + l.mobileChatLayout = e.target.value, po(), se() + }), D(g[p].querySelector("button.reset"), "click", function() { + for (var e = 0; e < u.length; e++) { + var t = u[e]; t.key = t.def, t.listing.querySelector("input").value = t.key; for (var n = 0; n < t.changed.length; n++) t.changed[n](t) } - se() - }), D(Wn[1], "focus", function(e) { - to(), Rn.classList.add("mobile-input-focus") - }), D(Wn[1], "blur", function(e) { - to(), Rn.classList.remove("mobile-input-focus") - }), D(Wn, "input", function(e) { - oo(this.parentNode, this.value.length) - }), D(Nn, "submit", function(e) { + ie() + }), D(_n[1], "focus", function(e) { + function t(e) { + h.removeEventListener("scroll", t), h.scroll(0, 0), e.preventDefault() + } + uo(), On.classList.add("mobile-input-focus"), a && (h.addEventListener("scroll", t), setTimeout(function() { + t(e) + }, 200), e.preventDefault()) + }), D(_n[1], "blur", function(e) { + uo(), On.classList.remove("mobile-input-focus") + }), D(_n, "input", function(e) { + mo(this.parentNode, this.value.length) + }), D(Bn, "submit", function(e) { const input = this.querySelector("input"); let rest = input.value.substring(100); input.value = input.value.substring(0,100); if(rest.length > 0) setTimeout(()=>{input.value = rest; this.dispatchEvent(new Event("submit"));},180); e.preventDefault(); var e = this.querySelector("input"); - return e.value && (e = e.value, l && l.connected ? l.emit("data", { - id: Ma, + return e.value && (e = e.value, S && S.connected ? S.emit("data", { + id: Na, data: e - }) : Aa(O(M), e)), this.reset(), oo(this, 0), !1 - }), to(), h.localStorageAvailable ? (Pn.value = a("name", ""), zn.value = (e => { - for (var t = u.querySelectorAll("#home .panel .container-name-lang select option"), n = 0; n < t.length; n++) + }) : Ua(O(x), e)), this.reset(), mo(this, 0), !1 + }), uo(), h.localStorageAvailable ? (Kn.value = le("name", ""), Fn.value = (e => { + for (var t = c.querySelectorAll("#home .panel .container-name-lang select option"), n = 0; n < t.length; n++) if (t[n].value == e) return t[n].value; return 0 - })(a("lang", 0)), p.displayLang = a("displaylang", "en"), p.volume = parseInt(a("volume", 100)), p.filterChat = 1 == parseInt(a("filter", 1)) ? 1 : 0, p.pressureSensitivity = 1 == parseInt(a("pressure", 1)) ? 1 : 0, p.avatar = (t = "ava", Qe = p.avatar, null == (t = c.getItem(t)) ? Qe : JSON.parse(t)), p.mobileChatLayout = a("mobileChatLayout", "bottom"), y[g].querySelector("#select-mobile-chat-input").value = p.mobileChatLayout, y[g].querySelector("#volume input").value = p.volume, N.setVolume(p.volume), ao(), console.log("Settings loaded.")) : console.log("Settings not loaded. LocalStorage unavailable."); - for (var ro = u.querySelectorAll("[data-translate]"), io = 0; io < ro.length; io++) { - var lo = ro[io]; - Be(lo, lo.dataset.translate) + })(le("lang", 0)), l.displayLang = le("displaylang", "en"), l.volume = parseInt(le("volume", 100)), l.filterChat = 1 == parseInt(le("filter", 1)) ? 1 : 0, l.pressureSensitivity = 1 == parseInt(le("pressure", 1)) ? 1 : 0, l.avatar = (t = "ava", Vn = l.avatar, null == (t = d.getItem(t)) ? Vn : JSON.parse(t)), l.mobileChatLayout = le("mobileChatLayout", "bottom"), ze.value = le("keyboard", a ? 1 : 0), Ue.value = le("keyboardlayout", "en"), _e(), g[p].querySelector("#select-mobile-chat-input").value = l.mobileChatLayout, g[p].querySelector("#volume input").value = l.volume, T.setVolume(l.volume), po(), console.log("Settings loaded.")) : console.log("Settings not loaded. LocalStorage unavailable."); + for (var go = c.querySelectorAll("[data-translate]"), fo = 0; fo < go.length; fo++) { + var yo = go[fo]; + je(yo, yo.dataset.translate) } - for (var so = Ye[p.displayLang], co = 0; co < He.length; co++) { - var uo = He[co], - ho = Ue(so, uo.key); - "text" == uo.type && (uo.element.textContent = ho), "placeholder" == uo.type && (uo.element.placeholder = ho) + for (var vo = Ke[l.displayLang], bo = 0; bo < Fe.length; bo++) { + var So = Fe[bo], + ko = Ve(vo, So.key); + "text" == So.type && (So.element.textContent = ko), "placeholder" == So.type && (So.element.placeholder = ko) } - function po(e) { - Xa.parts[e].classList.remove("bounce"), Xa.parts[e].offsetWidth, Xa.parts[e].classList.add("bounce") + function wo(e) { + io.parts[e].classList.remove("bounce"), io.parts[e].offsetWidth, io.parts[e].classList.add("bounce") } - D(Yn = u.querySelectorAll("[data-tooltip]"), "pointerenter", function(e) { - Pe(e.target) - }), D(Yn, "pointerleave", function(e) { - ze() - }), Nn = (Hn = u.querySelector("#home .avatar-customizer")).querySelector(".container"), Qe = Hn.querySelectorAll(".arrows.left .arrow"), t = Hn.querySelectorAll(".arrows.right .arrow"), Hn = Hn.querySelectorAll(".randomize"), (Xa = he(p.avatar)).classList.add("fit"), Nn.appendChild(Xa), D(Qe, "click", function() { + D(jn = c.querySelectorAll("[data-tooltip]"), "pointerenter", function(e) { + Oe(e.target) + }), D(jn, "pointerleave", function(e) { + Pe() + }), Vn = (Bn = c.querySelector("#home .avatar-customizer")).querySelector(".container"), t = Bn.querySelectorAll(".arrows.left .arrow"), jn = Bn.querySelectorAll(".arrows.right .arrow"), Bn = Bn.querySelectorAll(".randomize"), (io = ue(l.avatar)).classList.add("fit"), Vn.appendChild(io), D(t, "click", function() { var e = parseInt(this.dataset.avatarIndex); - --p.avatar[e], p.avatar[e] < 0 && (p.avatar[e] = n[e] - 1), po(e), pe(Xa, p.avatar), ce() - }), D(t, "click", function() { + --l.avatar[e], l.avatar[e] < 0 && (l.avatar[e] = n[e] - 1), wo(e), he(io, l.avatar), se() + }), D(jn, "click", function() { var e = parseInt(this.dataset.avatarIndex); - p.avatar[e] += 1, p.avatar[e] >= n[e] && (p.avatar[e] = 0), po(e), pe(Xa, p.avatar), ce() - }), D(Hn, "click", function() { - p.avatar[0] = Math.floor(Math.random() * n[0]), p.avatar[1] = Math.floor(Math.random() * n[1]), p.avatar[2] = Math.floor(Math.random() * n[2]), po(1), po(2), pe(Xa, p.avatar), ce() + l.avatar[e] += 1, l.avatar[e] >= n[e] && (l.avatar[e] = 0), wo(e), he(io, l.avatar), se() + }), D(Bn, "click", function() { + l.avatar[0] = Math.floor(Math.random() * n[0]), l.avatar[1] = Math.floor(Math.random() * n[1]), l.avatar[2] = Math.floor(Math.random() * n[2]), wo(1), wo(2), he(io, l.avatar), se() }); - for (var mo = Math.round(8 * Math.random()), go = u.querySelector("#home .logo-big .avatar-container"), fo = 0; fo < 8; fo++) { - var yo = [0, 0, 0, -1], - yo = (yo[0] = fo, yo[1] = Math.round(100 * Math.random()) % Y, yo[2] = Math.round(100 * Math.random()) % H, 100 * Math.random() < 1 && (yo[3] = Math.floor(20 * Math.random())), Un && 100 * Math.random() < 35 && (yo[3] = 96 + Math.floor(4 * Math.random())), he(yo, mo == fo)); - yo.index = fo, go.appendChild(yo), D(yo, "click", function() { + for (var Co = Math.round(8 * Math.random()), qo = c.querySelector("#home .logo-big .avatar-container"), xo = 0; xo < 8; xo++) { + var Mo = [0, 0, 0, -1], + Mo = (Mo[0] = xo, Mo[1] = Math.round(100 * Math.random()) % z, Mo[2] = Math.round(100 * Math.random()) % U, 100 * Math.random() < 1 && (Mo[3] = Math.floor(20 * Math.random())), Zn && 100 * Math.random() < 35 && (Mo[3] = 96 + Math.floor(4 * Math.random())), ue(Mo, Co == xo)); + Mo.index = xo, qo.appendChild(Mo), D(Mo, "click", function() { var e = [this.index, 0, 0, -1]; - e[1] = Math.round(100 * Math.random()) % Y, e[2] = Math.round(100 * Math.random()) % H, 1e3 * Math.random() < 10 && (e[3] = Math.floor(20 * Math.random())), pe(this, e), this.classList.remove("clicked"), this.offsetWidth, this.classList.add("clicked") + e[1] = Math.round(100 * Math.random()) % z, e[2] = Math.round(100 * Math.random()) % U, 1e3 * Math.random() < 10 && (e[3] = Math.floor(20 * Math.random())), he(this, e), this.classList.remove("clicked"), this.offsetWidth, this.classList.add("clicked") }) } document.dispatchEvent(new Event("skribblInitialized")); document.body.setAttribute("typo-skribbl-loaded", "true"); diff --git a/manifest.json b/manifest.json index 56e49e1..ce1634f 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Skribbl Typo", "description": "The most complete toolbox for skribbl.io with namefinder & Discord integration", - "version": "26.3.10", + "version": "26.3.11", "author": "tobeh", "icons": { "256": "res/icon/256MaxFit.png",