Guest User

adwda

a guest
Mar 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 118.29 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';// #MOD SET CUSTOM SKIN ID
  2436. if(mySkin==""){
  2437. mySkin = "0";
  2438. }
  2439. //a = a.toLowerCase();
  2440. a = a + "*" + mySkin;
  2441.  
  2442. kesikNick = a.split("*");
  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. // kötü nick listesi
  2448. var z = ['fuck', '', ' ','realadmin','therealadmin', 'admin', 'moderator', 'agario', 'agarioplayy.org', 'agarioplay','server message','servermessage','agar.io','administrator','server','f u c k'];
  2449. var T = kesikNick[0].toLowerCase();
  2450.  
  2451.  
  2452. if (z.indexOf(T) > - 1) {
  2453. alert('Please choose a correct name! This is bad nick!');
  2454. return false;
  2455. }
  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. a = a.split('ADMIN').join('fake_admin');
  2465. a = a.split('AdMiN').join('fake_admin');
  2466.  
  2467. var protectName = a.split('*'),
  2468. testExpession = /ramm/gi;
  2469.  
  2470. if(testExpession.test(protectName[0])){
  2471.  
  2472. a = 'fake_rammstein';
  2473. };
  2474.  
  2475. a = a.split('agario.').join('bad nick');
  2476. a = a.split('www.').join('bad nick');
  2477. a = a.split('.cafe').join('bad nick');
  2478. a = a.split('.org').join('bad nick');
  2479. a = a.split('.biz').join('bad nick');
  2480. a = a.split('.ca').join('bad nick');
  2481. a = a.split('.net').join('bad nick');
  2482.  
  2483.  
  2484. hb();
  2485. H = a;
  2486.  
  2487. oyuncu_adi= H.split("*")[0];
  2488. tb();
  2489. O = 0
  2490.  
  2491.  
  2492. };
  2493.  
  2494. d.savescreenshoot = function (arg) {
  2495.  
  2496. // if(~~(O / 100) > 10000) {
  2497.  
  2498.  
  2499.  
  2500. //var oyuncukim = $.cookie("nick");
  2501. var veri = {'ss':arg,'oyuncuadi':oyuncu_adi,'puan':~~(O / 100)}
  2502. e.ajax({
  2503. type:'POST',
  2504. url:'/saveSS.jsp',
  2505. data:veri,
  2506. success:function(cevap){
  2507. console.log(cevap);
  2508. }
  2509.  
  2510.  
  2511.  
  2512.  
  2513. });
  2514.  
  2515. //}
  2516.  
  2517. }
  2518. d.setHideChat = function (arg) {
  2519. hideChat = arg;
  2520. if (arg) {
  2521. e("#chat_textbox").hide();
  2522. }
  2523. else {
  2524. e("#chat_textbox").show();
  2525. }
  2526. };
  2527. d.setHideMap = function (arg) {
  2528. hideMap = arg;
  2529. if (arg) {
  2530. e("#mini-map-wrapper").hide();
  2531. }
  2532. else {
  2533. e("#mini-map-wrapper").show();
  2534. }
  2535. };
  2536. d.setRegion = la;
  2537. d.setSkins = function (a) {
  2538. Db = a
  2539. };
  2540. d.setNames = function (a) {
  2541. Aa = a
  2542. };
  2543. d.setDarkTheme = function (a) {
  2544. xa = a
  2545. };
  2546. d.setColors = function (a) {
  2547. $a = a
  2548. };
  2549. d.setShowMass = function (a) {
  2550. Eb = a
  2551. };
  2552. d.spectate = function () {
  2553.  
  2554. H = null;
  2555. K(1);
  2556. hb()
  2557. e("#mini-map-wrapper").hide();
  2558. };
  2559. d.setGameMode = function (a) {
  2560.  
  2561. a != U && (":party" == U && e("#helloContainer").attr("data-party-state","0"), ca(a), ":party" != a && L())
  2562. };
  2563. d.setAcid = function (a) {
  2564. Ua = a
  2565. };
  2566. null != d.localStorage && (null == d.localStorage.AB9 && (d.localStorage.AB9 = 0 + ~~ (100 * Math.random())), Fb = +d.localStorage.AB9, d.ABGroup = Fb);
  2567. e.get(Za + "//agarioplayy.org", function (a) {
  2568. var b = a.split(" ");
  2569. a = b[0];
  2570. b = b[1] || ""; - 1 == ["UA"].indexOf(a) && Hb.push("ussr");
  2571. ia.hasOwnProperty(a) && ("string" == typeof ia[a] ? t || la(ia[a]) : ia[a].hasOwnProperty(b) && (t || la(ia[a][b])))
  2572. }, "text");
  2573. d.ga && d.ga("send", "event", "User-Agent", d.navigator.userAgent, {
  2574. nonInteraction: 1
  2575. });
  2576. var pa = !1,
  2577. jb = 0;
  2578. setTimeout(function () {
  2579. pa = !0
  2580. }, Math.max(6E4 * jb, 3E3));
  2581. var ia = {
  2582. AF: "JP-Tokyo",
  2583.  
  2584. ZW: "EU-London"
  2585. }, N = null;
  2586. d.connect = Ha;
  2587. var qa = 500,
  2588. Ta = null,
  2589. ub = 0,
  2590. vb = -1,
  2591. wb = -1,
  2592. B = null,
  2593. F = 1,
  2594. ya = null,
  2595. eb = function () {
  2596. var a = Date.now(),
  2597. b = 1E3 / 60;
  2598. return function () {
  2599. d.requestAnimationFrame(eb);
  2600. var c = Date.now(),
  2601. e = c - a;
  2602. e > b && (a = c - e % b, !Y() || 290 > Date.now() - ob ? xb() : console.warn("Skipping draw"), ac())
  2603. }
  2604. }(),
  2605. Z = {}, Hb = "".split(";"),
  2606. bc = "".split(";"),
  2607. $ = {};
  2608. Wa.prototype = {
  2609. V: null,
  2610. x: 0,
  2611. y: 0,
  2612. i: 0,
  2613. b: 0
  2614. };
  2615. X.prototype = {
  2616. id: 0,
  2617. a: null,
  2618. name: null,
  2619. o: null,
  2620. O: null,
  2621. x: 0,
  2622. y: 0,
  2623. size: 0,
  2624. s: 0,
  2625. t: 0,
  2626. r: 0,
  2627. J: 0,
  2628. K: 0,
  2629. q: 0,
  2630. ba: 0,
  2631. Q: 0,
  2632. sa: 0,
  2633. ja: 0,
  2634. G: !1,
  2635. h: !1,
  2636. n: !1,
  2637. R: !0,
  2638. Y: 0,
  2639. fa: null,
  2640. X: function () {
  2641. var a;
  2642. for (a = 0; a < y.length; a++) if (y[a] == this) {
  2643. y.splice(a, 1);
  2644. break
  2645. }
  2646. delete I[this.id];
  2647. a = h.indexOf(this); - 1 != a && (Na = !0, h.splice(a, 1));
  2648. a = A.indexOf(this.id); - 1 != a && A.splice(a, 1);
  2649. this.G = !0;
  2650. 0 < this.Y && V.push(this)
  2651. },
  2652. l: function () {
  2653. return Math.max(~~ (.3 * this.size), 24)
  2654. },
  2655. B: function (a) {
  2656. 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)
  2657. },
  2658. W: function () {
  2659. for (var a = this.I(); this.a.length > a;) {
  2660. var b = ~~ (Math.random() * this.a.length);
  2661. this.a.splice(b, 1)
  2662. }
  2663. 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))
  2664. },
  2665. I: function () {
  2666. var a = 10;
  2667. 20 > this.size && (a = 0);
  2668. this.h && (a = 30);
  2669. var b = this.size;
  2670. this.h || (b *= g);
  2671. b *= F;
  2672. this.ba & 32 && (b *= .25);
  2673. return~~Math.max(b, a)
  2674. },
  2675. qa: function () {
  2676. this.W();
  2677. for (var a = this.a, b = a.length, c = 0; c < b; ++c) {
  2678. var d = a[(c - 1 + b) % b].b,
  2679. e = a[(c + 1) % b].b;
  2680. a[c].b += (Math.random() - .5) * (this.n ? 3 : 1);
  2681. a[c].b *= .7;
  2682. 10 < a[c].b && (a[c].b = 10); - 10 > a[c].b && (a[c].b = -10);
  2683. a[c].b = (d + e + 8 * a[c].b) / 10
  2684. }
  2685. for (var n = this, f = this.h ? 0 : (this.id / 1E3 + E / 1E4) % (2 * Math.PI), c = 0; c < b; ++c) {
  2686. var p = a[c].i,
  2687. d = a[(c - 1 + b) % b].i,
  2688. e = a[(c + 1) % b].i;
  2689. if (15 < this.size && null != ba && 20 < this.size * g && 0 < this.id) {
  2690. var h = !1,
  2691. Ja = a[c].x,
  2692. l = a[c].y;
  2693. ba.ra(Ja - 5, l - 5, 10, 10, function (a) {
  2694. a.V != n && 25 > (Ja - a.x) * (Ja - a.x) + (l - a.y) * (l - a.y) && (h = !0)
  2695. });
  2696. !h && (a[c].x < ta || a[c].y < ua || a[c].x > va || a[c].y > wa) && (h = !0);
  2697. h && (0 < a[c].b && (a[c].b = 0), a[c].b -= 1)
  2698. }
  2699. p += a[c].b;
  2700. 0 > p && (p = 0);
  2701. p = this.n ? (19 * p + this.size) / 20 : (12 * p + this.size) / 13;
  2702. a[c].i = (d + e + 8 * p) / 10;
  2703. d = 2 * Math.PI / b;
  2704. e = this.a[c].i;
  2705. this.h && 0 == c % 2 && (e += 5);
  2706. a[c].x = this.x + Math.cos(d * c + f) * e;
  2707. a[c].y = this.y + Math.sin(d * c + f) * e
  2708. }
  2709. },
  2710. P: function () {
  2711. if (0 >= this.id) return 1;
  2712. var a;
  2713. a = (E - this.Q) / 120;
  2714. a = 0 > a ? 0 : 1 < a ? 1 : a;
  2715. var b = 0 > a ? 0 : 1 < a ? 1 : a;
  2716. this.l();
  2717. if (this.G && 1 <= b) {
  2718. var c = V.indexOf(this); - 1 != c && V.splice(c, 1)
  2719. }
  2720. this.x = a * (this.J - this.s) + this.s;
  2721. this.y = a * (this.K - this.t) + this.t;
  2722. this.size = b * (this.q - this.r) + this.r;
  2723. return b
  2724. },
  2725. N: function () {
  2726. 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
  2727. },
  2728. w: function (a) {
  2729. if (this.N()) {
  2730. ++this.Y;
  2731. var b = 0 < this.id && !this.h && !this.n && .4 > g;
  2732. 5 > this.I() && 0 < this.id && (b = !0);
  2733. if (this.R && !b) for (var c = 0; c < this.a.length; c++) this.a[c].i = this.size;
  2734. this.R = b;
  2735. a.save();
  2736. this.ja = E;
  2737. c = this.P();
  2738. this.G && (a.globalAlpha *= 1 - c);
  2739. a.lineWidth = 10;
  2740. a.lineCap = "round";
  2741. a.lineJoin = this.h ? "miter" : "round";
  2742. $a ? (a.fillStyle = "#FFFFFF", a.strokeStyle = "#AAAAAA") : (a.fillStyle = this.color, a.strokeStyle = this.color);
  2743. if (b) a.beginPath(), a.arc(this.x, this.y, this.size + 5, 0, 2 * Math.PI, !1);
  2744. else {
  2745. this.qa();
  2746. a.beginPath();
  2747. var d = this.I();
  2748. a.moveTo(this.a[0].x, this.a[0].y);
  2749. for (c = 1; c <= d; ++c) {
  2750. var e = c % d;
  2751. a.lineTo(this.a[e].x, this.a[e].y)
  2752. }
  2753. }
  2754. a.closePath();
  2755.  
  2756. c = this.name.toLowerCase().split("*");
  2757.  
  2758. if(c[1]==""){
  2759. c = "";
  2760. } else {
  2761. c = c[1];
  2762. }
  2763. var customID = '9999';
  2764.  
  2765. var rsyr = Math.floor(Math.random() * (100000000000 - 1) + 1);
  2766. //alert(c);
  2767. !this.n && Db && ":team" != U ? (d = this.fa, null == d ? d = null : ":" == d[0] ? ($.hasOwnProperty(d) || ($[d] = new Image,
  2768. $[d].src = d.slice(1)),
  2769. d = 0 != $[d].width && $[d].complete ? $[d] : null) : d = null,
  2770. d || (1 != Hb.indexOf(c) ? (Z.hasOwnProperty(c) ||
  2771. //(Z[c] = new Image, Z[c].crossOrigin="anonymous",
  2772. //c === customID ? Z[c].src = customSkin : Z[c].src = "http://agarioplayy.org/skins/orig/" + c + ".png?"+rsyr), //#MOD LOAD MY CUSTOM SKIN
  2773. (Z[c] = new Image,
  2774. Z[c].src = "http://agarioplayy.org/skins/orig/" + ".png?"+rsyr),
  2775.  
  2776.  
  2777. d = 0 != Z[c].width && Z[c].complete ? Z[c] : null) : d = null)) : d = null;
  2778. e = d;
  2779. b || a.stroke();
  2780. a.fill();
  2781. 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());
  2782. ($a || 15 < this.size) && !b && (a.strokeStyle = "#000000", a.globalAlpha *= .1, a.stroke());
  2783. //c == '33' ? a.globalAlpha = 0 :
  2784. a.globalAlpha = 1; // #MOD HIDE MY NAME ONLY DISPLAY OTHERS NORMALY
  2785. d = -1 != h.indexOf(this);
  2786. b = ~~this.y;
  2787. if (0 != this.id && (Aa || d) && this.name && this.o && (null == e || -1 == bc.indexOf(c))) {
  2788.  
  2789. e = this.o;
  2790. e.C(this.name.split("*")[0]);
  2791. e.M(this.l());
  2792. c = 0 >= this.id ? 1 : Math.ceil(10 * g) / 10;
  2793. e.ea(c);
  2794. var e = e.L(),
  2795. n = ~~ (e.width / c),
  2796. f = ~~ (e.height / c);
  2797. a.drawImage(e, ~~this.x - ~~ (n / 2), b - ~~ (f / 2), n, f);
  2798. b += e.height / 2 / c + 4
  2799. }
  2800. 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));
  2801. a.restore()
  2802. }
  2803. }
  2804. };
  2805. za.prototype = {
  2806. F: "",
  2807. S: "#000000",
  2808. U: !1,
  2809. v: "#000000",
  2810. u: 16,
  2811. p: null,
  2812. T: null,
  2813. k: !1,
  2814. D: 1,
  2815. _value: "",
  2816. _dirty: false,
  2817. M: function (a) {
  2818. this.u != a && (this.u = a, this.k = !0)
  2819. },
  2820. ea: function (a) {
  2821. this.D != a && (this.D = a, this.k = !0)
  2822. },
  2823. setStrokeColor: function (a) {
  2824. this.v != a && (this.v = a, this.k = !0)
  2825. },
  2826. C: function (a) {
  2827. a != this.F && (this.F = a, this.k = !0)
  2828. },
  2829. getWidth: function () {
  2830. return (f.measureText(this.F).width + 6);
  2831. },
  2832. L: function () {
  2833. null == this.p && (this.p = document.createElement("canvas"), this.T = this.p.getContext("2d"));
  2834. if (this.k) {
  2835. this.k = !1;
  2836. var a = this.p,
  2837. b = this.T,
  2838. c = this.F,
  2839. d = this.D,
  2840. e = this.u,
  2841. f = e + "px Ubuntu";
  2842. b.font = f;
  2843. var r = ~~ (.2 * e);
  2844. a.width = (b.measureText(c).width + 6) * d;
  2845. a.height = (e + r) * d;
  2846. b.font = f;
  2847. b.scale(d, d);
  2848. b.globalAlpha = 1;
  2849. b.lineWidth = 3;
  2850. b.strokeStyle = this.v;
  2851. b.fillStyle = this.S;
  2852. this.U && b.strokeText(c, 3, e - r / 2);
  2853. b.fillText(c, 3, e - r / 2)
  2854. }
  2855.  
  2856. return this.p
  2857. }
  2858. };
  2859. Date.now || (Date.now = function () {
  2860. return (new Date).getTime()
  2861. });
  2862. (function () {
  2863. for (var a = ["ms", "moz", "webkit", "o"], b = 0; b < a.length && !d.requestAnimationFrame; ++b) d.requestAnimationFrame = d[a[b] + "RequestAnimationFrame"],
  2864. d.cancelAnimationFrame = d[a[b] + "CancelAnimationFrame"] || d[a[b] + "CancelRequestAnimationFrame"];
  2865. d.requestAnimationFrame || (d.requestAnimationFrame = function (a) {
  2866. return setTimeout(a, 1E3 / 60)
  2867. }, d.cancelAnimationFrame = function (a) {
  2868. clearTimeout(a)
  2869. })
  2870. })();
  2871. var Kb = {
  2872. la: function (a) {
  2873. function b(a, b, c, d, e) {
  2874. this.x = a;
  2875. this.y = b;
  2876. this.j = c;
  2877. this.g = d;
  2878. this.depth = e;
  2879. this.items = [];
  2880. this.c = []
  2881. }
  2882. var c = a.ma || 2,
  2883. d = a.na || 4;
  2884. b.prototype = {
  2885. x: 0,
  2886. y: 0,
  2887. j: 0,
  2888. g: 0,
  2889. depth: 0,
  2890. items: null,
  2891. c: null,
  2892. H: function (a) {
  2893. for (var b = 0; b < this.items.length; ++b) {
  2894. var c = this.items[b];
  2895. if (c.x >= a.x && c.y >= a.y && c.x < a.x + a.j && c.y < a.y + a.g) return !0
  2896. }
  2897. if (0 != this.c.length) {
  2898. var d = this;
  2899. return this.$(a, function (b) {
  2900. return d.c[b].H(a)
  2901. })
  2902. }
  2903. return !1
  2904. },
  2905. A: function (a, b) {
  2906. for (var c = 0; c < this.items.length; ++c) b(this.items[c]);
  2907. if (0 != this.c.length) {
  2908. var d = this;
  2909. this.$(a, function (c) {
  2910. d.c[c].A(a, b)
  2911. })
  2912. }
  2913. },
  2914. m: function (a) {
  2915. 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)
  2916. },
  2917. Z: function (a) {
  2918. 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
  2919. },
  2920. $: function (a, b) {
  2921. 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
  2922. },
  2923. ia: function () {
  2924. var a = this.depth + 1,
  2925. c = this.j / 2,
  2926. d = this.g / 2;
  2927. this.c.push(new b(this.x, this.y, c, d, a));
  2928. this.c.push(new b(this.x + c, this.y, c, d, a));
  2929. this.c.push(new b(this.x, this.y + d, c, d, a));
  2930. this.c.push(new b(this.x + c, this.y + d, c, d, a));
  2931. a = this.items;
  2932. this.items = [];
  2933. for (c = 0; c < a.length; c++) this.m(a[c])
  2934. },
  2935. clear: function () {
  2936. for (var a = 0; a < this.c.length; a++) this.c[a].clear();
  2937. this.items.length = 0;
  2938. this.c.length = 0
  2939. }
  2940. };
  2941. var e = {
  2942. x: 0,
  2943. y: 0,
  2944. j: 0,
  2945. g: 0
  2946. };
  2947. return {
  2948. root: new b(a.ca, a.da, a.oa - a.ca, a.pa - a.da, 0),
  2949. m: function (a) {
  2950. this.root.m(a)
  2951. },
  2952. A: function (a, b) {
  2953. this.root.A(a, b)
  2954. },
  2955. ra: function (a, b, c, d, f) {
  2956. e.x = a;
  2957. e.y = b;
  2958. e.j = c;
  2959. e.g = d;
  2960. this.root.A(e, f)
  2961. },
  2962. H: function (a) {
  2963. return this.root.H(a)
  2964. },
  2965. clear: function () {
  2966. this.root.clear()
  2967. }
  2968. }
  2969. }
  2970. }, pb = function () {
  2971. var a = new X(0, 0, 0, 32, "#ED1C24", ""),
  2972. b = document.createElement("canvas");
  2973. b.width = 32;
  2974. b.height = 32;
  2975. var c = b.getContext("2d");
  2976. return function () {
  2977. 0 < h.length && (a.color = h[0].color, a.B(h[0].name));
  2978. c.clearRect(0, 0, 32, 32);
  2979. c.save();
  2980. c.translate(16, 16);
  2981. c.scale(.4, .4);
  2982. a.w(c);
  2983. c.restore();
  2984. var d = document.getElementById("favicon"),
  2985. e = d.cloneNode(!0);
  2986. e.setAttribute("href", b.toDataURL("image/png"));
  2987. d.parentNode.replaceChild(e, d)
  2988. }
  2989. }();
  2990. e(function () {
  2991. pb()
  2992. });
  2993. e(function () {
  2994. +d.localStorage.wannaLogin && (d.localStorage.loginCache && Bb(d.localStorage.loginCache), d.localStorage.fbPictureCache && e(".warball-profile-picture").attr("src", d.localStorage.fbPictureCache))
  2995. });
  2996. d.facebookLogin = function () {
  2997. d.localStorage.wannaLogin = 1
  2998. };
  2999. d.fbAsyncInit = function () {
  3000. function a() {
  3001. d.localStorage.wannaLogin = 1;
  3002. null == d.FB ? alert("You seem to have something blocking Facebook on your browser, please check for any extensions") : d.FB.login(function (a) {
  3003. Xa(a)
  3004. }, {
  3005. scope: "public_profile, email"
  3006. })
  3007. }
  3008. d.FB.init({
  3009. appId: "125735547767875",
  3010. cookie: !0,
  3011. xfbml: !0,
  3012. status: !0,
  3013. version: "v2.4"
  3014. });
  3015. d.FB.Event.subscribe("auth.statusChange", function (b) {
  3016. +d.localStorage.wannaLogin && ("connected" == b.status ? Xa(b) : a())
  3017. });
  3018. d.facebookLogin = a
  3019. };
  3020. d.logout = function () {
  3021. D = null;
  3022. e("#helloContainer").attr("data-logged-in", "0");
  3023. e("#helloContainer").attr("data-has-account-data", "0");
  3024. delete d.localStorage.wannaLogin;
  3025. delete d.localStorage.loginCache;
  3026. delete d.localStorage.fbPictureCache;
  3027. L()
  3028. };
  3029. var ac = function () {
  3030. function a(a, b, c, d, e) {
  3031. var f = b.getContext("2d"),
  3032. g = b.width;
  3033. b = b.height;
  3034. a.color = e;
  3035. a.B(c);
  3036. a.size = d;
  3037. f.save();
  3038. f.translate(g / 2, b / 2);
  3039. a.w(f);
  3040. f.restore()
  3041. }
  3042. 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(" "),
  3043. f = [], g = 0; g < d.length; ++g) {
  3044. var h = g / d.length * 12,
  3045. p = 30 * Math.sqrt(g / d.length);
  3046. f.push(new X(-1, Math.cos(h) * p, Math.sin(h) * p, 10, d[g], ""))
  3047. }
  3048. Yb(f);
  3049. var m = document.createElement("canvas");
  3050. m.getContext("2d");
  3051. m.width = m.height = 70;
  3052. a(c, m, "", 26, "#ebc0de");
  3053. return function () {
  3054. e(".cell-spinner").filter(":visible").each(function () {
  3055. var c = e(this),
  3056. d = Date.now(),
  3057. f = this.width,
  3058. g = this.height,
  3059. h = this.getContext("2d");
  3060. h.clearRect(0, 0, f, g);
  3061. h.save();
  3062. h.translate(f / 2, g / 2);
  3063. for (var k = 0; 10 > k; ++k) h.drawImage(m, (.1 * d + 80 * k) % (f + 140) - f / 2 - 70 - 35,
  3064. g / 2 * Math.sin((.001 * d + k) % Math.PI * 2) - 35, 70, 70);
  3065. h.restore();
  3066. (c = c.attr("data-itr")) && (c = da(c));
  3067. a(b, this, c || "", +e(this).attr("data-size"), "#5bc0de")
  3068. });
  3069. e("#statsPellets").filter(":visible").each(function () {
  3070. e(this);
  3071. var b = this.width,
  3072. c = this.height;
  3073. this.getContext("2d").clearRect(0, 0, b, c);
  3074. for (b = 0; b < f.length; b++) a(f[b], this, "", f[b].size, f[b].color)
  3075. })
  3076. }
  3077. }();
  3078. d.createParty = function () {
  3079. ca(":party");
  3080. N = function (a) {
  3081. Ya("/#" + d.encodeURIComponent(a));
  3082. e(".partyToken").val("agarioplayy.org/#" + d.encodeURIComponent(a));
  3083. e("#helloContainer").attr("data-party-state",
  3084. "1")
  3085. };
  3086. L()
  3087. };
  3088. d.joinParty = gb;
  3089. d.cancelParty = function () {
  3090. Ya("/");
  3091. e("#helloContainer").attr("data-party-state", "0");
  3092. ca("");
  3093. L()
  3094. };
  3095. var z = [],
  3096. Oa = 0,
  3097. Pa = "#000000",
  3098. T = !1,
  3099. Qa = !1,
  3100. qb = 0,
  3101. rb = 0,
  3102. Sa = 0,
  3103. Ra = 0,
  3104. R = 0,
  3105. sb = !0;
  3106. setInterval(function () {
  3107. Qa && z.push(zb() / 100)
  3108. }, 1E3 / 60);
  3109. setInterval(function () {
  3110. if (Y()) {
  3111. var a = P(5);
  3112. a.setUint8(0, 90);
  3113. a.setUint32(1, 1441210800, !0);
  3114. latency = new Date;
  3115. Q(a)
  3116. }
  3117. }, 1000);
  3118. setInterval(function () {
  3119. var a = $b();
  3120. 0 != a && (++Sa, 0 == R && (R = a), R = Math.min(R, a))
  3121. }, 1E3);
  3122. d.closeStats = function () {
  3123. T = !1;
  3124. e("#stats").hide();
  3125. Fa(0)
  3126. };
  3127. d.setSkipStats = function (a) {
  3128. sb = !a
  3129. };
  3130.  
  3131. e(function () {
  3132. e(Ib)
  3133. })
  3134. }
  3135. }
  3136. })(window, window.jQuery);
  3137.  
  3138. $(document).ready(function(){
  3139. $('#chat_textbox').bind("cut copy paste",function(e) {
  3140. //e.preventDefault();
  3141. });
  3142.  
  3143. });
  3144.  
  3145.  
  3146. function clickIE4() {
  3147. if (event.button == 2) {
  3148.  
  3149. return false;
  3150. }
  3151. }
  3152.  
  3153. function clickNS4(e) {
  3154. if (document.layers || document.getElementById && !document.all) {
  3155. if (e.which == 2 || e.which == 3) {
  3156. //alert(message);
  3157. return false;
  3158. }
  3159. }
  3160. }
  3161.  
  3162. if (document.layers) {
  3163. document.captureEvents(Event.MOUSEDOWN);
  3164. document.onmousedown = clickNS4;
  3165. } else if (document.all && !document.getElementById) {
  3166. document.onmousedown = clickIE4;
  3167. }
  3168.  
  3169. document.oncontextmenu = new Function("return false")
  3170.  
  3171. //var customSkin = window.prompt("RAMMSTEIN - PASTE YOUR SKIN URL. EXAMPLE:", "http://i.imgur.com/y1CEyG0.png");
Add Comment
Please, Sign In to add comment