Guest User

dadawdasd

a guest
Mar 26th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 117.98 KB | None | 0 0
  1. this.msgpack || (function(globalScope) {
  2.  
  3. globalScope.msgpack = {
  4. pack: msgpackpack, // msgpack.pack(data:Mix,
  5. // toString:Boolean = false):ByteArray/ByteString/false
  6. // [1][mix to String] msgpack.pack({}, true) -> "..."
  7. // [2][mix to ByteArray] msgpack.pack({}) -> [...]
  8. unpack: msgpackunpack, // msgpack.unpack(data:BinaryString/ByteArray):Mix
  9. // [1][String to mix] msgpack.unpack("...") -> {}
  10. // [2][ByteArray to mix] msgpack.unpack([...]) -> {}
  11. worker: "msgpack.js", // msgpack.worker - WebWorkers script filename
  12. upload: msgpackupload, // msgpack.upload(url:String, option:Hash, callback:Function)
  13. download: msgpackdownload // msgpack.download(url:String, option:Hash, callback:Function)
  14. };
  15.  
  16. var _ie = /MSIE/.test(navigator.userAgent),
  17. _bin2num = {}, // BinaryStringToNumber { "\00": 0, ... "\ff": 255 }
  18. _num2bin = {}, // NumberToBinaryString { 0: "\00", ... 255: "\ff" }
  19. _num2b64 = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
  20. "abcdefghijklmnopqrstuvwxyz0123456789+/").split(""),
  21. _buf = [], // decode buffer
  22. _idx = 0, // decode buffer[index]
  23. _error = 0, // msgpack.pack() error code. 1 = CYCLIC_REFERENCE_ERROR
  24. _isArray = Array.isArray || (function(mix) {
  25. return Object.prototype.toString.call(mix) === "[object Array]";
  26. }),
  27. _toString = String.fromCharCode, // CharCode/ByteArray to String
  28. _MAX_DEPTH = 512;
  29.  
  30. // for WebWorkers Code Block
  31. self.importScripts && (onmessage = function(event) {
  32. if (event.data.method === "pack") {
  33. postMessage(base64encode(msgpackpack(event.data.data)));
  34. } else {
  35. postMessage(msgpackunpack(event.data.data));
  36. }
  37. });
  38.  
  39. // msgpack.pack
  40. function msgpackpack(data, // @param Mix:
  41. toString) { // @param Boolean(= false):
  42. // @return ByteArray/BinaryString/false:
  43. // false is error return
  44. // [1][mix to String] msgpack.pack({}, true) -> "..."
  45. // [2][mix to ByteArray] msgpack.pack({}) -> [...]
  46.  
  47. _error = 0;
  48.  
  49. var byteArray = encode([], data, 0);
  50.  
  51. return _error ? false
  52. : toString ? byteArrayToByteString(byteArray)
  53. : byteArray;
  54. }
  55.  
  56. // msgpack.unpack
  57. function msgpackunpack(data) { // @param BinaryString/ByteArray:
  58. // @return Mix/undefined:
  59. // undefined is error return
  60. // [1][String to mix] msgpack.unpack("...") -> {}
  61. // [2][ByteArray to mix] msgpack.unpack([...]) -> {}
  62.  
  63. _buf = typeof data === "string" ? toByteArray(data) : data;
  64. _idx = -1;
  65. return decode(); // mix or undefined
  66. }
  67.  
  68. // inner - encoder
  69. function encode(rv, // @param ByteArray: result
  70. mix, // @param Mix: source data
  71. depth) { // @param Number: depth
  72. var size, i, iz, c, pos, // for UTF8.encode, Array.encode, Hash.encode
  73. high, low, sign, exp, frac; // for IEEE754
  74.  
  75. if (mix == null) { // null or undefined -> 0xc0 ( null )
  76. rv.push(0xc0);
  77. } else if (mix === false) { // false -> 0xc2 ( false )
  78. rv.push(0xc2);
  79. } else if (mix === true) { // true -> 0xc3 ( true )
  80. rv.push(0xc3);
  81. } else {
  82. switch (typeof mix) {
  83. case "number":
  84. if (mix !== mix) { // isNaN
  85. rv.push(0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff); // quiet NaN
  86. } else if (mix === Infinity) {
  87. rv.push(0xcb, 0x7f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); // positive infinity
  88. } else if (Math.floor(mix) === mix) { // int or uint
  89. if (mix < 0) {
  90. // int
  91. if (mix >= -32) { // negative fixnum
  92. rv.push(0xe0 + mix + 32);
  93. } else if (mix > -0x80) {
  94. rv.push(0xd0, mix + 0x100);
  95. } else if (mix > -0x8000) {
  96. mix += 0x10000;
  97. rv.push(0xd1, mix >> 8, mix & 0xff);
  98. } else if (mix > -0x80000000) {
  99. mix += 0x100000000;
  100. rv.push(0xd2, mix >>> 24, (mix >> 16) & 0xff,
  101. (mix >> 8) & 0xff, mix & 0xff);
  102. } else {
  103. high = Math.floor(mix / 0x100000000);
  104. low = mix & 0xffffffff;
  105. rv.push(0xd3, (high >> 24) & 0xff, (high >> 16) & 0xff,
  106. (high >> 8) & 0xff, high & 0xff,
  107. (low >> 24) & 0xff, (low >> 16) & 0xff,
  108. (low >> 8) & 0xff, low & 0xff);
  109. }
  110. } else {
  111. // uint
  112. if (mix < 0x80) {
  113. rv.push(mix); // positive fixnum
  114. } else if (mix < 0x100) { // uint 8
  115. rv.push(0xcc, mix);
  116. } else if (mix < 0x10000) { // uint 16
  117. rv.push(0xcd, mix >> 8, mix & 0xff);
  118. } else if (mix < 0x100000000) { // uint 32
  119. rv.push(0xce, mix >>> 24, (mix >> 16) & 0xff,
  120. (mix >> 8) & 0xff, mix & 0xff);
  121. } else {
  122. high = Math.floor(mix / 0x100000000);
  123. low = mix & 0xffffffff;
  124. rv.push(0xcf, (high >> 24) & 0xff, (high >> 16) & 0xff,
  125. (high >> 8) & 0xff, high & 0xff,
  126. (low >> 24) & 0xff, (low >> 16) & 0xff,
  127. (low >> 8) & 0xff, low & 0xff);
  128. }
  129. }
  130. } else { // double
  131. // THX!! @edvakf
  132. // http://javascript.g.hatena.ne.jp/edvakf/20101128/1291000731
  133. sign = mix < 0;
  134. sign && (mix *= -1);
  135.  
  136. // add offset 1023 to ensure positive
  137. // 0.6931471805599453 = Math.LN2;
  138. exp = ((Math.log(mix) / 0.6931471805599453) + 1023) | 0;
  139.  
  140. // shift 52 - (exp - 1023) bits to make integer part exactly 53 bits,
  141. // then throw away trash less than decimal point
  142. frac = mix * Math.pow(2, 52 + 1023 - exp);
  143.  
  144. // S+-Exp(11)--++-----------------Fraction(52bits)-----------------------+
  145. // || || |
  146. // v+----------++--------------------------------------------------------+
  147. // 00000000|00000000|00000000|00000000|00000000|00000000|00000000|00000000
  148. // 6 5 55 4 4 3 2 1 8 0
  149. // 3 6 21 8 0 2 4 6
  150. //
  151. // +----------high(32bits)-----------+ +----------low(32bits)------------+
  152. // | | | |
  153. // +---------------------------------+ +---------------------------------+
  154. // 3 2 21 1 8 0
  155. // 1 4 09 6
  156. low = frac & 0xffffffff;
  157. sign && (exp |= 0x800);
  158. high = ((frac / 0x100000000) & 0xfffff) | (exp << 20);
  159.  
  160. rv.push(0xcb, (high >> 24) & 0xff, (high >> 16) & 0xff,
  161. (high >> 8) & 0xff, high & 0xff,
  162. (low >> 24) & 0xff, (low >> 16) & 0xff,
  163. (low >> 8) & 0xff, low & 0xff);
  164. }
  165. break;
  166. case "string":
  167. // http://d.hatena.ne.jp/uupaa/20101128
  168. iz = mix.length;
  169. pos = rv.length; // keep rewrite position
  170.  
  171. rv.push(0); // placeholder
  172.  
  173. // utf8.encode
  174. for (i = 0; i < iz; ++i) {
  175. c = mix.charCodeAt(i);
  176. if (c < 0x80) { // ASCII(0x00 ~ 0x7f)
  177. rv.push(c & 0x7f);
  178. } else if (c < 0x0800) {
  179. rv.push(((c >>> 6) & 0x1f) | 0xc0, (c & 0x3f) | 0x80);
  180. } else if (c < 0x10000) {
  181. rv.push(((c >>> 12) & 0x0f) | 0xe0,
  182. ((c >>> 6) & 0x3f) | 0x80, (c & 0x3f) | 0x80);
  183. }
  184. }
  185. size = rv.length - pos - 1;
  186.  
  187. if (size < 32) {
  188. rv[pos] = 0xa0 + size; // rewrite
  189. } else if (size < 0x10000) { // 16
  190. rv.splice(pos, 1, 0xda, size >> 8, size & 0xff);
  191. } else if (size < 0x100000000) { // 32
  192. rv.splice(pos, 1, 0xdb,
  193. size >>> 24, (size >> 16) & 0xff,
  194. (size >> 8) & 0xff, size & 0xff);
  195. }
  196. break;
  197. default: // array or hash
  198. if (++depth >= _MAX_DEPTH) {
  199. _error = 1; // CYCLIC_REFERENCE_ERROR
  200. return rv = []; // clear
  201. }
  202. if (_isArray(mix)) {
  203. size = mix.length;
  204. if (size < 16) {
  205. rv.push(0x90 + size);
  206. } else if (size < 0x10000) { // 16
  207. rv.push(0xdc, size >> 8, size & 0xff);
  208. } else if (size < 0x100000000) { // 32
  209. rv.push(0xdd, size >>> 24, (size >> 16) & 0xff,
  210. (size >> 8) & 0xff, size & 0xff);
  211. }
  212. for (i = 0; i < size; ++i) {
  213. encode(rv, mix[i], depth);
  214. }
  215. } else { // hash
  216. // http://d.hatena.ne.jp/uupaa/20101129
  217. pos = rv.length; // keep rewrite position
  218. rv.push(0); // placeholder
  219. size = 0;
  220. for (i in mix) {
  221. ++size;
  222. encode(rv, i, depth);
  223. encode(rv, mix[i], depth);
  224. }
  225. if (size < 16) {
  226. rv[pos] = 0x80 + size; // rewrite
  227. } else if (size < 0x10000) { // 16
  228. rv.splice(pos, 1, 0xde, size >> 8, size & 0xff);
  229. } else if (size < 0x100000000) { // 32
  230. rv.splice(pos, 1, 0xdf,
  231. size >>> 24, (size >> 16) & 0xff,
  232. (size >> 8) & 0xff, size & 0xff);
  233. }
  234. }
  235. }
  236. }
  237. return rv;
  238. }
  239.  
  240. // inner - decoder
  241. function decode() { // @return Mix:
  242. var size, i, iz, c, num = 0,
  243. sign, exp, frac, ary, hash,
  244. buf = _buf, type = buf[++_idx];
  245.  
  246. if (type >= 0xe0) { // Negative FixNum (111x xxxx) (-32 ~ -1)
  247. return type - 0x100;
  248. }
  249. if (type < 0xc0) {
  250. if (type < 0x80) { // Positive FixNum (0xxx xxxx) (0 ~ 127)
  251. return type;
  252. }
  253. if (type < 0x90) { // FixMap (1000 xxxx)
  254. num = type - 0x80;
  255. type = 0x80;
  256. } else if (type < 0xa0) { // FixArray (1001 xxxx)
  257. num = type - 0x90;
  258. type = 0x90;
  259. } else { // if (type < 0xc0) { // FixRaw (101x xxxx)
  260. num = type - 0xa0;
  261. type = 0xa0;
  262. }
  263. }
  264. switch (type) {
  265. case 0xc0: return null;
  266. case 0xc2: return false;
  267. case 0xc3: return true;
  268. case 0xca: // float
  269. num = buf[++_idx] * 0x1000000 + (buf[++_idx] << 16) +
  270. (buf[++_idx] << 8) + buf[++_idx];
  271. sign = num & 0x80000000; // 1bit
  272. exp = (num >> 23) & 0xff; // 8bits
  273. frac = num & 0x7fffff; // 23bits
  274. if (!num || num === 0x80000000) { // 0.0 or -0.0
  275. return 0;
  276. }
  277. if (exp === 0xff) { // NaN or Infinity
  278. return frac ? NaN : Infinity;
  279. }
  280. return (sign ? -1 : 1) *
  281. (frac | 0x800000) * Math.pow(2, exp - 127 - 23); // 127: bias
  282. case 0xcb: // double
  283. num = buf[++_idx] * 0x1000000 + (buf[++_idx] << 16) +
  284. (buf[++_idx] << 8) + buf[++_idx];
  285. sign = num & 0x80000000; // 1bit
  286. exp = (num >> 20) & 0x7ff; // 11bits
  287. frac = num & 0xfffff; // 52bits - 32bits (high word)
  288. if (!num || num === 0x80000000) { // 0.0 or -0.0
  289. _idx += 4;
  290. return 0;
  291. }
  292. if (exp === 0x7ff) { // NaN or Infinity
  293. _idx += 4;
  294. return frac ? NaN : Infinity;
  295. }
  296. num = buf[++_idx] * 0x1000000 + (buf[++_idx] << 16) +
  297. (buf[++_idx] << 8) + buf[++_idx];
  298. return (sign ? -1 : 1) *
  299. ((frac | 0x100000) * Math.pow(2, exp - 1023 - 20) // 1023: bias
  300. + num * Math.pow(2, exp - 1023 - 52));
  301. // 0xcf: uint64, 0xce: uint32, 0xcd: uint16
  302. case 0xcf: num = buf[++_idx] * 0x1000000 + (buf[++_idx] << 16) +
  303. (buf[++_idx] << 8) + buf[++_idx];
  304. return num * 0x100000000 +
  305. buf[++_idx] * 0x1000000 + (buf[++_idx] << 16) +
  306. (buf[++_idx] << 8) + buf[++_idx];
  307. case 0xce: num += buf[++_idx] * 0x1000000 + (buf[++_idx] << 16);
  308. case 0xcd: num += buf[++_idx] << 8;
  309. case 0xcc: return num + buf[++_idx];
  310. // 0xd3: int64, 0xd2: int32, 0xd1: int16, 0xd0: int8
  311. case 0xd3: num = buf[++_idx];
  312. if (num & 0x80) { // sign -> avoid overflow
  313. return ((num ^ 0xff) * 0x100000000000000 +
  314. (buf[++_idx] ^ 0xff) * 0x1000000000000 +
  315. (buf[++_idx] ^ 0xff) * 0x10000000000 +
  316. (buf[++_idx] ^ 0xff) * 0x100000000 +
  317. (buf[++_idx] ^ 0xff) * 0x1000000 +
  318. (buf[++_idx] ^ 0xff) * 0x10000 +
  319. (buf[++_idx] ^ 0xff) * 0x100 +
  320. (buf[++_idx] ^ 0xff) + 1) * -1;
  321. }
  322. return num * 0x100000000000000 +
  323. buf[++_idx] * 0x1000000000000 +
  324. buf[++_idx] * 0x10000000000 +
  325. buf[++_idx] * 0x100000000 +
  326. buf[++_idx] * 0x1000000 +
  327. buf[++_idx] * 0x10000 +
  328. buf[++_idx] * 0x100 +
  329. buf[++_idx];
  330. case 0xd2: num = buf[++_idx] * 0x1000000 + (buf[++_idx] << 16) +
  331. (buf[++_idx] << 8) + buf[++_idx];
  332. return num < 0x80000000 ? num : num - 0x100000000; // 0x80000000 * 2
  333. case 0xd1: num = (buf[++_idx] << 8) + buf[++_idx];
  334. return num < 0x8000 ? num : num - 0x10000; // 0x8000 * 2
  335. case 0xd0: num = buf[++_idx];
  336. return num < 0x80 ? num : num - 0x100; // 0x80 * 2
  337. // 0xdb: raw32, 0xda: raw16, 0xa0: raw ( string )
  338. case 0xdb: num += buf[++_idx] * 0x1000000 + (buf[++_idx] << 16);
  339. case 0xda: num += (buf[++_idx] << 8) + buf[++_idx];
  340. case 0xa0: // utf8.decode
  341. for (ary = [], i = _idx, iz = i + num; i < iz; ) {
  342. c = buf[++i]; // lead byte
  343. ary.push(c < 0x80 ? c : // ASCII(0x00 ~ 0x7f)
  344. c < 0xe0 ? ((c & 0x1f) << 6 | (buf[++i] & 0x3f)) :
  345. ((c & 0x0f) << 12 | (buf[++i] & 0x3f) << 6
  346. | (buf[++i] & 0x3f)));
  347. }
  348. _idx = i;
  349. return ary.length < 10240 ? _toString.apply(null, ary)
  350. : byteArrayToByteString(ary);
  351. // 0xdf: map32, 0xde: map16, 0x80: map
  352. case 0xdf: num += buf[++_idx] * 0x1000000 + (buf[++_idx] << 16);
  353. case 0xde: num += (buf[++_idx] << 8) + buf[++_idx];
  354. case 0x80: hash = {};
  355. while (num--) {
  356. // make key/value pair
  357. size = buf[++_idx] - 0xa0;
  358.  
  359. for (ary = [], i = _idx, iz = i + size; i < iz; ) {
  360. c = buf[++i]; // lead byte
  361. ary.push(c < 0x80 ? c : // ASCII(0x00 ~ 0x7f)
  362. c < 0xe0 ? ((c & 0x1f) << 6 | (buf[++i] & 0x3f)) :
  363. ((c & 0x0f) << 12 | (buf[++i] & 0x3f) << 6
  364. | (buf[++i] & 0x3f)));
  365. }
  366. _idx = i;
  367. hash[_toString.apply(null, ary)] = decode();
  368. }
  369. return hash;
  370. // 0xdd: array32, 0xdc: array16, 0x90: array
  371. case 0xdd: num += buf[++_idx] * 0x1000000 + (buf[++_idx] << 16);
  372. case 0xdc: num += (buf[++_idx] << 8) + buf[++_idx];
  373. case 0x90: ary = [];
  374. while (num--) {
  375. ary.push(decode());
  376. }
  377. return ary;
  378. }
  379. return;
  380. }
  381.  
  382. // inner - byteArray To ByteString
  383. function byteArrayToByteString(byteArray) { // @param ByteArray
  384. // @return String
  385. // http://d.hatena.ne.jp/uupaa/20101128
  386. try {
  387. return _toString.apply(this, byteArray); // toString
  388. } catch(err) {
  389. ; // avoid "Maximum call stack size exceeded"
  390. }
  391. var rv = [], i = 0, iz = byteArray.length, num2bin = _num2bin;
  392.  
  393. for (; i < iz; ++i) {
  394. rv[i] = num2bin[byteArray[i]];
  395. }
  396. return rv.join("");
  397. }
  398.  
  399. // msgpack.download - load from server
  400. function msgpackdownload(url, // @param String:
  401. option, // @param Hash: { worker, timeout, before, after }
  402. // option.worker - Boolean(= false): true is use WebWorkers
  403. // option.timeout - Number(= 10): timeout sec
  404. // option.before - Function: before(xhr, option)
  405. // option.after - Function: after(xhr, option, { status, ok })
  406. callback) { // @param Function: callback(data, option, { status, ok })
  407. // data - Mix/null:
  408. // option - Hash:
  409. // status - Number: HTTP status code
  410. // ok - Boolean:
  411. option.method = "GET";
  412. option.binary = true;
  413. ajax(url, option, callback);
  414. }
  415.  
  416. // msgpack.upload - save to server
  417. function msgpackupload(url, // @param String:
  418. option, // @param Hash: { data, worker, timeout, before, after }
  419. // option.data - Mix:
  420. // option.worker - Boolean(= false): true is use WebWorkers
  421. // option.timeout - Number(= 10): timeout sec
  422. // option.before - Function: before(xhr, option)
  423. // option.after - Function: after(xhr, option, { status, ok })
  424. callback) { // @param Function: callback(data, option, { status, ok })
  425. // data - String: responseText
  426. // option - Hash:
  427. // status - Number: HTTP status code
  428. // ok - Boolean:
  429. option.method = "PUT";
  430. option.binary = true;
  431.  
  432. if (option.worker && globalScope.Worker) {
  433. var worker = new Worker(msgpack.worker);
  434.  
  435. worker.onmessage = function(event) {
  436. option.data = event.data;
  437. ajax(url, option, callback);
  438. };
  439. worker.postMessage({ method: "pack", data: option.data });
  440. } else {
  441. // pack and base64 encode
  442. option.data = base64encode(msgpackpack(option.data));
  443. ajax(url, option, callback);
  444. }
  445. }
  446.  
  447. // inner -
  448. function ajax(url, // @param String:
  449. option, // @param Hash: { data, ifmod, method, timeout,
  450. // header, binary, before, after, worker }
  451. // option.data - Mix: upload data
  452. // option.ifmod - Boolean: true is "If-Modified-Since" header
  453. // option.method - String: "GET", "POST", "PUT"
  454. // option.timeout - Number(= 10): timeout sec
  455. // option.header - Hash(= {}): { key: "value", ... }
  456. // option.binary - Boolean(= false): true is binary data
  457. // option.before - Function: before(xhr, option)
  458. // option.after - Function: after(xhr, option, { status, ok })
  459. // option.worker - Boolean(= false): true is use WebWorkers
  460. callback) { // @param Function: callback(data, option, { status, ok })
  461. // data - String/Mix/null:
  462. // option - Hash:
  463. // status - Number: HTTP status code
  464. // ok - Boolean:
  465. function readyStateChange() {
  466. if (xhr.readyState === 4) {
  467. var data, status = xhr.status, worker, byteArray,
  468. rv = { status: status, ok: status >= 200 && status < 300 };
  469.  
  470. if (!run++) {
  471. if (method === "PUT") {
  472. data = rv.ok ? xhr.responseText : "";
  473. } else {
  474. if (rv.ok) {
  475. if (option.worker && globalScope.Worker) {
  476. worker = new Worker(msgpack.worker);
  477. worker.onmessage = function(event) {
  478. callback(event.data, option, rv);
  479. };
  480. worker.postMessage({ method: "unpack",
  481. data: xhr.responseText });
  482. gc();
  483. return;
  484. } else {
  485. byteArray = _ie ? toByteArrayIE(xhr)
  486. : toByteArray(xhr.responseText);
  487. data = msgpackunpack(byteArray);
  488. }
  489. }
  490. }
  491. after && after(xhr, option, rv);
  492. callback(data, option, rv);
  493. gc();
  494. }
  495. }
  496. }
  497.  
  498. function ng(abort, status) {
  499. if (!run++) {
  500. var rv = { status: status || 400, ok: false };
  501.  
  502. after && after(xhr, option, rv);
  503. callback(null, option, rv);
  504. gc(abort);
  505. }
  506. }
  507.  
  508. function gc(abort) {
  509. abort && xhr && xhr.abort && xhr.abort();
  510. watchdog && (clearTimeout(watchdog), watchdog = 0);
  511. xhr = null;
  512. globalScope.addEventListener &&
  513. globalScope.removeEventListener("beforeunload", ng, false);
  514. }
  515.  
  516. var watchdog = 0,
  517. method = option.method || "GET",
  518. header = option.header || {},
  519. before = option.before,
  520. after = option.after,
  521. data = option.data || null,
  522. xhr = globalScope.XMLHttpRequest ? new XMLHttpRequest() :
  523. globalScope.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") :
  524. null,
  525. run = 0, i,
  526. overrideMimeType = "overrideMimeType",
  527. setRequestHeader = "setRequestHeader",
  528. getbinary = method === "GET" && option.binary;
  529.  
  530. try {
  531. xhr.onreadystatechange = readyStateChange;
  532. xhr.open(method, url, true); // ASync
  533.  
  534. before && before(xhr, option);
  535.  
  536. getbinary && xhr[overrideMimeType] &&
  537. xhr[overrideMimeType]("text/plain; charset=x-user-defined");
  538. data &&
  539. xhr[setRequestHeader]("Content-Type",
  540. "application/x-www-form-urlencoded");
  541.  
  542. for (i in header) {
  543. xhr[setRequestHeader](i, header[i]);
  544. }
  545.  
  546. globalScope.addEventListener &&
  547. globalScope.addEventListener("beforeunload", ng, false); // 400: Bad Request
  548.  
  549. xhr.send(data);
  550. watchdog = setTimeout(function() {
  551. ng(1, 408); // 408: Request Time-out
  552. }, (option.timeout || 10) * 1000);
  553. } catch (err) {
  554. ng(0, 400); // 400: Bad Request
  555. }
  556. }
  557.  
  558. // inner - BinaryString To ByteArray
  559. function toByteArray(data) { // @param BinaryString: "\00\01"
  560. // @return ByteArray: [0x00, 0x01]
  561. var rv = [], bin2num = _bin2num, remain,
  562. ary = data.split(""),
  563. i = -1, iz;
  564.  
  565. iz = ary.length;
  566. remain = iz % 8;
  567.  
  568. while (remain--) {
  569. ++i;
  570. rv[i] = bin2num[ary[i]];
  571. }
  572. remain = iz >> 3;
  573. while (remain--) {
  574. rv.push(bin2num[ary[++i]], bin2num[ary[++i]],
  575. bin2num[ary[++i]], bin2num[ary[++i]],
  576. bin2num[ary[++i]], bin2num[ary[++i]],
  577. bin2num[ary[++i]], bin2num[ary[++i]]);
  578. }
  579. return rv;
  580. }
  581.  
  582. // inner - BinaryString to ByteArray
  583. function toByteArrayIE(xhr) {
  584. var rv = [], data, remain,
  585. charCodeAt = "charCodeAt",
  586. loop, v0, v1, v2, v3, v4, v5, v6, v7,
  587. i = -1, iz;
  588.  
  589. iz = vblen(xhr);
  590. data = vbstr(xhr);
  591. loop = Math.ceil(iz / 2);
  592. remain = loop % 8;
  593.  
  594. while (remain--) {
  595. v0 = data[charCodeAt](++i); // 0x00,0x01 -> 0x0100
  596. rv.push(v0 & 0xff, v0 >> 8);
  597. }
  598. remain = loop >> 3;
  599. while (remain--) {
  600. v0 = data[charCodeAt](++i);
  601. v1 = data[charCodeAt](++i);
  602. v2 = data[charCodeAt](++i);
  603. v3 = data[charCodeAt](++i);
  604. v4 = data[charCodeAt](++i);
  605. v5 = data[charCodeAt](++i);
  606. v6 = data[charCodeAt](++i);
  607. v7 = data[charCodeAt](++i);
  608. rv.push(v0 & 0xff, v0 >> 8, v1 & 0xff, v1 >> 8,
  609. v2 & 0xff, v2 >> 8, v3 & 0xff, v3 >> 8,
  610. v4 & 0xff, v4 >> 8, v5 & 0xff, v5 >> 8,
  611. v6 & 0xff, v6 >> 8, v7 & 0xff, v7 >> 8);
  612. }
  613. iz % 2 && rv.pop();
  614.  
  615. return rv;
  616. }
  617.  
  618. // inner - base64.encode
  619. function base64encode(data) { // @param ByteArray:
  620. // @return Base64String:
  621. var rv = [],
  622. c = 0, i = -1, iz = data.length,
  623. pad = [0, 2, 1][data.length % 3],
  624. num2bin = _num2bin,
  625. num2b64 = _num2b64;
  626.  
  627. if (globalScope.btoa) {
  628. while (i < iz) {
  629. rv.push(num2bin[data[++i]]);
  630. }
  631. return btoa(rv.join(""));
  632. }
  633. --iz;
  634. while (i < iz) {
  635. c = (data[++i] << 16) | (data[++i] << 8) | (data[++i]); // 24bit
  636. rv.push(num2b64[(c >> 18) & 0x3f],
  637. num2b64[(c >> 12) & 0x3f],
  638. num2b64[(c >> 6) & 0x3f],
  639. num2b64[ c & 0x3f]);
  640. }
  641. pad > 1 && (rv[rv.length - 2] = "=");
  642. pad > 0 && (rv[rv.length - 1] = "=");
  643. return rv.join("");
  644. }
  645.  
  646. // --- init ---
  647. (function() {
  648. var i = 0, v;
  649.  
  650. for (; i < 0x100; ++i) {
  651. v = _toString(i);
  652. _bin2num[v] = i; // "\00" -> 0x00
  653. _num2bin[i] = v; // 0 -> "\00"
  654. }
  655. // http://twitter.com/edvakf/statuses/15576483807
  656. for (i = 0x80; i < 0x100; ++i) { // [Webkit][Gecko]
  657. _bin2num[_toString(0xf700 + i)] = i; // "\f780" -> 0x80
  658. }
  659. })();
  660.  
  661. _ie && document.write('<script type="text/vbscript">\
  662. Function vblen(b)vblen=LenB(b.responseBody)End Function\n\
  663. Function vbstr(b)vbstr=CStr(b.responseBody)+chr(0)End Function</'+'script>');
  664.  
  665. })(this);// msgpac.
  666.  
  667.  
  668. window.msgpack = this.msgpack;
  669.  
  670. (function() {
  671. var _WebSocket = window._WebSocket = window.WebSocket;
  672. var $ = window.jQuery;
  673. var msgpack = window.msgpack;
  674. var options = {
  675. enableMultiCells: false,
  676. enablePosition: false,
  677. enableCross: false
  678. };
  679.  
  680. // game states
  681.  
  682. var map_server = null;
  683. var player_name = [];
  684. var players = [];
  685. var id_players = [];
  686. var cells = [];
  687. var current_cell_ids = [];
  688. var start_x = -7000,
  689. start_y = -7000,
  690. end_x = 7000,
  691. end_y = 7000,
  692. length_x = 14000,
  693. length_y = 14000;
  694. var render_timer = null;
  695.  
  696.  
  697.  
  698. function miniMapSendRawData(data) {
  699. if (map_server !== null && map_server.readyState === window._WebSocket.OPEN) {
  700. var array = new Uint8Array(data);
  701. map_server.send(array.buffer);
  702. }
  703. }
  704.  
  705. function miniMapConnectToServer(address, onOpen, onClose) {
  706. try {
  707. var ws = new window._WebSocket(address);
  708. } catch (ex) {
  709. onClose();
  710. console.error(ex);
  711. return false;
  712. }
  713. ws.binaryType = "arraybuffer";
  714.  
  715. ws.onopen = function() {
  716. onOpen();
  717. //console.log(address + ' connected');
  718. }
  719.  
  720. ws.onmessage = function(event) {
  721. var buffer = new Uint8Array(event.data);
  722. var packet = msgpack.unpack(buffer);
  723. switch(packet.type) {
  724. case 128:
  725. for (var i=0; i < packet.data.addition.length; ++i) {
  726. var cell = packet.data.addition[i];
  727. if (! miniMapIsRegisteredToken(cell.id))
  728. {
  729. miniMapRegisterToken(
  730. cell.id,
  731. miniMapCreateToken(cell.id, cell.color)
  732. );
  733. }
  734.  
  735. var size_n = cell.size/length_x;
  736. miniMapUpdateToken(cell.id, (cell.x - start_x)/length_x, (cell.y - start_y)/length_y, size_n);
  737. }
  738.  
  739. for (var i=0; i < packet.data.deletion.length; ++i) {
  740. var id = packet.data.deletion[i];
  741. miniMapUnregisterToken(id);
  742. }
  743. break;
  744.  
  745. }
  746. }
  747.  
  748. ws.onerror = function() {
  749. onClose();
  750. console.error('failed to connect to map server');
  751. }
  752.  
  753. ws.onclose = function() {
  754. onClose();
  755. map_server = null;
  756. //console.log('map server disconnected');
  757. }
  758.  
  759. map_server = ws;
  760. }
  761.  
  762. function miniMapRender() {
  763. var canvas = window.mini_map;
  764. var ctx = canvas.getContext('2d');
  765. ctx.clearRect(0, 0, canvas.width, canvas.height);
  766. for (var id in window.mini_map_tokens) {
  767. var token = window.mini_map_tokens[id];
  768. var x = token.x * canvas.width;
  769. var y = token.y * canvas.height;
  770. var size = token.size * canvas.width;
  771.  
  772. ctx.beginPath();
  773. ctx.arc(
  774. x,
  775. y,
  776. size,
  777. 0,
  778. 2 * Math.PI,
  779. false
  780. );
  781. ctx.closePath();
  782. ctx.fillStyle = token.color;
  783. ctx.fill();
  784.  
  785.  
  786. if (id_players[id] !== undefined) {
  787. ctx.font = size * 2 + 'px Arial';
  788. ctx.textAlign = 'center';
  789. ctx.textBaseline = 'middle';
  790. ctx.fillStyle = 'white';
  791. ctx.fillText(id_players[id] + 1, x, y);
  792. }
  793. };
  794. }
  795.  
  796. function miniMapDrawCross(x, y) {
  797. var canvas = window.mini_map;
  798. var ctx = canvas.getContext('2d');
  799. ctx.lineWidth = 0.5;
  800. ctx.beginPath();
  801. ctx.moveTo(0, y * canvas.height);
  802. ctx.lineTo(canvas.width, y * canvas.height);
  803. ctx.moveTo(x * canvas.width, 0);
  804. ctx.lineTo(x * canvas.width, canvas.height);
  805. ctx.closePath();
  806. ctx.strokeStyle = '#FFFFFF';
  807. ctx.stroke();
  808. }
  809.  
  810. function miniMapCreateToken(id, color) {
  811. var mini_map_token = {
  812. id: id,
  813. color: color,
  814. x: 0,
  815. y: 0,
  816. size: 0
  817. };
  818. return mini_map_token;
  819. }
  820.  
  821. function miniMapRegisterToken(id, token) {
  822. if (window.mini_map_tokens[id] === undefined) {
  823. // window.mini_map.append(token);
  824. window.mini_map_tokens[id] = token;
  825. }
  826. }
  827.  
  828. function miniMapUnregisterToken(id) {
  829. if (window.mini_map_tokens[id] !== undefined) {
  830. // window.mini_map_tokens[id].detach();
  831. delete window.mini_map_tokens[id];
  832. }
  833. }
  834.  
  835. function miniMapIsRegisteredToken(id) {
  836. return window.mini_map_tokens[id] !== undefined;
  837. }
  838.  
  839. function miniMapUpdateToken(id, x, y, size) {
  840. if (window.mini_map_tokens[id] !== undefined) {
  841.  
  842. window.mini_map_tokens[id].x = x;
  843. window.mini_map_tokens[id].y = y;
  844. window.mini_map_tokens[id].size = size + 0.015;
  845.  
  846.  
  847. return true;
  848. } else {
  849. return false;
  850. }
  851. }
  852.  
  853. function miniMapUpdatePos(x, y) {
  854. window.mini_map_pos.text('x: ' + x.toFixed(0) + ', y: ' + y.toFixed(0));
  855. }
  856.  
  857. function miniMapReset() {
  858. cells = [];
  859. window.mini_map_tokens = [];
  860. }
  861.  
  862. function miniMapInit() {
  863. window.mini_map_tokens = [];
  864.  
  865. cells = [];
  866. current_cell_ids = [];
  867. start_x = -7000;
  868. start_y = -7000;
  869. end_x = 7000;
  870. end_y = 7000;
  871. length_x = 14000;
  872. length_y = 14000;
  873.  
  874. // minimap dom
  875. if ($('#mini-map-wrapper').length === 0) {
  876. var wrapper = $('<div>').attr('id', 'mini-map-wrapper').css({
  877. position: 'fixed',
  878. bottom: 10,
  879. right: 10,
  880. width: 150,
  881. height: 150,
  882. // background: 'rgba(128, 128, 128, 0.58)'
  883. background: "url('img/mini_map.png')"
  884. });
  885.  
  886. var mini_map = $('<canvas>').attr({
  887. id: 'mini-map',
  888. width: 150,
  889. height: 150
  890. }).css({
  891. width: '100%',
  892. height: '100%',
  893. position: 'relative'
  894. });
  895.  
  896. wrapper.append(mini_map).appendTo(document.body);
  897.  
  898. window.mini_map = mini_map[0];
  899. }
  900.  
  901. // minimap renderer
  902. if (render_timer === null)
  903. render_timer = setInterval(miniMapRender, 1000 / 30);
  904.  
  905. // minimap location
  906. if ($('#mini-map-pos').length === 0) {
  907. window.mini_map_pos = $('<div>').attr('id', 'mini-map-pos').css({
  908. bottom: 10,
  909. right: 10,
  910. color: 'white',
  911. fontSize: 15,
  912. fontWeight: 800,
  913. position: 'fixed'
  914. }).appendTo(document.body);
  915. }
  916.  
  917.  
  918.  
  919. // minimap party
  920. }
  921.  
  922. // cell constructor
  923. function Cell(id, x, y, size, color, name) {
  924. cells[id] = this;
  925. this.id = id;
  926. this.color = color;
  927. this.points = [];
  928. this.pointsAcc = [];
  929. this.setName(name);
  930. }
  931.  
  932. Cell.prototype = {
  933. id: 0,
  934. points: null,
  935. pointsAcc: null,
  936. name: null,
  937. nameCache: null,
  938. sizeCache: null,
  939. x: 0,
  940. y: 0,
  941. size: 0,
  942. ox: 0,
  943. oy: 0,
  944. oSize: 0,
  945. nx: 0,
  946. ny: 0,
  947. nSize: 0,
  948. updateTime: 0,
  949. updateCode: 0,
  950. drawTime: 0,
  951. destroyed: false,
  952. isVirus: false,
  953. isAgitated: false,
  954. wasSimpleDrawing: true,
  955.  
  956. destroy: function() {
  957. delete cells[this.id];
  958. id = current_cell_ids.indexOf(this.id);
  959. -1 != id && current_cell_ids.splice(id, 1);
  960. this.destroyed = true;
  961. if (map_server === null || map_server.readyState !== window._WebSocket.OPEN) {
  962. miniMapUnregisterToken(this.id);
  963. }
  964. },
  965. setName: function(name) {
  966. this.name = name;
  967. },
  968. updatePos: function() {
  969. if (map_server === null || map_server.readyState !== window._WebSocket.OPEN) {
  970. if (options.enableMultiCells || -1 != current_cell_ids.indexOf(this.id)) {
  971. if (! miniMapIsRegisteredToken(this.id))
  972. {
  973. miniMapRegisterToken(
  974. this.id,
  975. miniMapCreateToken(this.id, this.color)
  976. );
  977. }
  978.  
  979. var size_n = this.nSize/length_x;
  980. miniMapUpdateToken(this.id, (this.nx - start_x)/length_x, (this.ny - start_y)/length_y, size_n);
  981. }
  982. }
  983.  
  984.  
  985. }
  986. };
  987.  
  988. String.prototype.capitalize = function() {
  989. return this.charAt(0).toUpperCase() + this.slice(1);
  990. };
  991.  
  992. function camel2cap(str) {
  993. return str.replace(/([A-Z])/g, function(s){return ' ' + s.toLowerCase();}).capitalize();
  994. };
  995.  
  996. // create a linked property from slave object
  997. // whenever master[prop] update, slave[prop] update
  998. function refer(master, slave, prop) {
  999. Object.defineProperty(master, prop, {
  1000. get: function(){
  1001. return slave[prop];
  1002. },
  1003. set: function(val) {
  1004. slave[prop] = val;
  1005. },
  1006. enumerable: true,
  1007. configurable: true
  1008. });
  1009. };
  1010.  
  1011. // extract a websocket packet which contains the information of cells
  1012. function extractCellPacket(data, offset) {
  1013. ////
  1014. var dataToSend = {
  1015. destroyQueue : [],
  1016. nodes : [],
  1017. nonVisibleNodes : []
  1018. };
  1019. ////
  1020.  
  1021. var I = +new Date;
  1022. var qa = false;
  1023. var b = Math.random(), c = offset;
  1024. var size = data.getUint16(c, true);
  1025. c = c + 2;
  1026.  
  1027. // Nodes to be destroyed (killed)
  1028. for (var e = 0; e < size; ++e) {
  1029. var p = cells[data.getUint32(c, true)],
  1030. f = cells[data.getUint32(c + 4, true)],
  1031. c = c + 8;
  1032. p && f && (
  1033. f.destroy(),
  1034. f.ox = f.x,
  1035. f.oy = f.y,
  1036. f.oSize = f.size,
  1037. f.nx = p.x,
  1038. f.ny = p.y,
  1039. f.nSize = f.size,
  1040. f.updateTime = I,
  1041. dataToSend.destroyQueue.push(f.id));
  1042. }
  1043.  
  1044. // Nodes to be updated
  1045. for (e = 0; ; ) {
  1046. var d = data.getUint32(c, true);
  1047. c += 4;
  1048. if (0 == d) {
  1049. break;
  1050. }
  1051. ++e;
  1052. var p = data.getInt32(c, true),
  1053. c = c + 4,
  1054. f = data.getInt32(c, true),
  1055. c = c + 4;
  1056. g = data.getInt16(c, true);
  1057. c = c + 2;
  1058. for (var h = data.getUint8(c++), m = data.getUint8(c++), q = data.getUint8(c++), h = (h << 16 | m << 8 | q).toString(16); 6 > h.length; )
  1059. h = "0" + h;
  1060.  
  1061. var h = "#" + h,
  1062. k = data.getUint8(c++),
  1063. m = !!(k & 1),
  1064. q = !!(k & 16);
  1065.  
  1066. k & 2 && (c += 4);
  1067. k & 4 && (c += 8);
  1068. k & 8 && (c += 16);
  1069.  
  1070. for (var n, k = ""; ; ) {
  1071. n = data.getUint16(c, true);
  1072. c += 2;
  1073. if (0 == n)
  1074. break;
  1075. k += String.fromCharCode(n)
  1076. }
  1077.  
  1078. n = k;
  1079. k = null;
  1080.  
  1081. var updated = false;
  1082. // if d in cells then modify it, otherwise create a new cell
  1083. cells.hasOwnProperty(d)
  1084. ? (k = cells[d],
  1085. k.updatePos(),
  1086. k.ox = k.x,
  1087. k.oy = k.y,
  1088. k.oSize = k.size,
  1089. k.color = h,
  1090. updated = true)
  1091. : (k = new Cell(d, p, f, g, h, n),
  1092. k.pX = p,
  1093. k.pY = f);
  1094.  
  1095. k.isVirus = m;
  1096. k.isAgitated = q;
  1097. k.nx = p;
  1098. k.ny = f;
  1099. k.nSize = g;
  1100. k.updateCode = b;
  1101. k.updateTime = I;
  1102. n && k.setName(n);
  1103.  
  1104. // ignore food creation
  1105.  
  1106. }
  1107.  
  1108. // Destroy queue + nonvisible nodes
  1109. b = data.getUint32(c, true);
  1110. c += 4;
  1111. for (e = 0; e < b; e++) {
  1112. d = data.getUint32(c, true);
  1113. c += 4, k = cells[d];
  1114. null != k && k.destroy();
  1115. dataToSend.nonVisibleNodes.push(d);
  1116. }
  1117.  
  1118. var packet = {
  1119. type: 16,
  1120. data: dataToSend
  1121. }
  1122.  
  1123. miniMapSendRawData(msgpack.pack(packet));
  1124. }
  1125.  
  1126. // extract the type of packet and dispatch it to a corresponding extractor
  1127. function extractPacket(event) {
  1128. var c = 0;
  1129. var data = new DataView(event.data);
  1130. 240 == data.getUint8(c) && (c += 5);
  1131. var opcode = data.getUint8(c);
  1132. c++;
  1133. switch (opcode) {
  1134. case 16: // cells data
  1135. extractCellPacket(data, c);
  1136. break;
  1137. case 20: // cleanup ids
  1138. current_cell_ids = [];
  1139. break;
  1140. case 32: // cell id belongs me
  1141. var id = data.getUint32(c, true);
  1142.  
  1143. if (current_cell_ids.indexOf(id) === -1)
  1144. current_cell_ids.push(id);
  1145.  
  1146. miniMapSendRawData(msgpack.pack({
  1147. type: 32,
  1148. data: id
  1149. }));
  1150. break;
  1151. case 64: // get borders
  1152. start_x = data.getFloat64(c, !0), c += 8,
  1153. start_y = data.getFloat64(c, !0), c += 8,
  1154. end_x = data.getFloat64(c, !0), c += 8,
  1155. end_y = data.getFloat64(c, !0), c += 8,
  1156. center_x = (start_x + end_x) / 2,
  1157. center_y = (start_y + end_y) / 2,
  1158. length_x = Math.abs(start_x - end_x),
  1159. length_y = Math.abs(start_y - end_y);
  1160. }
  1161. };
  1162.  
  1163. function extractSendPacket(data) {
  1164. var view = new DataView(data);
  1165. switch (view.getUint8(0, true)) {
  1166. case 0:
  1167. player_name = [];
  1168. for (var i=1; i < data.byteLength; i+=2) {
  1169. player_name.push(view.getUint16(i, true));
  1170. }
  1171.  
  1172. miniMapSendRawData(msgpack.pack({
  1173. type: 0,
  1174. data: player_name
  1175. }));
  1176. break;
  1177. }
  1178. }
  1179.  
  1180. // the injected point, overwriting the WebSocket constructor
  1181. window.WebSocket = function(url, protocols) {
  1182. //console.log('Listen');
  1183.  
  1184. if (protocols === undefined) {
  1185. protocols = [];
  1186. }
  1187.  
  1188. var ws = new _WebSocket(url, protocols);
  1189.  
  1190. refer(this, ws, 'binaryType');
  1191. refer(this, ws, 'bufferedAmount');
  1192. refer(this, ws, 'extensions');
  1193. refer(this, ws, 'protocol');
  1194. refer(this, ws, 'readyState');
  1195. refer(this, ws, 'url');
  1196.  
  1197. this.send = function(data){
  1198. extractSendPacket(data);
  1199. return ws.send.call(ws, data);
  1200. };
  1201.  
  1202. this.close = function(){
  1203. return ws.close.call(ws);
  1204. };
  1205.  
  1206. this.onopen = function(event){};
  1207. this.onclose = function(event){};
  1208. this.onerror = function(event){};
  1209. this.onmessage = function(event){};
  1210.  
  1211. ws.onopen = function(event) {
  1212. miniMapInit();
  1213. agar_server = url;
  1214. miniMapSendRawData(msgpack.pack({
  1215. type: 100,
  1216. data: {url: url, region: $('#region').val(), gamemode: $('#gamemode').val(), party: location.hash}
  1217. }));
  1218. if (this.onopen)
  1219. return this.onopen.call(ws, event);
  1220. }.bind(this);
  1221.  
  1222. ws.onmessage = function(event) {
  1223. extractPacket(event);
  1224. if (this.onmessage)
  1225. return this.onmessage.call(ws, event);
  1226. }.bind(this);
  1227.  
  1228. ws.onclose = function(event) {
  1229. if (this.onclose)
  1230. return this.onclose.call(ws, event);
  1231. }.bind(this);
  1232.  
  1233. ws.onerror = function(event) {
  1234. if (this.onerror)
  1235. return this.onerror.call(ws, event);
  1236. }.bind(this);
  1237. };
  1238.  
  1239. window.WebSocket.prototype = _WebSocket;
  1240.  
  1241. $(window.document).ready(function() {
  1242. miniMapInit();
  1243. });
  1244.  
  1245. $(window).load(function() {
  1246. var main_canvas = document.getElementById('canvas');
  1247. if (main_canvas && main_canvas.onmousemove) {
  1248. document.onmousemove = main_canvas.onmousemove;
  1249. main_canvas.onmousemove = null;
  1250. }
  1251. });
  1252. })();
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259. (function (d, e) {
  1260. //
  1261.  
  1262. //alert();
  1263.  
  1264. var isTyping = false;
  1265. var chattxt;
  1266.  
  1267. function Ib() {
  1268. Ca = !0;
  1269. ab();
  1270. e("#mini-map-wrapper").hide();
  1271. setInterval(ab, 18E4);
  1272. J = Da = document.getElementById("canvas");
  1273. f = J.getContext("2d");
  1274. J.onmousedown = function (a) {
  1275. if (bb) {
  1276. var b = a.clientX - (5 + m / 5 / 2),
  1277. c = a.clientY - (5 + m / 5 / 2);
  1278. if (Math.sqrt(b * b + c * c) <= m / 5 / 2) {
  1279. aa();
  1280. K(17);
  1281. return
  1282. }
  1283. }
  1284. ja = a.clientX;
  1285. ka = a.clientY;
  1286. Ea();
  1287. aa()
  1288. };
  1289. J.onmousemove = function (a) {
  1290. ja = a.clientX;
  1291. ka = a.clientY;
  1292. Ea()
  1293. };
  1294. J.onmouseup = function () {};
  1295. /firefox/i.test(navigator.userAgent) ? document.addEventListener("DOMMouseScroll", cb, !1) : document.body.onmousewheel = cb;
  1296.  
  1297.  
  1298.  
  1299. J.onfocus = function () {
  1300. isTyping = false;
  1301. };
  1302.  
  1303. document.getElementById("chat_textbox").onblur = function () {
  1304. isTyping = false;
  1305. };
  1306.  
  1307.  
  1308. document.getElementById("chat_textbox").onfocus = function () {
  1309. isTyping = true;
  1310. };
  1311.  
  1312. var spacePressed = false,
  1313. qPressed = false,
  1314. wPressed = false;
  1315.  
  1316.  
  1317. function spltt()
  1318. {
  1319. //alert(isTyping);
  1320. if(isTyping != true)
  1321. {
  1322. (aa(), K(17), a = !0);
  1323. }
  1324. }
  1325.  
  1326. function fedvir()
  1327. {
  1328. if(isTyping != true)
  1329. {
  1330. (aa(), K(21), c = !0);
  1331. }
  1332. }
  1333.  
  1334. var a = !0,
  1335. b = !1,
  1336. c = !1;
  1337. d.onkeydown = function (k) {
  1338. 32 != k.keyCode || a || spltt();
  1339. 81 != k.keyCode || b || (K(18), b = !0);
  1340. 87 != k.keyCode || c || fedvir();
  1341. 27 == k.keyCode && Fa(300)
  1342. 13 == k.keyCode && cht();
  1343. };
  1344.  
  1345. var lastChatCount = 0;
  1346.  
  1347. function cht(){
  1348. if (isTyping) {
  1349. isTyping = false;
  1350. document.getElementById("chat_textbox").blur();
  1351. chattxt = document.getElementById("chat_textbox").value;
  1352. /////REKLAM KORUMA/////
  1353.  
  1354. if (chattxt.length > 0) sendChat(chattxt);
  1355. document.getElementById("chat_textbox").value = "";
  1356.  
  1357. }
  1358. else {
  1359. if (!hasOverlay) {
  1360. document.getElementById("chat_textbox").focus();
  1361. isTyping = true;
  1362. }
  1363. }
  1364.  
  1365.  
  1366.  
  1367. lastChatCount = 0;
  1368. }
  1369.  
  1370.  
  1371.  
  1372. d.onkeyup = function (k) {
  1373. 32 == k.keyCode && (a = !1);
  1374. 87 == k.keyCode && (c = !1);
  1375. 81 == k.keyCode && b && (K(19), b = !1)
  1376. };
  1377. d.onblur = function () {
  1378. K(19);
  1379. c = b = a = !1
  1380. };
  1381. d.onresize = db;
  1382. d.requestAnimationFrame(eb);
  1383. setInterval(aa, 40);
  1384. t && e("#region").val(t);
  1385. fb();
  1386. la(e("#region").val());
  1387. 0 == Ga && t && L();
  1388. S = !0;
  1389. e("#overlays").show();
  1390. db();
  1391. d.location.hash && 6 <= d.location.hash.length && gb(d.location.hash);
  1392.  
  1393.  
  1394.  
  1395. }
  1396.  
  1397.  
  1398. function sendChat(str) {
  1399. if (Y() && (str.length < 200) && (str.length > 0)) {
  1400. var msg = P(2 + 2 * str.length);
  1401. var offset = 0;
  1402. msg.setUint8(offset++, 99);
  1403. msg.setUint8(offset++, 0); // flags (0 for now)
  1404. for (var i = 0; i < str.length; ++i) {
  1405. msg.setUint16(offset, str.charCodeAt(i), !0);
  1406. offset += 2;
  1407. }
  1408. Q(msg);
  1409.  
  1410. }
  1411. }
  1412.  
  1413.  
  1414. function cb( a ) {
  1415. M *= Math.pow(.9, a.wheelDelta / -120 || a.detail || 0);
  1416. if(.9>M){
  1417. M < .05 / g && (M = .05 / g)
  1418. } else{
  1419. M > .9 / g && (M = .9 / g)
  1420. }
  1421. }
  1422. function Jb() {
  1423. if (.4 > g) ba = null;
  1424. else {
  1425. for (var a = Number.POSITIVE_INFINITY, b = Number.POSITIVE_INFINITY, c = Number.NEGATIVE_INFINITY, k = Number.NEGATIVE_INFINITY, d = 0, n = 0; n < y.length; n++) {
  1426. var e = y[n];
  1427. !e.N() || e.R || 20 >= e.size * g || (d = Math.max(e.size, d), a = Math.min(e.x, a), b = Math.min(e.y, b), c = Math.max(e.x, c), k = Math.max(e.y, k))
  1428. }
  1429. ba = Kb.la({
  1430. ca: a - (d + 100),
  1431. da: b - (d + 100),
  1432. oa: c + (d + 100),
  1433. pa: k + (d + 100),
  1434. ma: 2,
  1435. na: 4
  1436. });
  1437. for (n = 0; n < y.length; n++) if (e = y[n],
  1438. e.N() && !(20 >= e.size * g)) for (a = 0; a < e.a.length; ++a) b = e.a[a].x, c = e.a[a].y, b < u - m / 2 / g || c < v - q / 2 / g || b > u + m / 2 / g || c > v + q / 2 / g || ba.m(e.a[a])
  1439. }
  1440. }
  1441. function Ea() {
  1442. ma = (ja - m / 2) / g + u;
  1443. na = (ka - q / 2) / g + v
  1444. }
  1445. function ab() {
  1446. null == oa && (oa = {}, e("#region").children().each(function () {
  1447. var a = e(this),
  1448. b = a.val();
  1449. b && (oa[b] = a.text())
  1450. }));
  1451. e.get("info.php", function (a) {
  1452. var b = {}, c;
  1453. for (c in a.regions) {
  1454. var k = c.split(":")[0];
  1455. b[k] = b[k] || 0;
  1456. b[k] += a.regions[c].numPlayers
  1457. }
  1458. for (c in b) e('#region option[value="' + c + '"]').text(oa[c] + " (" + b[c] + " players)")
  1459. },
  1460. "json")
  1461. }
  1462. function hb() {
  1463. hasOverlay = false;
  1464. e("#adsBottom").hide();
  1465. e("#overlays").hide();
  1466. e("#stats").hide();
  1467. e("#mainPanel").hide();
  1468. e("#mini-map-wrapper").show();
  1469. T = S = !1;
  1470. fb();
  1471. d.googletag && d.googletag.pubads && d.googletag.pubads().clear && d.googletag.pubads().clear(d.aa.concat(d.ab))
  1472. }
  1473. function la(a) {
  1474. a && a != t && (e("#region").val() != a && e("#region").val(a), t = d.localStorage.location = a, e(".region-message").hide(), e(".region-message." + a).show(), e(".btn-needs-server").prop("disabled", !1), Ca && L())
  1475. }
  1476. function Fa(a) {
  1477. S || T || (H = null, ib(d.aa), 1E3 > a && (x = 1), S = !0, e("#mainPanel").show(),
  1478. 0 < a ? e("#overlays").fadeIn(a) : e("#overlays").show())
  1479. }
  1480. function ca(a) {
  1481. if(a ==":rainbow")
  1482. {
  1483. host = [""];
  1484.  
  1485. }
  1486. else if(a == ":ffa")
  1487. {
  1488. host = ["151.80.110.119:1001"];
  1489.  
  1490. }
  1491.  
  1492. else if(a == ":ffa2")
  1493. {
  1494. host = ["74.222.20.47:1002"];
  1495.  
  1496. }
  1497.  
  1498.  
  1499. else if(a == ":giant")
  1500. {
  1501. host = ["163.172.55.162:1003"];
  1502.  
  1503. }
  1504.  
  1505. else if(a == ":giant2")
  1506. {
  1507. host = ["163.172.55.162:1099"];
  1508.  
  1509. }
  1510.  
  1511. else if(a == ":giant13")
  1512. {
  1513. host = ["151.80.110.119:1003"];
  1514.  
  1515. }
  1516.  
  1517.  
  1518. else if(a == ":giantus")
  1519. {
  1520. host = ["74.222.20.47:1003"];
  1521.  
  1522. }
  1523. else if(a == ":giantmass")
  1524. {
  1525. host = ["151.80.108.25:1219"];
  1526.  
  1527. }
  1528. else if(a == ":giantmass2")
  1529. {
  1530. host = ["74.222.20.47:1222"];
  1531.  
  1532. }
  1533.  
  1534. else if(a == ":bigbox")
  1535. {
  1536. host = ["151.80.108.25:1007"];
  1537.  
  1538. }
  1539. else if(a == ":bigbox2")
  1540. {
  1541. host = ["163.172.105.2:1007"];
  1542.  
  1543. }
  1544. else if(a == ":bigboxus")
  1545. {
  1546. host = ["74.222.20.47:1008"];
  1547.  
  1548. }
  1549.  
  1550. else if(a ==":team")
  1551. {
  1552. host = ["151.80.108.25:1009"];
  1553.  
  1554. }
  1555. else if(a ==":teamus")
  1556. {
  1557. host = ["74.222.20.47:1010"];
  1558.  
  1559. }
  1560.  
  1561. else
  1562. {
  1563. a = ":ffa"
  1564. host = ["151.80.230.81:1001"];
  1565. }
  1566. e("#helloContainer").attr("data-gamemode", a);
  1567. U = a;
  1568. e("#gamemode").val(a);
  1569. }
  1570. function fb() {
  1571. e("#region").val() ? d.localStorage.location = e("#region").val() : d.localStorage.location && e("#region").val(d.localStorage.location);
  1572. e("#region").val() ? e("#locationKnown").append(e("#region")) : e("#locationUnknown").append(e("#region"))
  1573. }
  1574. function ib(a) {
  1575. pa && (pa = !1, setTimeout(function () {
  1576. pa = !0
  1577. }, 6E4 * jb), d.googletag && d.googletag.pubads && d.googletag.pubads().refresh && d.googletag.pubads().refresh(a))
  1578. }
  1579. function da(a) {
  1580. return d.i18n[a] || d.i18n_dict.en[a] || a
  1581. }
  1582. function kb() {
  1583. Ha("ws://"+ host);
  1584. }
  1585. function L() {
  1586. Ca && t && (e("#overlays").show(), kb())
  1587. }
  1588. function Ha(a, b) {
  1589. if (s) {
  1590. s.onopen = null;
  1591. s.onmessage = null;
  1592. s.onclose = null;
  1593. try {
  1594. s.close()
  1595. } catch (c) {}
  1596. s = null
  1597. }
  1598. var c = a;
  1599. a = c;
  1600. A = [];
  1601. h = [];
  1602. I = {};
  1603. y = [];
  1604. V = [];
  1605. w = [];
  1606. B = C = null;
  1607. O = 0;
  1608. ea = !1;
  1609. //console.log("Connecting to " + a);
  1610. a = a + '/?base=' + base;
  1611. s = new WebSocket(a);
  1612. s.binaryType = "arraybuffer";
  1613. s.onopen = function () {
  1614. var a;
  1615. //console.log("socket open");
  1616. a = P(5);
  1617. a.setUint8(0, 254);
  1618. a.setUint32(1, 5, !0);
  1619. Q(a);
  1620. a = P(5);
  1621. a.setUint8(0, 255);
  1622. a.setUint32(1, 154669603, !0);
  1623. Q(a);
  1624. mb()
  1625. };
  1626. s.onmessage = Lb;
  1627. s.onclose = Mb;
  1628. s.onerror = function () {
  1629. //console.log("socket error")
  1630. }
  1631. }
  1632. function P(a) {
  1633. return new DataView(new ArrayBuffer(a))
  1634. }
  1635. function Q(a) {
  1636. s.send(a.buffer)
  1637. }
  1638. function Mb() {
  1639. ea && (qa = 500);
  1640. //console.log("socket close");
  1641. setTimeout(L, qa);
  1642. qa *= 2
  1643. }
  1644. function Lb(a) {
  1645. Nb(new DataView(a.data))
  1646. }
  1647. function Nb(a) {
  1648. function b() {
  1649. for (var b = "";;) {
  1650. var d = a.getUint16(c, !0);
  1651. c += 2;
  1652. if (0 == d) break;
  1653. b += String.fromCharCode(d)
  1654. }
  1655. return b
  1656. }
  1657. var c = 0;
  1658. 240 == a.getUint8(c) && (c += 5);
  1659. switch (a.getUint8(c++)) {
  1660. case 16:
  1661. Ob(a, c);
  1662. break;
  1663. case 17:
  1664. fa = a.getFloat32(c, !0);
  1665. c += 4;
  1666. ga = a.getFloat32(c, !0);
  1667. c += 4;
  1668. ha = a.getFloat32(c, !0);
  1669. c += 4;
  1670. break;
  1671. case 20:
  1672. h = [];
  1673. A = [];
  1674. break;
  1675. case 21:
  1676. Ka = a.getInt16(c, !0);
  1677. c += 2;
  1678. La = a.getInt16(c, !0);
  1679. c += 2;
  1680. Ma || (Ma = !0, ra = Ka, sa = La);
  1681. break;
  1682. case 32:
  1683. A.push(a.getUint32(c, !0));
  1684. c += 4;
  1685. break;
  1686. case 49:
  1687. if (null != C) break;
  1688. var k = a.getUint32(c, !0),
  1689. c = c + 4;
  1690. w = [];
  1691. for (var d = 0; d < k; ++d) {
  1692. var e = a.getUint32(c, !0),
  1693. c = c + 4;
  1694. w.push({
  1695. id: e,
  1696. name: b()
  1697. })
  1698. }
  1699. nb();
  1700. break;
  1701. case 50:
  1702. C = [];
  1703. k = a.getUint32(c, !0);
  1704. c += 4;
  1705. for (d = 0; d < k; ++d) C.push(a.getFloat32(c, !0)), c += 4;
  1706. nb();
  1707. break;
  1708. case 64:
  1709. ta = a.getFloat64(c, !0);
  1710. c += 8;
  1711. ua = a.getFloat64(c, !0);
  1712. c += 8;
  1713. va = a.getFloat64(c, !0);
  1714. c += 8;
  1715. wa = a.getFloat64(c, !0);
  1716. c += 8;
  1717. fa = (va + ta) / 2;
  1718. ga = (wa + ua) / 2;
  1719. ha = 1;
  1720. 0 == h.length && (u = fa, v = ga, g = ha);
  1721. break;
  1722. case 81:
  1723. var r = a.getUint32(c, !0),
  1724. c = c + 4,
  1725. p = a.getUint32(c, !0),
  1726. c = c + 4,
  1727. f = a.getUint32(c, !0),
  1728. c = c + 4;
  1729. setTimeout(function () {
  1730. W({
  1731. e: r,
  1732. f: p,
  1733. d: f
  1734. })
  1735. }, 1200)
  1736. break;
  1737. case 90:
  1738. // Server Info / ping
  1739. var Uping = (new Date) - latency;
  1740. jQuery('#latency').html('Latency ' + Uping + ' ms;');
  1741.  
  1742. var Uuptime = a.getFloat64(c, !0);
  1743. c += 8;
  1744. jQuery('#uptime').html('Uptime ' + Uuptime + ' sec;' );
  1745. // Do something with the info
  1746.  
  1747. var Uplayers = a.getFloat64(c, !0);
  1748. c += 8;
  1749. jQuery('#onlineplayers').html('Players ' + Uplayers+ ';' );
  1750. // Do something with the info, example >> jQuery('#onlineplayers').html('Players ' + Uplayers );
  1751.  
  1752. var Umapsize = a.getFloat64(c, !0);
  1753. c += 8;
  1754. jQuery('#mapsize').html('Mapsize ' + Umapsize+ ';' );
  1755. // Do something with the info, example >> jQuery('#mapsize').html('Mapsize ' + Umapsize );
  1756.  
  1757. var Umapfood = a.getFloat64(c, !0);
  1758. c += 8;
  1759. jQuery('#mapfood').html('Mapfood ' + Umapfood );
  1760. // Do something with the info, example >> jQuery('#mapsize').html('Mapfood ' + Umapfood );
  1761.  
  1762. if (a.byteLength > 36) {
  1763. var Ugamemode = a.getFloat64(c, !0);
  1764. // Game mode is the number, so 0 for FFA etc...
  1765. }
  1766. break;
  1767. case 99:
  1768. addChat(a, c);
  1769. break;
  1770. }
  1771. }
  1772.  
  1773. function addChat(view, offset) {
  1774. function getString() {
  1775. var text = '',
  1776. char;
  1777. while ((char = view.getUint16(offset, true)) != 0) {
  1778. offset += 2;
  1779. text += String.fromCharCode(char);
  1780. }
  1781. offset += 2;
  1782. return text;
  1783. }
  1784.  
  1785. var flags = view.getUint8(offset++);
  1786. // for future expansions
  1787. if (flags & 2) {
  1788. offset += 4;
  1789. }
  1790. if (flags & 4) {
  1791. offset += 8;
  1792. }
  1793. if (flags & 8) {
  1794. offset += 16;
  1795. }
  1796.  
  1797. var r = view.getUint8(offset++),
  1798. g = view.getUint8(offset++),
  1799. b = view.getUint8(offset++),
  1800. color = (r << 16 | g << 8 | b).toString(16);
  1801. while (color.length > 6) {
  1802. color = '0' + color;
  1803. }
  1804. color = '#' + color;
  1805. chatBoard.push({
  1806. "name": getString(),
  1807. "color": color,
  1808. "message": getString(),
  1809. "time": Date.now()
  1810. });
  1811.  
  1812. drawChatBoard();
  1813.  
  1814. }
  1815.  
  1816.  
  1817.  
  1818. function drawChatBoard() {
  1819. chatCanvas = null;
  1820. chatCanvas = document.createElement("canvas");
  1821.  
  1822. var ctx = chatCanvas.getContext("2d");
  1823. var scaleFactor = Math.min(Math.max(m / 1200, 0.75),1); //scale factor = 0.75 to 1
  1824. chatCanvas.width = 1000 * scaleFactor;
  1825. chatCanvas.height = 550 * scaleFactor;
  1826. ctx.scale(scaleFactor, scaleFactor);
  1827. var nowtime = Date.now();
  1828. var lasttime = 0;
  1829. if (chatBoard.length >= 1)
  1830. lasttime = chatBoard[chatBoard.length - 1].time;
  1831. else return;
  1832. var deltat = nowtime - lasttime;
  1833.  
  1834. ctx.globalAlpha = 0.8 * Math.exp(-deltat / 25000);
  1835.  
  1836.  
  1837.  
  1838. var len = chatBoard.length;
  1839. var from = len - 15;
  1840. if (from < 0) from = 0;
  1841. for (var i = 0; i < (len - from); i++) {
  1842. var chatName = new za(18, chatBoard[i + from].color);
  1843. chatName.C(chatBoard[i + from].name.split("*")[0]);
  1844. var a = ctx.measureText(chatBoard[i + from].name.split("*")[0]);
  1845. var width = chatName.getWidth();
  1846. var a = chatName.L();
  1847.  
  1848. ctx.drawImage(a, 18, chatCanvas.height / scaleFactor - 24 * (len - i - from));
  1849. var chatText = new za(18,'#666666');
  1850. chatText.C(': ' + chatBoard[i + from].message);
  1851. a = chatText.L();
  1852. ctx.drawImage(a, 20 + width * 1.8, chatCanvas.height / scaleFactor - 24 * (len - from - i));
  1853. }
  1854. //ctx.restore();
  1855. }
  1856.  
  1857.  
  1858.  
  1859.  
  1860. function Ob(a, b) {
  1861. function c() {
  1862. for (var c = "";;) {
  1863. var d = a.getUint16(b, !0);
  1864. b += 2;
  1865. if (0 == d) break;
  1866. c += String.fromCharCode(d)
  1867. }
  1868. return c
  1869. }
  1870. function k() {
  1871. for (var c = "";;) {
  1872. var d = a.getUint8(b++);
  1873. if (0 == d) break;
  1874. c += String.fromCharCode(d)
  1875. }
  1876. return c
  1877. }
  1878. ob = E = Date.now();
  1879. ea || (ea = !0, Pb());
  1880. var G = Math.random();
  1881. Na = !1;
  1882. var n = a.getUint16(b, !0);
  1883. b += 2;
  1884. for (var r = 0; r < n; ++r) {
  1885. var p = I[a.getUint32(b, !0)],
  1886. f = I[a.getUint32(b + 4, !0)];
  1887. b += 8;
  1888. p && f && (f.X(), f.s = f.x, f.t = f.y, f.r = f.size, f.J = p.x, f.K = p.y, f.q = f.size, f.Q = E, Qb(p, f))
  1889. }
  1890. for (r = 0;;) {
  1891. n = a.getUint32(b, !0);
  1892. b += 4;
  1893. if (0 == n) break;
  1894. ++r;
  1895. var g, p = a.getInt32(b, !0);
  1896. b += 4;
  1897. f = a.getInt32(b, !0);
  1898. b += 4;
  1899. g = a.getInt16(b, !0);
  1900. b += 2;
  1901. var l = a.getUint8(b++),
  1902. m = a.getUint8(b++),
  1903. q = a.getUint8(b++),
  1904. m = Rb(l << 16 | m << 8 | q),
  1905. q = a.getUint8(b++),
  1906. s = !! (q & 1),
  1907. x = !! (q & 16),
  1908. w = null;
  1909. q & 2 && (b += 4 + a.getUint32(b, !0));
  1910. q & 4 && (w = k());
  1911. var t = c(),
  1912. l = null;
  1913. I.hasOwnProperty(n) ? (l = I[n], l.P(), l.s = l.x, l.t = l.y, l.r = l.size, l.color = m) : (l = new X(n, p, f, g, m, t), y.push(l), I[n] = l, l.ua = p, l.va = f);
  1914. l.h = s;
  1915. l.n = x;
  1916. l.J = p;
  1917. l.K = f;
  1918. l.q = g;
  1919. l.sa = G;
  1920. l.Q = E;
  1921. l.ba = q;
  1922. l.fa = w;
  1923. t && l.B(t); - 1 != A.indexOf(n) && -1 == h.indexOf(l) && (h.push(l), 1 == h.length && (u = l.x, v = l.y, pb(), document.getElementById("overlays").style.display = "none", z = [], Oa = 0, Pa = h[0].color, Qa = !0, qb = Date.now(), R = Ra = Sa = 0))
  1924. }
  1925. G = a.getUint32(b, !0);
  1926. b += 4;
  1927. for (r = 0; r < G; r++) n = a.getUint32(b, !0), b += 4, l = I[n], null != l && l.X();
  1928. Na && 0 == h.length && (rb = Date.now(), Qa = !1, S || T || (sb ? (ib(d.ab), Sb(), T = !0, e("#overlays").fadeIn(3E3),e("#mini-map-wrapper").hide() , e("#stats").show()) : Fa(3E3)))
  1929. }
  1930. function Pb() {
  1931. e("#connecting").hide();
  1932. tb();
  1933. N && (N(), N = null);
  1934. null != Ta && clearTimeout(Ta);
  1935. Ta = setTimeout(function () {
  1936. d.ga && (++ub, d.ga("set", "dimension2", ub))
  1937. }, 1E4)
  1938. }
  1939. function aa() {
  1940. if (Y()) {
  1941. var a = ja - m / 2,
  1942. b = ka - q / 2;
  1943. 64 > a * a + b * b || .01 > Math.abs(vb - ma) && .01 > Math.abs(wb - na) || (vb = ma, wb = na, a = P(21), a.setUint8(0, 16), a.setFloat64(1,
  1944. ma, !0), a.setFloat64(9, na, !0), a.setUint32(17, 0, !0), Q(a))
  1945. }
  1946. }
  1947. function tb() {
  1948. if (Y() && ea && null != H) {
  1949. var a = P(1 + 2 * H.length);
  1950. a.setUint8(0, 0);
  1951. for (var b = 0; b < H.length; ++b) a.setUint16(1 + 2 * b, H.charCodeAt(b), !0);
  1952. Q(a);
  1953. H = null
  1954. }
  1955. }
  1956. function Y() {
  1957. return null != s && s.readyState == s.OPEN
  1958. }
  1959. function K(a) {
  1960. if (Y()) {
  1961. var b = P(1);
  1962. b.setUint8(0, a);
  1963. Q(b)
  1964. }
  1965. }
  1966. function mb() {
  1967. if (Y() && null != D) {
  1968. var a = P(1 + D.length);
  1969. a.setUint8(0, 81);
  1970. for (var b = 0; b < D.length; ++b) a.setUint8(b + 1, D.charCodeAt(b));
  1971. Q(a)
  1972. }
  1973. }
  1974. function db() {
  1975. m = d.innerWidth;
  1976. q = d.innerHeight;
  1977. Da.width = J.width = m;
  1978. Da.height = J.height = q;
  1979. var a = e("#helloContainer");
  1980. a.css("transform", "none");
  1981. var b = a.height(),
  1982. c = d.innerHeight;
  1983. b > c / 1.1 ? a.css("transform", "translate(-50%, -50%) scale(" + c / b / 1.1 + ")") : a.css("transform", "translate(-50%, -50%)");
  1984. xb()
  1985. }
  1986. function yb() {
  1987. var a;
  1988. a = 1 * Math.max(q / 1080, m / 1920);
  1989. return a *= M
  1990. }
  1991. function Tb() {
  1992. if (0 != h.length) {
  1993. for (var a = 0, b = 0; b < h.length; b++) a += h[b].size;
  1994. a = Math.pow(Math.min(64 / a, 1), .4) * yb();
  1995. g = (9 * g + a) / 10
  1996. }
  1997. }
  1998. function xb() {
  1999. var a, b = Date.now();
  2000. ++Ub;
  2001. E = b;
  2002. if (0 < h.length) {
  2003. Tb();
  2004. for (var c = a = 0, d = 0; d < h.length; d++) h[d].P(),
  2005. a += h[d].x / h.length, c += h[d].y / h.length;
  2006. fa = a;
  2007. ga = c;
  2008. ha = g;
  2009. u = (u + a) / 2;
  2010. v = (v + c) / 2
  2011. } else u = (29 * u + fa) / 30, v = (29 * v + ga) / 30, g = (9 * g + ha * yb()) / 10;
  2012. Jb();
  2013. Ea();
  2014. Ua || f.clearRect(0, 0, m, q);
  2015. Ua ? (f.fillStyle = xa ? "#111111" : "#F2FBFF", f.globalAlpha = .05, f.fillRect(0, 0, m, q), f.globalAlpha = 1) : Vb();
  2016. y.sort(function (a, b) {
  2017. return a.size == b.size ? a.id - b.id : a.size - b.size
  2018. });
  2019. f.save();
  2020. f.translate(m / 2, q / 2);
  2021. f.scale(g, g);
  2022. f.translate(-u, -v);
  2023. for (d = 0; d < V.length; d++) V[d].w(f);
  2024. for (d = 0; d < y.length; d++) y[d].w(f);
  2025. if (Ma) {
  2026. ra = (3 * ra + Ka) / 4;
  2027. sa = (3 * sa + La) / 4;
  2028. f.save();
  2029. f.strokeStyle = "#FFAAAA";
  2030. f.lineWidth = 10;
  2031. f.lineCap = "round";
  2032. f.lineJoin = "round";
  2033. f.globalAlpha = .5;
  2034. f.beginPath();
  2035. for (d = 0; d < h.length; d++) f.moveTo(h[d].x, h[d].y), f.lineTo(ra, sa);
  2036. f.stroke();
  2037. f.restore()
  2038. }
  2039. f.restore();
  2040. B && B.width && f.drawImage(B, m - B.width - 10, 10);
  2041. if (!hideChat)
  2042. {
  2043. if ((chatCanvas != null)&&(chatCanvas.width > 0)) f.drawImage(chatCanvas, 0, q - chatCanvas.height - 50); // draw Chat Board
  2044. }
  2045. O = Math.max(O, zb());
  2046. 0 != O && (null == ya && (ya = new za(24, "#FFFFFF")), ya.C(da("score") + ": " + ~~ (O / 100)), c = ya.L(), a = c.width, f.globalAlpha = .2, f.fillStyle = "#000000", f.fillRect(10, 10, a + 10, 34), f.globalAlpha = 1, f.drawImage(c, 15, 15));
  2047. Wb();
  2048. b = Date.now() - b;
  2049. b > 1E3 / 60 ? F -= .01 : b < 1E3 / 65 && (F += .01);.4 > F && (F = .4);
  2050. 1 < F && (F = 1);
  2051. b = E - Ab;
  2052. !Y() || S || T ? (x += b / 2E3, 1 < x && (x = 1)) : (x -= b / 300, 0 > x && (x = 0));
  2053. 0 < x && (f.fillStyle = "#000000", f.globalAlpha = .5 * x, f.fillRect(0, 0, m, q), f.globalAlpha = 1);
  2054. Ab = E
  2055. }
  2056.  
  2057. function skorkaydet() {
  2058. var skor = "skor=" + ~~(O / 100) + "&c=1&oyuncuadi="+ oyuncu_adi;
  2059. e.ajax({
  2060. type:'POST',
  2061. url:'skor.php',
  2062. data:skor,
  2063. success:function(cevap){
  2064. console.log("Add:" + ~~(O / 100) + cevap);
  2065. }
  2066. });
  2067. }
  2068. function Vb() {
  2069. f.fillStyle = xa ? "#111111" : "#F2FBFF";
  2070. f.fillRect(0, 0, m, q);
  2071. f.save();
  2072. f.strokeStyle = xa ? "#AAAAAA" : "#000000";
  2073. f.globalAlpha = .2 * g;
  2074. for (var a = m / g, b = q / g, c = (-u + a / 2) % 50; c < a; c += 50) f.beginPath(), f.moveTo(c * g - .5, 0), f.lineTo(c * g - .5, b * g), f.stroke();
  2075. for (c = (-v + b / 2) % 50; c < b; c += 50) f.beginPath(), f.moveTo(0,
  2076. c * g - .5), f.lineTo(a * g, c * g - .5), f.stroke();
  2077. f.restore()
  2078. }
  2079. function Wb() {
  2080. if (bb && Va.width) {
  2081. var a = m / 5;
  2082. f.drawImage(Va, 5, 5, a, a)
  2083. }
  2084. }
  2085. function zb() {
  2086. for (var a = 0, b = 0; b < h.length; b++) a += h[b].q * h[b].q;
  2087. return a
  2088. }
  2089. function nb() {
  2090. B = null;
  2091. if (null != C || 0 != w.length) if (null != C || Aa) {
  2092. B = document.createElement("canvas");
  2093. var a = B.getContext("2d"),
  2094. b = 60,
  2095. b = null == C ? b + 24 * w.length : b + 180,
  2096. c = Math.min(200, .3 * m) / 200;
  2097. B.width = 200 * c;
  2098. B.height = b * c;
  2099. a.scale(c, c);
  2100. a.globalAlpha = .4;
  2101. a.fillStyle = "#000000";
  2102. a.fillRect(0, 0, 200, b);
  2103. a.globalAlpha = 1;
  2104. a.fillStyle = "#FFFFFF";
  2105. c = null;
  2106. c = da("leaderboard");
  2107. a.font = "30px Ubuntu";
  2108. a.fillText(c, 100 - a.measureText(c).width / 2, 40);
  2109.  
  2110. var leaderColors = ["#E6339B", "#FFD700", "#33E660", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF"];
  2111.  
  2112. if (null == C) for (a.font = "20px Ubuntu", b = 0; b < w.length; ++b) c = w[b].name.split("*")[0] || da("unnamed_cell"),
  2113. Aa || (c = da("unnamed_cell")),
  2114. -1 != A.indexOf(w[b].id) ? (h[0].name.split("*")[0] && (c = h[0].name.split("*")[0]),
  2115. a.fillStyle = "#FFAAAA") :
  2116. a.fillStyle = leaderColors[b],
  2117. c = b + 1 + ". " + c, a.fillText(c, 100 - a.measureText(c).width / 2, 70 + 24 * b);
  2118. else for (b = c = 0; b < C.length; ++b) {
  2119. var d = c + C[b] * Math.PI * 2;
  2120. a.fillStyle = Xb[b + 1];
  2121. a.beginPath();
  2122. a.moveTo(100, 140);
  2123. a.arc(100, 140, 80, c, d, !1);
  2124. a.fill();
  2125. c = d
  2126. }
  2127. }
  2128. }
  2129. function Wa(a, b, c, d, e) {
  2130. this.V = a;
  2131. this.x = b;
  2132. this.y = c;
  2133. this.i = d;
  2134. this.b = e
  2135. }
  2136. function X(a, b, c, d, e, n) {
  2137. this.id = a;
  2138. this.s = this.x = b;
  2139. this.t = this.y = c;
  2140. this.r = this.size = d;
  2141. this.color = e;
  2142. this.a = [];
  2143. this.W();
  2144. this.B(n)
  2145. }
  2146. function Rb(a) {
  2147. for (a = a.toString(16); 6 > a.length;) a = "0" + a;
  2148. return "#" + a
  2149. }
  2150. function za(a, b, c, d) {
  2151. a && (this.u = a);
  2152. b && (this.S = b);
  2153. this.U = !! c;
  2154. d && (this.v = d)
  2155. }
  2156. function Yb(a) {
  2157. for (var b = a.length, c, d; 0 < b;) d = Math.floor(Math.random() * b), b--, c = a[b], a[b] = a[d], a[d] = c
  2158. }
  2159. function W(a, b) {
  2160. var c = "1" == e("#helloContainer").attr("data-has-account-data");
  2161. e("#helloContainer").attr("data-has-account-data", "1");
  2162. if (null == b && d.localStorage.loginCache) {
  2163. var k = JSON.parse(d.localStorage.loginCache);
  2164. k.f = a.f;
  2165. k.d = a.d;
  2166. k.e = a.e;
  2167. d.localStorage.loginCache = JSON.stringify(k)
  2168. }
  2169. if (c) {
  2170. var G = +e(".warball-exp-bar .progress-bar-text").first().text().split("/")[0],
  2171. c = +e(".warball-exp-bar .progress-bar-text").first().text().split("/")[1].split(" ")[0],
  2172. k = e(".warball-profile-panel .progress-bar-star").first().text();
  2173. if (k != a.e) W({
  2174. f: c,
  2175. d: c,
  2176. e: k
  2177. }, function () {
  2178. e(".warball-profile-panel .progress-bar-star").text(a.e);
  2179. e(".warball-exp-bar .progress-bar").css("width", "100%");
  2180. e(".progress-bar-star").addClass("animated tada").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend", function () {
  2181. e(".progress-bar-star").removeClass("animated tada")
  2182. });
  2183. setTimeout(function () {
  2184. e(".warball-exp-bar .progress-bar-text").text(a.d + "/" + a.d + " XP");
  2185. W({
  2186. f: 0,
  2187. d: a.d,
  2188. e: a.e
  2189. }, function () {
  2190. W(a, b)
  2191. })
  2192. }, 1E3)
  2193. });
  2194. else {
  2195. var n = Date.now(),
  2196. f = function () {
  2197. var c;
  2198. c = (Date.now() - n) / 1E3;
  2199. c = 0 > c ? 0 : 1 < c ? 1 : c;
  2200. c = c * c * (3 - 2 * c);
  2201. e(".warball-exp-bar .progress-bar-text").text(~~ (G + (a.f - G) * c) + "/" + a.d + " XP");
  2202. e(".warball-exp-bar .progress-bar").css("width", (88 * (G + (a.f - G) * c) / a.d).toFixed(2) + "%");
  2203. 1 > c ? d.requestAnimationFrame(f) : b && b()
  2204. };
  2205. d.requestAnimationFrame(f)
  2206. }
  2207. } else e(".warball-profile-panel .progress-bar-star").text(a.e), e(".warball-exp-bar .progress-bar-text").text(a.f + "/" + a.d + " XP"), e(".warball-exp-bar .progress-bar").css("width", (88 * a.f / a.d).toFixed(2) + "%"), b && b()
  2208. }
  2209. function Bb(a) {
  2210. "string" == typeof a && (a = JSON.parse(a));
  2211. Date.now() + 18E5 > a.ka ? e("#helloContainer").attr("data-logged-in",
  2212. "0") : (d.localStorage.loginCache = JSON.stringify(a), D = a.ha, e(".warball-profile-name").text(a.name), mb(), W({
  2213. f: a.f,
  2214. d: a.d,
  2215. e: a.e
  2216. }), e("#helloContainer").attr("data-logged-in", "1"))
  2217. }
  2218. function Zb(a) {
  2219. a = a.split("\n");
  2220. Bb({
  2221. name: a[0],
  2222. ta: a[1],
  2223. ha: a[2],
  2224. ka: 1E3 * +a[3],
  2225. e: +a[4],
  2226. f: +a[5],
  2227. d: +a[6]
  2228. })
  2229. }
  2230. function Xa(a) {
  2231. if ("connected" == a.status) {
  2232. var b = a.authResponse.accessToken;
  2233. d.FB.api("/me/picture?width=180&height=180", function (a) {
  2234. d.localStorage.fbPictureCache = a.data.url;
  2235. e(".warball-profile-picture").attr("src", a.data.url)
  2236. });
  2237. e("#helloContainer").attr("data-logged-in",
  2238. "1");
  2239. null != D ? e.ajax("http://agarioplayy.org/", {
  2240. error: function () {
  2241. D = null;
  2242. Xa(a)
  2243. },
  2244. success: function (a) {
  2245. a = a.split("\n");
  2246. W({
  2247. e: +a[0],
  2248. f: +a[1],
  2249. d: +a[2]
  2250. })
  2251. },
  2252. dataType: "text",
  2253. method: "POST",
  2254. cache: !1,
  2255. crossDomain: !0,
  2256. data: D
  2257. }) : e.ajax("http://agarioplayy.org/", {
  2258. error: function () {
  2259. D = null;
  2260. e("#helloContainer").attr("data-logged-in", "0")
  2261. },
  2262. success: Zb,
  2263. dataType: "text",
  2264. method: "POST",
  2265. cache: !1,
  2266. crossDomain: !0,
  2267. data: b
  2268. })
  2269. }
  2270. }
  2271. function gb(a) {
  2272. ca(":party");
  2273. e("#helloContainer").attr("data-party-state", "4");
  2274. a = decodeURIComponent(a).replace(/.*#/gim,
  2275. "");
  2276. Ya("#" + d.encodeURIComponent(a));
  2277. e.ajax(Za + "//agarioplayy.org", {
  2278. error: function () {
  2279. e("#helloContainer").attr("data-party-state", "6")
  2280. },
  2281. success: function (b) {
  2282. b = b.split("\n");
  2283. e(".partyToken").val("agarioplayy.org/#" + d.encodeURIComponent(a));
  2284. e("#helloContainer").attr("data-party-state", "5");
  2285. ca(":party");
  2286. Ha("ws://" + b[0], a)
  2287. },
  2288. dataType: "text",
  2289. method: "POST",
  2290. cache: !1,
  2291. crossDomain: !0,
  2292. data: a
  2293. })
  2294. }
  2295. function Ya(a) {
  2296. d.history && d.history.replaceState && d.history.replaceState({}, d.document.title, a)
  2297. }
  2298. function Qb(a, b) {
  2299. var c = -1 != A.indexOf(a.id),
  2300. d = -1 != A.indexOf(b.id),
  2301. e = 30 > b.size;
  2302. c && e && ++Oa;
  2303. e || !c || d || ++Ra
  2304. }
  2305. function Cb(a) {
  2306. a = ~~a;
  2307. var b = (a % 60).toString();
  2308. a = (~~ (a / 60)).toString();
  2309. 2 > b.length && (b = "0" + b);
  2310. return a + ":" + b
  2311. }
  2312. function $b() {
  2313. if (null == w) return 0;
  2314. for (var a = 0; a < w.length; ++a) if (-1 != A.indexOf(w[a].id)) return a + 1;
  2315. return 0
  2316. }
  2317. function Sb() {
  2318.  
  2319.  
  2320. skorkaydet();
  2321. e(".stats-food-eaten").text(Oa);
  2322. e(".stats-time-alive").text(Cb((rb - qb) / 1E3));
  2323. e(".stats-leaderboard-time").text(Cb(Sa));
  2324. e(".stats-highest-mass").text(~~ (O / 100));
  2325. e(".stats-cells-eaten").text(Ra);
  2326. e(".stats-top-position").text(0 == R ? ":(" : R);
  2327. var a = document.getElementById("statsGraph");
  2328. if (a) {
  2329. var b = a.getContext("2d"),
  2330. c = a.width,
  2331. a = a.height;
  2332. b.clearRect(0, 0, c, a);
  2333. if (2 < z.length) {
  2334. for (var d = 200, f = 0; f < z.length; f++) d = Math.max(z[f], d);
  2335. b.lineWidth = 3;
  2336. b.lineCap = "round";
  2337. b.lineJoin = "round";
  2338. b.strokeStyle = Pa;
  2339. b.fillStyle = Pa;
  2340. b.beginPath();
  2341. b.moveTo(0, a - z[0] / d * (a - 10) + 10);
  2342. for (f = 1; f < z.length; f += Math.max(~~ (z.length / c), 1)) {
  2343. for (var n = f / (z.length - 1) * c, r = [], p = -20; 20 >= p; ++p) 0 > f + p || f + p >= z.length || r.push(z[f + p]);
  2344. r = r.reduce(function (a, b) {
  2345. return a + b
  2346. }) / r.length / d;
  2347. b.lineTo(n, a - r * (a - 10) + 10)
  2348. }
  2349. b.stroke();
  2350. b.globalAlpha = .5;
  2351. b.lineTo(c, a);
  2352. b.lineTo(0, a);
  2353. b.fill();
  2354. b.globalAlpha = 1
  2355. }
  2356. }
  2357. }
  2358. if (!d.agarioNoInit) {
  2359.  
  2360. var Za = d.location.protocol,
  2361. lb = "https:" == Za;
  2362. var Da, f, J, m, q, ba, chatCanvas = null,
  2363. s = null,
  2364. chatBoard = [],
  2365. u = 0,
  2366. v = 0,
  2367. A = [],
  2368. h = [],
  2369. I = {}, y = [],
  2370. V = [],
  2371. w = [],
  2372. ja = 0,
  2373. ka = 0,
  2374. ma = -1,
  2375. na = -1,
  2376. Ub = 0,
  2377. E = 0,
  2378. Ab = 0,
  2379. H = null,
  2380. ta = 0,
  2381. ua = 0,
  2382. va = 1E4,
  2383. wa = 1E4,
  2384. hideChat = false,
  2385. g = 1,
  2386.  
  2387. t = null,
  2388. Db = !0,
  2389. Aa = !0,
  2390. $a = !1,
  2391. Na = !1,
  2392. O = 0,
  2393. xa = !1,
  2394. hasOverlay = true,
  2395. Eb = !1,
  2396. fa = u = ~~ ((ta + va) / 2),
  2397. ga = v = ~~ ((ua + wa) / 2),
  2398. ha = 1,
  2399. U = "",
  2400. C = null,
  2401. Ca = !1,
  2402. Ma = !1,
  2403. Ka = 0,
  2404. La = 0,
  2405. ra = 0,
  2406. sa = 0,
  2407. Fb = 0,
  2408. Xb = ["#333333",
  2409. "#FF3333", "#33FF33", "#3333FF"],
  2410. Ua = !1,
  2411. ea = !1,
  2412. ob = 0,
  2413. D = null,
  2414. M = 1,
  2415. x = 1,
  2416. S = !0,
  2417. Ga = 0,
  2418. Ia = {};
  2419. (function () {
  2420. var a = d.location.search;
  2421. "?" == a.charAt(0) && (a = a.slice(1));
  2422. for (var a = a.split("&"), b = 0; b < a.length; b++) {
  2423. var c = a[b].split("=");
  2424. Ia[c[0]] = c[1]
  2425. }
  2426. })();
  2427. var bb = "ontouchstart" in d && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(d.navigator.userAgent),
  2428. Va = new Image;
  2429. Va.src = "img/split.png";
  2430. var Gb = document.createElement("canvas");
  2431. if ("undefined" == typeof console || "undefined" == typeof DataView || "undefined" == typeof WebSocket || null == Gb || null == Gb.getContext || null == d.localStorage) alert("You browser does not support this game, we recommend you to use Firefox to play this");
  2432. else {
  2433. var oa = null;
  2434. d.setNick = function (a,mySkin) {
  2435. mySkin = '9999';
  2436. if(mySkin==""){
  2437. mySkin = "0";
  2438. }
  2439. //a = a.toLowerCase();
  2440. a = a + "*" + mySkin;
  2441.  
  2442.  
  2443. a = a.split('Admin').join('fake_admin'); // boÅŸluk karakterini temizleme...
  2444. a = a.split('ADMIN').join('fake_admin'); // boÅŸluk karakterini temizleme...
  2445. a = a.split('admin').join('fake_admin'); // boÅŸluk karakterini temizleme...
  2446.  
  2447.  
  2448.  
  2449.  
  2450. if (z.indexOf(T) > - 1) {
  2451. alert('Please choose a correct name! This is bad nick!');
  2452. return false;
  2453. }
  2454. a = a.split('Admin').join('fake_admin');
  2455. a = a.split('admin').join('fake_admin');
  2456. a = a.split('ADMIN').join('fake_admin');
  2457. a = a.split('admin').join('fake_admin');
  2458. a = a.split('Admin').join('fake_admin');
  2459. a = a.split('ADmin').join('fake_admin');
  2460. a = a.split('ADMin').join('fake_admin');
  2461. a = a.split('ADMIn').join('fake_admin');
  2462. a = a.split('ADMIN').join('fake_admin');
  2463. a = a.split('AdMiN').join('fake_admin');
  2464.  
  2465. var protectName = a.split('*'),
  2466. testExpession = /ramm/gi;
  2467.  
  2468. if(testExpession.test(protectName[0])){
  2469.  
  2470. a = 'fake_rammstein';
  2471. };
  2472.  
  2473. a = a.split('agario.').join('bad nick');
  2474. a = a.split('www.').join('bad nick');
  2475. a = a.split('.cafe').join('bad nick');
  2476. a = a.split('.org').join('bad nick');
  2477. a = a.split('.biz').join('bad nick');
  2478. a = a.split('.ca').join('bad nick');
  2479. a = a.split('.net').join('bad nick');
  2480.  
  2481.  
  2482. hb();
  2483. H = a;
  2484.  
  2485. oyuncu_adi= H.split("*")[0];
  2486. tb();
  2487. O = 0
  2488.  
  2489.  
  2490. };
  2491.  
  2492. d.savescreenshoot = function (arg) {
  2493.  
  2494. // if(~~(O / 100) > 10000) {
  2495.  
  2496.  
  2497.  
  2498. //var oyuncukim = $.cookie("nick");
  2499. var veri = {'ss':arg,'oyuncuadi':oyuncu_adi,'puan':~~(O / 100)}
  2500. e.ajax({
  2501. type:'POST',
  2502. url:'/saveSS.jsp',
  2503. data:veri,
  2504. success:function(cevap){
  2505. console.log(cevap);
  2506. }
  2507.  
  2508.  
  2509.  
  2510.  
  2511. });
  2512.  
  2513. //}
  2514.  
  2515. }
  2516. d.setHideChat = function (arg) {
  2517. hideChat = arg;
  2518. if (arg) {
  2519. e("#chat_textbox").hide();
  2520. }
  2521. else {
  2522. e("#chat_textbox").show();
  2523. }
  2524. };
  2525. d.setHideMap = function (arg) {
  2526. hideMap = arg;
  2527. if (arg) {
  2528. e("#mini-map-wrapper").hide();
  2529. }
  2530. else {
  2531. e("#mini-map-wrapper").show();
  2532. }
  2533. };
  2534. d.setRegion = la;
  2535. d.setSkins = function (a) {
  2536. Db = a
  2537. };
  2538. d.setNames = function (a) {
  2539. Aa = a
  2540. };
  2541. d.setDarkTheme = function (a) {
  2542. xa = a
  2543. };
  2544. d.setColors = function (a) {
  2545. $a = a
  2546. };
  2547. d.setShowMass = function (a) {
  2548. Eb = a
  2549. };
  2550. d.spectate = function () {
  2551.  
  2552. H = null;
  2553. K(1);
  2554. hb()
  2555. e("#mini-map-wrapper").hide();
  2556. };
  2557. d.setGameMode = function (a) {
  2558.  
  2559. a != U && (":party" == U && e("#helloContainer").attr("data-party-state","0"), ca(a), ":party" != a && L())
  2560. };
  2561. d.setAcid = function (a) {
  2562. Ua = a
  2563. };
  2564. null != d.localStorage && (null == d.localStorage.AB9 && (d.localStorage.AB9 = 0 + ~~ (100 * Math.random())), Fb = +d.localStorage.AB9, d.ABGroup = Fb);
  2565. e.get(Za + "//agarioplayy.org", function (a) {
  2566. var b = a.split(" ");
  2567. a = b[0];
  2568. b = b[1] || ""; - 1 == ["UA"].indexOf(a) && Hb.push("ussr");
  2569. ia.hasOwnProperty(a) && ("string" == typeof ia[a] ? t || la(ia[a]) : ia[a].hasOwnProperty(b) && (t || la(ia[a][b])))
  2570. }, "text");
  2571. d.ga && d.ga("send", "event", "User-Agent", d.navigator.userAgent, {
  2572. nonInteraction: 1
  2573. });
  2574. var pa = !1,
  2575. jb = 0;
  2576. setTimeout(function () {
  2577. pa = !0
  2578. }, Math.max(6E4 * jb, 3E3));
  2579. var ia = {
  2580. AF: "JP-Tokyo",
  2581.  
  2582. ZW: "EU-London"
  2583. }, N = null;
  2584. d.connect = Ha;
  2585. var qa = 500,
  2586. Ta = null,
  2587. ub = 0,
  2588. vb = -1,
  2589. wb = -1,
  2590. B = null,
  2591. F = 1,
  2592. ya = null,
  2593. eb = function () {
  2594. var a = Date.now(),
  2595. b = 1E3 / 60;
  2596. return function () {
  2597. d.requestAnimationFrame(eb);
  2598. var c = Date.now(),
  2599. e = c - a;
  2600. e > b && (a = c - e % b, !Y() || 290 > Date.now() - ob ? xb() : console.warn("Skipping draw"), ac())
  2601. }
  2602. }(),
  2603. Z = {}, Hb = "".split(";"),
  2604. bc = "".split(";"),
  2605. $ = {};
  2606. Wa.prototype = {
  2607. V: null,
  2608. x: 0,
  2609. y: 0,
  2610. i: 0,
  2611. b: 0
  2612. };
  2613. X.prototype = {
  2614. id: 0,
  2615. a: null,
  2616. name: null,
  2617. o: null,
  2618. O: null,
  2619. x: 0,
  2620. y: 0,
  2621. size: 0,
  2622. s: 0,
  2623. t: 0,
  2624. r: 0,
  2625. J: 0,
  2626. K: 0,
  2627. q: 0,
  2628. ba: 0,
  2629. Q: 0,
  2630. sa: 0,
  2631. ja: 0,
  2632. G: !1,
  2633. h: !1,
  2634. n: !1,
  2635. R: !0,
  2636. Y: 0,
  2637. fa: null,
  2638. X: function () {
  2639. var a;
  2640. for (a = 0; a < y.length; a++) if (y[a] == this) {
  2641. y.splice(a, 1);
  2642. break
  2643. }
  2644. delete I[this.id];
  2645. a = h.indexOf(this); - 1 != a && (Na = !0, h.splice(a, 1));
  2646. a = A.indexOf(this.id); - 1 != a && A.splice(a, 1);
  2647. this.G = !0;
  2648. 0 < this.Y && V.push(this)
  2649. },
  2650. l: function () {
  2651. return Math.max(~~ (.3 * this.size), 24)
  2652. },
  2653. B: function (a) {
  2654. if (this.name = a) null == this.o ? this.o = new za(this.l(), "#FFFFFF", !0, "#000000") : this.o.M(this.l()), this.o.C(this.name)
  2655. },
  2656. W: function () {
  2657. for (var a = this.I(); this.a.length > a;) {
  2658. var b = ~~ (Math.random() * this.a.length);
  2659. this.a.splice(b, 1)
  2660. }
  2661. for (0 == this.a.length && 0 < a && this.a.push(new Wa(this, this.x, this.y, this.size, Math.random() - .5)); this.a.length < a;) b = ~~ (Math.random() * this.a.length), b = this.a[b], this.a.push(new Wa(this, b.x, b.y, b.i, b.b))
  2662. },
  2663. I: function () {
  2664. var a = 10;
  2665. 20 > this.size && (a = 0);
  2666. this.h && (a = 30);
  2667. var b = this.size;
  2668. this.h || (b *= g);
  2669. b *= F;
  2670. this.ba & 32 && (b *= .25);
  2671. return~~Math.max(b, a)
  2672. },
  2673. qa: function () {
  2674. this.W();
  2675. for (var a = this.a, b = a.length, c = 0; c < b; ++c) {
  2676. var d = a[(c - 1 + b) % b].b,
  2677. e = a[(c + 1) % b].b;
  2678. a[c].b += (Math.random() - .5) * (this.n ? 3 : 1);
  2679. a[c].b *= .7;
  2680. 10 < a[c].b && (a[c].b = 10); - 10 > a[c].b && (a[c].b = -10);
  2681. a[c].b = (d + e + 8 * a[c].b) / 10
  2682. }
  2683. for (var n = this, f = this.h ? 0 : (this.id / 1E3 + E / 1E4) % (2 * Math.PI), c = 0; c < b; ++c) {
  2684. var p = a[c].i,
  2685. d = a[(c - 1 + b) % b].i,
  2686. e = a[(c + 1) % b].i;
  2687. if (15 < this.size && null != ba && 20 < this.size * g && 0 < this.id) {
  2688. var h = !1,
  2689. Ja = a[c].x,
  2690. l = a[c].y;
  2691. ba.ra(Ja - 5, l - 5, 10, 10, function (a) {
  2692. a.V != n && 25 > (Ja - a.x) * (Ja - a.x) + (l - a.y) * (l - a.y) && (h = !0)
  2693. });
  2694. !h && (a[c].x < ta || a[c].y < ua || a[c].x > va || a[c].y > wa) && (h = !0);
  2695. h && (0 < a[c].b && (a[c].b = 0), a[c].b -= 1)
  2696. }
  2697. p += a[c].b;
  2698. 0 > p && (p = 0);
  2699. p = this.n ? (19 * p + this.size) / 20 : (12 * p + this.size) / 13;
  2700. a[c].i = (d + e + 8 * p) / 10;
  2701. d = 2 * Math.PI / b;
  2702. e = this.a[c].i;
  2703. this.h && 0 == c % 2 && (e += 5);
  2704. a[c].x = this.x + Math.cos(d * c + f) * e;
  2705. a[c].y = this.y + Math.sin(d * c + f) * e
  2706. }
  2707. },
  2708. P: function () {
  2709. if (0 >= this.id) return 1;
  2710. var a;
  2711. a = (E - this.Q) / 120;
  2712. a = 0 > a ? 0 : 1 < a ? 1 : a;
  2713. var b = 0 > a ? 0 : 1 < a ? 1 : a;
  2714. this.l();
  2715. if (this.G && 1 <= b) {
  2716. var c = V.indexOf(this); - 1 != c && V.splice(c, 1)
  2717. }
  2718. this.x = a * (this.J - this.s) + this.s;
  2719. this.y = a * (this.K - this.t) + this.t;
  2720. this.size = b * (this.q - this.r) + this.r;
  2721. return b
  2722. },
  2723. N: function () {
  2724. return 0 >= this.id ? !0 : this.x + this.size + 40 < u - m / 2 / g || this.y + this.size + 40 < v - q / 2 / g || this.x - this.size - 40 > u + m / 2 / g || this.y - this.size - 40 > v + q / 2 / g ? !1 : !0
  2725. },
  2726. w: function (a) {
  2727. if (this.N()) {
  2728. ++this.Y;
  2729. var b = 0 < this.id && !this.h && !this.n && .4 > g;
  2730. 5 > this.I() && 0 < this.id && (b = !0);
  2731. if (this.R && !b) for (var c = 0; c < this.a.length; c++) this.a[c].i = this.size;
  2732. this.R = b;
  2733. a.save();
  2734. this.ja = E;
  2735. c = this.P();
  2736. this.G && (a.globalAlpha *= 1 - c);
  2737. a.lineWidth = 10;
  2738. a.lineCap = "round";
  2739. a.lineJoin = this.h ? "miter" : "round";
  2740. $a ? (a.fillStyle = "#FFFFFF", a.strokeStyle = "#AAAAAA") : (a.fillStyle = this.color, a.strokeStyle = this.color);
  2741. if (b) a.beginPath(), a.arc(this.x, this.y, this.size + 5, 0, 2 * Math.PI, !1);
  2742. else {
  2743. this.qa();
  2744. a.beginPath();
  2745. var d = this.I();
  2746. a.moveTo(this.a[0].x, this.a[0].y);
  2747. for (c = 1; c <= d; ++c) {
  2748. var e = c % d;
  2749. a.lineTo(this.a[e].x, this.a[e].y)
  2750. }
  2751. }
  2752. a.closePath();
  2753.  
  2754. c = this.name.toLowerCase().split("*");
  2755.  
  2756. if(c[1]==""){
  2757. c = "";
  2758. } else {
  2759. c = c[1];
  2760. }
  2761. var customID = '9999';
  2762.  
  2763. var rsyr = Math.floor(Math.random() * (100000000000 - 1) + 1);
  2764. //alert(c);
  2765. !this.n && Db && ":team" != U ? (d = this.fa, null == d ? d = null : ":" == d[0] ? ($.hasOwnProperty(d) || ($[d] = new Image,
  2766. $[d].src = d.slice(1)),
  2767. d = 0 != $[d].width && $[d].complete ? $[d] : null) : d = null,
  2768. d || (1 != Hb.indexOf(c) ? (Z.hasOwnProperty(c) ||
  2769. (Z[c] = new Image, Z[c].crossOrigin="anonymous",
  2770. c === customID ? Z[c].src = customSkin : Z[c].src = "http://agarioplayy.org/skins/orig/" + c + ".png?"+rsyr), //#MOD LOAD MY CUSTOM SKIN
  2771. //(Z[c] = new Image,
  2772. //Z[c].src = "http://agarioplayy.org/skins/orig/" + ".png?"+rsyr),
  2773.  
  2774.  
  2775. d = 0 != Z[c].width && Z[c].complete ? Z[c] : null) : d = null)) : d = null;
  2776. e = d;
  2777. b || a.stroke();
  2778. a.fill();
  2779. null != e && (a.save(), a.clip(), a.drawImage(e, this.x - this.size, this.y - this.size, 2 * this.size, 2 * this.size), a.restore());
  2780. ($a || 15 < this.size) && !b && (a.strokeStyle = "#000000", a.globalAlpha *= .1, a.stroke());
  2781. //c == customID ? a.globalAlpha = 0 :
  2782. a.globalAlpha = 1; // #MOD HIDE MY NAME ONLY DISPLAY OTHERS NORMALY
  2783. d = -1 != h.indexOf(this);
  2784. b = ~~this.y;
  2785. if (0 != this.id && (Aa || d) && this.name && this.o && (null == e || -1 == bc.indexOf(c))) {
  2786.  
  2787. e = this.o;
  2788. e.C(this.name.split("*")[0]);
  2789. e.M(this.l());
  2790. c = 0 >= this.id ? 1 : Math.ceil(10 * g) / 10;
  2791. e.ea(c);
  2792. var e = e.L(),
  2793. n = ~~ (e.width / c),
  2794. f = ~~ (e.height / c);
  2795. a.drawImage(e, ~~this.x - ~~ (n / 2), b - ~~ (f / 2), n, f);
  2796. b += e.height / 2 / c + 4
  2797. }
  2798. 0 < this.id && Eb && (d || 0 == h.length && (!this.h || this.n) && 20 < this.size) && (null == this.O && (this.O = new za(this.l() / 2, "#FFFFFF", !0, "#000000")), d = this.O, d.M(this.l() / 2), d.C(~~ (this.size * this.size / 100)), c = Math.ceil(10 * g) / 10, d.ea(c), e = d.L(), n = ~~ (e.width / c), f = ~~ (e.height / c), a.drawImage(e, ~~this.x - ~~ (n / 2), b - ~~ (f / 2), n, f));
  2799. a.restore()
  2800. }
  2801. }
  2802. };
  2803. za.prototype = {
  2804. F: "",
  2805. S: "#000000",
  2806. U: !1,
  2807. v: "#000000",
  2808. u: 16,
  2809. p: null,
  2810. T: null,
  2811. k: !1,
  2812. D: 1,
  2813. _value: "",
  2814. _dirty: false,
  2815. M: function (a) {
  2816. this.u != a && (this.u = a, this.k = !0)
  2817. },
  2818. ea: function (a) {
  2819. this.D != a && (this.D = a, this.k = !0)
  2820. },
  2821. setStrokeColor: function (a) {
  2822. this.v != a && (this.v = a, this.k = !0)
  2823. },
  2824. C: function (a) {
  2825. a != this.F && (this.F = a, this.k = !0)
  2826. },
  2827. getWidth: function () {
  2828. return (f.measureText(this.F).width + 6);
  2829. },
  2830. L: function () {
  2831. null == this.p && (this.p = document.createElement("canvas"), this.T = this.p.getContext("2d"));
  2832. if (this.k) {
  2833. this.k = !1;
  2834. var a = this.p,
  2835. b = this.T,
  2836. c = this.F,
  2837. d = this.D,
  2838. e = this.u,
  2839. f = e + "px Ubuntu";
  2840. b.font = f;
  2841. var r = ~~ (.2 * e);
  2842. a.width = (b.measureText(c).width + 6) * d;
  2843. a.height = (e + r) * d;
  2844. b.font = f;
  2845. b.scale(d, d);
  2846. b.globalAlpha = 1;
  2847. b.lineWidth = 3;
  2848. b.strokeStyle = this.v;
  2849. b.fillStyle = this.S;
  2850. this.U && b.strokeText(c, 3, e - r / 2);
  2851. b.fillText(c, 3, e - r / 2)
  2852. }
  2853.  
  2854. return this.p
  2855. }
  2856. };
  2857. Date.now || (Date.now = function () {
  2858. return (new Date).getTime()
  2859. });
  2860. (function () {
  2861. for (var a = ["ms", "moz", "webkit", "o"], b = 0; b < a.length && !d.requestAnimationFrame; ++b) d.requestAnimationFrame = d[a[b] + "RequestAnimationFrame"],
  2862. d.cancelAnimationFrame = d[a[b] + "CancelAnimationFrame"] || d[a[b] + "CancelRequestAnimationFrame"];
  2863. d.requestAnimationFrame || (d.requestAnimationFrame = function (a) {
  2864. return setTimeout(a, 1E3 / 60)
  2865. }, d.cancelAnimationFrame = function (a) {
  2866. clearTimeout(a)
  2867. })
  2868. })();
  2869. var Kb = {
  2870. la: function (a) {
  2871. function b(a, b, c, d, e) {
  2872. this.x = a;
  2873. this.y = b;
  2874. this.j = c;
  2875. this.g = d;
  2876. this.depth = e;
  2877. this.items = [];
  2878. this.c = []
  2879. }
  2880. var c = a.ma || 2,
  2881. d = a.na || 4;
  2882. b.prototype = {
  2883. x: 0,
  2884. y: 0,
  2885. j: 0,
  2886. g: 0,
  2887. depth: 0,
  2888. items: null,
  2889. c: null,
  2890. H: function (a) {
  2891. for (var b = 0; b < this.items.length; ++b) {
  2892. var c = this.items[b];
  2893. if (c.x >= a.x && c.y >= a.y && c.x < a.x + a.j && c.y < a.y + a.g) return !0
  2894. }
  2895. if (0 != this.c.length) {
  2896. var d = this;
  2897. return this.$(a, function (b) {
  2898. return d.c[b].H(a)
  2899. })
  2900. }
  2901. return !1
  2902. },
  2903. A: function (a, b) {
  2904. for (var c = 0; c < this.items.length; ++c) b(this.items[c]);
  2905. if (0 != this.c.length) {
  2906. var d = this;
  2907. this.$(a, function (c) {
  2908. d.c[c].A(a, b)
  2909. })
  2910. }
  2911. },
  2912. m: function (a) {
  2913. 0 != this.c.length ? this.c[this.Z(a)].m(a) : this.items.length >= c && this.depth < d ? (this.ia(), this.c[this.Z(a)].m(a)) : this.items.push(a)
  2914. },
  2915. Z: function (a) {
  2916. return a.x < this.x + this.j / 2 ? a.y < this.y + this.g / 2 ? 0 : 2 : a.y < this.y + this.g / 2 ? 1 : 3
  2917. },
  2918. $: function (a, b) {
  2919. return a.x < this.x + this.j / 2 && (a.y < this.y + this.g / 2 && b(0) || a.y >= this.y + this.g / 2 && b(2)) || a.x >= this.x + this.j / 2 && (a.y < this.y + this.g / 2 && b(1) || a.y >= this.y + this.g / 2 && b(3)) ? !0 : !1
  2920. },
  2921. ia: function () {
  2922. var a = this.depth + 1,
  2923. c = this.j / 2,
  2924. d = this.g / 2;
  2925. this.c.push(new b(this.x, this.y, c, d, a));
  2926. this.c.push(new b(this.x + c, this.y, c, d, a));
  2927. this.c.push(new b(this.x, this.y + d, c, d, a));
  2928. this.c.push(new b(this.x + c, this.y + d, c, d, a));
  2929. a = this.items;
  2930. this.items = [];
  2931. for (c = 0; c < a.length; c++) this.m(a[c])
  2932. },
  2933. clear: function () {
  2934. for (var a = 0; a < this.c.length; a++) this.c[a].clear();
  2935. this.items.length = 0;
  2936. this.c.length = 0
  2937. }
  2938. };
  2939. var e = {
  2940. x: 0,
  2941. y: 0,
  2942. j: 0,
  2943. g: 0
  2944. };
  2945. return {
  2946. root: new b(a.ca, a.da, a.oa - a.ca, a.pa - a.da, 0),
  2947. m: function (a) {
  2948. this.root.m(a)
  2949. },
  2950. A: function (a, b) {
  2951. this.root.A(a, b)
  2952. },
  2953. ra: function (a, b, c, d, f) {
  2954. e.x = a;
  2955. e.y = b;
  2956. e.j = c;
  2957. e.g = d;
  2958. this.root.A(e, f)
  2959. },
  2960. H: function (a) {
  2961. return this.root.H(a)
  2962. },
  2963. clear: function () {
  2964. this.root.clear()
  2965. }
  2966. }
  2967. }
  2968. }, pb = function () {
  2969. var a = new X(0, 0, 0, 32, "#ED1C24", ""),
  2970. b = document.createElement("canvas");
  2971. b.width = 32;
  2972. b.height = 32;
  2973. var c = b.getContext("2d");
  2974. return function () {
  2975. 0 < h.length && (a.color = h[0].color, a.B(h[0].name));
  2976. c.clearRect(0, 0, 32, 32);
  2977. c.save();
  2978. c.translate(16, 16);
  2979. c.scale(.4, .4);
  2980. a.w(c);
  2981. c.restore();
  2982. var d = document.getElementById("favicon"),
  2983. e = d.cloneNode(!0);
  2984. e.setAttribute("href", b.toDataURL("image/png"));
  2985. d.parentNode.replaceChild(e, d)
  2986. }
  2987. }();
  2988. e(function () {
  2989. pb()
  2990. });
  2991. e(function () {
  2992. +d.localStorage.wannaLogin && (d.localStorage.loginCache && Bb(d.localStorage.loginCache), d.localStorage.fbPictureCache && e(".warball-profile-picture").attr("src", d.localStorage.fbPictureCache))
  2993. });
  2994. d.facebookLogin = function () {
  2995. d.localStorage.wannaLogin = 1
  2996. };
  2997. d.fbAsyncInit = function () {
  2998. function a() {
  2999. d.localStorage.wannaLogin = 1;
  3000. null == d.FB ? alert("You seem to have something blocking Facebook on your browser, please check for any extensions") : d.FB.login(function (a) {
  3001. Xa(a)
  3002. }, {
  3003. scope: "public_profile, email"
  3004. })
  3005. }
  3006. d.FB.init({
  3007. appId: "125735547767875",
  3008. cookie: !0,
  3009. xfbml: !0,
  3010. status: !0,
  3011. version: "v2.4"
  3012. });
  3013. d.FB.Event.subscribe("auth.statusChange", function (b) {
  3014. +d.localStorage.wannaLogin && ("connected" == b.status ? Xa(b) : a())
  3015. });
  3016. d.facebookLogin = a
  3017. };
  3018. d.logout = function () {
  3019. D = null;
  3020. e("#helloContainer").attr("data-logged-in", "0");
  3021. e("#helloContainer").attr("data-has-account-data", "0");
  3022. delete d.localStorage.wannaLogin;
  3023. delete d.localStorage.loginCache;
  3024. delete d.localStorage.fbPictureCache;
  3025. L()
  3026. };
  3027. var ac = function () {
  3028. function a(a, b, c, d, e) {
  3029. var f = b.getContext("2d"),
  3030. g = b.width;
  3031. b = b.height;
  3032. a.color = e;
  3033. a.B(c);
  3034. a.size = d;
  3035. f.save();
  3036. f.translate(g / 2, b / 2);
  3037. a.w(f);
  3038. f.restore()
  3039. }
  3040. for (var b = new X(-1, 0, 0, 32, "#5bc0de", ""), c = new X(-1, 0, 0, 32, "#5bc0de", ""), d = "#0791ff #5a07ff #ff07fe #ffa507 #ff0774 #077fff #3aff07 #ff07ed #07a8ff #ff076e #3fff07 #ff0734 #07ff20 #ff07a2 #ff8207 #07ff0e".split(" "),
  3041. f = [], g = 0; g < d.length; ++g) {
  3042. var h = g / d.length * 12,
  3043. p = 30 * Math.sqrt(g / d.length);
  3044. f.push(new X(-1, Math.cos(h) * p, Math.sin(h) * p, 10, d[g], ""))
  3045. }
  3046. Yb(f);
  3047. var m = document.createElement("canvas");
  3048. m.getContext("2d");
  3049. m.width = m.height = 70;
  3050. a(c, m, "", 26, "#ebc0de");
  3051. return function () {
  3052. e(".cell-spinner").filter(":visible").each(function () {
  3053. var c = e(this),
  3054. d = Date.now(),
  3055. f = this.width,
  3056. g = this.height,
  3057. h = this.getContext("2d");
  3058. h.clearRect(0, 0, f, g);
  3059. h.save();
  3060. h.translate(f / 2, g / 2);
  3061. for (var k = 0; 10 > k; ++k) h.drawImage(m, (.1 * d + 80 * k) % (f + 140) - f / 2 - 70 - 35,
  3062. g / 2 * Math.sin((.001 * d + k) % Math.PI * 2) - 35, 70, 70);
  3063. h.restore();
  3064. (c = c.attr("data-itr")) && (c = da(c));
  3065. a(b, this, c || "", +e(this).attr("data-size"), "#5bc0de")
  3066. });
  3067. e("#statsPellets").filter(":visible").each(function () {
  3068. e(this);
  3069. var b = this.width,
  3070. c = this.height;
  3071. this.getContext("2d").clearRect(0, 0, b, c);
  3072. for (b = 0; b < f.length; b++) a(f[b], this, "", f[b].size, f[b].color)
  3073. })
  3074. }
  3075. }();
  3076. d.createParty = function () {
  3077. ca(":party");
  3078. N = function (a) {
  3079. Ya("/#" + d.encodeURIComponent(a));
  3080. e(".partyToken").val("agarioplayy.org/#" + d.encodeURIComponent(a));
  3081. e("#helloContainer").attr("data-party-state",
  3082. "1")
  3083. };
  3084. L()
  3085. };
  3086. d.joinParty = gb;
  3087. d.cancelParty = function () {
  3088. Ya("/");
  3089. e("#helloContainer").attr("data-party-state", "0");
  3090. ca("");
  3091. L()
  3092. };
  3093. var z = [],
  3094. Oa = 0,
  3095. Pa = "#000000",
  3096. T = !1,
  3097. Qa = !1,
  3098. qb = 0,
  3099. rb = 0,
  3100. Sa = 0,
  3101. Ra = 0,
  3102. R = 0,
  3103. sb = !0;
  3104. setInterval(function () {
  3105. Qa && z.push(zb() / 100)
  3106. }, 1E3 / 60);
  3107. setInterval(function () {
  3108. if (Y()) {
  3109. var a = P(5);
  3110. a.setUint8(0, 90);
  3111. a.setUint32(1, 1441210800, !0);
  3112. latency = new Date;
  3113. Q(a)
  3114. }
  3115. }, 1000);
  3116. setInterval(function () {
  3117. var a = $b();
  3118. 0 != a && (++Sa, 0 == R && (R = a), R = Math.min(R, a))
  3119. }, 1E3);
  3120. d.closeStats = function () {
  3121. T = !1;
  3122. e("#stats").hide();
  3123. Fa(0)
  3124. };
  3125. d.setSkipStats = function (a) {
  3126. sb = !a
  3127. };
  3128.  
  3129. e(function () {
  3130. e(Ib)
  3131. })
  3132. }
  3133. }
  3134. })(window, window.jQuery);
  3135.  
  3136. $(document).ready(function(){
  3137. $('#chat_textbox').bind("cut copy paste",function(e) {
  3138. //e.preventDefault();
  3139. });
  3140.  
  3141. });
  3142.  
  3143.  
  3144. function clickIE4() {
  3145. if (event.button == 2) {
  3146.  
  3147. return false;
  3148. }
  3149. }
  3150.  
  3151. function clickNS4(e) {
  3152. if (document.layers || document.getElementById && !document.all) {
  3153. if (e.which == 2 || e.which == 3) {
  3154. //alert(message);
  3155. return false;
  3156. }
  3157. }
  3158. }
  3159.  
  3160. if (document.layers) {
  3161. document.captureEvents(Event.MOUSEDOWN);
  3162. document.onmousedown = clickNS4;
  3163. } else if (document.all && !document.getElementById) {
  3164. document.onmousedown = clickIE4;
  3165. }
  3166.  
  3167. document.oncontextmenu = new Function("return false")
  3168.  
  3169. var customSkin = window.prompt("RAMMSTEIN - PASTE YOUR SKIN URL. EXAMPLE:", "http://i.imgur.com/y1CEyG0.png");
Add Comment
Please, Sign In to add comment