DeathlyShadow9

Cursors.io 2019

Sep 18th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 68.79 KB | None | 0 0
  1. /* How to use:
  2. 1. Go to cursors.io, open console (ctrl + shift + j or F12)
  3. and paste this entire script into the console, then hit enter
  4. -if you experience problems running the script, make sure to block "cursors.io/client_out.js"
  5. 2. To type: type message and hit enter (shift+enter for new row)
  6. -all ascii characters are available
  7. 3. To move your cursor only when clicking: press numpad . OR delete
  8. -Pathfinder will be active in this mode. (CTRL+click to ignore pathfinder)
  9. -try not to use a too low value of the delay, or you may get disconnected on some levels
  10. --make sure 'no cursor lock' is marked so pathfinder works correctly
  11. To move your cursor normally: press numpad . again
  12. 4. To draw a circle: press numpad 0 OR insert
  13. To stop drawing a circle: press numpad 0 again
  14. 5. To draw arrows, use the arrow keys
  15. 6. To draw different images press numpad 1 - numpad 9 keys
  16. 7. To make drawings bigger/smaller use numpad + and -
  17. 8. Reset drawing size with numpad *
  18. 9. To show/hide cursors ids: press F8
  19. 10. Change ids position with: F9
  20. 11. To show this help: press F1
  21. */
  22.  
  23. var _tempOnClose;
  24. var _tempChangeCanvasID = undefined;
  25. var canvas = document.getElementById("canvas"),
  26. _tempEvt = function() {
  27. _tempOnClose();
  28. };
  29. if (_tempChangeCanvasID != undefined) canvas.setAttribute("id", _tempChangeCanvasID);
  30. if (canvas.style.cursor == "none") {
  31. var _tempWSSend = WebSocket.prototype.send;
  32. WebSocket.prototype.send = function(send) {
  33. return function(data) {
  34. if (this.readyState == 1) {
  35. this.onclose = _tempEvt;
  36. this.close();
  37. }
  38. if (this.readyState > 0) {
  39. clearInterval(_tempInterval);
  40. WebSocket.prototype.send = _tempWSSend;
  41. }
  42. return {}
  43. }
  44. }(WebSocket.prototype.send);
  45. var _tempCanvasEvent = function(_mevt) {
  46. var _tempMouseEvent;
  47. if (document.createEvent) {
  48. _tempMouseEvent = document.createEvent("HTMLEvents");
  49. _tempMouseEvent.initEvent(_mevt, true, true);
  50. } else {
  51. _tempMouseEvent = document.createEventObject();
  52. _tempMouseEvent.eventType = _mevt;
  53. }
  54. _tempMouseEvent.eventName = _mevt;
  55. if (document.createEvent) {
  56. canvas.dispatchEvent(_tempMouseEvent);
  57. } else {
  58. canvas.fireEvent("on" + _tempMouseEvent.eventType, _tempMouseEvent);
  59. }
  60. };
  61. var _tempInterval = setInterval(function() {
  62. _tempCanvasEvent("mousedown");
  63. _tempCanvasEvent("mousedown");
  64. }, 100)
  65. } else {
  66. setTimeout(_tempEvt, 0);
  67. }
  68. _tempOnClose = function() {
  69. var A = window;
  70. var E = document;
  71. var posX, posY;
  72. var lastX, lastY;
  73. var serverPosX, serverPosY;
  74. var initialLoad = true;
  75. var clicksCount = 3;
  76. var auraEnabled = false;
  77. var auraTime = 0;
  78. var auraRadius = 10;
  79. var movementEnabled = true;
  80. var imgSizeShow = false;
  81. var showcursorsid = false;
  82. var hideExtraInfo = false;
  83.  
  84. var fontthin = false;
  85. var fontSize = 2;
  86. var kerning = 3;
  87. var alphabet = {
  88. 33:[[0,1,1.5,1],[2,1,2.5,1]],//!
  89. 34:[[0,0.5,1,0.5],[0,1.25,1,1.25]],//"
  90. 35:[[0.5,-0.25,0.5,2.3],[1.5,-0.25,1.5,2.3],[-0.25,0.5,2.3,0.5],[-0.25,1.5,2.3,1.5]],//#
  91. 36:[[0,0,0,2],[1,0,1,2],[2,0,2,2],[0,0,1,0],[1,2,2,2],[-0.5,1,0,1],[2,1,2.5,1]],//$
  92. 37:[[1,0,0,0],[0,0,0,1],[0,1,2,1],[2,1,2,2],[2,2,1,2],[1,2,1,0],[2,0,0,2]],//% v1
  93. //37:[[0,0,0,0.75],[0,0.75,0.75,0.75],[0.75,0.75,0.75,0],[0.75,0,0,0],[2,0,0,2],[1.25,1.25,1.25,2],[1.25,2,2,2],[2,2,2,1.25],[2,1.25,1.25,1.25]],//% v2
  94. //37:[[1,0.5,0.5,0],[0.5,0,0,0.5],[0,0.5,0.5,1],[0.5,1,1,0.5],[2,0,0,2],[2,1.5,1.5,1],[1.5,1,1,1.5],[1,1.5,1.5,2],[1.5,2,2,1.5]],//% v3
  95. 38:[[0.5,1,0,1],[0,1,0,0],[0,0,2,0],[2,0,2,0.5],[2,0.5,1,1.5],[1,0,1,0.5],[1,0.5,2,1.5]],//&
  96. 39:[[0,0.5,1,0.5]], // '
  97. 40:[[0,2,0.5,1],[0.5,1,1.5,1],[1.5,1,2,2]],//(
  98. 41:[[0,0,0.5,1],[0.5,1,1.5,1],[1.5,1,2,0]],//)
  99. 42:[[0.5,0,1.5,2],[1.5,0,0.5,2],[0,1,2,1]],//*
  100. 43:[[0,1,2,1],[1,0,1,2]],//+
  101. 44:[[2,0,3,0]],//,
  102. 45:[[0.6,0.3,0.6,1.7]],//-
  103. 46:[[1.5,0,2,0]],//.
  104. 47:[[2,0.4,0,1.6]],// /
  105. 48:[[2,0,0,0],[0,0,0,2],[0,2,2,2],[2,2,2,0],[2,0,0,2]],//0
  106. 49:[[0,1,2,1],[1,0,0,1],[2,0,2,2]],//1
  107. 50:[[0,0,0,2],[0,2,1,2],[1,2,1,0],[1,0,2,0],[2,0,2,2]],//2
  108. 51:[[0,0,0,2],[0,2,2,2],[2,2,2,0],[1,0,1,2]],
  109. 52:[[0,0,1,0],[1,0,1,2],[0,2,2,2]],
  110. 53:[[0,2,0,0],[0,0,1,0],[1,0,1,2],[1,2,2,2],[2,2,2,0]],
  111. 54:[[0,2,0,0],[0,0,2,0],[2,0,2,2],[2,2,1,2],[1,2,1,0]],
  112. 55:[[0,0,0,2],[0,2,2,0]],
  113. 56:[[0,0,0,2],[0,2,2,2],[2,2,2,0],[2,0,0,0],[1,0,1,2]],
  114. 57:[[0,0,1,0],[1,0,1,2],[0,2,2,2],[0,0,0,2],[2,0,2,2]],//9
  115. 58:[[0,1,0.5,1],[1.5,1,2,1]],//:
  116. 59:[[0,1,0.5,1],[2,1,3,1]],//;
  117. 60:[[0,2,1,0],[1,0,2,2]],//<
  118. 61:[[0.5,0,0.5,2],[1.5,0,1.5,2]],//=
  119. 62:[[0,0,1,2],[1,2,2,0]],//>
  120. 63:[[1,0,0,0],[0,0,0,2],[0,2,1,2],[1,2,1,1],[1,1,1.5,1],[2,1,2.5,1] ],//?
  121. 64:[[2.5,2,2.5,0],[2.5,0,-0.5,0],[-0.5,0,-0.5,2],[-0.5,2,1.5,2],[1.5,2,1.5,1],[1.5,1,0.5,1],[0.5,1,0.5,2]],//@
  122. 91:[[0,1.5,0,0.5],[0,0.5,2,0.5],[2,0.5,2,1.5]],// [
  123. 92:[[0,0.4,2,1.6]],// backslash
  124. 93:[[0,0.5,0,1.5],[0,1.5,2,1.5],[2,1.5,2,0.5]],// ]
  125. 94:[[1.5,0,0,1],[0,1,1.5,2]],//^
  126. 95:[[2,0,2,2] ],//_
  127. 96:[[0,0.5,1,0.5]], // ` display same as 39
  128. 97:[[2,0,0,0],[0,2,0,0],[0,2,2,2],[1,0,1,2]],//a
  129. 98:[[2,0,0,0],[0,0,0,1],[1,0,1,1],[2,0,2,1],[0,1,0.5,2],[0.5,2,1,1],[1,1,1.5,2],[1.5,2,2,1]],//b
  130. 99:[[2,2,2,0],[2,0,0,0],[0,0,0,2]],//c
  131. 100:[[2,0,0,0],[0,0,0,1],[0,1,1,2],[1,2,2,1],[2,1,2,0]],
  132. 101:[[2,2,2,0],[2,0,0,0],[0,0,0,2],[1,0,1,2]],
  133. 102:[[2,0,0,0],[0,0,0,2],[1,0,1,2]],
  134. 103:[[1,1,1,2],[1,2,2,2],[2,2,2,0],[2,0,0,0],[0,0,0,2]],
  135. 104:[[0,0,2,0],[0,2,2,2],[1,0,1,2]],
  136. 105:[[0,0,0,2],[0,1,2,1],[2,0,2,2]],
  137. //106:[[0,0,0,2],[0,1,2,1],[2,0,2,1]], //j v1
  138. 106:[[1.5,0,2,0],[2,0,2,1.5],[0,1.5,2,1.5],[0,0.85,0,2.25]], //j v2
  139. 107:[[0,0,2,0],[1,0,0,2],[1,0,2,2]],
  140. 108:[[0,0,2,0],[2,0,2,2]],
  141. 109:[[0,0,2,0],[0,0,2,1],[2,1,0,2],[0,2,2,2]],
  142. 110:[[0,0,2,0],[0,0,2,2],[0,2,2,2]],
  143. 111:[[2,0,0,0],[0,0,0,2],[0,2,2,2],[2,2,2,0]],
  144. 112:[[2,0,0,0],[0,0,0,2],[0,2,1,2],[1,2,1,0]],
  145. 113:[[2,0,0,0],[0,0,0,2],[0,2,2,2],[2,2,2,0],[1,1,2,2]],
  146. 114:[[2,0,0,0],[0,0,0,2],[0,2,1,2],[1,2,1,0],[1,1,2,2]],
  147. 115:[[0,0,0,2],[1,0,1,2],[2,0,2,2],[0,0,1,0],[1,2,2,2]],
  148. 116:[[0,0,0,2],[0,1,2,1]],
  149. 117:[[0,0,2,0],[0,2,2,2],[2,0,2,2]],
  150. 118:[[0,0,2,1],[0,2,2,1]],
  151. 119:[[0,0,2,0],[0,2,2,2],[2,0,1,1],[2,2,1,1]],
  152. 120:[[0,0,2,2],[2,0,0,2]],
  153. 121:[[0,0,1,1],[0,2,1,1],[2,1,1,1]],
  154. 122:[[0,0,0,2],[0,2,2,0],[2,0,2,2]],//z
  155. 123:[[0,1.5,0,0.5],[0,0.5,0.5,0.5],[0.5,0.5,1,0],[1,0,1.5,0.5],[1.5,0.5,2,0.5],[2,0.5,2,1.5]],// {
  156. 124:[[0,1,2,1]],// |
  157. 125:[[0,0.5,0,1.5],[0,1.5,0.5,1.5],[0.5,1.5,1,2],[1,2,1.5,1.5],[1.5,1.5,2,1.5],[2,1.5,2,0.5]],// }
  158. 126:[[0.5,0,0,0.75],[0,0.75,0.5,1.5],[0.5,1.5,0,2.25]],// ~
  159. };
  160.  
  161. var imageScale = 1.0;
  162. var imgData = [
  163. /* arrow left */
  164. [[0,0,0,9],[0,0,-3,3],[0,0,3,3]],
  165.  
  166. /* arrow up */
  167. [[0,0,9,0],[0,0,3,-3],[0,0,3,3]],
  168.  
  169. /* arrow right */
  170. [[0,0,0,-9],[0,0,-3,-3],[0,0,3,-3]],
  171.  
  172. /* arrow down */
  173. [[0,0,-9,0],[0,0,-3,-3],[0,0,-3,3]],
  174.  
  175. /*star 5*/
  176. [[8,0,8,24],[8,24,24,4],[24,4,0,12],[0,12,24,20],[24,20,8,0]],
  177.  
  178. /* reversed star */
  179. [[0,4,24,12],[24,12,0,20],[0,20,16,0],[16,0,16,24],[16,24,0,4]],
  180.  
  181. /*tictactoe*/
  182. [[72,24,0,24],[0,48,72,48],[24,0,24,72],[48,0,48,72],[0,0,0,72],[0,72,72,72],[72,72,72,0],[72,0,0,0]],
  183.  
  184. /*triforce*/
  185. [[20,0,0,10],[0,10,20,20],[20,20,20,0],[10,5,10,15],[10,15,20,10],[20,10,10,5],[2,9,2,11],[3,9,3,11],[4,8,4,12],[5,8,5,12],[6,7,6,13],[7,7,7,13],[8,6,8,14],[9,6,9,14],[12,4,12,6],[12,14,12,16],[13,4,13,6],[13,14,13,16],[14,3,14,7],[14,13,14,17],[15,3,15,7],[15,13,15,17],[16,2,16,8],[16,12,16,18],[17,2,17,8],[17,12,17,18],[18,1,18,9],[18,11,18,19],[19,1,19,9],[19,11,19,19]],
  186.  
  187. /*pentashot*/
  188. [[50,16,66,17],[66,17,65,32],[51,26,72,36],[65,32,65,33],[72,36,64,52],[49,35,69,58],[69,58,54,71],[54,71,35,48],[49,65,33,70],[33,70,25,49],[16,46,16,63],[16,63,30,63],[50,16,51,19],[51,19,51,26],[51,26,49,35],[49,35,46,40],[46,40,43,43],[43,43,38,47],[38,47,32,49],[32,49,27,49],[27,49,24,49],[24,49,21,48],[21,48,16,46],[16,46,13,44],[13,44,10,41],[10,41,8,38],[8,38,5,32],[5,32,4,24],[4,24,5,18],[5,18,8,11],[8,11,12,7],[12,7,16,4],[16,4,21,2],[21,2,25,1],[25,1,31,1],[31,1,35,2],[35,2,40,4],[40,4,45,8],[45,8,48,13],[48,13,50,16]],
  189.  
  190. /*heart*/
  191. [[9,5,4,0],[4,0,2,0],[2,0,1,1],[4,10,9,5],[1,1,1,3],[1,3,3,5],[3,5,1,7],[1,7,1,9],[1,9,2,10],[2,10,4,10]],
  192.  
  193. /*penrose*/
  194. [[33,34,42,40],[36,36,27,42],[33,38,33,26],[27,22,48,36],[48,36,27,50],[27,50,27,22],[42,40,42,52],[48,36,48,56],[48,56,39,50],[42,48,33,54],[33,54,54,68],[54,68,46,72],[48,28,39,22],[42,20,33,26],[42,24,42,12],[42,12,27,22],[48,28,48,0],[48,0,54,4],[54,4,54,68],[27,42,18,36],[21,38,21,26],[21,34,12,40],[27,50,12,40],[21,26,0,40],[0,40,0,32],[0,32,48,0],[0,40,46,72]],
  195.  
  196. /*boxception*/
  197. [[60,0,0,0],[0,0,0,60],[0,60,60,60],[60,60,60,0],[60,0,0,3],[0,3,3,60],[3,60,60,57],[60,57,57,0],[57,0,0,6],[0,6,6,60],[6,60,60,54],[60,54,54,0],[54,0,0,9],[0,9,9,60],[9,60,60,51],[60,51,51,0],[51,0,0,12],[0,12,12,60],[12,60,60,48],[60,48,48,0],[48,0,0,15],[0,15,15,60],[15,60,60,45],[60,45,45,0],[45,0,0,18],[0,18,18,60],[18,60,60,42],[60,42,42,0],[42,0,0,21],[0,21,21,60],[21,60,60,39],[60,39,39,0],[39,0,0,24],[0,24,24,60],[24,60,60,36],[60,36,36,0],[36,0,0,27],[0,27,27,60],[27,60,60,33],[60,33,33,0],[33,0,0,30],[0,30,30,60],[30,60,60,30],[60,30,30,0],[30,0,0,33],[0,33,33,60],[33,60,60,27],[60,27,27,0],[27,0,0,36],[0,36,36,60],[36,60,60,24],[60,24,24,0],[24,0,0,39],[0,39,39,60],[39,60,60,21],[60,21,21,0],[21,0,0,42],[0,42,42,60],[42,60,60,18],[60,18,18,0],[18,0,0,45],[0,45,45,60],[45,60,60,15],[60,15,15,0],[15,0,0,48],[0,48,48,60],[48,60,60,12],[60,12,12,0],[12,0,0,51],[0,51,51,60],[51,60,60,9],[60,9,9,0],[9,0,0,54],[0,54,54,60],[54,60,60,6],[60,6,6,0],[6,0,0,57],[0,57,57,60],[57,60,60,3],[60,3,3,0],[3,0,0,60]],
  198.  
  199. /*cursor*/
  200. [[0,0,7,7],[7,7,7,3],[7,3,9.5,0],[9.5,0,0,0]],
  201.  
  202. /*dickbutt*/
  203. [[105,27,81,12],[81,12,45,5],[45,5,39,2],[39,2,29,8],[29,8,30,15],[30,15,35,19],[35,19,43,15],[43,15,45,5],[45,5,40,12],[40,12,34,13],[34,13,29,8],[22,38,33,32],[33,32,39,35],[39,35,37,47],[37,47,29,50],[29,50,24,46],[24,46,22,38],[22,38,28,43],[28,43,35,40],[35,40,39,35],[33,24,46,17],[46,17,49,20],[49,20,46,28],[41,52,60,8],[29,8,14,14],[14,14,6,23],[6,23,3,37],[3,37,5,47],[5,47,15,55],[15,55,48,63],[48,63,71,74],[71,74,63,81],[63,81,58,91],[58,91,59,99],[59,99,29,103],[29,103,27,109],[27,109,31,115],[31,115,60,114],[60,114,55,123],[55,123,57,127],[57,127,63,127],[63,127,65,120],[63,127,66,132],[66,132,73,132],[73,132,78,121],[78,121,69,116],[69,116,66,105],[66,105,67,96],[67,96,59,99],[67,96,70,89],[70,89,68,83],[70,89,77,84],[78,121,86,122],[86,122,103,114],[103,114,110,104],[110,104,111,97],[111,97,138,103],[138,103,132,85],[132,85,125,81],[125,81,127,94],[127,94,113,91],[113,91,120,79],[120,79,122,64],[122,64,152,62],[152,62,144,46],[144,46,138,44],[138,44,141,57],[141,57,122,58],[122,58,119,43],[119,43,105,27],[61,50,91,59],[91,59,96,57],[96,57,102,58],[102,58,102,62],[102,62,95,61],[95,61,102,65],[102,65,101,68],[101,68,94,66],[94,66,94,75],[94,75,91,75],[91,75,88,64],[88,64,60,56],[73,82,74,80],[79,97,82,95],[92,96,94,94],[96,100,98,98],[100,105,101,104],[48,111,49,109],[52,111,53,109]],
  204.  
  205.  
  206. ];
  207.  
  208. function sa(f) {
  209. return f << 1;
  210. }
  211.  
  212. function ta(f) {
  213. return f << 1;
  214. }
  215.  
  216. function U() {
  217. return E.pointerLockElement === y || E.mozPointerLockElement === y || E.webkitPointerLockElement === y;
  218. }
  219.  
  220. function ba() {
  221. a.fillStyle = "#000000";
  222. a.font = "35px NovaSquare";
  223. a.fillText("Please do not embed our website, thank you.", 400 - a.measureText("Please do not embed our website, thank you.").width / 2, 300);
  224. a.font = "16px NovaSquare";
  225. a.fillText("Play http://cursors.io/", 400 - a.measureText("Play http://cursors.io/").width /
  226. 2, 330);
  227. top.location = "http://cursors.io";
  228. throw "Please do not embed our website, thank you.";
  229. }
  230.  
  231. function ua(f) {
  232. V(f);
  233. }
  234.  
  235. function W(f, b) {
  236. J = f;
  237. K = b;
  238. posX = k = v = f;
  239. posY = q = w = b;
  240. B = v << 1;
  241. C = w << 1;
  242. }
  243.  
  244. function unfocus() {
  245. elm.forEach(function(i) { i.blur() });
  246. }
  247.  
  248. window.changedelay = function(d) {
  249. d = Math.floor(parseInt(d));
  250. var dd = document.getElementById('delay');
  251. if (d >= 0) {dd.value = delay = d;}
  252. else dd.value = delay = 0;
  253. }
  254.  
  255. window.changefontsize = function(d) {
  256. d = parseFloat(d);
  257. var dd = document.getElementById('fontsize');
  258. if (d >0) {dd.value = fontSize = d;}
  259. else dd.value = fontSize = 2;
  260. }
  261.  
  262. window.changefontwidth = function(d) {
  263. if (d.checked) { textwidth=2/3; fontthin=true; d.blur(); }
  264. else { textwidth=1; fontthin=false; d.blur(); }
  265. }
  266.  
  267. window.cmessage = "by q1k";
  268. window.changecmessage = function(d) {
  269. var dd = document.getElementById('cmessage');
  270. cmessage = d;
  271. }
  272.  
  273. window.changeImgSize = function(d) {
  274. d = Math.floor(parseInt(d));
  275. var tmp = d/100;
  276. var dd = document.getElementById('imgsize');
  277. if (d > 0) {
  278. dd.value = d;
  279. imageScale = tmp;
  280. imgSizeDisplay();
  281. }
  282. else {
  283. dd.value = 10;
  284. imageScale = 0.1;
  285. imgSizeDisplay();
  286. }
  287. }
  288.  
  289. window.disablemovement = function(d) {
  290. if (d.checked) { movementEnabled = false; d.blur() }
  291. else { movementEnabled = true; d.blur() }
  292. }
  293.  
  294. window.changeextrainfo = function(d) {
  295. if (d.checked) { hideExtraInfo = true; d.blur(); }
  296. else { hideExtraInfo = false; d.blur(); }
  297. }
  298.  
  299. window.toggler = function() {
  300. var dd = document.getElementById('toggle');
  301. dd.classList.toggle('open');
  302. if (dd.classList.contains('open')) dd.innerHTML = "hide advanced options <span></span>";
  303. else dd.innerHTML = "show advanced options <span></span>";
  304. }
  305.  
  306. var elm=[];
  307. function Ma() {
  308. var el1 = document.querySelectorAll("a[href='https://m28.studio/']");
  309. var par = el1[0].parentElement;
  310. var add = "<label id='help' title='Press F1 for help' onclick='showHelp=!showHelp'><span></span></label>"
  311. +"<div id='options-cont'><label id='toggle' onclick='toggler()'>show advanced options <span></span></label><div id='options'>"
  312. +"<div><label title='Pathfinder delay for each move (in miliseconds)'>delay: <input id='delay' type='number' step='5' min='0' value='"+delay+"' onchange='changedelay(this.value)'></label>"
  313. +"<input id='pathfinder' type='checkbox' title='Pathfinder/Movement (numpad . OR delete)' onclick='disablemovement(this)'><span class='info pf'></span></div>"
  314. +"<div><label title='Size of font (default = 2)'>font size: <input id='fontsize' type='number' step='any' value='"+fontSize+"' onchange='changefontsize(this.value)'></label>"
  315. +"<input id='fontwidth' type='checkbox' title='Thin text (F10)' onclick='changefontwidth(this)'><span class='info font'></span></div>"
  316. +"<div><label title='Custom message on pressing Page Up'>message: <input id='cmessage' type='text' value='"+cmessage+"' onchange='changecmessage(this.value)'></label><span class='info msg'></span></div>"
  317. +"<div><label title='Image size in %'>image size: <input id='imgsize' type='number' step='10' min='0' value='"+imgSizePrcnt+"' onchange='changeImgSize(this.value)'></label><span class='info img'></span></div>"
  318. +"<div><label title='On-screen extra information (F11)'>always hide extra labels: <input id='extrainfo' type='checkbox' onclick='changeextrainfo(this)'></label><span class='info einfo'></span></div>"
  319. +"</div></div>";
  320.  
  321. par.appendChild(document.createElement('div')).setAttribute('id','h-options');
  322. document.getElementById('h-options').innerHTML = add;
  323. elm = Array.from(document.querySelectorAll("input"));
  324. }
  325.  
  326. var css = "<style>#options,#options>div{margin-top:.5em;position:relative}#help,#toggle{cursor:pointer}#options,#options>div,#toggle span{position:relative}#help span,#toggle span::after{background-size:100% 100%;width:100%}#options>div span.info::before,#toggle span::after{content:'';background-repeat:no-repeat}a[href*=m28],a[href*=m28]~br,div[style*='height: 90px']{display:none}*{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{opacity:1}#h-options{float:right;margin-bottom:1em}#help{float:right;width:1.75em;height:1.75em}#help span{display:block;background-color:#bfeaf8;background-image:url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgMTAwMCAxMDAwIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAxMDAwIDEwMDAiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxnPjxwYXRoIGQ9Ik01MDAsOTkwQzIyOS44LDk5MCwxMCw3NzAuMiwxMCw1MDBDMTAsMjI5LjgsMjI5LjgsMTAsNTAwLDEwYzI3MC4yLDAsNDkwLDIxOS44LDQ5MCw0OTBDOTkwLDc3MC4yLDc3MC4yLDk5MCw1MDAsOTkweiBNNTAwLDYwLjRDMjU3LjYsNjAuNCw2MC40LDI1Ny42LDYwLjQsNTAwYzAsMjQyLjQsMTk3LjIsNDM5LjYsNDM5LjYsNDM5LjZjMjQyLjQsMCw0MzkuNi0xOTcuMSw0MzkuNi00MzkuNkM5MzkuNiwyNTcuNiw3NDIuNCw2MC40LDUwMCw2MC40eiIvPjxwYXRoIGQ9Ik00NTAuMyw2NTIuNHYtMzIuM2MwLTEzLjYsMS0yNS44LDMtMzYuNWMyLTEwLjcsNS0yMC45LDkuMy0zMC41YzQuMy05LjYsOS45LTE5LDE3LTI4YzcuMS05LjEsMTYtMTguNywyNi43LTI4LjlsMzguMi0zNi41YzEwLjctOS42LDE5LjktMjAuNCwyNy42LTMyLjNjNy43LTExLjksMTEuNS0yNi4zLDExLjUtNDMuM2MwLTIyLjEtNy00MC42LTIwLjgtNTUuNmMtMTMuOS0xNS0zMy42LTIyLjUtNTkuMS0yMi41Yy0xMywwLTI0LjcsMi40LTM1LjIsNy4yYy0xMC40LDQuOC0xOS41LDExLjMtMjcuMSwxOS41Yy03LjcsOC4yLTEzLjUsMTcuNy0xNy40LDI4LjRjLTMuOSwxMC44LTYuMiwyMS44LTYuOCwzMy4xTDMxMi45LDM4NWMzLjMtMjcuMiwxMC42LTUxLjQsMjEuNi03Mi42YzExLTIxLjIsMjUuMy0zOS4yLDQyLjgtNTMuOWMxNy42LTE0LjcsMzcuNy0yNS45LDYwLjMtMzMuNWMyMi42LTcuNyw0Ny0xMS40LDczLTExLjRjMjQuMywwLDQ3LjQsMy42LDY5LjIsMTAuNmMyMS44LDcuMSw0MSwxNy42LDU3LjcsMzEuNGMxNi43LDEzLjgsMjkuOCwzMSwzOS40LDUxLjRjOS42LDIwLjMsMTQuNCw0My45LDE0LjQsNzAuNGMwLDE4LjEtMiwzMy45LTUuOSw0Ny41Yy0zLjksMTMuNi05LjYsMjYtMTcsMzcuNGMtNy4zLDExLjMtMTYuMiwyMi4yLTI2LjcsMzIuNmMtMTAuNCwxMC40LTIyLjIsMjEuNC0zNS4yLDMyLjZjLTExLjMsOS42LTIwLjUsMTguMi0yNy42LDI1LjVjLTcuMSw3LjMtMTIuNywxNC43LTE3LDIyLjFjLTQuMyw3LjMtNy4yLDE1LjItOC45LDIzLjdjLTEuNyw4LjUtMi42LDE4LjktMi42LDMxLjR2MjIuMUg0NTAuM3ogTTQzMy4zLDc3MC4zYzAtMTgsNi42LTMzLjYsMjAtNDYuNmMxMy4yLTEzLDI5LjMtMTkuNSw0Ny45LTE5LjVjMTguMSwwLDM0LDYuMiw0Ny41LDE4LjdjMTMuNiwxMi40LDIwLjQsMjcuNywyMC40LDQ1LjhjMCwxOC4xLTYuNywzMy43LTIwLDQ2LjdjLTEzLjMsMTMtMjkuMywxOS41LTQ4LDE5LjVjLTkuMSwwLTE3LjctMS44LTI1LjktNS4xYy04LjEtMy40LTE1LjQtNy45LTIxLjUtMTMuNmMtNi4yLTUuNi0xMS4yLTEyLjQtMTQuOS0yMC4zQzQzNS4xLDc4Ny44LDQzMy4zLDc3OS4zLDQzMy4zLDc3MC4zeiIvPjwvZz48L3N2Zz4=);border-radius:100%;height:100%}#options,#options::after{border:1px solid #AAA;background-color:#FCFCFC}#options-cont{float:right;text-align:right;margin-right:1.5em}#options{visibility:hidden;opacity:0;transition:all 250ms;text-align:right;display:flex;flex-direction:column;width:auto}#options>div,#toggle,#toggle span{display:inline-block}#options::after{content:'';border-width:1px 0 0 1px;border-radius:0 0 100%;width:8px;height:8px;position:absolute;right:.75em;top:-5px;transform:rotate(45deg)}#options>div{padding-right:1.75em}#options>:first-child{margin-top:0}#options label input:not([type=checkbox]){width:10em}#options #delay,#options #fontsize{width:8.5em}#options #fontwidth,#options #pathfinder{padding:0;margin:0 .1em 0 .4em;width:1em}#toggle.open~#options::after{opacity:1}#toggle.open~#options{visibility:visible;padding:.5em;opacity:1}#toggle{-webkit-appearance:button;-moz-appearance:button;-ms-appearance:button;appearance:button;height:1.25em;line-height:1.25em;padding:.25em .5em}#toggle span{margin-left:.25em;height:0;width:1.125em}#toggle span::after{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMSAzMSI+PHBvbHlnb24gZmlsbD0ibm9uZSIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjEuNSIgcG9pbnRzPSIxIDEsMTYgMzAsMzAgMSwxNiAxMCwxIDEiLz48L3N2Zz4=);position:absolute;height:1em;bottom:0;right:0;margin-bottom:-.25em}#toggle.open span::after{transform:rotate(180deg)}#options>div span.info{display:inline-block;position:absolute;width:1.25em;right:0;top:0}#options>div span.info::before{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTYwIiB3aWR0aD0iMTYwIiB2ZXJzaW9uPSIxLjAiPjxnIGZpbGw9IiM0YjRiNGIiPjxwYXRoIGQ9Im04MCAxNWMtMzUuODggMC02NSAyOS4xMi02NSA2NXMyOS4xMiA2NSA2NSA2NSA2NS0yOS4xMiA2NS02NS0yOS4xMi02NS02NS02NXptMCAxMGMzMC4zNiAwIDU1IDI0LjY0IDU1IDU1cy0yNC42NCA1NS01NSA1NS01NS0yNC42NC01NS01NSAyNC42NC01NSA1NS01NXoiLz48cGF0aCBkPSJtNTcuMzczIDE4LjIzMWE5LjM4MzQgOS4xMTUzIDAgMSAxIC0xOC43NjcgMCA5LjM4MzQgOS4xMTUzIDAgMSAxIDE4Ljc2NyAweiIgdHJhbnNmb3JtPSJtYXRyaXgoMS4xOTg5IDAgMCAxLjIzNDIgMjEuMjE0IDI4Ljc1KSIvPjxwYXRoIGQ9Im05MC42NjUgMTEwLjk2Yy0wLjA2OSAyLjczIDEuMjExIDMuNSA0LjMyNyAzLjgybDUuMDA4IDAuMXY1LjEyaC0zOS4wNzN2LTUuMTJsNS41MDMtMC4xYzMuMjkxLTAuMSA0LjA4Mi0xLjM4IDQuMzI3LTMuODJ2LTMwLjgxM2MwLjAzNS00Ljg3OS02LjI5Ni00LjExMy0xMC43NTctMy45Njh2LTUuMDc0bDMwLjY2NS0xLjEwNSIvPjwvZz48L3N2Zz4=);background-size:contain;background-position:center right;width:100%;padding-top:80%;position:absolute;top:0;right:0;cursor:help}span.info::after{pointer-events:none;text-align:center;white-space:pre;font-size:85%;font-family:Arial,sans-serif;background-color:#FCFCFC;border:1px solid #AAA;box-shadow:0 0 10px 1px #AAA;padding:.35em;position:absolute;bottom:0;left:50%;transform:translateX(calc(-50% + .125em));z-index:2;display:none}span.info:hover::after{display:block}span.info.pf::after{content:'Enter your prefered delay for the pathfinder.\\A But beware of using too small values,\\A the server may kick you on some levels\\A if you pass a large distance too quickly.\\A\\A Use CTRL+click to ignore pathfinder.\\A Toggle with numpad dot OR delete'}span.info.font::after{content:'Enter font size for writing.\\A\\A Mark the checkbox for thin text\\A Hotkey: F10'}span.info.msg::after{content:'Enter your own message to spam.\\A\\A Hotkey: Page Up'}span.info.img::after{content:'Enter image size (%).\\A\\A Draw images with numpad 1 to 9\\A\\A Increase img size: numpad +\\A Descrease img size: numpad -\\A Reset img size: numpad *'}span.info.einfo::after{content:'Hide the top corners indicators\\A of movement/pathfinder and aura\\A\\A Hotkey: F11'}</style>";
  327.  
  328. function va(f) {
  329. if (D) return L = !1, V(f), !1;
  330. U() ? X || (X = !0, W(k, q)) : (X = !1, D || M.checked || y.requestPointerLock && y.requestPointerLock());
  331. if (L) L = !1, Q();
  332. else if (V(f), (f.ctrlKey || f.shiftKey) && !H.checked) Y = !0, R = k, S = q;
  333. else if (100 < t - ca && v == k && w == q) {
  334. ca = t;
  335. I.push([v << 1, w << 1, t]);
  336. wa(v, w, clicksCount);
  337. var b = [v, w];
  338. N.push(b);
  339. setTimeout(function() {
  340. N.remove(b);
  341. }, 1E3);
  342. }
  343. return !1;
  344. }
  345.  
  346. function xa(f) {
  347. Y = !1;
  348. }
  349.  
  350. function ya() {
  351. A.localStorage && M && (A.localStorage.setItem("noCursorLock", M.checked ? "1" : "0"), A.localStorage.setItem("noDrawings", H.checked ? "1" : "0"));
  352. }
  353.  
  354. function V(f) {
  355. if (U()) {
  356. var b = f.webkitMovementX || f.mozMovementX || f.movementX || 0;
  357. f = f.webkitMovementY || f.mozMovementY || f.movementY || 0;
  358. 300 > Math.abs(b) + Math.abs(f) && (B += b, C += f, v = B >> 1, w = C >> 1);
  359. } else f.offsetX ? (B = f.offsetX, C = f.offsetY) : f.layerX && (B = f.layerX, C = f.layerY), v = B >> 1, w = C >> 1;
  360. lastX = posX;
  361. lastY = posY;
  362. posX = k;
  363. posY = q;
  364. if (Z(), !U() || v == k && w == q || (f = b = 0, v > k && (b = 1),
  365. w > q && (f = 1), v = k, w = q, B = (v << 1) + b, C = (w << 1) + f), Y && (R != k || S != q) && 50 < t - da) {
  366. b = R;
  367. f = S;
  368. var a = k,
  369. d = q;
  370. if (!D && null != u && u.readyState == WebSocket.OPEN) {
  371. var g = new ArrayBuffer(9),
  372. e = new DataView(g);
  373. e.setUint8(0, 3);
  374. e.setUint16(1, b, !0);
  375. e.setUint16(3, f, !0);
  376. e.setUint16(5, a, !0);
  377. e.setUint16(7, d, !0);
  378. u.Send(g);
  379. }
  380. R = k;
  381. S = q;
  382. da = t;
  383. }
  384. }
  385.  
  386. function Z() {
  387. ea(k, q) && Q();
  388. if (z(k, q)) {
  389. var a;
  390. a: {
  391. a = k;
  392. var b = q,
  393. c = [],
  394. d = new Uint8Array(12E4);
  395. c.push([a, b]);
  396. d[a + 400 * b] = 1;
  397. do {
  398. var g = c.shift(),
  399. e = g[0],
  400. g = g[1];
  401. if (!(0 > e || 0 > g || 400 <= e || 300 <= g)) {
  402. if (!z(e, g)) {
  403. a = {
  404. x: e,
  405. y: g
  406. };
  407. break a;
  408. }
  409. d[e - 1 + 400 * g] || (c.push([e - 1, g]), d[e - 1 + 400 * g] = 1);
  410. d[e + 1 + 400 * g] || (c.push([e + 1, g]), d[e + 1 + 400 * g] = 1);
  411. d[e + 400 * (g - 1)] || (c.push([e, g - 1]), d[e + 400 * (g - 1)] = 1);
  412. d[e + 400 * (g + 1)] || (c.push([e, g + 1]), d[e + 400 * (g + 1)] = 1);
  413. }
  414. } while (0 < c.length);
  415. a = {
  416. x: a,
  417. y: b
  418. };
  419. }
  420. k = a.x;
  421. q = a.y;
  422. }
  423. if (k != v || q != w) a = fa(k, q, v, w), k = a.x, q = a.y;
  424. ea(k, q) && Q();
  425. }
  426.  
  427. var countlevels=-2;
  428. function next() {
  429. console.log("Next map");
  430. initialLoad = true;
  431. T.set(za);
  432. r = [];
  433. I = [];
  434. O = [];
  435. countlevels+=1;
  436. }
  437.  
  438. function ga(f) {
  439. a.imageSmoothingEnabled = f;
  440. a.mozImageSmoothingEnabled = f;
  441. a.oImageSmoothingEnabled = f;
  442. a.webkitImageSmoothingEnabled = f;
  443. }
  444.  
  445. function Aa() {
  446. next();
  447. console.log("Connected!");
  448. }
  449.  
  450. function Ba(a) {
  451. next();
  452. console.log("Socket closed: " + a.reason);
  453. }
  454.  
  455. function Ca(a) {
  456. console.log("Socket error");
  457. }
  458.  
  459. function Da(a, b) {
  460. for (var c = "", d = 0, g = 0; 0 != (g = a.getUint8(b)); ++b) d <<= 8, d |= g, g & 128 || (c += String.fromCharCode(d), d = 0);
  461. 0 != d && (c += String.fromCharCode(d));
  462. return [c, b + 1];
  463. }
  464.  
  465. function Ea(a, b) {
  466. setTimeout(function() {
  467. var c = a.getUint16(b, !0),
  468. d = 0;
  469. a: for (; d < c; d++) {
  470. for (var g = a.getUint16(b + 2 + 4 * d, !0), e = a.getUint16(b + 4 + 4 * d, !0), n = 0; n < N.length; n++) {
  471. var l = N[n];
  472. if (l[0] == g && l[1] == e) {
  473. N.splice(n, 1);
  474. continue a;
  475. }
  476. }
  477. I.push([g << 1, e << 1, t]);
  478. }
  479. }, 100);
  480. return b + 2 + 4 * a.getUint16(b, !0);
  481. }
  482.  
  483. function Fa(a, b) {
  484. !H.checked && setTimeout(function() {
  485. for (var c = a.getUint16(b, !0), d = 0; d < c; d++) {
  486. var g = a.getUint16(b + 2 + 8 * d, !0),
  487. e = a.getUint16(b + 4 + 8 * d, !0),
  488. n = a.getUint16(b + 6 + 8 * d, !0),
  489. l = a.getUint16(b + 8 + 8 * d, !0);
  490. O.push([g << 1, e << 1, n << 1, l << 1, t]);
  491. }
  492. }, 50);
  493. return b + 2 + 8 * a.getUint16(b, !0);
  494. }
  495.  
  496. function Ga(a) {
  497. buttonIndex = 0;
  498. initialLoad = false;
  499. a = a.data;
  500. var b = new DataView(a);
  501. switch (b.getUint8(0)) {
  502. case 0:
  503. ha = b.getUint32(1, !0);
  504. break;
  505. case 1:
  506. var c;
  507. ia = c = b.getUint16(1, !0);
  508. ja = 100 <= c;
  509. var d = [],
  510. g;
  511. for (g in F) F.hasOwnProperty(g) && d.push(g);
  512.  
  513. for (var e =
  514. 0; e < c; e++) {
  515. g = b.getUint32(3 + 8 * e, !0);
  516. var n = b.getUint16(7 + 8 * e, !0),
  517. l = b.getUint16(9 + 8 * e, !0);
  518. if (g != ha) {
  519. if (null != F[g]) {
  520. for (var p = 0; p < d.length; p++)
  521. if (d[p] == g) {
  522. d.splice(p, 1);
  523. break;
  524. }
  525. g = F[g];
  526. g.oldX = g.getX();
  527. g.oldY = g.getY();
  528. g.newX = n;
  529. g.newY = l;
  530. g.time = t;
  531. } else F[g] = new ka(n, l);
  532. } else {
  533. serverPosX = n;
  534. serverPosY = l;
  535. }
  536. }
  537. for (e = 0; e < d.length; e++) delete F[d[e]];
  538. c = Ea(b, 3 + 8 * c);
  539. g = b.getUint16(c, !0);
  540. c += 2;
  541. for (d = 0; d < g; d++) {
  542. a: for (n = b.getUint32(c, !0), e = 0; e < r.length; e++)
  543. if (r[e].id == n) {
  544. var k = r[e];
  545. if (1 == k.type)
  546. for (var n = k.x | 0, l = k.y | 0, p = k.width | 0, k = k.height | 0, m = l; m < l + k; ++m)
  547. for (var h =
  548. n; h < n + p; ++h) --T[h + 400 * m];
  549. r.splice(e, 1);
  550. break a;
  551. }c += 4;
  552. }
  553. g = b.getUint16(c, !0);
  554. c += 2;
  555. for (d = 0; d < g; d++) {
  556. a: {
  557. e = b.getUint32(c, !0);
  558. for (n = 0; n < r.length; n++)
  559. if (r[n].id == e) {
  560. e = r[n];
  561. break a;
  562. }
  563. e = {
  564. id: e
  565. };
  566. r.push(e);
  567. }
  568. c += 4;c = la(b, c, e);
  569. }
  570. c = Fa(b, c);
  571. if (a.byteLength < c + 4) break;
  572. aa = b.getUint32(c, !0);
  573. break;
  574. case 4:
  575. next();
  576. W(b.getUint16(1, !0), b.getUint16(3, !0));
  577. g = b.getUint16(5, !0);
  578. c = 7;
  579. for (d = 0; d < g; d++) e = {}, e.id = b.getUint32(c, !0), c += 4, c = la(b, c, e), r.push(e);
  580. a.byteLength >= c + 4 ? G = Math.max(G, b.getUint32(c, !0)) : a.byteLength >= c + 2 && (G = Math.max(G, b.getUint16(c, !0)));
  581. Z();
  582. break;
  583. case 5:
  584. W(b.getUint16(1, !0), b.getUint16(3, !0)), 9 <= b.byteLength ? G = Math.max(G, b.getUint32(5, !0)) : 7 <= b.byteLength && (G = Math.max(G, b.getUint16(5, !0))), Z();
  585. }
  586. }
  587.  
  588. function Q() {
  589. if (!(D || L || null == u || u.readyState != WebSocket.OPEN || k == J && q == K) && movementEnabled) {
  590. var a = new ArrayBuffer(9);
  591. b = new DataView(a);
  592. b.setUint8(0, 1);
  593. b.setUint16(1, k, !0);
  594. b.setUint16(3, q, !0);
  595. b.setUint32(5, G, !0);
  596. u.send(a);
  597. J = k;
  598. K = q;
  599. }
  600.  
  601. }
  602.  
  603. function Au() {
  604. Throttler.sendOut();
  605. if (auraEnabled) drawAura(J, K);
  606. }
  607.  
  608. function wa(a, b, numClicks) {
  609. if (!D && null != u && u.readyState == WebSocket.OPEN) {
  610. var c = new ArrayBuffer(9),
  611. d = new DataView(c);
  612. d.setUint8(0, 2);
  613. d.setUint16(1, a, !0);
  614. d.setUint16(3, b, !0);
  615. d.setUint32(5, G, !0);
  616. for (var i = 0; i < numClicks; i++) { u.Send(c); }
  617. }
  618. }
  619.  
  620. function la(f, b, c) {
  621. function d() {
  622. c.x = f.getUint16(b, !0);
  623. b += 2;
  624. c.y = f.getUint16(b, !0);
  625. b += 2;
  626. c.width = f.getUint16(b, !0);
  627. b += 2;
  628. c.height = f.getUint16(b, !0);
  629. b += 2;
  630. }
  631. function g() {
  632. for (var a = f.getUint32(b, !0).toString(16); 6 > a.length;) a = "0" + a;
  633. b += 4;
  634. c.color = "#" + a;
  635. }
  636. var e = f.getUint8(b);
  637. b += 1;
  638. c.type = e;
  639. switch (e) {
  640. case 255:
  641. break;
  642. case 0:
  643. c.x = f.getUint16(b, !0);
  644. b += 2;
  645. c.y = f.getUint16(b, !0);
  646. b += 2;
  647. c.size = f.getUint8(b);
  648. b += 1;
  649. c.isCentered = !!f.getUint8(b);
  650. b += 1;
  651. e = Da(f, b);
  652. c.text = e[0];
  653. b = e[1];
  654. break;
  655. case 1:
  656. d();
  657. var n = !c.color;
  658. g();
  659. var e = c.x | 0,
  660. l = c.y | 0,
  661. p = c.width | 0,
  662. k = c.height | 0;
  663. if (n)
  664. for (n = l; n < l + k; ++n)
  665. for (var m = e; m < e + p; ++m) ++T[m + 400 * n];
  666. break;
  667. case 2:
  668. d();
  669. c.isBad = !!f.getUint8(b);
  670. b += 1;
  671. break;
  672. case 3:
  673. d();
  674. c.count = f.getUint16(b, !0);
  675. b += 2;
  676. g();
  677. break;
  678. case 4:
  679. d();
  680. c.count ? c.count > f.getUint16(b, !0) && (c.lastClickAt = t) : c.lastClickAt = 0;
  681. c.count = f.getUint16(b, !0);
  682. b += 2;
  683. g();
  684. break;
  685. case 5:
  686. c.x = f.getUint16(b, !0);
  687. b += 2;
  688. c.y = f.getUint16(b, !0);
  689. b += 2;
  690. c.queue = [ [0, c.x, c.y]];
  691. c.potentialQueue = [];
  692. c.explored = new Uint8Array(12E4);
  693. c.img = a.createImageData(400, 300);
  694. e = E.createElement("canvas");
  695. e.width = 400;
  696. e.height = 300;
  697. c.canvas = e;
  698. c.ctx = c.canvas.getContext("2d");
  699. break;
  700. default:
  701. throw Error("Unknown object type " + e);
  702. }
  703. return b;
  704. }
  705.  
  706. function ea(a, b) {
  707. if (-1 != J && -1 != K) {
  708. var c = fa(J, K, a, b);
  709. if (c.x != a || c.y != b) return !0;
  710. }
  711. for (c = 0; c < r.length; c++) {
  712. var d = r[c];
  713. if (2 == d.type && !(k < d.x || q < d.y || k >= d.x + d.width || q >= d.y + d.height)) return !0;
  714. }
  715. return !1;
  716. }
  717.  
  718. //var cursorsonline=0;
  719. window.showHelp = false;
  720. function ma() {
  721. a.clearRect(0, 0, a.canvas.width, a.canvas.height);
  722. a.save();
  723. if (null != u && u.readyState != WebSocket.OPEN || L) {
  724. var f;
  725. if (null == u) f = "Click to begin";
  726. else switch (u.readyState) {
  727. case WebSocket.CONNECTING:
  728. f = "Connecting";
  729. break;
  730. case WebSocket.CLOSING:
  731. case WebSocket.CLOSED:
  732. f = "Lost connection to server";
  733. break;
  734. default:
  735. f = "Click to begin";
  736. }
  737. a.font = 60 + "px NovaSquare";
  738. a.fillText(f, 400 - a.measureText(f).width / 2, 300);
  739. a.font = 20 + "px NovaSquare";
  740. f = "-> script remastered by q1k <-";
  741. a.fillText(f, 400 - a.measureText(f).width / 2, 345);
  742. na();
  743. oa(!1);
  744. } else {
  745. a.fillStyle = "#000000";
  746. a.save();
  747. a.globalAlpha = 1;
  748. var typeZeroCount = 0;
  749. var typeOneCount = 0;
  750. var typeTwoCount = 0;
  751. var typeThreeCount = 0;
  752. var typeFourCount = 0;
  753. for (f = 0; f < r.length; f++) {
  754. var b = r[f];
  755. if (0 == b.type) {
  756. a.font = b.size + "px NovaSquare";
  757. var c = b.x << 1,
  758. d = b.y << 1;
  759. b.isCentered && (c -= a.measureText(b.text).width / 2);
  760. a.fillStyle = "#000000";
  761. a.fillText(b.text, c, d);
  762. typeZeroCount++;
  763. } else if (1 == b.type) {
  764. a.fillStyle = b.color, a.fillRect(b.x << 1, b.y << 1, b.width << 1, b.height << 1);
  765. a.strokeStyle = "#000000", a.globalAlpha = .2, a.lineWidth = 2;
  766. a.strokeRect((b.x << 1) + 1, (b.y << 1) + 1, (b.width << 1) - 2, (b.height << 1) - 2);
  767. a.globalAlpha = 1;
  768. typeOneCount++;
  769. } else if (2 == b.type) {
  770. a.fillStyle = b.isBad ? "#FF0000" : "#00FF00", a.globalAlpha = .2;
  771. a.fillRect(b.x << 1, b.y << 1, b.width << 1, b.height << 1);
  772. a.globalAlpha = 1;
  773. typeTwoCount++;
  774. } else if (3 == b.type) {
  775. var c = b.x << 1,
  776. d = b.y << 1,
  777. g = b.width << 1,
  778. e = b.height << 1;
  779. a.fillStyle = b.color;
  780. a.globalAlpha = .2;
  781. a.fillRect(c, d, g, e);
  782. a.globalAlpha = .5;
  783. a.fillStyle = "#000000";
  784. if (40 > b.width || 40 > b.height) {
  785. a.font = 30 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 10);
  786. } else {
  787. a.font = 60 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 20);
  788. };
  789. a.globalAlpha = 1;
  790. typeThreeCount++;
  791. } else if (4 == b.type) {
  792. c = b.x << 1;
  793. d = b.y << 1;
  794. g = b.width << 1;
  795. e = b.height << 1;
  796. a.fillStyle = b.color;
  797. a.strokeStyle = b.color;
  798. a.globalAlpha = 1;
  799. a.fillRect(c, d, g, e);
  800. a.globalAlpha = .2;
  801. a.fillStyle = "#000000";
  802. a.fillRect(c, d, g, e);
  803. a.globalAlpha = 1;
  804. a.fillStyle = b.color;
  805. var n = 150 > t - b.lastClickAt, l = n ? 8 : 12;
  806. a.fillRect(c + l, d + l, g - 2 * l, e - 2 * l);
  807. a.strokeStyle = "#000000";
  808. a.globalAlpha = .1;
  809. a.beginPath();
  810. a.moveTo(c, d);
  811. a.lineTo(c + l, d + l);
  812. a.moveTo(c + g, d);
  813. a.lineTo(c + g - l, d + l);
  814. a.moveTo(c, d + e);
  815. a.lineTo(c + l, d + e - l);
  816. a.moveTo(c + g, d + e);
  817. a.lineTo(c + g - l, d + e - l);
  818. a.moveTo(c, d);
  819. a.rect(c, d, g, e);
  820. a.rect(c + l, d + l, g - 2 * l, e - 2 * l);
  821. a.stroke();
  822. a.fillStyle = "#000000";
  823. a.globalAlpha = .5;
  824. if (50 > b.width || 50 > b.height) {
  825. a.font = 35 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 13);
  826. } else {
  827. a.font = 45 + "px NovaSquare", a.fillText(b.count, c + g / 2 - a.measureText(b.count).width / 2, d + e / 2 + 16);
  828. }
  829. n && (a.fillStyle = "#000000", a.globalAlpha = .15, a.fillRect(c + l, d + l, g - 2 * l, e - 2 * l));
  830. a.globalAlpha = 1;
  831. typeFourCount++;
  832. } else 5 == b.type && (ga(!1), a.drawImage(b.canvas, 0, 0, 400, 300, 0, 0, 800, 600, ga(!0)));
  833. }
  834. if (r.length == 8 && typeZeroCount == 4 && typeOneCount == 3 && typeTwoCount == 1 && typeThreeCount == 0 && typeFourCount == 0) {
  835. a.globalAlpha = 1;
  836. f = "(Or just play cursors.io)", a.font = 15 + "px NovaSquare", a.fillStyle = "#000000";
  837. a.fillText(f, 400 - a.measureText(f).width / 2, 408);
  838. }
  839. a.restore();
  840. if (!D) {
  841. a.font = 12 + "px NovaSquare", a.strokeStyle = "#000000", a.fillStyle = "#FFFFFF", a.lineWidth = 2.5;
  842. f = ja ? "Area too full, not all cursors are shown" : 30 < ia ? "Area too full, drawing is disabled" : "Use shift+click to draw";
  843. a.globalAlpha = .5, a.strokeText(f, 10, 590), a.globalAlpha = 1;
  844. a.fillText(f, 10, 590);
  845. if (aa != 0) {
  846. //f = (cursorsonline+1) + "/" +
  847. f = aa + " players online", b = a.measureText(f).width, a.globalAlpha = .5, a.strokeText(f, 790 - b, 590), a.globalAlpha = 1;
  848. a.fillText(f, 790 - b, 590);
  849. };
  850. if (!movementEnabled && !hideExtraInfo) {
  851. f = "movement disabled / pathfinder enabled";
  852. a.globalAlpha = .5, a.strokeText(f, 10, 15), a.globalAlpha = 1;
  853. a.fillText(f, 10, 15);
  854. f = "press numpad . OR delete to toggle";
  855. a.globalAlpha = .5, a.strokeText(f, 10, 30), a.globalAlpha = 1;
  856. a.fillText(f, 10, 30);
  857. }
  858. if (auraEnabled && !hideExtraInfo) {
  859. f = "aura enabled", b = a.measureText(f).width, a.globalAlpha = .5, a.strokeText(f, 790 - b, 15), a.globalAlpha = 1;
  860. a.fillText(f, 790 - b, 15);
  861. f = "press numpad 0 OR insert to disable", b = a.measureText(f).width, a.globalAlpha = .5, a.strokeText(f, 790 - b, 30), a.globalAlpha = 1;
  862. a.fillText(f, 790 - b, 30);
  863. }
  864. if (imgSizeShow) {
  865. f = "image size: " + imgSizePrcnt + "%"; a.globalAlpha = .5, a.strokeText(f, 10, 560), a.globalAlpha = 1;
  866. a.fillText(f, 10, 560);
  867. //f = "image size: " + imgSizePrcnt + "%", b = a.measureText(f).width, a.globalAlpha = .5, a.strokeText(f, 790 - b, 560), a.globalAlpha = 1;
  868. //a.fillText(f, 790 - b, 560);
  869. }
  870. if (countlevels>0) {
  871. f = "level: "+countlevels, b = a.measureText(f).width, a.globalAlpha = .5, a.strokeText(f, 790 - b, 560), a.globalAlpha = 1;
  872. a.fillText(f, 790 - b, 560);
  873. }
  874. }
  875. na();
  876. if (!H.checked) {
  877. a.save();
  878. a.strokeStyle = "#000000";
  879. a.lineWidth = 1;
  880. t = +new Date;
  881. a.beginPath();
  882. for (f = 0; f < O.length; f++) {
  883. b = O[f];
  884. c = 10 - (t - b[4]) / 1E3;
  885. if (c <= 0) {
  886. O.splice(f, 1),
  887. --f;
  888. } else {
  889. 1 < c && (c = 1), a.globalAlpha = .3 * c;
  890. a.moveTo(b[0] - .5, b[1] - .5);
  891. a.lineTo(b[2] - .5, b[3] - .5);
  892. }
  893. }
  894. a.stroke();
  895. a.restore();
  896. }
  897. a.save();
  898. //for (var p in F) F.hasOwnProperty(p) && a.drawImage(P, scale(sa(F[p].getX()) - 6), scale(ta(F[p].getY()) - 6), scale(P.width), scale(P.height));
  899. //cursorsonline=0;
  900. for (var p in F) {
  901. F.hasOwnProperty(p) && a.drawImage(P, sa(F[p].getX()) - 6, ta(F[p].getY()) - 6);
  902. //cursorsonline+=1;
  903. // show ids?
  904. if (showcursorsid) {
  905. if(cursorIDPos==2) {
  906. cp=a.measureText(p).width;
  907. a.globalAlpha = .5; a.strokeText( p, sa(F[p].getX()) - cp + cursorIDX, ta(F[p].getY()) + cursorIDY );
  908. a.globalAlpha= 1; a.fillText( p, sa(F[p].getX()) - cp + cursorIDX, ta(F[p].getY()) + cursorIDY );
  909. }
  910. else{
  911. a.globalAlpha = .5; a.strokeText( p, sa(F[p].getX()) + cursorIDX, ta(F[p].getY()) + cursorIDY );
  912. a.globalAlpha= 1; a.fillText( p, sa(F[p].getX()) + cursorIDX, ta(F[p].getY()) + cursorIDY );
  913. }
  914. }
  915. }
  916. if (showcursorsid) {
  917. if(cursorIDPos==2) {
  918. cp=a.measureText(ha).width;
  919. a.globalAlpha = .5; a.strokeText( ha, sa(k) - cp + cursorIDX, ta(q) + cursorIDY ) ;
  920. a.globalAlpha= 1; a.fillText( ha, sa(k) - cp + cursorIDX, ta(q) + cursorIDY ) ;
  921. }
  922. else{
  923. a.globalAlpha = .5; a.strokeText( ha, sa(k) + cursorIDX, ta(q) + cursorIDY ) ;
  924. a.globalAlpha= 1; a.fillText( ha, sa(k) + cursorIDX, ta(q) + cursorIDY ) ;
  925. }
  926. }
  927.  
  928. a.restore();
  929. oa(!0);
  930. if (!D) {
  931. a.font = 15 + "px NovaSquare", a.strokeStyle = "#000000", a.fillStyle = "#FFFFFF", a.lineWidth = 2.5;
  932. if (message.length>0) {
  933. b = a.measureText(message).width/2;
  934. a.globalAlpha = .5, a.strokeText(message, 400 - b, 580), a.globalAlpha = 1;
  935. a.fillText(message, 400 - b, 580);
  936. }
  937. for (var i=0; i < messages.length; i++) {
  938. b = a.measureText(messages[i]).width/2;
  939. a.globalAlpha = .5, a.strokeText(messages[i], 400 - b, 580 - messages.length*15 + i*15 ), a.globalAlpha = 1;
  940. a.fillText(messages[i], 400 - b, 580 - messages.length*15 + i*15);
  941. }
  942. if (showHelp) {
  943. var oo = a.measureText("->").width;
  944. a.font = 12 + "px NovaSquare";
  945. f = "How to use (press F1 to hide):", a.globalAlpha = .5, a.strokeText(f, 10, 45), a.globalAlpha = 1, a.fillText(f, 10, 45);
  946. f = "-> To type: type message and hit enter (shift+enter for new row)", a.globalAlpha = .5, a.strokeText(f, 10, 60), a.globalAlpha = 1, a.fillText(f, 10, 60);
  947. f = "-> To enable or disable movement: press numpad . OR delete", a.globalAlpha = .5, a.strokeText(f, 10, 75), a.globalAlpha = 1, a.fillText(f, 10, 75);
  948. f = "pathfiner will be active in this mode", a.globalAlpha = .5, a.strokeText(f, 10+oo, 90), a.globalAlpha = 1, a.fillText(f, 10+oo, 90);
  949. f = "-> To start/stop drawing circle: press numpad 0 OR insert", a.globalAlpha = .5, a.strokeText(f, 10, 105), a.globalAlpha = 1, a.fillText(f, 10, 105);
  950. f = "-> To draw arrows, use the arrow keys", a.globalAlpha = .5, a.strokeText(f, 10, 120), a.globalAlpha = 1, a.fillText(f, 10, 120);
  951. f = "-> To draw images: press numpad 1 - numpad 9", a.globalAlpha = .5, a.strokeText(f, 10, 135), a.globalAlpha = 1, a.fillText(f, 10, 135);
  952. f = "-> To make images bigger/smaller use numpad + and -", a.globalAlpha = .5, a.strokeText(f, 10, 150), a.globalAlpha = 1, a.fillText(f, 10, 150);
  953. f = "-> To reset image size press numpad *", a.globalAlpha = .5, a.strokeText(f, 10, 165), a.globalAlpha = 1, a.fillText(f, 10, 165);
  954. f = "-> To show/hide cursors ids: press F8", a.globalAlpha = .5, a.strokeText(f, 10, 180), a.globalAlpha = 1, a.fillText(f, 10, 180);
  955. f = "-> Change ids position: press F9", a.globalAlpha = .5, a.strokeText(f, 10, 195), a.globalAlpha = 1, a.fillText(f, 10, 195);
  956. }
  957. }
  958. }
  959. a.restore();
  960. A.requestAnimationFrame(ma)
  961. }
  962.  
  963. function scale(z) {
  964. return Math.round(z/600*a.canvas.height);
  965. }
  966.  
  967. function na() {
  968. a.save();
  969. a.strokeStyle = "#000000";
  970. t = +new Date;
  971. for (var f = 0; f < I.length; f++) {
  972. var b = I[f],
  973. c = (t - b[2]) / 1E3,
  974. d = 1 - 2 * c;
  975. 0 >= d ? (I.splice(f, 1), --f) : (c *= 50, a.beginPath(), a.globalAlpha = .3 * d, a.arc(b[0], b[1], c, 0, 2 * Math.PI, !1), a.stroke());
  976. }
  977. a.restore()
  978. }
  979.  
  980. function oa(f) {
  981. if (D) a.save(), a.globalAlpha = 1, a.drawImage(P, B - 5, C - 5, P.width, P.height);
  982. else {
  983. var b = 0,
  984. c = 0;
  985. if (v != k || w != q) {
  986. a.save();
  987. if (f) {
  988. a.globalAlpha = .2, a.fillStyle = "#FF0000", a.beginPath();
  989. a.arc(B + 2, C + 8, 20, 0, 2 * Math.PI, !1);
  990. a.fill();
  991. }
  992. a.globalAlpha = .5;
  993. a.drawImage(P, B - 5, C - 5, P.width, P.height);
  994. a.restore();
  995. } else {
  996. b = B & 1, c = C & 1;
  997. }
  998. a.save();
  999. if (f) {
  1000. a.globalAlpha = .2, a.fillStyle = "#FFFF00", a.beginPath();
  1001. a.arc((k << 1) + b + 2, (q << 1) + c + 8, 20, 0, 2 * Math.PI, !1);
  1002. a.fill();
  1003. }
  1004. a.globalAlpha = 1;
  1005. a.drawImage(Ia, (k << 1) + b - 5, (q << 1) + c - 5, Ia.width, Ia.height);
  1006. if (!movementEnabled) {
  1007. a.strokeStyle = "#DD4444", a.lineWidth = 1;
  1008. a.beginPath();
  1009. a.arc(serverPosX << 1, serverPosY << 1, 4, 0, 2*Math.PI);
  1010. a.stroke();
  1011. }
  1012. }
  1013. a.restore();
  1014. }
  1015.  
  1016. function ka(a, b) {
  1017. this.oldX = this.newX = a;
  1018. this.oldY = this.newY = b;
  1019. this.time = t
  1020. }
  1021.  
  1022. function pa(a) {
  1023. return a * a * (3 - 2 * a)
  1024. }
  1025.  
  1026. function fa(a, b, c, d) {
  1027. a |= 0;
  1028. b |= 0;
  1029. c |= 0;
  1030. d |= 0;
  1031. if (z(a, b)) return {
  1032. x: a,
  1033. y: b
  1034. };
  1035. if (a == c && b == d) return {
  1036. x: c,
  1037. y: d
  1038. };
  1039. var g = a,
  1040. e = b;
  1041. c = c - a | 0;
  1042. d = d - b | 0;
  1043. var n =
  1044. 0,
  1045. l = 0,
  1046. p = 0,
  1047. k = 0;
  1048. 0 > c ? n = -1 : 0 < c && (n = 1);
  1049. 0 > d ? l = -1 : 0 < d && (l = 1);
  1050. 0 > c ? p = -1 : 0 < c && (p = 1);
  1051. var m = Math.abs(c) | 0,
  1052. h = Math.abs(d) | 0;
  1053. m <= h && (m = Math.abs(d) | 0, h = Math.abs(c) | 0, 0 > d ? k = -1 : 0 < d && (k = 1), p = 0);
  1054. c = m >> 1;
  1055. for (d = 0; d <= m && !z(a, b); d++) g = a, e = b, c += h, c >= m ? (c -= m, a += n, b += l) : (a += p, b += k);
  1056. return {
  1057. x: g,
  1058. y: e
  1059. }
  1060. }
  1061.  
  1062. function z(a, b) {
  1063. return 0 > a || 400 <= a || 0 > b || 300 <= b ? !0 : T[a + 400 * b]
  1064. }
  1065.  
  1066. function Ja() {
  1067. for (var a = 0; a < r.length; a++) {
  1068. var b = r[a];
  1069. 5 == b.type && Ka(b)
  1070. }
  1071. }
  1072.  
  1073. function Ka(a) {
  1074. function b(a, b, c) {
  1075. e.push([c, a, b]);
  1076. l[a + 400 * b] = !0;
  1077. g(a, b)
  1078. }
  1079.  
  1080. function c(a, b, c) {
  1081. p.push([c,
  1082. a, b
  1083. ]);
  1084. l[a + 400 * b] = !0
  1085. }
  1086.  
  1087. function d(a, b) {
  1088. return 255 != k[4 * (a + 400 * b) + 3] && !l[a + 400 * b]
  1089. }
  1090.  
  1091. function g(a, b) {
  1092. var c = 4 * (a + 400 * b);
  1093. k[c + 0] = 255;
  1094. k[c + 1] = 153;
  1095. k[c + 2] = 153;
  1096. k[c + 3] = 255
  1097. }
  1098. for (var e = a.queue, k = a.img.data, l = a.explored, p = a.potentialQueue, r = e.length, m = 0; m < p.length; m++) z(p[m][1], p[m][2]) || (g(p[m][1], p[m][2]), e.push(p[m]), p.splice(m, 1), --m);
  1099. for (m = 0; m < r; ++m) z(e[m][1], e[m][2]) && (p.push(e[m]), e.splice(m, 1), --m, --r);
  1100. for (r = 0; 50 > r && 0 != e.length; ++r) {
  1101. for (var h = Number.POSITIVE_INFINITY, q = [e[0]], m = 1; m < e.length; ++m) {
  1102. var x = e[m][0];
  1103. .01 > Math.abs(x - h) ? q.push(e[m]) : x < h && (h = x, q = [e[m]])
  1104. }
  1105. for (m = 0; m < q.length; ++m) {
  1106. var x = q[m][0],
  1107. h = q[m][1],
  1108. s = q[m][2],
  1109. qa = e.indexOf(q[m]); - 1 != qa && e.splice(qa, 1);
  1110. 0 < h && d(h - 1, s) && (z(h - 1, s) ? c(h - 1, s, x + 1) : b(h - 1, s, x + 1));
  1111. 0 < s && d(h, s - 1) && (z(h, s - 1) ? c(h, s - 1, x + 1) : b(h, s - 1, x + 1));
  1112. 400 > h + 1 && d(h + 1, s) && (z(h + 1, s) ? c(h + 1, s, x + 1) : b(h + 1, s, x + 1));
  1113. 300 > s + 1 && d(h, s + 1) && (z(h, s + 1) ? c(h, s + 1, x + 1) : b(h, s + 1, x + 1));
  1114. 0 < h && 0 < s && d(h - 1, s - 1) && (z(h - 1, s - 1) ? c(h - 1, s - 1, x + Math.SQRT2) : b(h - 1, s - 1, x + Math.SQRT2));
  1115. 0 < h && 300 > s + 1 && d(h - 1, s + 1) && (z(h - 1, s + 1) ? c(h - 1, s + 1, x + Math.SQRT2) :
  1116. b(h - 1, s + 1, x + Math.SQRT2));
  1117. 400 > h + 1 && 0 < s && d(h + 1, s - 1) && (z(h + 1, s - 1) ? c(h + 1, s - 1, x + Math.SQRT2) : b(h + 1, s - 1, x + Math.SQRT2));
  1118. 400 > h + 1 && 300 > s + 1 && d(h + 1, s + 1) && (z(h + 1, s + 1) ? c(h + 1, s + 1, x + Math.SQRT2) : b(h + 1, s + 1, x + Math.SQRT2))
  1119. }
  1120. }
  1121. a.ctx.putImageData(a.img, 0, 0)
  1122. }
  1123. var y, a, ia = 0,
  1124. Rat = A.devicePixelRatio;
  1125. cp = 0,
  1126. v = 0,
  1127. w = 0,
  1128. B = 0,
  1129. C = 0,
  1130. k = 0,
  1131. q = 0,
  1132. J = -1,
  1133. K = -1,
  1134. M = null,
  1135. H = null,
  1136. P = new Image;
  1137. P.src = "img/cursor.png";
  1138. var Ia = P,
  1139. D = -1 != A.location.search.indexOf("editor"),
  1140. I = [],
  1141. O = [],
  1142. t = 0,
  1143. ca = 0,
  1144. u = null,
  1145. ha = -1,
  1146. F = {},
  1147. aa = 0,
  1148. ja = !1,
  1149. Y = !1,
  1150. R = 0,
  1151. S = 0,
  1152. da = 0,
  1153. X = !1,
  1154. L = !D && !0,
  1155. T = new Uint8Array(12E4),
  1156. r = [],
  1157. N = [];
  1158. Array.prototype.remove =
  1159. function(a) {
  1160. a = this.indexOf(a);
  1161. return -1 != a ? (this.splice(a, 1), !0) : !1
  1162. };
  1163. var G = 0;
  1164. ka.prototype = {
  1165. oldX: 0,
  1166. oldY: 0,
  1167. newX: 0,
  1168. newY: 0,
  1169. time: 0,
  1170. getX: function() {
  1171. var a = this.newX - this.oldX,
  1172. b = (t - this.time) / 100,
  1173. b = pa(0 >= b ? 0 : 1 <= b ? 1 : b);
  1174. return this.oldX + b * a
  1175. },
  1176. getY: function() {
  1177. var a = this.newY - this.oldY,
  1178. b = (t - this.time) / 100,
  1179. b = pa(0 >= b ? 0 : 1 <= b ? 1 : b);
  1180. return this.oldY + b * a
  1181. }
  1182. };
  1183.  
  1184. var za = new Uint8Array(12E4);
  1185. Array.prototype.remove = function(a) {
  1186. a = this.indexOf(a);
  1187. return -1 != a ? (this.splice(a, 1), !0) : !1
  1188. };
  1189.  
  1190. var imgSizeShowDur;
  1191. var imgSizePrcnt=100;
  1192. function imgSizeDisplay() {
  1193. clearTimeout(imgSizeShowDur);
  1194. imgSizePrcnt = Math.round(imageScale*100);
  1195. imgSizeInput(imgSizePrcnt);
  1196. imgSizeShow = true;
  1197. imgSizeShowDur = setTimeout(function() { imgSizeShow = false; }, 3000);
  1198. }
  1199.  
  1200. function imgSizeInput(d) {
  1201. var dd = document.getElementById('imgsize');
  1202. dd.value=d;
  1203. }
  1204.  
  1205. function imgSizeUp() {
  1206. imageScale += 0.1;
  1207. imgSizeDisplay();
  1208. }
  1209.  
  1210. function imgSizeDown() {
  1211. if(imageScale > 0.19) imageScale -= 0.1;
  1212. imgSizeDisplay();
  1213. }
  1214.  
  1215. function imgSizeReset() {
  1216. imageScale = 1.0;
  1217. imgSizeDisplay();
  1218. }
  1219.  
  1220. function pathfinderbox() {
  1221. dd = document.getElementById('pathfinder');
  1222. movementEnabled = !movementEnabled;
  1223. if (movementEnabled) dd.checked = false;
  1224. else dd.checked = true;
  1225. }
  1226.  
  1227. function fontwidth() {
  1228. dd = document.getElementById('fontwidth');
  1229. fontthin = !fontthin;
  1230. if (fontthin) { textwidth=2/3; dd.checked = true; }
  1231. else { textwidth=1; dd.checked = false; }
  1232. }
  1233.  
  1234. function hideExtraInfoLbls() {
  1235. dd = document.getElementById('extrainfo');
  1236. hideExtraInfo=!hideExtraInfo;
  1237. if (hideExtraInfo) dd.checked = true;
  1238. else dd.checked = false;
  1239. }
  1240.  
  1241. var taploop, tapchk=false;
  1242. function tap() {// send a click every 3 seconds
  1243. if (tapchk) { clearInterval(taploop); tapchk=false; }
  1244. else { taploop = setInterval(function() { wa(k,q,1); }, 3000); tapchk=true; }
  1245. }
  1246.  
  1247. var message = new String();
  1248. var messages = new Array();
  1249.  
  1250. function drawM(m,d,x,y) {
  1251. setTimeout(function() {
  1252. drawWord(m, x, y );
  1253. }, d);
  1254. }
  1255.  
  1256. function handleKeypress(e) {
  1257. if (e.target.tagName.toUpperCase() == 'INPUT') return;
  1258. if ((e.which >= 32 && e.which <= 64) ||
  1259. (e.which >= 65 && e.which <= 90) ||
  1260. (e.which >= 91 && e.which <= 126) ) {
  1261. e.preventDefault();
  1262. message = message.concat(String.fromCharCode(e.which));
  1263. return;
  1264. }
  1265. switch(e.which) {
  1266. case 13:
  1267. e.preventDefault();
  1268. if (e.shiftKey) { //add new row
  1269. messages.push(message);
  1270. message = "";
  1271. }
  1272. else { //print all rows
  1273. messages.push(message);
  1274. for(var i=0; i < messages.length; i++) {
  1275. if (i>0) var del = messages[i-1].length*i*50;
  1276. else var del=0;
  1277. drawM(messages[i],del,k,q+i*kerning*fontSize);//not ideal printing, but better than printing as columns
  1278. }
  1279. message = "";
  1280. messages = [];
  1281. }
  1282.  
  1283. break;
  1284. default:
  1285. return;
  1286. }
  1287. }
  1288.  
  1289. function handleKeydown(e) {
  1290. if (e.target.tagName.toUpperCase() == 'INPUT') return;
  1291. if (e.keyCode == 8 || e.keyCode == 9 || (e.keyCode >=33 && e.keyCode <= 40)
  1292. || (e.keyCode >= 96 && e.keyCode <= 122)
  1293. //|| e.keyCode == 12 || e.keyCode == 45 || (e.keyCode >= 33 && e.keyCode <= 36)
  1294. ) {
  1295. e.preventDefault();
  1296. }
  1297. if (e.keyCode == 8) {
  1298. if (message.length > 0) {
  1299. message = message.substring(0, message.length - 1);
  1300. }
  1301. else if (messages.length > 0) {
  1302. message = messages.pop();
  1303. }
  1304. }
  1305. switch(e.keyCode) {
  1306. case 37: // left arrow
  1307. drawImage(0, posX, posY); // draw arrow pointing left
  1308. break;
  1309. case 38: // up arrow
  1310. drawImage(1, posX, posY); // draw arrow pointing up
  1311. break;
  1312. case 39: // right arrow
  1313. drawImage(2, posX, posY); // draw arrow right
  1314. break;
  1315. case 40: // down arrow
  1316. drawImage(3, posX, posY); // draw arrow down
  1317. break;
  1318. case 106: //numpad *
  1319. imgSizeReset(); // reset drawings size
  1320. break;
  1321. case 107: //numpad +
  1322. imgSizeUp(); // make drawings bigger
  1323. break;
  1324. case 109: //numpad -
  1325. imgSizeDown(); // make drawings smaller
  1326. break;
  1327. case 33: // Page Up
  1328. drawWord(cmessage, posX, posY); //print message
  1329. break;
  1330. case 46: case 110: // numpad .
  1331. pathfinderbox(); // disable/enable movement by click
  1332. break;
  1333. case 45: case 96: // numpad 0
  1334. auraEnabled = !auraEnabled; // start/stop drawing circle
  1335. break;
  1336. case 97: //case 35: // numpad 1
  1337. drawImage(4, posX, posY); // star
  1338. break;
  1339. case 98: //case 40: // numpad 2
  1340. drawImage(5, posX, posY); // reversed star
  1341. break;
  1342. case 99: //case 34: // numpad 3
  1343. drawImage(6, posX, posY); // tictactoe
  1344. break;
  1345. case 100: //case 37: // numpad 4
  1346. drawImage(7, posX, posY); // triforce
  1347. break;
  1348. case 101: //case 12: // numpad 5
  1349. drawImage(8, posX, posY); // cannon - pentashot
  1350. break;
  1351. case 102: //case 39: // numpad 6
  1352. drawImage(9, posX,posY); // heart
  1353. break;
  1354. case 103: //case 36: // numpad 7
  1355. imageScale/=1.25;
  1356. drawImage(10, posX, posY); // penrose
  1357. imageScale*=1.25;
  1358. break;
  1359. case 104: //case 38: // numpad 8
  1360. //imageScale/=2.5;
  1361. drawImage(11, posX, posY); // boxception
  1362. //imageScale*=2.5;
  1363. break;
  1364. case 105: // numpad 9
  1365. drawImage(12, posX, posY); // cursor
  1366. break;
  1367. case 111: // numpad /
  1368. imageScale/=2.5;
  1369. drawImage(13, posX, posY); // dickboob
  1370. imageScale*=2.5;
  1371. break;
  1372. case 112: // F1
  1373. showHelp = !showHelp; // show/hide help
  1374. break;
  1375. case 115: // F4
  1376. //tap();
  1377. break;
  1378. case 119: // F8
  1379. showcursorsid = !showcursorsid; // show/hide cursors ids
  1380. break;
  1381. case 120: // F9
  1382. cursorIDPos+=1;
  1383. changeCursorIDpos(cursorIDPos);
  1384. break;
  1385. case 121: // F10
  1386. fontwidth();
  1387. break;
  1388. case 122: // F11
  1389. hideExtraInfoLbls();
  1390. break;
  1391. default:
  1392. return;
  1393. }
  1394. }
  1395.  
  1396. var cursorIDPos=1;
  1397. var cursorIDX=-2;
  1398. var cursorIDY=24;
  1399.  
  1400. function changeCursorIDpos(c) {
  1401. switch(c) {
  1402. case 1: cursorIDX=-2; cursorIDY=24; break;
  1403. case 2: cursorIDX=-3; cursorIDY=14; break;
  1404. case 3: cursorIDX=-2; cursorIDY=-3; break;
  1405. case 4: cursorIDX=10; cursorIDY=14; break;
  1406. default: cursorIDX=-2; cursorIDY=24; cursorIDPos=1;
  1407. }
  1408. }
  1409.  
  1410. function drawAura(x, y) {
  1411. var dt = 360/(1000/40)/2;
  1412. if (u != null && u.readyState == WebSocket.OPEN) {
  1413. var g = new ArrayBuffer(9),
  1414. e = new DataView(g);
  1415. e.setUint8(0, 3);
  1416. e.setUint16(1, x+Math.sin(degToRad(auraTime+dt))*auraRadius, !0);
  1417. e.setUint16(3, y+Math.cos(degToRad(auraTime+dt))*auraRadius, !0);
  1418. e.setUint16(5, x+Math.sin(degToRad(auraTime))*auraRadius, !0);
  1419. e.setUint16(7, y+Math.cos(degToRad(auraTime))*auraRadius, !0);
  1420. u.Send(g)
  1421. }
  1422.  
  1423. auraTime += dt;
  1424. }
  1425.  
  1426. function drawImage(ind, x, y) {
  1427. if (!imgData[ind]) return;
  1428. for (var i = 0; i < imgData[ind].length; i++) {
  1429. var g = new ArrayBuffer(9),
  1430. e = new DataView(g);
  1431. e.setUint8(0, 3);
  1432. e.setUint16(1, x+imgData[ind][i][1]*imageScale, !0);
  1433. e.setUint16(3, y+imgData[ind][i][0]*imageScale, !0);
  1434. e.setUint16(5, x+imgData[ind][i][3]*imageScale, !0);
  1435. e.setUint16(7, y+imgData[ind][i][2]*imageScale, !0);
  1436. u.Send(g);
  1437. }
  1438. }
  1439.  
  1440. function degToRad(deg) {
  1441. return deg * (Math.PI / 180);
  1442. }
  1443.  
  1444. function radToDeg(rad) {
  1445. return rad * (180 / Math.PI);
  1446. }
  1447.  
  1448. var textwidth = 1; // 1 = full width, 2/3 = thin text
  1449. function drawLetter(a, x, y) {
  1450. var letter;
  1451. var capital = 1;
  1452. var shift = 0;
  1453. if (alphabet.hasOwnProperty(a)) {
  1454. letter = alphabet[a];
  1455. } else if (a + 32 >= 97 && a + 32 <= 122) {
  1456. capital = 1.5;
  1457. shift = -2;
  1458. letter = alphabet[a + 32];
  1459. } else return;
  1460. for (var i = 0; i < letter.length; i++) {
  1461. var g = new ArrayBuffer(9),
  1462. e = new DataView(g);
  1463. e.setUint8(0, 3);
  1464. e.setUint16(1, x+letter[i][1]*fontSize*textwidth, !0);
  1465. e.setUint16(3, y+letter[i][0]*fontSize*capital + shift, !0);
  1466. e.setUint16(5, x+letter[i][3]*fontSize*textwidth, !0);
  1467. e.setUint16(7, y+letter[i][2]*fontSize*capital + shift, !0);
  1468. u.Send(g);
  1469. }
  1470. }
  1471.  
  1472. function drawWord(s, x, y) {
  1473. if (s == null) return;
  1474. setTimeout(function () {
  1475. if (!z(Math.round(x+fontSize*kerning*textwidth), Math.round(y))) {
  1476. drawLetter(s.charCodeAt(0), x, y);
  1477. if (s.length > 0) drawWord(s.substring(1, s.length), x+fontSize*kerning*textwidth, y);
  1478. }
  1479. }, 1);
  1480. }
  1481. WebSocket.prototype.Send = function(frm) {
  1482. if (u != null && u.readyState == WebSocket.OPEN) {
  1483. if (Throttler.check(frm)) this.send(frm);
  1484. }
  1485. };
  1486.  
  1487. var Throttler = {
  1488. rate: 3,
  1489. per: 150,
  1490. storage: [],
  1491. allowed: 3,
  1492. lastFrameAt: 0,
  1493. sendOut: function() {
  1494. if (this.storage.length != 0) {
  1495. u.Send(this.storage.shift());
  1496. }
  1497. },
  1498. check: function(frm) {
  1499. var now = Date.now();
  1500. var allowance = this.allowed;
  1501. var timeDiff = now - this.lastFrameAt;
  1502. this.lastFrameAt = now;
  1503. allowance += timeDiff*(this.rate/this.per);
  1504. if (allowance > this.rate) allowance = this.rate;
  1505. this.allowed = allowance;
  1506. if (this.allowed < 1) {
  1507. if (this.storage.length < 300) {
  1508. var dv = new DataView(frm);
  1509. if (dv.getUint8(0) == 3) this.storage.push(frm);
  1510. }
  1511. return false;
  1512. }
  1513. this.allowed -= 1;
  1514. return true;
  1515. }
  1516. };
  1517.  
  1518. var ff = navigator.userAgent.indexOf("Chrome") == -1;
  1519.  
  1520. function dos(head) {
  1521. var gridX = 400,
  1522. gridY = 300;
  1523. var grid = [];
  1524. visit = [];
  1525. for (var i = 0; i < gridY; i++) {
  1526. grid[i] = [];
  1527. visit[i] = [];
  1528. for (var j = 0; j < gridX; j++) grid[i][j] = 0, visit[i][j] = 0;
  1529. }
  1530. r.forEach(function(d) {
  1531. if ((d.type == 1) || (d.type == 2 && d.isBad))
  1532. for (var j = 0; j < d.height; j++)
  1533. for (var i = 0; i < d.width; i++) grid[d.y + j][d.x + i] = 3
  1534. });
  1535. var bfs = [head],
  1536. bfs2 = [];
  1537. while (bfs.length) {
  1538. bfs.forEach(function(dat) {
  1539. var x = dat[0],
  1540. y = dat[1];
  1541. if (x == null || y == null) return;
  1542. if (grid[y][x] == 3) return;
  1543. grid[y][x] = 3;
  1544. for (var X = x + 1; X < gridX && !(grid[y][X] & 1); X++) {
  1545. grid[y][X] |= 1;
  1546. if (!visit[y][X]) {
  1547. visit[y][X] = [x, y], bfs2.push([X, y]);
  1548. }
  1549. }
  1550. for (var X = x - 1; X >= 0 && !(grid[y][X] & 1); X--) {
  1551. grid[y][X] |= 1;
  1552. if (!visit[y][X]) {
  1553. visit[y][X] = [x, y], bfs2.push([X, y]);
  1554. }
  1555. }
  1556. for (var Y = y + 1; Y < gridY && !(grid[Y][x] & 2); Y++) {
  1557. grid[Y][x] |= 2;
  1558. if (!visit[Y][x]) {
  1559. visit[Y][x] = [x, y], bfs2.push([x, Y]);
  1560. }
  1561. }
  1562. for (var Y = y - 1; Y >= 0 && !(grid[Y][x] & 2); Y--) {
  1563. grid[Y][x] |= 2;
  1564. if (!visit[Y][x]) {
  1565. visit[Y][x] = [x, y], bfs2.push([x, Y]);
  1566. }
  1567. }
  1568. });
  1569. bfs = bfs2;
  1570. bfs2 = [];
  1571. }
  1572. }
  1573.  
  1574. window.head=[];
  1575. window.delay=30;
  1576. function fm(mov, i=0) {
  1577. if (!D && null != u && u.readyState == WebSocket.OPEN) {
  1578. if (i >= mov.length) {
  1579. var buf = new ArrayBuffer(9),
  1580. q = new DataView(buf);
  1581. q.setUint8(0, 2, 1);
  1582. q.setUint16(1, mov[i-1][0], 1);
  1583. q.setUint16(3, mov[i-1][1], 1);
  1584. q.setInt32(5, -1, 1);
  1585. WebSocket.prototype.send.call(u, buf);
  1586. WebSocket.prototype.send.call(u, buf);
  1587. return;
  1588. }
  1589. var buf = new ArrayBuffer(9),
  1590. q = new DataView(buf);
  1591. q.setUint8(0, 1, 1);
  1592. q.setUint16(1, mov[i][0], 1);
  1593. q.setUint16(3, mov[i][1], 1);
  1594. q.setInt32(5, -1, 1);
  1595. WebSocket.prototype.send.call(u, buf);
  1596. W(mov[i][0], mov[i][1]);
  1597. if(delay == 0) {
  1598. fm(mov,i+1);
  1599. } else {
  1600. setTimeout(function() {
  1601. fm(mov, i + 1)
  1602. }, delay);
  1603. }
  1604. }
  1605. }
  1606.  
  1607. function clickAllButtons() {
  1608. for (var i = 0; i < maxButtons; i++) {
  1609. if (buttons[i][0] == null) break;
  1610. wa(buttons[i][0], buttons[i][1], buttons[i][2]);
  1611. }
  1612. }
  1613. function pf(e) {
  1614. auraEnabled = false;
  1615. unfocus();
  1616. if(ff) {e.offsetX = e.pageX - canvas.offsetLeft; e.offsetY = e.pageY - canvas.offsetTop}
  1617. var xy = [e.offsetX / 2 | 0, e.offsetY / 2 | 0];
  1618. var mov = [];
  1619. if (r && !(xy[0] == head[0] && xy[1] == head[1]) && !e.ctrlKey && !movementEnabled) {
  1620. head = [serverPosX,serverPosY];
  1621. dos(head);
  1622. var xy2 = xy.slice(0);
  1623. while (visit[xy2[1]][xy2[0]]) {
  1624. mov.push(xy2);
  1625. xy2 = visit[xy2[1]][xy2[0]]
  1626. }
  1627. mov = mov.reverse();
  1628. if (mov.length == 0) {
  1629. return;
  1630. }
  1631. else fm(mov);
  1632. } else if (!movementEnabled) {mov.push(xy); fm(mov);}
  1633. else {}
  1634. }
  1635.  
  1636. function connect() {
  1637. if (m28n.findServerPreference) {
  1638. if (!u) m28n.findServerPreference("cursors", function(e,a) {
  1639. if (e||0 == a.length) {
  1640. setTimeout(self.connect, 1E3);
  1641. } else {
  1642. var ipv4 = a[0].ipv4;
  1643. var ipv6 = a[0].ipv6;
  1644. var port = a[0].port;
  1645. port = 2828;
  1646. u = new WebSocket("ws://" + (ipv4 || "[" + ipv6 + "]") + ":" + port);
  1647. setHandlers();
  1648. }
  1649. });
  1650. } else {
  1651. if (!u) u = new WebSocket("ws://s1.cursors.io:443/");
  1652. setHandlers();
  1653. }
  1654. function setHandlers() {
  1655. u.binaryType = "arraybuffer";
  1656. u.onopen = Aa, u.onmessage = Ga, u.onclose = Ba, u.onerror = Ca;
  1657. }
  1658. }
  1659.  
  1660. var messageDisplay;
  1661. function doit() {
  1662. //document.body.innerHTML += '<div id="messageDisplay"></div>';
  1663. //messageDisplay = document.getElementById("messageDisplay");
  1664. var el0 = document.getElementById('h-options');
  1665. if (el0 != null) { el0.remove(); }
  1666.  
  1667. document.body.innerHTML += css;
  1668.  
  1669. y = E.getElementById("canvas");
  1670. a = y.getContext("2d");
  1671.  
  1672. try {
  1673. A.top.location.origin != A.location.origin && ba()
  1674. } catch (f) {
  1675. ba()
  1676. }
  1677. y.width = 800 * Rat;
  1678. y.height = 600 * Rat;
  1679. a.scale(Rat, Rat);
  1680. y.onmousemove = ua;
  1681. y.onmousedown = va;
  1682. y.onmouseup = xa;
  1683. y.onclick = pf;
  1684. M = E.getElementById("noCursorLock");
  1685. H = E.getElementById("noDrawings");
  1686. null != localStorage && (Ma(), M.checked = "1" == A.localStorage.getItem("noCursorLock") ? !0 : !1, H.checked = "1" == A.localStorage.getItem("noDrawings") ? !0 : !1);
  1687. A.onbeforeunload = ya;
  1688. y.requestPointerLock = y.requestPointerLock || y.mozRequestPointerLock || y.webkitRequestPointerLock;
  1689. y.style.cursor = "none";
  1690. D || connect();
  1691. setInterval(Q, 40);
  1692. //setInterval(Ja, 40);
  1693. setInterval(Au, 50);
  1694. A.requestAnimationFrame(ma);
  1695.  
  1696. document.onkeypress = handleKeypress;
  1697. document.onkeydown = handleKeydown;
  1698. }
  1699. doit();
  1700. }
Add Comment
Please, Sign In to add comment