Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 85.50 KB | None | 0 0
  1. var instaban = !1;
  2. void 0 !== window.App && (instaban = !0);
  3. window.App = function() {
  4. var A = function(a, b, c) {
  5. var d = function(a, b, c) {
  6. var d = new Date;
  7. b = escape(b);
  8. d.setDate(d.getDate() + c);
  9. b += null === c ? "" : "; expires\x3d" + d.toUTCString();
  10. document.cookie = a + "\x3d" + b
  11. };
  12. return {
  13. haveSupport: null,
  14. support: function() {
  15. if (null === this.haveSupport) try {
  16. a.setItem("test", 1), this.haveSupport = 1 == a.getItem("test"), a.removeItem("test")
  17. } catch (e) {
  18. this.haveSupport = !1
  19. }
  20. return this.haveSupport
  21. },
  22. get: function(c) {
  23. if (this.support()) c = a.getItem(c);
  24. else a: {
  25. c = b + c;
  26. var d, e, q, v = document.cookie.split(";");
  27. for (d = 0; d < v.length; d++)
  28. if (e = v[d].substr(0, v[d].indexOf("\x3d")), q = v[d].substr(v[d].indexOf("\x3d") + 1), e = e.replace(/^\s+|\s+$/g, ""), e == c) {
  29. c = unescape(q);
  30. break a
  31. }
  32. c = void 0
  33. }
  34. void 0 === c && (c = null);
  35. try {
  36. return JSON.parse(c)
  37. } catch (N) {
  38. return null
  39. }
  40. },
  41. set: function(e, f) {
  42. f = JSON.stringify(f);
  43. this.support() ? a.setItem(e, f) : d(b + e, f, c)
  44. },
  45. remove: function(c) {
  46. this.support() ? a.removeItem(c) : d(b + c, "", -1)
  47. }
  48. }
  49. },
  50. J = function(a, b, c) {
  51. var d = new XMLHttpRequest;
  52. d.open("GET", a, !0);
  53. d.responseType = "arraybuffer";
  54. d.onload = function(a) {
  55. 4 == d.readyState &&
  56. (200 == d.status ? d.response && (a = new Uint8Array(d.response), b(a)) : c && c())
  57. };
  58. d.send(null)
  59. },
  60. K = function(a, b) {
  61. try {
  62. return new ImageData(a, b)
  63. } catch (d) {
  64. var c = document.createElement("canvas");
  65. c.width = a;
  66. c.height = b;
  67. return c.getContext("2d").getImageData(0, 0, a, b)
  68. }
  69. },
  70. u = function() {
  71. window.ga && window.ga.apply(this, arguments)
  72. },
  73. r = navigator.userAgent,
  74. w = function() {
  75. var a = function(a, c, d, e) {
  76. var b = document.createElement("div");
  77. return c && (b.style.imageRendering = a + "crisp-edges", b.style.imageRendering === a + "crisp-edges") || d && (b.style.imageRendering =
  78. a + "pixelated", b.style.imageRendering === a + "pixelated") || e && (b.style.imageRendering = a + "optimize-contrast", b.style.imageRendering === a + "optimize-contrast") ? !0 : !1
  79. };
  80. return a("", !0, !0, !1) || a("-o-", !0, !1, !1) || a("-moz-", !0, !1, !1) || a("-webkit-", !0, !1, !0)
  81. }(),
  82. B = !1,
  83. x = r.match(/(iPod|iPhone|iPad)/i) && r.match(/AppleWebKit/i),
  84. M = r.match(/safari/i) && !r.match(/chrome/i),
  85. r = -1 < r.indexOf("Edge");
  86. x ? (x = parseFloat(("" + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0, ""])[1]).replace("undefined",
  87. "3_2").replace("_", ".").replace("_", "")) || !1, w = !1, 11 <= x && (B = !0)) : M && (w = !1, B = !0);
  88. r && (w = !1);
  89. var g = A(localStorage, "ls_", 99),
  90. C = A(sessionStorage, "ss_", null),
  91. m = function() {
  92. var a = {
  93. params: {},
  94. initialized: !1,
  95. _trigger: function(a, c, d) {
  96. $(window).trigger("pxls:queryUpdated", [a, c, d])
  97. },
  98. _update: function(b) {
  99. var c = window.location.hash.substring(1);
  100. 0 < window.location.search.length && (c += "\x26" + window.location.search.substring(1));
  101. var d = {};
  102. c.split("\x26").forEach(function(a) {
  103. a = a.split("\x3d");
  104. var b = a.shift().toLowerCase();
  105. b.length && (d[b] = a.shift())
  106. });
  107. for (var e = Object.keys(d), c = 0; c < e.length; c++) {
  108. var f = e[c],
  109. F = d[f];
  110. if (!0 === b) {
  111. if (!a.params.hasOwnProperty(f) || a.params[f] !== d[f]) {
  112. var q = a.params[f];
  113. a.params[f] = null == d[f] ? null : d[f].toString();
  114. a._trigger(f, q, F)
  115. }
  116. } else a.params.hasOwnProperty(f) || (a.params[f] = d[f])
  117. }!0 === b && Object.keys(a.params).filter(function(a) {
  118. return !e.includes(a)
  119. }).forEach(function(b) {
  120. return a.remove(b)
  121. });
  122. window.location.search.substring(1) && (window.location = window.location.pathname + "#" + a.getStr())
  123. },
  124. setIfDifferent: function(b,
  125. c, d) {
  126. var e = {},
  127. f = !1;
  128. "string" === typeof b ? (f = d, e[b] = c) : "object" === typeof b && (e = b, f = c);
  129. f = null == f ? !1 : !0 === f;
  130. b = Object.entries(e);
  131. for (c = 0; c < b.length; c++) d = b[c][0], e = b[c][1].toString(), a.get(d) !== e && a.set(d, e, f)
  132. },
  133. init: function() {
  134. C.get("url_params") ? (window.location.hash = C.get("url_params"), C.remove("url_params")) : (a._update(), "replaceState" in window.history && (window.onhashchange = function() {
  135. a._update(!0)
  136. }))
  137. },
  138. has: function(b) {
  139. return null != a.get(b)
  140. },
  141. getStr: function() {
  142. var b = [],
  143. c;
  144. for (c in a.params)
  145. if (a.params.hasOwnProperty(c)) {
  146. var d =
  147. encodeURIComponent(c);
  148. if (null !== a.params[c]) {
  149. var e = decodeURIComponent(a.params[c]),
  150. f = a.params[c];
  151. e === f && (f = encodeURIComponent(f));
  152. d += "\x3d" + f
  153. }
  154. b.push(d)
  155. }
  156. return b.join("\x26")
  157. },
  158. update: function() {
  159. var b = a.getStr();
  160. window.history.replaceState ? window.history.replaceState(null, null, "#" + b) : window.location.hash = b
  161. },
  162. set: function(b, c, d) {
  163. var e = a.params[b];
  164. a.params[b] = c.toString();
  165. !0 !== d && a._trigger(b, e, c.toString());
  166. a.lazy_update()
  167. },
  168. get: function(b) {
  169. return a.params[b]
  170. },
  171. remove: function(b, c) {
  172. delete a.params[b];
  173. a.lazy_update();
  174. !0 !== c && a._trigger(b, a.params[b], null)
  175. },
  176. timer: null,
  177. lazy_update: function() {
  178. null !== a.timer && clearTimeout(a.timer);
  179. a.timer = setTimeout(function() {
  180. a.timer = null;
  181. a.update()
  182. }, 200)
  183. }
  184. };
  185. return {
  186. init: a.init,
  187. get: a.get,
  188. set: a.setIfDifferent,
  189. has: a.has,
  190. update: a.update,
  191. remove: a.remove,
  192. lazy_update: a.lazy_update
  193. }
  194. }(),
  195. y = function() {
  196. var a = {
  197. bad_src: [/^https?:\/\/[^\/]*raw[^\/]*git[^\/]*\/(metonator|Deklost|NomoX|RogerioBlanco)/gi, /^chrome\-extension:\/\/lmleofkkoohkbgjikogbpmnjmpdedfil/gi, /^https?:\/\/.*mlpixel\.org/gi],
  198. bad_events: ["mousedown",
  199. "mouseup", "click"
  200. ],
  201. checkSrc: function(b) {
  202. for (var c = 0; c < a.bad_src.length; c++) b.match(a.bad_src[c]) && a.shadow()
  203. },
  204. init: function() {
  205. setInterval(a.update, 5E3);
  206. var b = window.WebSocket;
  207. window.WebSocket = function(c, d) {
  208. a.shadow();
  209. return new b(c, d)
  210. };
  211. window.MouseEvent = function() {
  212. a.me()
  213. };
  214. var c = window.Event;
  215. window.Event = function(b, d) {
  216. -1 !== a.bad_events.indexOf(b.toLowerCase()) && a.shadow();
  217. return new c(b, d)
  218. };
  219. var d = window.CustomEvent;
  220. window.CustomEvent = function(b, c) {
  221. -1 !== a.bad_events.indexOf(b.toLowerCase()) && a.shadow();
  222. return new d(b, c)
  223. };
  224. var e = window.document.createEvent;
  225. document.createEvent = function(b, c) {
  226. -1 !== a.bad_events.indexOf(b.toLowerCase()) && a.shadow();
  227. return e(b, c)
  228. };
  229. $(window).on("DOMNodeInserted", function(b) {
  230. "SCRIPT" == b.target.nodeName && a.checkSrc(b.target.src)
  231. });
  232. $("script").map(function() {
  233. a.checkSrc(this.src)
  234. })
  235. },
  236. shadow: function() {
  237. h.send('{"type":"shadowbanme"}')
  238. },
  239. me: function() {
  240. h.send('{"type":"banme"}');
  241. h.close();
  242. window.location.href = "https://www.youtube.com/watch?v\x3dQHvKSo4BFi0"
  243. },
  244. update: function() {
  245. var b =
  246. function() {
  247. a.me()
  248. };
  249. window.App.attemptPlace = window.App.doPlace = b;
  250. document.autoPxlsScriptRevision && b();
  251. document.autoPxlsScriptRevision_ && b();
  252. document.autoPxlsRandomNumber && b();
  253. document.RN && b();
  254. window.AutoPXLS && b();
  255. window.AutoPXLS2 && b();
  256. document.defaultCaptchaFaviconSource && b();
  257. window.CFS && b();
  258. $("div.info").find("#autopxlsinfo").length && b();
  259. window.xD && b();
  260. window.vdk && b();
  261. $(".botpanel").length && b();
  262. window.Notabot && b();
  263. $("div:contains(Настройки)").length && b();
  264. window.Botnet && b();
  265. window.DrawIt && b();
  266. window.NomoXBot &&
  267. b()
  268. }
  269. };
  270. return {
  271. init: a.init,
  272. shadow: a.shadow,
  273. me: a.me
  274. }
  275. }(),
  276. h = function() {
  277. var a = {
  278. ws: null,
  279. ws_constructor: WebSocket,
  280. hooks: [],
  281. wps: WebSocket.prototype.send,
  282. wpc: WebSocket.prototype.close,
  283. reconnect: function() {
  284. $("#reconnecting").show();
  285. setTimeout(function() {
  286. $.get(window.location.pathname + "?_" + (new Date).getTime(), function() {
  287. window.location.reload()
  288. }).fail(function() {
  289. console.log("Server still down...");
  290. a.reconnect()
  291. })
  292. }, 3E3)
  293. },
  294. reconnectSocket: function() {
  295. a.ws.onclose = function() {};
  296. a.connectSocket()
  297. },
  298. connectSocket: function() {
  299. var b =
  300. window.location;
  301. a.ws = new a.ws_constructor(("https:" === b.protocol ? "wss://" : "ws://") + b.host + b.pathname + "ws");
  302. a.ws.onmessage = function(b) {
  303. var c = JSON.parse(b.data);
  304. $.map(a.hooks, function(a) {
  305. a.type === c.type && a.fn(c)
  306. })
  307. };
  308. a.ws.onclose = function() {
  309. a.reconnect()
  310. }
  311. },
  312. init: function() {
  313. null === a.ws && (a.connectSocket(), $(window).on("beforeunload", function() {
  314. a.ws.onclose = function() {};
  315. a.close()
  316. }), $("#board-container").show(), $("#ui").show(), $("#loading").fadeOut(500), z.wsinit())
  317. },
  318. on: function(b, c) {
  319. a.hooks.push({
  320. type: b,
  321. fn: c
  322. })
  323. },
  324. close: function() {
  325. a.ws.close = a.wpc;
  326. a.ws.close()
  327. },
  328. send: function(b) {
  329. a.ws.send = a.wps;
  330. "string" == typeof b ? a.ws.send(b) : a.ws.send(JSON.stringify(b))
  331. }
  332. };
  333. return {
  334. init: a.init,
  335. on: a.on,
  336. send: a.send,
  337. close: a.close,
  338. reconnect: a.reconnect,
  339. reconnectSocket: a.reconnectSocket
  340. }
  341. }(),
  342. k = function() {
  343. var a = {
  344. elements: {
  345. board: $("#board"),
  346. board_render: null,
  347. mover: $("#board-mover"),
  348. zoomer: $("#board-zoomer"),
  349. container: $("#board-container")
  350. },
  351. ctx: null,
  352. use_js_render: !w && !B,
  353. use_zoom: !w && B,
  354. width: 0,
  355. height: 0,
  356. scale: 1,
  357. id: null,
  358. intView: null,
  359. pan: {
  360. x: 0,
  361. y: 0
  362. },
  363. allowDrag: !0,
  364. pannedWithKeys: !1,
  365. rgbPalette: [],
  366. loaded: !1,
  367. pixelBuffer: [],
  368. holdTimer: {
  369. id: -1,
  370. holdTimeout: 500,
  371. handler: function(b) {
  372. a.holdTimer.id = -1;
  373. G.runLookup(b.x, b.y)
  374. }
  375. },
  376. centerOn: function(b, c) {
  377. a.pan.x = a.width / 2 - b;
  378. a.pan.y = a.height / 2 - c;
  379. a.update()
  380. },
  381. replayBuffer: function() {
  382. $.map(a.pixelBuffer, function(b) {
  383. a.setPixel(b.x, b.y, b.c, !1)
  384. });
  385. a.refresh();
  386. a.pixelBuffer = []
  387. },
  388. draw: function(b) {
  389. a.id = K(a.width, a.height);
  390. a.ctx.mozImageSmoothingEnabled = a.ctx.webkitImageSmoothingEnabled = a.ctx.msImageSmoothingEnabled =
  391. a.ctx.imageSmoothingEnabled = !1;
  392. a.intView = new Uint32Array(a.id.data.buffer);
  393. a.rgbPalette = l.getPaletteRGB();
  394. for (var c = 0; c < a.width * a.height; c++) a.intView[c] = 255 == b[c] ? 0 : a.rgbPalette[b[c]];
  395. a.ctx.putImageData(a.id, 0, 0);
  396. a.update();
  397. a.loaded = !0;
  398. a.replayBuffer()
  399. },
  400. initInteraction: function() {
  401. function b(b) {
  402. var c, d, q = !0;
  403. b.changedTouches && b.changedTouches[0] ? (c = b.changedTouches[0].clientX, d = b.changedTouches[0].clientY) : (c = b.clientX, d = b.clientY, null != b.button && (q = 0 === b.button));
  404. e = c;
  405. f = d;
  406. q && -1 === a.holdTimer.id && (a.holdTimer.id =
  407. setTimeout(a.holdTimer.handler, a.holdTimer.holdTimeout, {
  408. x: c,
  409. y: d
  410. }));
  411. g = Date.now()
  412. }
  413.  
  414. function c(b) {
  415. if (-1 !== a.holdTimer.id) {
  416. var c;
  417. b.changedTouches && b.changedTouches[0] ? (c = b.changedTouches[0].clientX, b = b.changedTouches[0].clientY) : (c = b.clientX, b = b.clientY);
  418. if (5 < Math.abs(e - c) || 5 < Math.abs(f - b)) clearTimeout(a.holdTimer.id), a.holdTimer.id = -1
  419. }
  420. }
  421. var d = function(b) {
  422. a.allowDrag && (a.pan.x += b.dx / a.scale, a.pan.y += b.dy / a.scale, a.update())
  423. };
  424. interact(a.elements.container[0]).draggable({
  425. inertia: !0,
  426. onmove: d
  427. }).gesturable({
  428. onmove: function(b) {
  429. a.scale *=
  430. 1 + b.ds;
  431. d(b)
  432. }
  433. });
  434. $(document.body).on("keydown", function(b) {
  435. switch (b.key || b.keyCode) {
  436. case "w":
  437. case "W":
  438. case "ArrowUp":
  439. case 87:
  440. case 38:
  441. a.pan.y += 100 / a.scale;
  442. break;
  443. case "d":
  444. case "D":
  445. case "ArrowRight":
  446. case 68:
  447. case 39:
  448. a.pan.x -= 100 / a.scale;
  449. break;
  450. case "s":
  451. case "S":
  452. case "ArrowDown":
  453. case 83:
  454. case 40:
  455. a.pan.y -= 100 / a.scale;
  456. break;
  457. case "a":
  458. case "A":
  459. case "ArrowLeft":
  460. case 65:
  461. case 37:
  462. a.pan.x += 100 / a.scale;
  463. break;
  464. case "e":
  465. case "E":
  466. case "\x3d":
  467. case 187:
  468. case 69:
  469. case 171:
  470. a.nudgeScale(1);
  471. break;
  472. case "q":
  473. case "Q":
  474. case "-":
  475. case 189:
  476. case 81:
  477. case 173:
  478. a.nudgeScale(-1);
  479. break;
  480. case "p":
  481. case "P":
  482. case 80:
  483. a.save();
  484. break;
  485. case "l":
  486. case "L":
  487. case 76:
  488. a.allowDrag = !a.allowDrag;
  489. break;
  490. case "j":
  491. case "J":
  492. case 74:
  493. 1 > l.color ? l.switch(l.getPaletteRGB().length - 1) : l.switch(l.color - 1);
  494. break;
  495. case "k":
  496. case "K":
  497. case 75:
  498. l.color + 1 >= l.getPaletteRGB().length ? l.switch(0) : l.switch(l.color + 1)
  499. }
  500. a.pannedWithKeys = !0;
  501. a.update()
  502. });
  503. a.elements.container[0].addEventListener("wheel", function(b) {
  504. if (a.allowDrag) {
  505. var c = a.scale;
  506. 0 < b.deltaY ? a.nudgeScale(-1) : a.nudgeScale(1);
  507. if (c !== a.scale) {
  508. var d = b.clientX - a.elements.container.width() /
  509. 2;
  510. b = b.clientY - a.elements.container.height() / 2;
  511. a.pan.x -= d / c;
  512. a.pan.x += d / a.scale;
  513. a.pan.y -= b / c;
  514. a.pan.y += b / a.scale;
  515. a.update();
  516. l.update()
  517. }
  518. }
  519. }, {
  520. passive: !0
  521. });
  522. var e, f, g;
  523. a.elements.board_render.on("pointerdown mousedown", b).on("pointermove mousemove", c).on("pointerup mouseup touchend", function(b) {
  524. if (!0 !== b.shiftKey) {
  525. -1 !== a.holdTimer.id && clearTimeout(a.holdTimer.id);
  526. a.holdTimer.id = -1;
  527. var c = !1,
  528. d = b.clientX,
  529. h = b.clientY,
  530. k = Date.now() - g;
  531. "touchend" === b.type && (c = !0, d = b.changedTouches[0].clientX, h = b.changedTouches[0].clientY);
  532. var F = Math.abs(f - h);
  533. 5 > Math.abs(e - d) && 5 > F && (0 === b.button || c) && 500 > k && (b = a.fromScreen(d, h), l.place(b.x | 0, b.y | 0))
  534. }
  535. }).contextmenu(function(a) {
  536. a.preventDefault();
  537. l.switch(-1)
  538. });
  539. a.elements.board_render[0].addEventListener("touchstart", b, {
  540. passive: !1
  541. });
  542. a.elements.board_render[0].addEventListener("touchmove", c, {
  543. passive: !1
  544. })
  545. },
  546. init: function() {
  547. $(window).on("pxls:queryUpdated", function(a, c, d, e) {
  548. switch (c.toLowerCase()) {
  549. case "x":
  550. case "y":
  551. k.centerOn(m.get("x") >> 0, m.get("y") >> 0);
  552. break;
  553. case "scale":
  554. k.setScale(e >> 0);
  555. break;
  556. case "template":
  557. p.queueUpdate({
  558. template: e,
  559. use: null !== e
  560. });
  561. break;
  562. case "ox":
  563. p.queueUpdate({
  564. ox: null === e ? null : e >> 0
  565. });
  566. break;
  567. case "oy":
  568. p.queueUpdate({
  569. oy: null === e ? null : e >> 0
  570. });
  571. break;
  572. case "tw":
  573. p.queueUpdate({
  574. tw: null === e ? null : e >> 0
  575. });
  576. break;
  577. case "oo":
  578. a = parseFloat(e), Number.isFinite(a) || (a = null), p.queueUpdate({
  579. oo: null === a ? null : a
  580. })
  581. }
  582. });
  583. $("#ui").hide();
  584. a.elements.container.hide();
  585. a.use_js_render ? (a.elements.board_render = $("\x3ccanvas\x3e").css({
  586. width: "100vw",
  587. height: "100vh",
  588. margin: 0,
  589. marginTop: 3
  590. }), a.elements.board.parent().append(a.elements.board_render),
  591. a.elements.board.detach()) : a.elements.board_render = a.elements.board;
  592. a.ctx = a.elements.board[0].getContext("2d");
  593. a.initInteraction()
  594. },
  595. start: function() {
  596. $.get("/info", function(b) {
  597. H.webinit(b);
  598. z.webinit(b);
  599. a.width = b.width;
  600. a.height = b.height;
  601. l.setPalette(["#820080","#FF00FF","#CF6EE4","#0000EA","#0083C7","#00D3DD","#005F00","#02BE01","#94E044","#E5D900","#604028","#A06A42","#E59500","#F6B389","#FFDDCA","#800000","#E50000","#FFA7D1","#000000","#222222","#555555","#888888","#CDCDCD","#FFFFFF"]);
  602. t.setMax(b.maxStacked);
  603. b.captchaKey && ($(".g-recaptcha").attr("data-sitekey", b.captchaKey), $.getScript("https://www.google.com/recaptcha/api.js"));
  604. a.elements.board.attr({
  605. width: a.width,
  606. height: a.height
  607. });
  608. b = m.get("x") || a.width / 2;
  609. var c = m.get("y") ||
  610. a.height / 2;
  611. a.scale = m.get("scale") || a.scale;
  612. a.centerOn(b, c);
  613. h.init();
  614. J("/boarddata?_" + (new Date).getTime(), a.draw, h.reconnect);
  615. a.use_js_render ? $(window).resize(function() {
  616. a.update()
  617. }).resize() : $(window).resize(function() {
  618. l.update();
  619. D.update()
  620. });
  621. (b = m.get("template")) && p.queueUpdate({
  622. use: !0,
  623. x: parseFloat(m.get("ox")),
  624. y: parseFloat(m.get("oy")),
  625. opacity: parseFloat(m.get("oo")),
  626. width: parseFloat(m.get("tw")),
  627. url: b
  628. });
  629. var d = parseFloat(m.get("spin"));
  630. if (d) {
  631. var d = 360 / (1E3 * d),
  632. e = 0,
  633. f = null,
  634. g = function(b) {
  635. f || (f = b);
  636. e += d * (b - f);
  637. e %= 360;
  638. f = b;
  639. a.elements.container.css("transform", "rotate(" + e + "deg)");
  640. window.requestAnimationFrame(g)
  641. };
  642. window.requestAnimationFrame(g)
  643. }
  644. }).fail(function() {
  645. h.reconnect()
  646. })
  647. },
  648. update: function(b) {
  649. a.pan.x = Math.min(a.width / 2, Math.max(-a.width / 2, a.pan.x));
  650. a.pan.y = Math.min(a.height / 2, Math.max(-a.height / 2, a.pan.y));
  651. m.set({
  652. x: Math.round(a.width / 2 - a.pan.x),
  653. y: Math.round(a.height / 2 - a.pan.y),
  654. scale: Math.round(100 * a.scale) / 100
  655. }, !0);
  656. if (a.use_js_render) {
  657. b = a.elements.board_render[0].getContext("2d");
  658. var c = -a.pan.x +
  659. (a.width - window.innerWidth / a.scale) / 2,
  660. d = -a.pan.y + (a.height - window.innerHeight / a.scale) / 2,
  661. e = 0,
  662. f = 0,
  663. g = 0,
  664. h = 0,
  665. k = window.innerWidth / a.scale,
  666. n = window.innerHeight / a.scale;
  667. 0 > c && (e = -c, c = 0, k -= e, g += e);
  668. 0 > d && (f = -d, d = 0, n -= f, h += f);
  669. c + k > a.width && (g += k + c - a.width, k = a.width - c);
  670. d + n > a.height && (h += n + d - a.height, n = a.height - d);
  671. b.canvas.width = window.innerWidth;
  672. b.canvas.height = window.innerHeight;
  673. b.mozImageSmoothingEnabled = b.webkitImageSmoothingEnabled = b.msImageSmoothingEnabled = b.imageSmoothingEnabled = 1 > Math.abs(a.scale);
  674. b.globalAlpha =
  675. 1;
  676. b.fillStyle = "#CCCCCC";
  677. b.fillRect(0, 0, b.canvas.width, b.canvas.height);
  678. b.drawImage(a.elements.board[0], c, d, k, n, 0 + e * a.scale, 0 + f * a.scale, window.innerWidth - g * a.scale, window.innerHeight - h * a.scale);
  679. p.draw(b, c, d);
  680. l.update();
  681. D.update();
  682. return !0
  683. }
  684. if (b) return !1;
  685. 1 > Math.abs(a.scale) ? a.elements.board.removeClass("pixelate") : a.elements.board.addClass("pixelate");
  686. (a.allowDrag || !a.allowDrag && a.pannedWithKeys) && a.elements.mover.css({
  687. width: a.width,
  688. height: a.height,
  689. transform: "translate(" + a.pan.x + "px, " + a.pan.y + "px)"
  690. });
  691. a.use_zoom ? a.elements.zoomer.css("zoom", (100 * a.scale).toString() + "%") : a.elements.zoomer.css("transform", "scale(" + a.scale + ")");
  692. l.update();
  693. D.update();
  694. return !0
  695. },
  696. getScale: function() {
  697. return Math.abs(a.scale)
  698. },
  699. setScale: function(b) {
  700. 50 < b ? b = 50 : 0 >= b && (b = .5);
  701. a.scale = b;
  702. a.update()
  703. },
  704. nudgeScale: function(b) {
  705. var c = Math.abs(a.scale),
  706. d = Math.sign(a.scale);
  707. a.scale = -1 === b ? 1 >= c ? .5 : 2 >= c ? 1 : Math.round(Math.max(2, c / 1.25)) : .5 === c ? 1 : 1 === c ? 2 : Math.round(Math.min(50, 1.25 * c));
  708. a.scale *= d;
  709. a.update()
  710. },
  711. setPixel: function(b, c, d, e) {
  712. a.loaded ?
  713. (void 0 === e && (e = !0), a.intView[c * a.width + b] = -1 == d || 255 == d ? 0 : a.rgbPalette[d], e && a.ctx.putImageData(a.id, 0, 0)) : a.pixelBuffer.push({
  714. x: b,
  715. y: c,
  716. c: d
  717. })
  718. },
  719. refresh: function() {
  720. a.loaded && a.ctx.putImageData(a.id, 0, 0)
  721. },
  722. fromScreen: function(b, c) {
  723. var d = 0,
  724. e = 0;
  725. 0 > a.scale && (d = a.width, e = a.height);
  726. if (a.use_js_render) return {
  727. x: -a.pan.x + (a.width - window.innerWidth / a.scale) / 2 + b / a.scale + d,
  728. y: -a.pan.y + (a.height - window.innerHeight / a.scale) / 2 + c / a.scale + e
  729. };
  730. var f = a.elements.board[0].getBoundingClientRect();
  731. return a.use_zoom ? {
  732. x: b / a.scale -
  733. f.left + d,
  734. y: c / a.scale - f.top + e
  735. } : {
  736. x: (b - f.left) / a.scale + d,
  737. y: (c - f.top) / a.scale + e
  738. }
  739. },
  740. toScreen: function(b, c) {
  741. 0 > a.scale && (b -= a.width - 1, c -= a.height - 1);
  742. if (a.use_js_render) return {
  743. x: (b + a.pan.x - (a.width - window.innerWidth / a.scale) / 2) * a.scale,
  744. y: (c + a.pan.y - (a.height - window.innerHeight / a.scale) / 2) * a.scale
  745. };
  746. var d = a.elements.board[0].getBoundingClientRect();
  747. return a.use_zoom ? {
  748. x: (b + d.left) * a.scale,
  749. y: (c + d.top) * a.scale
  750. } : {
  751. x: b * a.scale + d.left,
  752. y: c * a.scale + d.top
  753. }
  754. },
  755. save: function() {
  756. var b = document.createElement("a");
  757. b.href = a.elements.board[0].toDataURL("image/png");
  758. b.download = (new Date).toISOString().replace(/^(\d+-\d+-\d+)T(\d+):(\d+):(\d).*$/, "pxls canvas $1 $2.$3.$4.png");
  759. document.body.appendChild(b);
  760. b.click();
  761. document.body.removeChild(b);
  762. "function" === typeof b.remove && b.remove()
  763. },
  764. getRenderBoard: function() {
  765. return a.elements.board_render
  766. }
  767. };
  768. return {
  769. init: a.init,
  770. start: a.start,
  771. update: a.update,
  772. getScale: a.getScale,
  773. nudgeScale: a.nudgeScale,
  774. setScale: a.setScale,
  775. setPixel: a.setPixel,
  776. fromScreen: a.fromScreen,
  777. toScreen: a.toScreen,
  778. save: a.save,
  779. centerOn: a.centerOn,
  780. getRenderBoard: a.getRenderBoard,
  781. refresh: a.refresh
  782. }
  783. }(),
  784. H = function() {
  785. var a = {
  786. elements: {
  787. heatmap: $("#heatmap"),
  788. heatmapLoadingBubble: $("#heatmapLoadingBubble")
  789. },
  790. ctx: null,
  791. id: null,
  792. intView: null,
  793. width: 0,
  794. height: 0,
  795. lazy_inited: !1,
  796. is_shown: !1,
  797. color: 6053069,
  798. loop: function() {
  799. for (var b = 0; b < a.width * a.height; b++) {
  800. var c = a.intView[b] >> 24;
  801. c && (c--, a.intView[b] = c << 24 | a.color)
  802. }
  803. a.ctx.putImageData(a.id, 0, 0);
  804. setTimeout(a.loop, 1E3 * a.seconds / 256)
  805. },
  806. lazy_init: function() {
  807. a.lazy_inited ? a.elements.heatmapLoadingBubble.hide() : (a.elements.heatmapLoadingBubble.show(),
  808. a.lazy_inited = !0, J("/heatmap?_" + (new Date).getTime(), function(b) {
  809. a.ctx = a.elements.heatmap[0].getContext("2d");
  810. a.ctx.mozImageSmoothingEnabled = a.ctx.webkitImageSmoothingEnabled = a.ctx.msImageSmoothingEnabled = a.ctx.imageSmoothingEnabled = !1;
  811. a.id = K(a.width, a.height);
  812. a.intView = new Uint32Array(a.id.data.buffer);
  813. for (var c = 0; c < a.width * a.height; c++) a.intView[c] = b[c] << 24 | a.color;
  814. a.ctx.putImageData(a.id, 0, 0);
  815. a.elements.heatmap.fadeIn(200);
  816. a.elements.heatmapLoadingBubble.hide();
  817. setTimeout(a.loop, 1E3 * a.seconds /
  818. 256);
  819. h.on("pixel", function(b) {
  820. a.ctx.fillStyle = "#CD5C5C";
  821. $.map(b.pixels, function(b) {
  822. a.ctx.fillRect(b.x, b.y, 1, 1);
  823. a.intView[b.y * a.width + b.x] = 4278190080 | a.color
  824. })
  825. })
  826. }))
  827. },
  828. clear: function() {
  829. !0 === g.get("hm_clearable") && a._clear()
  830. },
  831. _clear: function() {
  832. for (var b = 0; b < a.width * a.height; b++) a.intView[b] = 0;
  833. a.ctx.putImageData(a.id, 0, 0)
  834. },
  835. setBackgroundOpacity: function(b) {
  836. "string" === typeof b && (b = parseFloat(b), isNaN(b) && (b = .5));
  837. if (null === b || void 0 === b) b = .5;
  838. if (0 > b || 1 < b) b = .5;
  839. g.set("heatmap_background_opacity", b);
  840. a.elements.heatmap.css("background-color",
  841. "rgba(0, 0, 0, " + b + ")")
  842. },
  843. init: function() {
  844. a.elements.heatmap.hide();
  845. a.elements.heatmapLoadingBubble.hide();
  846. a.setBackgroundOpacity(g.get("heatmap_background_opacity"));
  847. $("#heatmap-opacity").val(g.get("heatmap_background_opacity"));
  848. $("#heatmap-opacity").on("change input", function() {
  849. a.setBackgroundOpacity(parseFloat(this.value))
  850. });
  851. $("#heatmapClearable")[0].checked = g.get("hm_clearable");
  852. $("#heatmapClearable").change(function() {
  853. g.set("hm_clearable", this.checked)
  854. });
  855. $(window).keydown(function(b) {
  856. "o" != b.key &&
  857. "O" != b.key && 79 != b.which || a.clear()
  858. })
  859. },
  860. show: function() {
  861. a.is_shown = !1;
  862. a.toggle()
  863. },
  864. hide: function() {
  865. a.is_shown = !0;
  866. a.toggle()
  867. },
  868. toggle: function() {
  869. a.is_shown = !a.is_shown;
  870. g.set("heatmap", a.is_shown);
  871. $("#heatmaptoggle")[0].checked = a.is_shown;
  872. a.lazy_inited ? a.is_shown ? this.elements.heatmap.fadeIn(200) : this.elements.heatmap.fadeOut(200) : a.is_shown && a.lazy_init()
  873. },
  874. webinit: function(b) {
  875. a.width = b.width;
  876. a.height = b.height;
  877. a.seconds = b.heatmapCooldown;
  878. a.elements.heatmap.attr({
  879. width: a.width,
  880. height: a.height
  881. });
  882. g.get("heatmap") &&
  883. a.show();
  884. $("#heatmaptoggle")[0].checked = g.get("heatmap");
  885. $("#heatmaptoggle").change(function() {
  886. this.checked ? a.show() : a.hide()
  887. });
  888. $(window).keydown(function(b) {
  889. if ("h" == b.key || "H" == b.key || 72 == b.which) a.toggle(), $("#heatmaptoggle")[0].checked = g.get("heatmap")
  890. })
  891. }
  892. };
  893. return {
  894. init: a.init,
  895. webinit: a.webinit,
  896. toggle: a.toggle,
  897. setBackgroundOpacity: a.setBackgroundOpacity,
  898. clear: a.clear
  899. }
  900. }(),
  901. p = function() {
  902. var a = {
  903. elements: {
  904. template: null
  905. },
  906. queueTimer: 0,
  907. _queuedUpdates: {},
  908. _defaults: {
  909. url: "",
  910. x: 0,
  911. y: 0,
  912. width: -1,
  913. opacity: .5
  914. },
  915. options: {},
  916. lazy_init: function() {
  917. if (null == a.elements.template) {
  918. a.options.use = !0;
  919. var b = 0,
  920. c = 0;
  921. a.elements.template = $("\x3cimg\x3e").addClass("noselect pixelate").attr({
  922. id: "board-template",
  923. src: a.options.url,
  924. alt: "template"
  925. }).css({
  926. top: a.options.y,
  927. left: a.options.x,
  928. opacity: a.options.opacity,
  929. width: -1 === a.options.width ? "auto" : a.options.width
  930. }).data("dragging", !1).on("mousedown pointerdown", function(a) {
  931. a.preventDefault();
  932. $(this).data("dragging", !0);
  933. b = a.clientX;
  934. c = a.clientY;
  935. a.stopPropagation()
  936. }).on("mouseup pointerup", function(a) {
  937. a.preventDefault();
  938. $(this).data("dragging", !1);
  939. a.stopPropagation()
  940. }).on("mousemove pointermove", function(d) {
  941. d.preventDefault();
  942. if ($(this).data("dragging")) {
  943. var e = k.fromScreen(b, c),
  944. f = k.fromScreen(d.clientX, d.clientY),
  945. g = (f.x | 0) - (e.x | 0),
  946. e = (f.y | 0) - (e.y | 0),
  947. f = a.options.x + g,
  948. h = a.options.y + e;
  949. a._update({
  950. x: f,
  951. y: h
  952. });
  953. m.set({
  954. ox: f,
  955. oy: h
  956. }, !0);
  957. 0 != g && (b = d.clientX);
  958. 0 != e && (c = d.clientY)
  959. }
  960. });
  961. k.update(!0) || k.getRenderBoard().parent().prepend(a.elements.template)
  962. }
  963. },
  964. update_drawer: function() {
  965. $("#template-use")[0].checked = a.options.use;
  966. $("#template-url").val(a.options.url);
  967. $("#template-opacity").val(a.options.opacity)
  968. },
  969. normalizeTemplateObj: function(a, c) {
  970. var b = [
  971. ["tw", "width"],
  972. ["ox", "x"],
  973. ["oy", "y"],
  974. ["oo", "opacity"],
  975. ["template", "url"]
  976. ];
  977. if (!0 !== c)
  978. for (c = 0; c < b.length; c++) b[c].reverse();
  979. for (c = 0; c < b.length; c++) {
  980. var e = b[c];
  981. e[0] in a && null == a[e[1]] && (a[e[1]] = a[e[0]], delete a[e[0]])
  982. }
  983. return a
  984. },
  985. queueUpdate: function(b) {
  986. b = a.normalizeTemplateObj(b, !0);
  987. a._queuedUpdates = Object.assign(a._queuedUpdates, b);
  988. a.queueTimer && clearTimeout(a.queueTimer);
  989. a.queueTimer = setTimeout(function() {
  990. a._update(a._queuedUpdates);
  991. a._queuedUpdates = {};
  992. a.queueTimer = 0
  993. }, 200)
  994. },
  995. _update: function(b) {
  996. var c = b.url !== a.options.url && decodeURIComponent(b.url) !== a.options.url && null != b.url && null != a.options.url;
  997. null != b.url && 0 < b.url.length && (b.url = decodeURIComponent(b.url));
  998. c && !a.options.use && ["width", "x", "y", "opacity"].forEach(function(c) {
  999. b.hasOwnProperty(c) || (b[c] = a._defaults[c])
  1000. });
  1001. b = Object.assign({}, a._defaults, a.options, a.normalizeTemplateObj(b, !0));
  1002. Object.keys(a._defaults).forEach(function(c) {
  1003. if (null == b[c] || "number" === typeof b[c] && isNaN(b[c])) b[c] =
  1004. a._defaults[c]
  1005. });
  1006. b.opacity = parseFloat(b.opacity.toFixed(2));
  1007. a.options = b;
  1008. 0 === b.url.length || !1 === b.use ? (a.options.use = !1, a.elements.template && (a.elements.template.remove(), a.elements.template = null), k.update(!0), ["template", "ox", "oy", "oo", "tw"].forEach(function(a) {
  1009. return m.remove(a, !0)
  1010. })) : (a.options.use = !0, !0 === c && null != a.elements.template && (a.elements.template.remove(), a.elements.template = null), a.lazy_init(), [
  1011. ["left", "x"],
  1012. ["top", "y"],
  1013. ["opacity", "opacity"]
  1014. ].forEach(function(c) {
  1015. a.elements.template.css(c[0],
  1016. b[c[1]])
  1017. }), a.elements.template.css("width", 0 < b.width ? b.width : "auto"), [
  1018. ["url", "template"],
  1019. ["x", "ox"],
  1020. ["y", "oy"],
  1021. ["width", "tw"],
  1022. ["opacity", "oo"]
  1023. ].forEach(function(b) {
  1024. m.set(b[1], a.options[b[0]], !0)
  1025. }));
  1026. a.update_drawer()
  1027. },
  1028. disableTemplate: function() {
  1029. a._update({
  1030. url: null
  1031. })
  1032. },
  1033. draw: function(b, c, d) {
  1034. if (a.options.use) {
  1035. var e = a.elements.template[0].width,
  1036. f = a.elements.template[0].height,
  1037. g = k.getScale(); - 1 !== a.options.width && (f *= a.options.width / e, e = a.options.width);
  1038. b.globalAlpha = a.options.opacity;
  1039. b.drawImage(a.elements.template[0], (a.options.x - c) * g, (a.options.y - d) * g, e * g, f * g)
  1040. }
  1041. },
  1042. init: function() {
  1043. I.create("#template-control", 84, "template_open", !1);
  1044. $("#template-use").change(function() {
  1045. a._update({
  1046. use: this.checked
  1047. })
  1048. });
  1049. $("#template-url").change(function() {
  1050. a._update({
  1051. url: this.value
  1052. })
  1053. }).keydown(function(a) {
  1054. "Enter" != a.key && 13 !== a.which || $(this).change();
  1055. "p" != a.key && "P" != a.key && 86 != a.which || !a.ctrlKey || $(this).trigger("paste");
  1056. a.stopPropagation()
  1057. }).on("paste", function() {
  1058. var b = this;
  1059. setTimeout(function() {
  1060. a._update({
  1061. use: !0,
  1062. url: b.value
  1063. })
  1064. },
  1065. 100)
  1066. });
  1067. $("#template-opacity").on("change input", function() {
  1068. a._update({
  1069. opacity: parseFloat(this.value)
  1070. })
  1071. });
  1072. $(window).keydown(function(b) {
  1073. b.ctrlKey && a.options.use && (b.preventDefault(), a.elements.template.css("pointer-events", "initial"));
  1074. switch (b.key || b.which) {
  1075. case "PageUp":
  1076. case 33:
  1077. b = Math.min(1, a.options.opacity + .1);
  1078. a._update({
  1079. opacity: b
  1080. });
  1081. break;
  1082. case "PageDown":
  1083. case 34:
  1084. b = Math.max(0, a.options.opacity - .1);
  1085. a._update({
  1086. opacity: b
  1087. });
  1088. break;
  1089. case "v":
  1090. case "V":
  1091. case 86:
  1092. a._update({
  1093. use: !a.options.use
  1094. })
  1095. }
  1096. }).on("keyup blur",
  1097. function(b) {
  1098. a.options.use && a.elements.template.css("pointer-events", "none").data("dragging", !1)
  1099. })
  1100. }
  1101. };
  1102. return {
  1103. normalizeTemplateObj: a.normalizeTemplateObj,
  1104. update: a._update,
  1105. draw: a.draw,
  1106. init: a.init,
  1107. queueUpdate: a.queueUpdate
  1108. }
  1109. }(),
  1110. D = function() {
  1111. var a = {
  1112. elements: {
  1113. grid: $("#grid")
  1114. },
  1115. init: function() {
  1116. a.elements.grid.hide();
  1117. $("#gridtoggle")[0].checked = g.get("view_grid");
  1118. $("#gridtoggle").change(function() {
  1119. g.set("view_grid", this.checked);
  1120. a.elements.grid.fadeToggle({
  1121. duration: 100
  1122. })
  1123. });
  1124. g.get("view_grid") && a.elements.grid.fadeToggle({
  1125. duration: 100
  1126. });
  1127. $(document.body).on("keydown", function(a) {
  1128. if ("g" == a.key || "G" == a.key || 71 === a.keyCode) $("#gridtoggle")[0].checked = !$("#gridtoggle")[0].checked, $("#gridtoggle").trigger("change")
  1129. })
  1130. },
  1131. update: function() {
  1132. var b = k.fromScreen(0, 0),
  1133. c = k.getScale();
  1134. a.elements.grid.css({
  1135. backgroundSize: c + "px " + c + "px",
  1136. transform: "translate(" + Math.floor(-b.x % 1 * c) + "px," + Math.floor(-b.y % 1 * c) + "px)",
  1137. opacity: (c - 2) / 6
  1138. })
  1139. }
  1140. };
  1141. return {
  1142. init: a.init,
  1143. update: a.update
  1144. }
  1145. }(),
  1146. l = function() {
  1147. var a = {
  1148. elements: {
  1149. palette: $("#palette"),
  1150. cursor: $("#cursor"),
  1151. reticule: $("#reticule"),
  1152. undo: $("#undo")
  1153. },
  1154. palette: [],
  1155. reticule: {
  1156. x: 0,
  1157. y: 0
  1158. },
  1159. audio: new Audio("place.wav"),
  1160. color: -1,
  1161. pendingPixel: {
  1162. x: 0,
  1163. y: 0,
  1164. color: -1
  1165. },
  1166. autoreset: !0,
  1167. setAutoReset: function(b) {
  1168. a.autoreset = b ? !0 : !1;
  1169. g.set("auto_reset", a.autoreset)
  1170. },
  1171. switch: function(b) {
  1172. a.color = b;
  1173. $(".palette-color").removeClass("active");
  1174. $("body").toggleClass("show-placeable-bubble", -1 === b); - 1 === b ? (a.elements.cursor.hide(), a.elements.reticule.hide()) : (15 >= a.scale && a.elements.cursor.show(), a.elements.cursor.css("background-color", a.palette[b]), a.elements.reticule.css("background-color",
  1175. a.palette[b]), $($(".palette-color")[b]).addClass("active"))
  1176. },
  1177. place: function(b, c) {
  1178. E.cooledDown() && -1 !== a.color && a._place(b, c)
  1179. },
  1180. _place: function(b, c) {
  1181. a.pendingPixel.x = b;
  1182. a.pendingPixel.y = c;
  1183. a.pendingPixel.color = a.color;
  1184. h.send({
  1185. type: "pixel",
  1186. x: b,
  1187. y: c,
  1188. color: a.color
  1189. });
  1190. u("send", "event", "Pixels", "Place");
  1191. a.autoreset && a.switch(-1)
  1192. },
  1193. update: function(b, c) {
  1194. void 0 !== b && (b = k.fromScreen(b, c), a.reticule = {
  1195. x: b.x |= 0,
  1196. y: b.y |= 0
  1197. }); - 1 === a.color ? (a.elements.reticule.hide(), a.elements.cursor.hide()) : (b = k.toScreen(a.reticule.x,
  1198. a.reticule.y), c = k.getScale(), a.elements.reticule.css({
  1199. left: b.x - 1,
  1200. top: b.y - 1,
  1201. width: c - 1,
  1202. height: c - 1
  1203. }).show(), a.elements.cursor.show())
  1204. },
  1205. setPalette: function(b) {
  1206. a.palette = b;
  1207. a.elements.palette.find(".palette-color").remove().end().append($.map(a.palette, function(b, d) {
  1208. return $("\x3cdiv\x3e").addClass("palette-color").addClass("ontouchstart" in window ? "touch" : "no-touch").css("background-color", a.palette[d]).click(function() {
  1209. (!1 === g.get("auto_reset") || E.cooledDown()) && a.switch(d)
  1210. })
  1211. }))
  1212. },
  1213. can_undo: !1,
  1214. undo: function(b) {
  1215. b.stopPropagation();
  1216. h.send({
  1217. type: "undo"
  1218. });
  1219. a.can_undo = !1;
  1220. a.elements.undo.hide()
  1221. },
  1222. init: function() {
  1223. a.elements.reticule.hide();
  1224. a.elements.cursor.hide();
  1225. a.elements.undo.hide();
  1226. k.getRenderBoard().on("pointermove mousemove", function(b) {
  1227. a.update(b.clientX, b.clientY)
  1228. });
  1229. $(window).on("pointermove mousemove touchstart touchmove", function(b) {
  1230. if (-1 !== a.color) {
  1231. var c;
  1232. b.changedTouches && b.changedTouches[0] ? (c = b.changedTouches[0].clientX, b = b.changedTouches[0].clientY) : (c = b.clientX, b = b.clientY);
  1233. a.elements.cursor.css("transform", "translate(" +
  1234. c + "px, " + b + "px)");
  1235. a.can_undo || a.elements.undo.css("transform", "translate(" + c + "px, " + b + "px)")
  1236. }
  1237. }).keydown(function(b) {
  1238. a.can_undo && ("z" == b.key || "Z" == b.key || 90 == b.keyCode) && b.ctrlKey && a.undo(b)
  1239. }).on("touchstart", function(b) {
  1240. -1 === a.color || a.can_undo || a.elements.undo.css("transform", "translate(" + b.originalEvent.changedTouches[0].clientX + "px, " + b.originalEvent.changedTouches[0].clientY + "px)")
  1241. });
  1242. h.on("pixel", function(a) {
  1243. $.map(a.pixels, function(a) {
  1244. k.setPixel(a.x, a.y, a.color, !1)
  1245. });
  1246. k.refresh();
  1247. k.update(!0)
  1248. });
  1249. h.on("ACK", function(b) {
  1250. switch (b.ackFor) {
  1251. case "PLACE":
  1252. g.get("audio_muted") || a.audio.cloneNode(!1).play();
  1253. case "UNDO":
  1254. 0 === t.getAvailable() && t.setPlaceableText("PLACE" === b.ackFor ? 0 : 1)
  1255. }
  1256. });
  1257. h.on("captcha_required", function(a) {
  1258. grecaptcha.reset();
  1259. grecaptcha.execute();
  1260. u("send", "event", "Captcha", "Execute")
  1261. });
  1262. h.on("captcha_status", function(b) {
  1263. b.success ? (b = a.pendingPixel, a.switch(b.color), a._place(b.x, b.y), u("send", "event", "Captcha", "Accepted")) : (n.show("Failed captcha verification"), u("send", "event", "Captcha",
  1264. "Failed"))
  1265. });
  1266. h.on("can_undo", function(b) {
  1267. a.elements.undo.show();
  1268. a.can_undo = !0;
  1269. setTimeout(function() {
  1270. a.elements.undo.hide();
  1271. a.can_undo = !1
  1272. }, 1E3 * b.time)
  1273. });
  1274. a.elements.undo.click(a.undo);
  1275. window.recaptchaCallback = function(a) {
  1276. h.send({
  1277. type: "captcha",
  1278. token: a
  1279. });
  1280. u("send", "event", "Captcha", "Sent")
  1281. }
  1282. },
  1283. hexToRgb: function(a) {
  1284. return (a = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a)) ? {
  1285. r: parseInt(a[1], 16),
  1286. g: parseInt(a[2], 16),
  1287. b: parseInt(a[3], 16)
  1288. } : null
  1289. },
  1290. getPaletteRGB: function() {
  1291. var b = new Uint32Array(a.palette.length);
  1292. $.map(a.palette, function(c, d) {
  1293. c = a.hexToRgb(c);
  1294. b[d] = 4278190080 | c.b << 16 | c.g << 8 | c.r
  1295. });
  1296. return b
  1297. }
  1298. };
  1299. return {
  1300. init: a.init,
  1301. update: a.update,
  1302. place: a.place,
  1303. switch: a.switch,
  1304. setPalette: a.setPalette,
  1305. getPaletteRGB: a.getPaletteRGB,
  1306. setAutoReset: a.setAutoReset,
  1307. get color() {
  1308. return a.color
  1309. }
  1310. }
  1311. }(),
  1312. G = function() {
  1313. var a = {
  1314. elements: {
  1315. lookup: $("#lookup"),
  1316. prompt: $("#prompt")
  1317. },
  1318. handle: null,
  1319. report: function(b, c, d) {
  1320. a.elements.prompt.empty().append($("\x3cp\x3e").addClass("text").css({
  1321. fontWeight: 800,
  1322. marginTop: 0
  1323. }).text("Report pixel to moderator"),
  1324. $("\x3cp\x3e").addClass("text").text("message:"), $("\x3ctextarea\x3e").css({
  1325. width: "100%",
  1326. height: "5em"
  1327. }).keydown(function(a) {
  1328. a.stopPropagation()
  1329. }), $("\x3cdiv\x3e").addClass("button").text("Cancel").css({
  1330. position: "fixed",
  1331. bottom: 20,
  1332. left: 30,
  1333. width: 66
  1334. }).click(function() {
  1335. a.elements.prompt.fadeOut(200)
  1336. }), $("\x3cdiv\x3e").addClass("button").text("Report").css({
  1337. position: "fixed",
  1338. bottom: 20,
  1339. right: 30
  1340. }).click(function() {
  1341. var e = a.elements.prompt.find("textarea").val().trim();
  1342. e ? $.post("/report", {
  1343. id: b,
  1344. x: c,
  1345. y: d,
  1346. message: e
  1347. },
  1348. function() {
  1349. n.show("Sent report!");
  1350. a.elements.prompt.hide();
  1351. a.elements.lookup.hide()
  1352. }).fail(function() {
  1353. n.show("Error sending report.")
  1354. }) : n.show("You must enter a message!")
  1355. })).fadeIn(200)
  1356. },
  1357. create: function(b) {
  1358. a._makeShell(b).find(".content").first().append(b ? $.map([
  1359. ["Coords", "coords"],
  1360. ["Username", "username"],
  1361. ["Time", "time_str"],
  1362. ["Total Pixels", "pixel_count"],
  1363. ["Alltime Pixels", "pixel_count_alltime"]
  1364. ], function(a) {
  1365. return $("\x3cdiv\x3e").append($("\x3cb\x3e").text(a[0] + ": "), $("\x3cspan\x3e").text(b[a[1]]))
  1366. }) :
  1367. $("\x3cp\x3e").text("This pixel is background (was not placed by a user)."));
  1368. a.elements.lookup.fadeIn(200)
  1369. },
  1370. _makeShell: function(b) {
  1371. return a.elements.lookup.empty().append($("\x3cdiv\x3e").addClass("content"), b && z.isLoggedIn() ? $("\x3cdiv\x3e").addClass("button").css("float", "left").addClass("report-button").text("Report").click(function() {
  1372. a.report(b.id, b.x, b.y)
  1373. }) : "", $("\x3cdiv\x3e").addClass("button").css("float", "right").text("Close").click(function() {
  1374. a.elements.lookup.fadeOut(200)
  1375. }))
  1376. },
  1377. runLookup: function(b,
  1378. c) {
  1379. b = k.fromScreen(b, c);
  1380. $.get("/lookup", {
  1381. x: Math.floor(b.x),
  1382. y: Math.floor(b.y)
  1383. }, function(b) {
  1384. if (b) {
  1385. b.coords = "(" + b.x + ", " + b.y + ")";
  1386. var c = ((new Date).getTime() - b.time) / 1E3;
  1387. if (86400 < c) b.time_str = (new Date(b.time)).toLocaleString();
  1388. else if (5 > c) b.time_str = "just now";
  1389. else {
  1390. var d = Math.floor(c % 60),
  1391. g = Math.floor(c / 60) % 60,
  1392. c = Math.floor(c / 3600);
  1393. b.time_str = (10 > c ? "0" + c : c) + ":" + (10 > g ? "0" + g : g) + ":" + (10 > d ? "0" + d : d) + " ago"
  1394. }
  1395. }
  1396. b = b || !1;
  1397. a.handle ? a.handle(b) : a.create(b)
  1398. }).fail(function() {
  1399. a._makeShell(!1).find(".content").first().append($("\x3cp\x3e").css("color",
  1400. "#c00").text("To be honest mate I really, really, wish this didn't happen while looking up users, but you gotta wait 60 seconds."));
  1401. a.elements.lookup.fadeIn(200)
  1402. })
  1403. },
  1404. init: function() {
  1405. a.elements.lookup.hide();
  1406. a.elements.prompt.hide();
  1407. k.getRenderBoard().on("click", function(b) {
  1408. b.shiftKey && (b.preventDefault(), a.runLookup(b.clientX, b.clientY))
  1409. })
  1410. },
  1411. registerHandle: function(b) {
  1412. a.handle = b
  1413. },
  1414. clearHandle: function() {
  1415. a.handle = null
  1416. }
  1417. };
  1418. return {
  1419. init: a.init,
  1420. registerHandle: a.registerHandle,
  1421. runLookup: a.runLookup,
  1422. clearHandle: a.clearHandle
  1423. }
  1424. }(),
  1425. I = function() {
  1426. var a = {
  1427. elements: {
  1428. container: $("#drawers"),
  1429. opener: $("#drawers-opener")
  1430. },
  1431. create: function(a, c, d, e) {
  1432. var b = $(a);
  1433. $(a + " \x3e .open").click(function() {
  1434. b.toggleClass("open");
  1435. g.set(d, b.hasClass("open") ^ e)
  1436. });
  1437. $(a + " .close").click(function() {
  1438. b.removeClass("open");
  1439. g.set(d, 0 ^ e)
  1440. });
  1441. g.get(d) ^ e && b.addClass("open");
  1442. $(document.body).keydown(function(a) {
  1443. a.keyCode === c && (b.toggleClass("open"), g.set(d, b.hasClass("open") ^ e))
  1444. })
  1445. },
  1446. updateDropdown: function() {
  1447. $("#drawers-opener-content").empty().append($("#drawers \x3e .drawer").map(function() {
  1448. var b =
  1449. $(this);
  1450. return $("\x3cdiv\x3e").text(b.find(".open").text()).click(function(c) {
  1451. c.stopPropagation();
  1452. b.toggleClass("open");
  1453. a.elements.opener.removeClass("open")
  1454. })
  1455. }).get())
  1456. },
  1457. init: function() {
  1458. a.elements.opener.find(".open").click(function(b) {
  1459. a.elements.opener.toggleClass("open")
  1460. });
  1461. a.elements.container.on("DOMNodeInserted", function(b) {
  1462. $(b.target).hasClass("drawer") && a.updateDropdown()
  1463. });
  1464. a.updateDropdown()
  1465. }
  1466. };
  1467. return {
  1468. create: a.create,
  1469. init: a.init
  1470. }
  1471. }(),
  1472. A = function() {
  1473. return {
  1474. init: function() {
  1475. I.create("#info", 73, "info_closed", !0);
  1476. $("#audiotoggle")[0].checked = g.get("audio_muted");
  1477. $("#audiotoggle").change(function() {
  1478. g.set("audio_muted", this.checked)
  1479. });
  1480. $("#rules-button").click(function(a) {
  1481. a.stopPropagation();
  1482. n.show($("#rules-content").html())
  1483. });
  1484. var a = g.get("auto_reset");
  1485. null === a && (a = !0);
  1486. l.setAutoReset(a);
  1487. $("#stickyColorToggle")[0].checked = !a;
  1488. $("#stickyColorToggle").change(function() {
  1489. l.setAutoReset(!this.checked)
  1490. })
  1491. }
  1492. }
  1493. }(),
  1494. n = function() {
  1495. var a = {
  1496. elements: {
  1497. alert: $("#alert")
  1498. },
  1499. show: function(b) {
  1500. a.elements.alert.find(".text,.custWrapper").empty();
  1501. a.elements.alert.find(".text").append(b);
  1502. a.elements.alert.fadeIn(200)
  1503. },
  1504. showElem: function(b) {
  1505. a.elements.alert.find(".text,.custWrapper").empty();
  1506. a.elements.alert.find(".custWrapper").append(b);
  1507. a.elements.alert.fadeIn(200)
  1508. },
  1509. init: function() {
  1510. a.elements.alert.hide().find(".button").click(function() {
  1511. a.elements.alert.fadeOut(200)
  1512. });
  1513. h.on("alert", function(b) {
  1514. a.show(b.message)
  1515. })
  1516. }
  1517. };
  1518. return {
  1519. init: a.init,
  1520. show: a.show,
  1521. showElem: a.showElem
  1522. }
  1523. }(),
  1524. t = function() {
  1525. var a = {
  1526. _available: -1,
  1527. maxStacked: -1,
  1528. elements: {
  1529. stackCount: $("#placeableCount-bubble, #placeableCount-cursor")
  1530. },
  1531. init: function() {
  1532. h.on("pixels", function(b) {
  1533. a.updateAvailable(b.count, b.cause)
  1534. })
  1535. },
  1536. updateAvailable: function(b, c) {
  1537. 0 < b && "stackGain" === c && E.playAudio();
  1538. a.setPlaceableText(b)
  1539. },
  1540. setMax: function(b) {
  1541. a.maxStacked = b + 1
  1542. },
  1543. setPlaceableText: function(b) {
  1544. a.elements.stackCount.text(b + "/" + a.maxStacked)
  1545. },
  1546. getAvailable: function() {
  1547. return a._available
  1548. }
  1549. };
  1550. return {
  1551. init: a.init,
  1552. updateTimer: a.updateTimer,
  1553. updateAvailable: a.updateAvailable,
  1554. getAvailable: a.getAvailable,
  1555. setPlaceableText: a.setPlaceableText,
  1556. setMax: a.setMax
  1557. }
  1558. }(),
  1559. E = function() {
  1560. var a = {
  1561. elements: {
  1562. timer_bubble: $("#cd-timer-bubble"),
  1563. timer_overlay: $("#cd-timer-overlay"),
  1564. timer: null
  1565. },
  1566. hasFiredNotification: !0,
  1567. cooldown: 0,
  1568. runningTimer: !1,
  1569. focus: !0,
  1570. audio: new Audio("notify.wav"),
  1571. title: "",
  1572. cooledDown: function() {
  1573. return a.cooldown < (new Date).getTime()
  1574. },
  1575. update: function(b) {
  1576. var c = (a.cooldown - (new Date).getTime() - 1) / 1E3;
  1577. !1 === a.runningTimer && (a.elements.timer = !1 === g.get("auto_reset") ? a.elements.timer_bubble : a.elements.timer_overlay, a.elements.timer_bubble.hide(), a.elements.timer_overlay.hide());
  1578. a.status &&
  1579. a.elements.timer.text(a.status);
  1580. if (0 < c) {
  1581. a.elements.timer.show();
  1582. c++;
  1583. var d = Math.floor(c % 60),
  1584. d = 10 > d ? "0" + d : d,
  1585. c = Math.floor(c / 60),
  1586. c = 10 > c ? "0" + c : c;
  1587. a.elements.timer.text(c + ":" + d);
  1588. document.title = "[" + c + ":" + d + "] " + a.title;
  1589. if (!a.runningTimer || b) a.runningTimer = !0, setTimeout(function() {
  1590. a.update(!0)
  1591. }, 1E3)
  1592. } else a.runningTimer = !1, a.hasFiredNotification || (a.playAudio(), a.focus || L.show("Your next pixel is available!"), t.setPlaceableText(1), a.hasFiredNotification = !0), document.title = a.title, a.elements.timer.hide()
  1593. },
  1594. init: function() {
  1595. a.title =
  1596. document.title;
  1597. a.elements.timer_bubble.hide();
  1598. a.elements.timer_overlay.hide();
  1599. $(window).focus(function() {
  1600. a.focus = !0
  1601. }).blur(function() {
  1602. a.focus = !1
  1603. });
  1604. setTimeout(function() {
  1605. a.cooledDown() && 0 === t.getAvailable() && t.setPlaceableText(1)
  1606. }, 250);
  1607. h.on("cooldown", function(b) {
  1608. a.cooldown = (new Date).getTime() + 1E3 * b.wait;
  1609. a.hasFiredNotification = 0 === b.wait;
  1610. a.update()
  1611. })
  1612. },
  1613. playAudio: function() {
  1614. g.get("audio_muted") || a.audio.play()
  1615. }
  1616. };
  1617. return {
  1618. init: a.init,
  1619. cooledDown: a.cooledDown,
  1620. playAudio: a.playAudio
  1621. }
  1622. }(),
  1623. x = function() {
  1624. var a = {
  1625. elements: {
  1626. coords: $("#coords")
  1627. },
  1628. init: function() {
  1629. function b(b) {
  1630. b = k.fromScreen(b.clientX, b.clientY);
  1631. a.elements.coords.text("(" + (b.x | 0) + ", " + (b.y | 0) + ")").fadeIn(200)
  1632. }
  1633.  
  1634. function c(b) {
  1635. b = k.fromScreen(b.changedTouches[0].clientX, b.changedTouches[0].clientY);
  1636. a.elements.coords.text("(" + (b.x | 0) + ", " + (b.y | 0) + ")").fadeIn(200)
  1637. }
  1638. a.elements.coords.hide();
  1639. var d = k.getRenderBoard()[0];
  1640. d.addEventListener("pointermove", b, {
  1641. passive: !1
  1642. });
  1643. d.addEventListener("mousemove", b, {
  1644. passive: !1
  1645. });
  1646. d.addEventListener("touchstart", c, {
  1647. passive: !1
  1648. });
  1649. d.addEventListener("touchmove", c, {
  1650. passive: !1
  1651. })
  1652. }
  1653. };
  1654. return {
  1655. init: a.init
  1656. }
  1657. }(),
  1658. z = function() {
  1659. var a = {
  1660. elements: {
  1661. users: $("#online"),
  1662. userInfo: $("#userinfo"),
  1663. loginOverlay: $("#login-overlay"),
  1664. userMessage: $("#user-message"),
  1665. prompt: $("#prompt"),
  1666. signup: $("#signup")
  1667. },
  1668. role: "USER",
  1669. pendingSignupToken: null,
  1670. loggedIn: !1,
  1671. getRole: function() {
  1672. return a.role
  1673. },
  1674. signin: function() {
  1675. var b = g.get("auth_respond");
  1676. b && (g.remove("auth_respond"), b.signup ? (a.pendingSignupToken = b.token, a.elements.signup.fadeIn(200)) : h.reconnectSocket(), a.elements.prompt.fadeOut(200))
  1677. },
  1678. isLoggedIn: function() {
  1679. return a.loggedIn
  1680. },
  1681. webinit: function(b) {
  1682. a.elements.loginOverlay.find("a").click(function(c) {
  1683. c.preventDefault();
  1684. a.elements.prompt.empty().append($("\x3ch1\x3e").html("Sign\x26nbsp;in\x26nbsp;with..."), $("\x3cul\x3e").append($.map(b.authServices, function(a) {
  1685. return $("\x3cli\x3e").append($("\x3ca\x3e").attr("href", "/signin/" + a.id + "?redirect\x3d1").text(a.name).click(function(a) {
  1686. window.open(this.href, "_blank") ? a.preventDefault() : g.set("auth_same_window", !0)
  1687. }))
  1688. })), $("\x3cdiv\x3e").addClass("button").text("Close").css({
  1689. position: "fixed",
  1690. bottom: 20,
  1691. right: 30,
  1692. width: 55
  1693. }).click(function() {
  1694. a.elements.prompt.fadeOut(200)
  1695. })).fadeIn(200)
  1696. })
  1697. },
  1698. wsinit: function() {
  1699. g.get("auth_proceed") && (g.remove("auth_proceed"), a.signin())
  1700. },
  1701. doSignup: function() {
  1702. a.pendingSignupToken && $.post({
  1703. type: "POST",
  1704. url: "/signup",
  1705. data: {
  1706. token: a.pendingSignupToken,
  1707. username: a.elements.signup.find("input").val()
  1708. },
  1709. success: function() {
  1710. a.elements.signup.find("#error").text("");
  1711. a.elements.signup.find("input").val("");
  1712. a.elements.signup.fadeOut(200);
  1713. h.reconnectSocket();
  1714. a.pendingSignupToken =
  1715. null
  1716. },
  1717. error: function(b) {
  1718. a.elements.signup.find("#error").text(b.responseJSON.message)
  1719. }
  1720. })
  1721. },
  1722. init: function() {
  1723. a.elements.userMessage.hide();
  1724. a.elements.signup.hide();
  1725. a.elements.signup.find("input").keydown(function(b) {
  1726. b.stopPropagation();
  1727. "Enter" != b.key && 13 !== b.which || a.doSignup()
  1728. });
  1729. a.elements.signup.find("#signup-button").click(a.doSignup);
  1730. a.elements.users.hide();
  1731. a.elements.userInfo.hide();
  1732. a.elements.userInfo.find(".logout").click(function(b) {
  1733. b.preventDefault();
  1734. $.get("/logout", function() {
  1735. a.elements.userInfo.fadeOut(200);
  1736. a.elements.userMessage.fadeOut(200);
  1737. a.elements.loginOverlay.fadeIn(200);
  1738. window.deInitAdmin && window.deInitAdmin();
  1739. a.loggedIn = !1;
  1740. h.reconnectSocket()
  1741. })
  1742. });
  1743. $(window).bind("storage", function(b) {
  1744. "auth" == b.originalEvent.key && (g.remove("auth"), a.signin())
  1745. });
  1746. h.on("users", function(b) {
  1747. a.elements.users.text(b.count + " online").fadeIn(200)
  1748. });
  1749. h.on("session_limit", function(a) {
  1750. h.close();
  1751. n.show("Too many sessions open, try closing some tabs.")
  1752. });
  1753. h.on("userinfo", function(b) {
  1754. var c = !1,
  1755. d = $("\x3cdiv\x3e").addClass("ban-alert-content");
  1756. a.loggedIn = !0;
  1757. a.elements.loginOverlay.fadeOut(200);
  1758. a.elements.userInfo.find("span.name").text(b.username);
  1759. "ip" == b.method ? a.elements.userInfo.hide() : a.elements.userInfo.fadeIn(200);
  1760. a.role = b.role;
  1761. "BANNED" == a.role ? (c = !0, d.append($("\x3cp\x3e").text("You are permanently banned."))) : !0 === b.banned ? (c = !0, d.append($("\x3cp\x3e").text("You are temporarily banned and will not be allowed to place until " + (new Date(b.banExpiry)).toLocaleString()))) : -1 != ["MODERATOR", "ADMIN"].indexOf(a.role) ? (window.deInitAdmin &&
  1762. window.deInitAdmin(), $.getScript("admin/admin.js").done(function() {
  1763. window.initAdmin({
  1764. socket: h,
  1765. user: z,
  1766. place: l,
  1767. alert: n,
  1768. lookup: G
  1769. })
  1770. })) : window.deInitAdmin && window.deInitAdmin();
  1771. c ? (a.elements.userMessage.show().text("You can contact us using one of the links in the info menu.").fadeIn(200), d.append($("\x3cp\x3e").text("If you think this was an error, please contact us using one of the links in the info tab.")).append($("\x3cp\x3e").append("Ban reason:")).append($("\x3cp\x3e").append(b.ban_reason)), n.showElem(d),
  1772. window.deInitAdmin && window.deInitAdmin()) : a.elements.userMessage.hide();
  1773. instaban && y.shadow();
  1774. u("send", "event", "Auth", "Login", b.method)
  1775. })
  1776. }
  1777. };
  1778. return {
  1779. init: a.init,
  1780. getRole: a.getRole,
  1781. webinit: a.webinit,
  1782. wsinit: a.wsinit,
  1783. isLoggedIn: a.isLoggedIn
  1784. }
  1785. }(),
  1786. L = function() {
  1787. return {
  1788. init: function() {
  1789. try {
  1790. Notification.requestPermission()
  1791. } catch (a) {
  1792. console.log("Notifications not available")
  1793. }
  1794. },
  1795. show: function(a) {
  1796. try {
  1797. (new Notification("pxls.space", {
  1798. body: a,
  1799. icon: "favicon.ico"
  1800. })).onclick = function() {
  1801. parent.focus();
  1802. window.focus();
  1803. this.close()
  1804. }
  1805. } catch (b) {
  1806. console.log("No notifications available!")
  1807. }
  1808. }
  1809. }
  1810. }();
  1811. m.init();
  1812. k.init();
  1813. H.init();
  1814. I.init();
  1815. G.init();
  1816. p.init();
  1817. y.init();
  1818. D.init();
  1819. l.init();
  1820. A.init();
  1821. n.init();
  1822. E.init();
  1823. t.init();
  1824. x.init();
  1825. z.init();
  1826. L.init();
  1827. k.start();
  1828. return {
  1829. ls: g,
  1830. ss: C,
  1831. query: m,
  1832. heatmap: {
  1833. clear: H.clear
  1834. },
  1835. template: {
  1836. update: function(a) {
  1837. p.queueUpdate(a)
  1838. },
  1839. normalize: function(a, b) {
  1840. return p.normalizeTemplateObj(a, void 0 === b ? !0 : b)
  1841. }
  1842. },
  1843. centerBoardOn: function(a, b) {
  1844. k.centerOn(a, b)
  1845. },
  1846. updateTemplate: function(a) {
  1847. p.queueUpdate(a)
  1848. },
  1849. alert: function(a) {
  1850. n.show($("\x3cspan\x3e").text(a).html())
  1851. },
  1852. doPlace: function() {
  1853. y.me()
  1854. },
  1855. attemptPlace: function() {
  1856. y.me()
  1857. },
  1858. banme: function() {
  1859. y.me()
  1860. }
  1861. }
  1862. }();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement