proborREf

Untitled

Aug 16th, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 253.48 KB | None | 0 0
  1. "use strict";
  2. console.log("agarplus_v2c0 ver.A414");
  3.  
  4. var GamePresetConfig = {
  5. UseExChatApp: false,
  6. EnableTeamRankingChart: false
  7. };
  8.  
  9. function trace(s) {
  10. console.log(s);
  11. }
  12.  
  13.  
  14. function GetQueryObject(key) {
  15. //if(location.href.indexOf('?') == -1) return {};
  16. //var queryStrs = location.href.split('?')[1];
  17. var queryStrs = location.search.replace('?', '');
  18. var queries = queryStrs.split('&');
  19. var obj = {};
  20. queries.forEach(q => {
  21. var qq = q.split('=');
  22. if(qq.length == 2) {
  23. var key = qq[0];
  24. var val = qq[1];
  25. obj[key] = val;
  26. }
  27. });
  28. return obj;
  29. }
  30.  
  31. //var gConnectionProc = null;
  32.  
  33. const CommunicationVersionKey2 = 'onxcnk_101';
  34. //console.log(`versionKey: ${CommunicationVersionKey2}`);
  35.  
  36.  
  37. function initialize_game_client() {
  38. 'use strict';
  39.  
  40. const CommonTeamName = '';
  41. const AddTeamTagPrefixForPlayerName = true;
  42.  
  43. const gUseChatApp = GamePresetConfig.UseExChatApp;
  44.  
  45. var chatAppModel = gUseChatApp ? window.chatAppModel : null;
  46.  
  47. var gconfig = {
  48. //client config
  49. commonTeamName: '',
  50. leaderboardCaption: 'leaderboard',
  51. teamRankingCaption: 'team ranks',
  52. enableTeamChatSeparation: false,
  53. enableTeamMapSeparation: false,
  54. enableTeamSkinSeparation: false,
  55. enableAllMapShownWhileSpectating: false,
  56. enableAllSkinShownWhileSpectating: false,
  57. showBotsAllwaysInMap: false,
  58. nameForUnnamedCell: 'an unnamed cell',
  59. enableTeamRankingBoard: false,
  60. showPlayerMassInLeaderBoard: false,
  61. //UseExtenedTeamSeparation : false
  62. allowChangesPlayerInfoWhilePlaying: false,
  63. //addTeamTagPrefixForPlayerName : true,
  64. //useTeamInputBox : true,
  65. teamInputUiType: 'none', //none/text/duel/combo
  66. duelTeamEntries: 'A,B',
  67. comboTeamEntries: 'A,B,C,D',
  68. showPlayerMassInMap: true,
  69. enablePartyCode: false,
  70. useCommonMapColorWhilePlaying: false,
  71. isolateBlankTagPlayers: false,
  72. addUserTokenToChatSenderName: false,
  73. addUserTokenToPlayerCellName : false,
  74. enableDualUnitOperation: false,
  75. enableDualSkinInput: false,
  76. showServerDebugStatusTexts: false,
  77. useExtendedChatSystem: false
  78. };
  79.  
  80. var gconfig_ex = {
  81. ForceChatIconShow: GamePresetConfig.UseExChatApp,
  82. UseFallbackGameChat: true,
  83. UseNoSkinFallbackSkin: true,
  84. NoSkinFallBackSkinUrl: 'http://ixagar.net/skins/noskin5.png'
  85. };
  86.  
  87. var gConfigChangedHandlerProc = null;
  88.  
  89. var gDuelTeamInputIndex = 0;
  90. var gComboTeamInputIndex = 0;
  91.  
  92. var gGameServerAddress = null;
  93.  
  94. var gActiveTurnPlayerId = 0;
  95.  
  96.  
  97. var gtexts_common = {
  98. msg1: 'Need backup!',
  99. msg2: 'Need a teammate!',
  100. msg3: 'Pop him!',
  101. msg4: 'We need to run!',
  102. msg5: 'Tricksplit!',
  103. msg6: 'Lets bait! ',
  104. msg7: 'Split into me!',
  105. msg8: 'Feed me!',
  106. msg9: 'Tank the virus!',
  107. msg10: 'Roger that!'
  108. };
  109.  
  110.  
  111. var texts_en = {
  112. tabHome: 'Home',
  113. tabSettings: 'Settings',
  114. tabTemes: 'Themes',
  115. tabKeybinds: 'Keys',
  116. tabExtended: 'Ex',
  117.  
  118. btPlay: 'Play',
  119. btSpectate: 'Spectate',
  120.  
  121. stFastZoom: 'Fast Zoom',
  122. stHideMyName: 'Hide My Name',
  123. stHideNames: 'Hide Names',
  124. stHideBlobColors: 'Hide Cell Colors',
  125. stShowMass: 'Show Mass',
  126. stSkipStats: 'Skip Stats',
  127. stGridLocations: 'Grid Locations',
  128. stCursorLine: 'Cursor Line',
  129. stZoom: 'Zoom',
  130. stHidePellets: 'Hide Pellets',
  131. stGridLines: 'Gridlines',
  132. stSimpleDrawing: 'Simple Drawing',
  133. stScore: 'Score',
  134. stSte: 'STE',
  135. stBallTotal: '[n/16]',
  136. stMinimap: 'Minimap',
  137. stRainbowColor: 'Rainbow Color',
  138. stTransparentBlobs: 'Transparent Cells',
  139. stFps: 'FPS',
  140. stPacktIo: 'Packet I/O',
  141. stAutoHideMass: 'Auto Hide Mass',
  142. stAutoHideNames: 'Auto Hide Names',
  143. stTextShadows: 'Text Shadows',
  144. stAutoZoom: 'Auto Zoom',
  145. stSplitIndicators: 'Split Indicators',
  146. stCustomSkins: 'Custom Skins',
  147. stYinSkins: 'Yin Skins',
  148. stChatBox: 'Chatbox',
  149. stChatPopup: 'Chat Popup',
  150. stEnableMouseControl: 'Enable Mouse Control',
  151. stInvertMouseButtons: 'Invert Mouse Buttons',
  152. stChatBoxLocation: 'Chat Box Location',
  153. stSplitOrderMarker: 'Split Order Marker',
  154. stAimCrosshair: 'Aim Crosshair',
  155. stActiveTurnMarker: 'Active Turn Marker',
  156. stEmphasisCursorLine: 'Emphassis Cursor Line',
  157.  
  158. tmBackground: 'Background',
  159. tmBorder: 'Border',
  160. tmPellet: 'Pellet',
  161.  
  162. hkHotkeySetup: 'Hotkey Setup',
  163. hkInst0: 'Step 1: Click on the function item',
  164. hkInst1: 'Step 2: Press wanted hotkey to modify',
  165. hkInst2: 'Press [DEL] key to remove selected hotkey',
  166. hkInst3: 'Allowed hotkey combinations: [CTRL] + [ALT] + 0-9, a-z, [TAB], [ENTER]',
  167.  
  168. hkHotkey: 'Hotkey',
  169. hkFunction: 'Function',
  170. hkMessage: 'Message',
  171. hkResetToDefault: 'Reset To Default',
  172. hkCancel: 'Cancel',
  173. hkSave: 'Save',
  174.  
  175. hkStartNewGame: 'Start New Game',
  176. hkMacroW: 'Macro W',
  177. hkQuickSpace: 'Quick Space',
  178. hkDoubleSpace: 'Double Space',
  179. hkStopMovementToggle: 'Stop Movement(Toggle)',
  180. hkStopMovementTemporary: 'Stop Movement(Temporary)',
  181. hkOnOffSplitIndicator: 'On/Off Split Indicator',
  182. hkOnOffAutoZoom: 'On/Off Auto Zoom',
  183. hkShowAttackRangeTemporary: 'Show Attack Range(Temporary)',
  184. hkShowAttackRangeToggle: 'Show Attack Range(Toggle)',
  185. hkSpectateTeammate: 'Spectate Teammate',
  186. hkOnOffCustomSkin: 'On/Off Custom Skin',
  187. hkShowHideSkins: 'Show/Hide Skins',
  188. hkOnOffRainbowColor: 'On/Off Rainbow Color',
  189. hkOnOffTransparentCell: 'On/Off Transparent Cell',
  190. hkShowHideFpsCounter: 'Show/Hide FPS Counter',
  191. hkZoomLevel1: 'Zoom Level 1',
  192. hkZoomLevel2: 'Zoom Level 2',
  193. hkZoomLevel3: 'Zoom Level 3',
  194. hkZoomLevel4: 'Zoom Level 4',
  195. hkZoomLevel5: 'Zoom Level 5',
  196. hkShowHideNames: 'Show/Hide Names',
  197. hkShowHideOwnName: 'Show/Hide Own Names',
  198. hkShowHideColors: 'Show/Hide Colors',
  199. hkShowHideMass: 'Show/Hide Mass',
  200. hkOnOffSkipStats: 'On/Off Skip Stats',
  201. hkOnOffZoom: 'On/Off Zoom',
  202. hkShowHidePellets: 'Show/Hide Pellets',
  203. hkShowHideGridline: 'Show/Hide Gridline',
  204. hkResetBorder: 'Reset Border',
  205. hkOnOffSimpleDraw: 'On/Off Simple Draw',
  206. hkShowHideScore: 'Show/Hide Score',
  207. hkShowHideSte: 'Show/Hide STE',
  208. hkShowHideN16: 'Show/Hide [n/16]',
  209. hkOnOffAutoHideMass: 'On/Off Auto Hide Mass',
  210. hkOnOffAutoHideName: 'On/Off Auto Hide Name',
  211. hkShowHideTextShadow: 'Show/Hide Text Shadow',
  212. hkShowHideMinimap: 'Show/Hide Minimap',
  213. hkChatboxSendMessage: 'Chatbox Send Message',
  214. hkChatboxSendMessage1: 'Chatbox Send Message 1',
  215. hkChatboxSendMessage2: 'Chatbox Send Message 2',
  216. hkChatboxSendMessage3: 'Chatbox Send Message 3',
  217. hkChatboxSendMessage4: 'Chatbox Send Message 4',
  218. hkChatboxSendMessage5: 'Chatbox Send Message 5',
  219. hkChatboxSendMessage6: 'Chatbox Send Message 6',
  220. hkChatboxSendMessage7: 'Chatbox Send Message 7',
  221. hkChatboxSendMessage8: 'Chatbox Send Message 8',
  222. hkChatboxSendMessage9: 'Chatbox Send Message 9',
  223. hkChatboxSendMessage10: 'Chatbox Send Message 10',
  224.  
  225. lnkServerFullList: 'Full List',
  226. lnkServerProgram: 'Server Program',
  227. lnkUserForum: 'User Forum'
  228. };
  229.  
  230. var texts_jp = {
  231. tabHome: 'ホーム',
  232. tabSettings: '設定',
  233. tabTemes: 'テーマ',
  234. tabKeybinds: 'キー',
  235. tabExtended: 'æ‹¡å¼µ',
  236.  
  237. btPlay: 'Play',
  238. btSpectate: '観戦',
  239.  
  240. stFastZoom: '高速ズーム',
  241. stHideMyName: 'è‡ªåˆ†ã®åå‰ã‚’éš ã™',
  242. stHideNames: 'åå‰ã‚’éš ã™',
  243. stHideBlobColors: 'ã‚»ãƒ«ã®è‰²ã‚’éš ã™',
  244. stShowMass: '質量を表示',
  245. stSkipStats: 'Skip stats',
  246. stGridLocations: 'エリア座標を表示',
  247. stCursorLine: 'カーソルラインを表示',
  248. stZoom: 'ズーム',
  249. stHidePellets: 'ãƒšãƒ¬ãƒƒãƒˆã‚’éš ã™',
  250. stGridLines: 'グリッドライン',
  251. stSimpleDrawing: '簡易描画',
  252. stScore: 'スコア',
  253. stSte: 'STE',
  254. stBallTotal: '[n/16]',
  255. stMinimap: 'ミニマップ',
  256. stRainbowColor: '虹色表示',
  257. stTransparentBlobs: 'セルを透過',
  258. stFps: 'フレームレート',
  259. stPacktIo: 'Packet I/O',
  260. stAutoHideMass: 'è³ªé‡ã‚’è‡ªå‹•ã§éš ã™',
  261. stAutoHideNames: 'åå‰ã‚’è‡ªå‹•ã§éš ã™',
  262. stTextShadows: 'テキストの影を表示',
  263. stAutoZoom: '自動ズーム',
  264. stSplitIndicators: 'スプリットインジケータ',
  265. stCustomSkins: 'カスタムスキン',
  266. stYinSkins: 'Yin Skins',
  267. stChatBox: 'チャットボックス',
  268. stChatPopup: 'チャットポップアップ',
  269. stEnableMouseControl: 'マウスボタンによる操作',
  270. stInvertMouseButtons: '左右ボタンの機能を入れ替える',
  271. stChatBoxLocation: 'チャットを下に表示',
  272. stSplitOrderMarker: '分裂セルマーカー',
  273. stAimCrosshair: 'AIMクロスヘア',
  274. stActiveTurnMarker: 'アクティブターンマーカー',
  275. stEmphasisCursorLine: 'カーソルラインを強調',
  276.  
  277. tmBackground: '背景色',
  278. tmBorder: 'æž è‰²',
  279. tmPellet: 'ペレットの色',
  280.  
  281.  
  282. hkHotkeySetup: 'Hotkey Setup',
  283. hkInst0: 'ステップ1: クリックで機能を選択します。',
  284. hkInst1: 'ステップ2: 割り当てたいキーを押します。',
  285. hkInst2: 'DELキーで選択されたキーの割り当てを解除します。',
  286. hkInst3: '使用可能なキーの組み合わせ: [CTRL] + [ALT] + 0-9, a-z, [TAB], [ENTER]',
  287.  
  288. hkHotkey: 'ホットキー',
  289. hkFunction: '機能',
  290. hkMessage: 'メッセージ',
  291. hkResetToDefault: '初期状態に戻す',
  292. hkCancel: 'キャンセル',
  293. hkSave: '保存',
  294.  
  295. hkStartNewGame: 'ゲーム開始',
  296. hkMacroW: 'マクロW',
  297. hkQuickSpace: 'クイック分裂',
  298. hkDoubleSpace: 'ダブル分裂',
  299. hkStopMovementToggle: '移動停止 (トグル)',
  300. hkStopMovementTemporary: '押している間移動停止',
  301. hkOnOffSplitIndicator: 'スプリットインジケータをon/off',
  302. hkOnOffAutoZoom: '自動ズームをon/off',
  303. hkShowAttackRangeTemporary: '押している間アタックレンジを表示',
  304. hkShowAttackRangeToggle: 'アタックレンジを表示(トグル)',
  305. hkSpectateTeammate: 'チームメイトをSpectate',
  306. hkOnOffCustomSkin: 'カスタムスキンをon/off',
  307. hkShowHideSkins: 'スキンを表示/éš ã™',
  308. hkOnOffRainbowColor: '虹色表示をon/off',
  309. hkOnOffTransparentCell: 'セルの透過をon/off',
  310. hkShowHideFpsCounter: 'FPSカウンタを表示/éš ã™',
  311. hkZoomLevel1: 'ズームレベル1',
  312. hkZoomLevel2: 'ズームレベル2',
  313. hkZoomLevel3: 'ズームレベル3',
  314. hkZoomLevel4: 'ズームレベル4',
  315. hkZoomLevel5: 'ズームレベル5',
  316. hkShowHideNames: '名前を表示/éš ã™',
  317. hkShowHideOwnName: '自分の名前を表示/éš ã™',
  318. hkShowHideColors: '色をon/off',
  319. hkShowHideMass: '質量を表示/éš ã™',
  320. hkOnOffSkipStats: 'Skip statsを表示/éš ã™',
  321. hkOnOffZoom: 'ズームをon/off',
  322. hkShowHidePellets: 'ペレットを表示/éš ã™',
  323. hkShowHideGridline: 'グリッドラインを表示/éš ã™',
  324. hkResetBorder: 'æž ã‚’ãƒªã‚»ãƒƒãƒˆ',
  325. hkOnOffSimpleDraw: '簡易描画をon/off',
  326. hkShowHideScore: 'スコアを表示/éš ã™',
  327. hkShowHideSte: 'STEを表示/éš ã™',
  328. hkShowHideN16: '[n/16]を表示/éš ã™',
  329. hkOnOffAutoHideMass: 'è³ªé‡ã‚’è‡ªå‹•ã§éš ã™æ©Ÿèƒ½ã‚’on/off',
  330. hkOnOffAutoHideName: 'åå‰ã‚’è‡ªå‹•ã§éš ã™æ©Ÿèƒ½ã‚’on/off',
  331. hkShowHideTextShadow: 'テキストの影を表示/éš ã™',
  332. hkShowHideMinimap: 'マップを表示/éš ã™',
  333. hkChatboxSendMessage: 'チャットを入力',
  334. hkChatboxSendMessage1: 'チャットメッセージ1',
  335. hkChatboxSendMessage2: 'チャットメッセージ2',
  336. hkChatboxSendMessage3: 'チャットメッセージ3',
  337. hkChatboxSendMessage4: 'チャットメッセージ4',
  338. hkChatboxSendMessage5: 'チャットメッセージ5',
  339. hkChatboxSendMessage6: 'チャットメッセージ6',
  340. hkChatboxSendMessage7: 'チャットメッセージ7',
  341. hkChatboxSendMessage8: 'チャットメッセージ8',
  342. hkChatboxSendMessage9: 'チャットメッセージ9',
  343. hkChatboxSendMessage10: 'チャットメッセージ10',
  344.  
  345. lnkServerFullList: '全サーバリスト',
  346. lnkServerProgram: 'サーバプログラム',
  347. lnkUserForum: 'ユーザフォーラム'
  348. };
  349.  
  350.  
  351. var gtexts = texts_en;
  352.  
  353. var glang = localStorage.getItem('language');
  354. if(glang == 'jp') {
  355. gtexts = texts_jp;
  356. }
  357.  
  358. function sform() {
  359. var args = Array.prototype.slice.call(arguments);
  360. var str = args[0];
  361. //console.log(str);
  362. for(var i = 1; i < args.length; i++) {
  363. str = str.replace('%o', args[i]);
  364. }
  365. return str;
  366. }
  367.  
  368. class utils {
  369. //引数が1文字以上の文字列かどうか判定
  370. static CheckValidString(s) {
  371. return (typeof (s) == 'string' || s instanceof String) && s != '';
  372. }
  373.  
  374. static confirm(b) {
  375. if(!b) { debugger; }
  376. }
  377.  
  378. static ByteArrayToDataView(ar) {
  379. var arbuf = new Uint8Array(ar.length);
  380. for(var i = 0; i < ar.length; i++) {
  381. arbuf[i] = ar;
  382. }
  383. return new DataView(arbuf);
  384. }
  385.  
  386. static ByteArrayFromDataView(view) {
  387. var ar = [];
  388. var pos = 0;
  389. while(pos < view.byteLength) {
  390. ar[pos] = view.getUint8(pos);
  391. pos++;
  392. }
  393. return ar;
  394. }
  395.  
  396. // static ArrayBufferToArray(arbuf){
  397. // var ar = [];
  398. // for(var i = 0; i < arbuf.length; i++){
  399. // ar[i] = arbuf[i];
  400. // }
  401. // return ar;
  402. // }
  403.  
  404. static vmap(val, s0, s1, d0, d1) {
  405. return (val - s0) * (d1 - d0) / (s1 - s0) + d0;
  406. }
  407.  
  408. static clamp(val, a, b) {
  409. return Math.min(a, (Math.max(val, b)));
  410. }
  411.  
  412. static scale(val, s, d) {
  413. return val * d / s;
  414. }
  415.  
  416. static makeColor(code) {
  417. //0xARGB
  418. var a = (code >> 12 & 0x0F) * 1.0 / 15;
  419. if(a == 0.0) a = 1.0;
  420. var r = parseInt((code >> 8 & 0x0F) * 255 / 15);
  421. var g = parseInt((code >> 4 & 0x0F) * 255 / 15);
  422. var b = parseInt((code >> 0 & 0x0F) * 255 / 15);
  423. return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
  424. }
  425. }
  426.  
  427. class nums {
  428. static lerp(a, b, m) {
  429. return (1.0 - m) * a + m * b;
  430. //return a + m * (b - a);
  431. }
  432.  
  433. static easyFilter(y, x, m) {
  434. return y * m + (1.0 - m) * x;
  435. }
  436. }
  437.  
  438.  
  439. if(window.webkitRequestFileSystem) {
  440. window.webkitRequestFileSystem(window.TEMPORARY, 1, () => { }, () => {
  441. window.connect('');
  442. });
  443. }
  444.  
  445. function initializeUserId() {
  446. function generateUuid() {
  447. var uuid = "", i, random;
  448. for(i = 0; i < 32; i++) {
  449. random = Math.random() * 16 | 0;
  450.  
  451. if(i == 8 || i == 12 || i == 16 || i == 20) {
  452. uuid += "-"
  453. }
  454. uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16);
  455. }
  456. return uuid;
  457. }
  458.  
  459. function generateShortUserId() {
  460. var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  461. var id = "%";
  462. for(var i = 0; i < 4; i++) {
  463. var idx = parseInt(Math.random() * (chars.length - 1));
  464. id += chars[idx];
  465. }
  466. return id;
  467. }
  468. var uid = localStorage.getItem('LongTermUserId');
  469. if(!(uid && uid.length == 5)) {
  470. uid = generateShortUserId();
  471. localStorage.setItem('LongTermUserId', uid);
  472. console.log("uid: " + uid);
  473. }
  474. return uid;
  475. }
  476.  
  477. var gUserId = initializeUserId();
  478.  
  479.  
  480. //サーバーの地域の設定をクリア
  481. //本家のサーバーに接続しようとしてプライベートサーバーから飛ばされるのを抑止
  482. localStorage.removeItem("location");
  483.  
  484. // if(localStorage.getItem('partycode') == 'undefined'){
  485. // localStorage.setItem('partycode', '');
  486. // }
  487.  
  488. //HTML調整?, 400
  489. //function AdjustHtml(){
  490. {
  491. //var _jquery = $;
  492. function vb(vc, vb) {
  493. var vd = $('<div class="minicolors" />'),
  494. ve = $.minicolors['defaults'];
  495. vc.attr('data-opacity');
  496. var vf;
  497. vc.data('minicolors-initialized') || (vb = $.extend(1, {}, ve, vb), vd.addClass('minicolors-theme-' + vb.theme)['toggleClass']('minicolors-with-opacity', vb.opacity)['toggleClass']('minicolors-no-data-uris', 1 !== vb.dataUris), void (0) !== vb.position && $.each(vb.position['split'](' '), function() {
  498. vd.addClass('minicolors-position-' + this)
  499. }), vf = 'rgb' === vb.format ? vb.opacity ? '25' : '20' : vb.keywords ? '11' : '7', vc.addClass('minicolors-input')['data']('minicolors-initialized', 0)['data']('minicolors-settings', vb)['prop']('size', vf)['wrap'](vd)['after']('<div class="minicolors-panel minicolors-slider-' + vb.control + '"><div class="minicolors-slider minicolors-sprite"><div class="minicolors-picker"></div></div><div class="minicolors-opacity-slider minicolors-sprite"><div class="minicolors-picker"></div></div><div class="minicolors-grid minicolors-sprite"><div class="minicolors-grid-inner"></div><div class="minicolors-picker"><div></div></div></div></div>'), vb.inline || (vc.after('<span class="minicolors-swatch minicolors-sprite"><span class="minicolors-swatch-color"></span></span>'), vc.next('.minicolors-swatch')['on']('click', function(va) {
  500. va.preventDefault();
  501. vc.focus()
  502. })), vc.parent()['find']('.minicolors-panel')['on']('selectstart', function() {
  503. return 0
  504. })['end'](), vb.inline && vc.parent()['addClass']('minicolors-inline'), vj(vc, 0), vc.data('minicolors-initialized', 1))
  505. }
  506.  
  507. function vf(va) {
  508. var vb = va.parent();
  509. va.removeData('minicolors-initialized')['removeData']('minicolors-settings')['removeProp']('size')['removeClass']('minicolors-input');
  510. vb.before(va)['remove']()
  511. }
  512.  
  513. function vg(va) {
  514. var vb = va.parent(),
  515. vd = vb.find('.minicolors-panel'),
  516. ve = va.data('minicolors-settings');
  517. !va.data('minicolors-initialized') || va.prop('disabled') || vb.hasClass('minicolors-inline') || vb.hasClass('minicolors-focus') || (vh(), vb.addClass('minicolors-focus'), vd.stop(1, 1)['fadeIn'](ve.showSpeed, function() {
  518. ve.show && ve.show['call'](va.get(0))
  519. }))
  520. }
  521.  
  522. function vh() {
  523. $('.minicolors-focus')['each'](function() {
  524. var vb = $(this),
  525. vd = vb.find('.minicolors-input'),
  526. ve = vb.find('.minicolors-panel'),
  527. vf = vd.data('minicolors-settings');
  528. ve.fadeOut(vf.hideSpeed, function() {
  529. vf.hide && vf.hide['call'](vd.get(0));
  530. vb.removeClass('minicolors-focus')
  531. })
  532. })
  533. }
  534.  
  535. function vd(va, vb, vd) {
  536. var vf = va.parents('.minicolors')['find']('.minicolors-input'),
  537. vi = vf.data('minicolors-settings'),
  538. vj = va.find('[class$=-picker]'),
  539. vg = va.offset()['left'],
  540. vh = va.offset()['top'],
  541. vk = Math.round(vb.pageX - vg),
  542. vl = Math.round(vb.pageY - vh);
  543. vd = vd ? vi.animationSpeed : 0;
  544. var vm, vn, vo, vp;
  545. vb.originalEvent['changedTouches'] && (vk = vb.originalEvent['changedTouches'][0]['pageX'] - vg, vl = vb.originalEvent['changedTouches'][0]['pageY'] - vh);
  546. 0 > vk && (vk = 0);
  547. 0 > vl && (vl = 0);
  548. vk > va.width() && (vk = va.width());
  549. vl > va.height() && (vl = va.height());
  550. va.parent()['is']('.minicolors-slider-wheel') && vj.parent()['is']('.minicolors-grid') && (vm = 75 - vk, vn = 75 - vl, vo = Math.sqrt(vm * vm + vn * vn), vp = Math.atan2(vn, vm), 0 > vp && (vp += 2 * Math.PI), 75 < vo && (vo = 75, vk = 75 - 75 * Math.cos(vp), vl = 75 - 75 * Math.sin(vp)), vk = Math.round(vk), vl = Math.round(vl));
  551. va.is('.minicolors-grid') ? vj.stop(1)['animate']({
  552. top: vl + 'px',
  553. left: vk + 'px'
  554. }, vd, vi.animationEasing, function() {
  555. ve(vf, va)
  556. }) : vj.stop(1)['animate']({
  557. top: vl + 'px'
  558. }, vd, vi.animationEasing, function() {
  559. ve(vf, va)
  560. })
  561. }
  562.  
  563. function ve(va, vb) {
  564. function vd(va, vb) {
  565. var vc, vf;
  566. return va.length && vb ? (vc = va.offset()['left'], vf = va.offset()['top'], {
  567. x: vc - vb.offset()['left'] + va.outerWidth() / 2,
  568. y: vf - vb.offset()['top'] + va.outerHeight() / 2
  569. }) : null
  570. }
  571.  
  572. var ve, vf, vi, vj, vg, vk;
  573. vj = va.val();
  574. var vh = va.attr('data-opacity');
  575. vg = va.parent();
  576. var vm = va.data('minicolors-settings'),
  577. vp = vg.find('.minicolors-swatch');
  578. vk = vg.find('.minicolors-grid');
  579. var vo = vg.find('.minicolors-slider'),
  580. vq = vg.find('.minicolors-opacity-slider');
  581. vi = vk.find('[class$=-picker]');
  582. var vr = vo.find('[class$=-picker]'),
  583. vs = vq.find('[class$=-picker]');
  584. vi = vd(vi, vk);
  585. vr = vd(vr, vo);
  586. vs = vd(vs, vq);
  587. if(vb.is('.minicolors-grid, .minicolors-slider, .minicolors-opacity-slider')) {
  588. switch(vm.control) {
  589. case 'wheel':
  590. vj = vk.width() / 2 - vi.x;
  591. vg = vk.height() / 2 - vi.y;
  592. vk = Math.sqrt(vj * vj + vg * vg);
  593. vj = Math.atan2(vg, vj);
  594. 0 > vj && (vj += 2 * Math.PI);
  595. 75 < vk && (vk = 75, vi.x = 69 - 75 * Math.cos(vj), vi.y = 69 - 75 * Math.sin(vj));
  596. vf = vl(vk / 0.75, 0, 100);
  597. ve = vl(180 * vj / Math.PI, 0, 360);
  598. vi = vl(100 - Math.floor(vr.y * (100 / vo.height())), 0, 100);
  599. vj = v_25({
  600. h: ve,
  601. s: vf,
  602. b: vi
  603. });
  604. vo.css('backgroundColor', v_25({
  605. h: ve,
  606. s: vf,
  607. b: 100
  608. }));
  609. break;
  610. case 'saturation':
  611. ve = vl(parseInt(vi.x * (360 / vk.width()), 10), 0, 360);
  612. vf = vl(100 - Math.floor(vr.y * (100 / vo.height())), 0, 100);
  613. vi = vl(100 - Math.floor(vi.y * (100 / vk.height())), 0, 100);
  614. vj = v_25({
  615. h: ve,
  616. s: vf,
  617. b: vi
  618. });
  619. vo.css('backgroundColor', v_25({
  620. h: ve,
  621. s: 100,
  622. b: vi
  623. }));
  624. vg.find('.minicolors-grid-inner')['css']('opacity', vf / 100);
  625. break;
  626. case 'brightness':
  627. ve = vl(parseInt(vi.x * (360 / vk.width()), 10), 0, 360);
  628. vf = vl(100 - Math.floor(vi.y * (100 / vk.height())), 0, 100);
  629. vi = vl(100 - Math.floor(vr.y * (100 / vo.height())), 0, 100);
  630. vj = v_25({
  631. h: ve,
  632. s: vf,
  633. b: vi
  634. });
  635. vo.css('backgroundColor', v_25({
  636. h: ve,
  637. s: vf,
  638. b: 100
  639. }));
  640. vg.find('.minicolors-grid-inner')['css']('opacity', 1 - vi / 100);
  641. break;
  642. default:
  643. ve = vl(360 - parseInt(vr.y * (360 / vo.height()), 10), 0, 360), vf = vl(Math.floor(vi.x * (100 / vk.width())), 0, 100), vi = vl(100 - Math.floor(vi.y * (100 / vk.height())), 0, 100), vj = v_25({
  644. h: ve,
  645. s: vf,
  646. b: vi
  647. }), vk.css('backgroundColor', v_25({
  648. h: ve,
  649. s: 100,
  650. b: 100
  651. }))
  652. }
  653. ;
  654. (vh = vm.opacity ? parseFloat(1 - vs.y / vq.height())['toFixed'](2) : 1, vm.opacity && va.attr('data-opacity', vh), 'rgb' === vm.format) ? (vo = vv(vj), vh = '' === va.attr('data-opacity') ? 1 : vl(parseFloat(va.attr('data-opacity'))['toFixed'](2), 0, 1), !isNaN(vh) && vm.opacity || (vh = 1), vf = 1 >= va.minicolors('rgbObject')['a'] && vo && vm.opacity ? 'rgba(' + vo.lb_r_strokeColor + ', ' + vo.g + ', ' + vo.b + ', ' + parseFloat(vh) + ')' : 'rgb(' + vo.lb_r_strokeColor + ', ' + vo.g + ', ' + vo.b + ')') : vf = vz(vj, vm.letterCase);
  655. va.val(vf)
  656. }
  657. ;
  658. vp.find('span')['css']({
  659. backgroundColor: vj,
  660. opacity: vh
  661. });
  662. vn(va, vf, vh);
  663. }
  664.  
  665. function vj(vb, vd) {
  666. var vf, ve, vi, vj, vk, vg, vh, vt;
  667. vt = vb.parent();
  668. var vu = vb.data('minicolors-settings'),
  669. vv = vt.find('.minicolors-swatch'),
  670. vo = vt.find('.minicolors-grid'),
  671. vq = vt.find('.minicolors-slider'),
  672. vw = vt.find('.minicolors-opacity-slider'),
  673. vs = vo.find('[class$=-picker]'),
  674. vx = vq.find('[class$=-picker]'),
  675. vy = vw.find('[class$=-picker]');
  676. switch(v_21(vb.val()) ? (vf = v_23(vb.val()), vk = vl(parseFloat(v_22(vb.val()))['toFixed'](2), 0, 1), vk && vb.attr('data-opacity', vk)) : vf = vz(vr(vb.val(), 1), vu.letterCase), vf || (vf = vz(vp(vu.defaultValue, 1), vu.letterCase)), ve = v_26(vf), vj = vu.keywords ? $.map(vu.keywords['split'](','), function(vb) {
  677. return $.trim(vb.toLowerCase())
  678. }) : [], vg = '' !== vb.val() && -1 < $.inArray(vb.val()['toLowerCase'](), vj) ? vz(vb.val()) : v_21(vb.val()) ? vm(vb.val()) : vf, vd || vb.val(vg), vu.opacity && (vi = '' === vb.attr('data-opacity') ? 1 : vl(parseFloat(vb.attr('data-opacity'))['toFixed'](2), 0, 1), isNaN(vi) && (vi = 1), vb.attr('data-opacity', vi), vv.find('span')['css']('opacity', vi), vh = vl(vw.height() - vw.height() * vi, 0, vw.height()), vy.css('top', vh + 'px')), 'transparent' === vb.val()['toLowerCase']() && vv.find('span')['css']('opacity', 0), vv.find('span')['css']('backgroundColor', vf), vu.control) {
  679. case 'wheel':
  680. vh = vl(Math.ceil(0.75 * ve.s), 0, vo.height() / 2);
  681. vt = ve.h * Math.PI / 180;
  682. vj = vl(75 - Math.cos(vt) * vh, 0, vo.width());
  683. vh = vl(75 - Math.sin(vt) * vh, 0, vo.height());
  684. vs.css({
  685. top: vh + 'px',
  686. left: vj + 'px'
  687. });
  688. vh = 150 - ve.b / (100 / vo.height());
  689. '' === vf && (vh = 0);
  690. vx.css('top', vh + 'px');
  691. vq.css('backgroundColor', v_25({
  692. h: ve.h,
  693. s: ve.s,
  694. b: 100
  695. }));
  696. break;
  697. case 'saturation':
  698. vj = vl(5 * ve.h / 12, 0, 150);
  699. vh = vl(vo.height() - Math.ceil(ve.b / (100 / vo.height())), 0, vo.height());
  700. vs.css({
  701. top: vh + 'px',
  702. left: vj + 'px'
  703. });
  704. vh = vl(vq.height() - ve.s * (vq.height() / 100), 0, vq.height());
  705. vx.css('top', vh + 'px');
  706. vq.css('backgroundColor', v_25({
  707. h: ve.h,
  708. s: 100,
  709. b: ve.b
  710. }));
  711. vt.find('.minicolors-grid-inner')['css']('opacity', ve.s / 100);
  712. break;
  713. case 'brightness':
  714. vj = vl(5 * ve.h / 12, 0, 150);
  715. vh = vl(vo.height() - Math.ceil(ve.s / (100 / vo.height())), 0, vo.height());
  716. vs.css({
  717. top: vh + 'px',
  718. left: vj + 'px'
  719. });
  720. vh = vl(vq.height() - ve.b * (vq.height() / 100), 0, vq.height());
  721. vx.css('top', vh + 'px');
  722. vq.css('backgroundColor', v_25({
  723. h: ve.h,
  724. s: ve.s,
  725. b: 100
  726. }));
  727. vt.find('.minicolors-grid-inner')['css']('opacity', 1 - ve.b / 100);
  728. break;
  729. default:
  730. vj = vl(Math.ceil(ve.s / (100 / vo.width())), 0, vo.width()), vh = vl(vo.height() - Math.ceil(ve.b / (100 / vo.height())), 0, vo.height()), vs.css({
  731. top: vh + 'px',
  732. left: vj + 'px'
  733. }), vh = vl(vq.height() - ve.h / (360 / vq.height()), 0, vq.height()), vx.css('top', vh + 'px'), vo.css('backgroundColor', v_25({
  734. h: ve.h,
  735. s: 100,
  736. b: 100
  737. }))
  738. }
  739. ;
  740. vb.data('minicolors-initialized') && vn(vb, vg, vi)
  741. }
  742.  
  743. function vn(va, vb, vd) {
  744. var ve = va.data('minicolors-settings'),
  745. vf = va.data('minicolors-lastChange');
  746. vf && vf.value === vb && vf.opacity === vd || (va.data('minicolors-lastChange', {
  747. value: vb,
  748. opacity: vd
  749. }), ve.change && (ve.changeDelay ? (clearTimeout(va.data('minicolors-changeTimeout')), va.data('minicolors-changeTimeout', setTimeout(function() {
  750. ve.change['call'](va.get(0), vb, vd)
  751. }, ve.changeDelay))) : ve.change['call'](va.get(0), vb, vd)), va.trigger('change')['trigger']('input'))
  752. }
  753.  
  754. function vk(vb) {
  755. var vd = vr($(vb)['val'](), 1),
  756. vd = vv(vd);
  757. vb = $(vb)['attr']('data-opacity');
  758. return vd ? (void (0) !== vb && $.extend(vd, {
  759. a: parseFloat(vb)
  760. }), vd) : null
  761. }
  762.  
  763. function vi(vb, vd) {
  764. var ve = vr($(vb)['val'](), 1),
  765. ve = vv(ve),
  766. vf = $(vb)['attr']('data-opacity');
  767. return ve ? (void (0) === vf && (vf = 1), vd ? 'rgba(' + ve.lb_r_strokeColor + ', ' + ve.g + ', ' + ve.b + ', ' + parseFloat(vf) + ')' : 'rgb(' + ve.lb_r_strokeColor + ', ' + ve.g + ', ' + ve.b + ')') : null
  768. }
  769.  
  770. function vz(va, vb) {
  771. return 'uppercase' === vb ? va.toUpperCase() : va.toLowerCase()
  772. }
  773.  
  774. function vr(va, vb) {
  775. return va = va.replace(/^#/g, ''), va.match(/^[A-F0-9]{3,6}/gi) ? 3 !== va.length && 6 !== va.length ? '' : (3 === va.length && vb && (va = va[0] + va[0] + va[1] + va[1] + va[2] + va[2]), '#' + va) : ''
  776. }
  777.  
  778. function vm(va, vb) {
  779. var vd = va.replace(/[^\d,.]/g, '')['split'](',');
  780. return vd[0] = vl(parseInt(vd[0], 10), 0, 255), vd[1] = vl(parseInt(vd[1], 10), 0, 255), vd[2] = vl(parseInt(vd[2], 10), 0, 255), vd[3] && (vd[3] = vl(parseFloat(vd[3], 10), 0, 1)), vb ? {
  781. lb_r_strokeColor: vd[0],
  782. g: vd[1],
  783. b: vd[2],
  784. a: vd[3] ? vd[3] : null
  785. } : 'undefined' != typeof vd[3] && 1 >= vd[3] ? 'rgba(' + vd[0] + ', ' + vd[1] + ', ' + vd[2] + ', ' + vd[3] + ')' : 'rgb(' + vd[0] + ', ' + vd[1] + ', ' + vd[2] + ')'
  786. }
  787.  
  788. function vp(va, vb) {
  789. return v_21(va) ? vm(va) : vr(va, vb)
  790. }
  791.  
  792. function vl(va, vb, vd) {
  793. return vb > va && (va = vb), va > vd && (va = vd), va
  794. }
  795.  
  796. function v_21(va) {
  797. return (va = va.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i)) && 4 === va.length ? 1 : 0
  798. }
  799.  
  800. function v_22(va) {
  801. return (va = va.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+(\.\d{1,2})?|\.\d{1,2})[\s+]?/i)) && 6 === va.length ? va[4] : '1'
  802. }
  803.  
  804. function v_23(va) {
  805. return va = va.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i), va && 4 === va.length ? '#' + ('0' + parseInt(va[1], 10).toString(16))['slice'](-2) + ('0' + parseInt(va[2], 10).toString(16))['slice'](-2) + ('0' + parseInt(va[3], 10).toString(16))['slice'](-2) : ''
  806. }
  807.  
  808. function v_24(vb) {
  809. var vd = [vb.lb_r_strokeColor.toString(16), vb.g.toString(16), vb.b.toString(16)];
  810. return $.each(vd, function(va, vb) {
  811. 1 === vb.length && (vd[va] = '0' + vb)
  812. }), '#' + vd.join('')
  813. }
  814.  
  815. function v_25(va) {
  816. var vb = v_24,
  817. vd, ve, vf, vi = Math.round(va.h),
  818. vj = Math.round(255 * va.s / 100);
  819. va = Math.round(255 * va.b / 100);
  820. if(0 === vj) {
  821. vd = ve = vf = va
  822. } else {
  823. var vj = (255 - vj) * va / 255,
  824. vh = vi % 60 * (va - vj) / 60;
  825. 360 === vi && (vi = 0);
  826. 60 > vi ? (vd = va, vf = vj, ve = vj + vh) : 120 > vi ? (ve = va, vf = vj, vd = va - vh) : 180 > vi ? (ve = va, vd = vj, vf = vj + vh) : 240 > vi ? (vf = va, vd = vj, ve = va - vh) : 300 > vi ? (vf = va, ve = vj, vd = vj + vh) : 360 > vi ? (vd = va, ve = vj, vf = va - vh) : (vd = 0, ve = 0, vf = 0)
  827. }
  828. ;
  829. return vb({
  830. lb_r_strokeColor: Math.round(vd),
  831. g: Math.round(ve),
  832. b: Math.round(vf)
  833. })
  834. }
  835.  
  836. function v_26(va) {
  837. va = vv(va);
  838. var vb = {
  839. h: 0,
  840. s: 0,
  841. b: 0
  842. },
  843. vd = Math.max(va.lb_r_strokeColor, va.g, va.b),
  844. ve = vd - Math.min(va.lb_r_strokeColor, va.g, va.b);
  845. va = (vb.b = vd, vb.s = 0 !== vd ? 255 * ve / vd : 0, 0 !== vb.s ? va.lb_r_strokeColor === vd ? vb.h = (va.g - va.b) / ve : va.g === vd ? vb.h = 2 + (va.b - va.lb_r_strokeColor) / ve : vb.h = 4 + (va.lb_r_strokeColor - va.g) / ve : vb.h = -1, vb.h *= 60, 0 > vb.h && (vb.h += 360), vb.s *= 100 / 255, vb.b *= 100 / 255, vb);
  846. return 0 === va.s && (va.h = 360), va
  847. }
  848.  
  849. function vv(va) {
  850. return va = parseInt(-1 < va.indexOf('#') ? va.substring(1) : va, 16), {
  851. lb_r_strokeColor: va >> 16,
  852. g: (65280 & va) >> 8,
  853. b: 255 & va
  854. }
  855. }
  856.  
  857. $.minicolors = {
  858. defaults: {
  859. animationSpeed: 50,
  860. animationEasing: 'swing',
  861. change: null,
  862. changeDelay: 0,
  863. control: 'hue',
  864. dataUris: 1,
  865. defaultValue: '',
  866. format: 'hex',
  867. hide: null,
  868. hideSpeed: 100,
  869. inline: 0,
  870. keywords: '',
  871. letterCase: 'lowercase',
  872. opacity: 0,
  873. position: 'bottom left',
  874. show: null,
  875. showSpeed: 100,
  876. theme: 'default'
  877. }
  878. };
  879. $.extend($.fn, {
  880. minicolors: function(vd, ve) {
  881. switch(vd) {
  882. case 'destroy':
  883. return $(this)['each'](function() {
  884. vf($(this))
  885. }), $(this);
  886. case 'hide':
  887. return vh(), $(this);
  888. case 'opacity':
  889. return void (0) === ve ? $(this)['attr']('data-opacity') : ($(this)['each'](function() {
  890. vj($(this)['attr']('data-opacity', ve))
  891. }), $(this));
  892. case 'rgbObject':
  893. return vk($(this), 'rgbaObject' === vd);
  894. case 'rgbString':
  895. ;
  896. case 'rgbaString':
  897. return vi($(this), 'rgbaString' === vd);
  898. case 'settings':
  899. return void (0) === ve ? $(this)['data']('minicolors-settings') : ($(this)['each'](function() {
  900. var vb = $(this)['data']('minicolors-settings') || {};
  901. vf($(this));
  902. $(this)['minicolors']($.extend(1, vb, ve))
  903. }), $(this));
  904. case 'show':
  905. return vg($(this)['eq'](0)), $(this);
  906. case 'value':
  907. return void (0) === ve ? $(this)['val']() : ($(this)['each'](function() {
  908. 'object' == typeof ve ? (ve.opacity && $(this)['attr']('data-opacity', vl(ve.opacity, 0, 1)), ve.color && $(this)['val'](ve.color)) : $(this)['val'](ve);
  909. vj($(this))
  910. }), $(this));
  911. default:
  912. return 'create' !== vd && (ve = vd), $(this)['each'](function() {
  913. vb($(this), ve)
  914. }), $(this)
  915. }
  916. }
  917. });
  918.  
  919. $(document)['on']('mousedown.minicolors touchstart.minicolors', function(vb) {
  920. $(vb.target)['parents']()['add'](vb.target)['hasClass']('minicolors') || vh()
  921. })['on']('mousedown.minicolors touchstart.minicolors', '.minicolors-grid, .minicolors-slider, .minicolors-opacity-slider', function(vb) {
  922. var ve = $(this);
  923. vb.preventDefault();
  924. $(document)['data']('minicolors-target', ve);
  925. vd(ve, vb, 1)
  926. })['on']('mousemove.minicolors touchmove.minicolors', function(vb) {
  927. var ve = $(document)['data']('minicolors-target');
  928. ve && vd(ve, vb)
  929. })['on']('mouseup.minicolors touchend.minicolors', function() {
  930. $(this)['removeData']('minicolors-target')
  931. })['on']('mousedown.minicolors touchstart.minicolors', '.minicolors-swatch', function(vb) {
  932. var vd = $(this)['parent']()['find']('.minicolors-input');
  933. vb.preventDefault();
  934. vg(vd)
  935. })['on']('focus.minicolors', '.minicolors-input', function() {
  936. var vb = $(this);
  937. vb.data('minicolors-initialized') && vg(vb)
  938. })['on']('blur.minicolors', '.minicolors-input', function() {
  939. var vb = $(this),
  940. vd = vb.data('minicolors-settings'),
  941. ve, vf, vi, vj, vh;
  942. vb.data('minicolors-initialized') && (ve = vd.keywords ? $.map(vd.keywords['split'](','), function(vb) {
  943. return $.trim(vb.toLowerCase())
  944. }) : [], '' !== vb.val() && -1 < $.inArray(vb.val()['toLowerCase'](), ve) ? vh = vb.val() : (v_21(vb.val()) ? vi = vm(vb.val(), 1) : (vf = vr(vb.val(), 1), vi = vf ? vv(vf) : null), vh = null === vi ? vd.defaultValue : 'rgb' === vd.format ? vm(vd.opacity ? 'rgba(' + vi.lb_r_strokeColor + ',' + vi.g + ',' + vi.b + ',' + vb.attr('data-opacity') + ')' : 'rgb(' + vi.lb_r_strokeColor + ',' + vi.g + ',' + vi.b + ')') : v_24(vi)), vj = vd.opacity ? vb.attr('data-opacity') : 1, 'transparent' === vh.toLowerCase() && (vj = 0), vb.closest('.minicolors')['find']('.minicolors-swatch > span')['css']('opacity', vj), vb.val(vh), '' === vb.val() && vb.val(vp(vd.defaultValue, 1)), vb.val(vz(vb.val(), vd.letterCase)))
  945. })['on']('keydown.minicolors', '.minicolors-input', function(vb) {
  946. var vd = $(this);
  947. if(vd.data('minicolors-initialized')) {
  948. switch(vb.keyCode) {
  949. case 9:
  950. vh();
  951. break;
  952. case 13:
  953. ;
  954. case 27:
  955. vh(), vd.blur()
  956. }
  957. }
  958. })['on']('keyup.minicolors', '.minicolors-input', function() {
  959. var vb = $(this);
  960. vb.data('minicolors-initialized') && vj(vb, 1)
  961. })['on']('paste.minicolors', '.minicolors-input', function() {
  962. var vb = $(this);
  963. vb.data('minicolors-initialized') && setTimeout(function() {
  964. vj(vb, 1)
  965. }, 1)
  966. })
  967. }
  968.  
  969. //var myApp = null;
  970. var gSelfMass = 100;
  971. var gSplitTimingTick = -1;
  972. var gSplitTimingDuration = 10;
  973. var conn2 = null;
  974.  
  975. var gSiteArea = { x: 0.0, y: 0.0, scale: 1.0, scw: 1000, sch: 800, field_sz: 14142.0 };
  976.  
  977. //var gTeamTagOverride = null;
  978.  
  979. var gIsConnected = false;
  980.  
  981. //var stopPositionX, stopPositionY;
  982. //var refPositionX, refPositionY;
  983. //var gZoomScaling = 1.0;
  984.  
  985. //var gLocalPlayerIdPerConnection = 0; //接続するごとに乱数で決めるID
  986. //var gPlayerSignature = '';
  987. //var gSelfPlayerId = -1;
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995. class TeamEntryInfo {
  996. constructor(teamId, teamName, color, section) { //tag, col_lb, col_map, col_name){
  997. //this.tag = tag;
  998. //this.col_lb = col_lb;
  999. //this.col_map = col_map;
  1000. //this.col_name = col_name;
  1001. this.teamId = teamId;
  1002. this.teamName = teamName;
  1003. //this.code = code;
  1004. this.color = color;
  1005. this.section = section;
  1006. }
  1007. }
  1008.  
  1009. class TeamInfoManager {
  1010. constructor() {
  1011. this.teamInfos = {};
  1012. //this.fallbackInfo = null;
  1013. }
  1014.  
  1015. addTeam(teamId, teamName, color, section) { //tag, col_lb, col_map, col_name){
  1016. //if(teamName === '@DEFAULT'){
  1017. // this.fallbackInfo = new TeamEntryInfo(teamId, teamName, color); //tag, col_lb, col_map, col_name);
  1018. //}else {
  1019. this.teamInfos[teamId] = new TeamEntryInfo(teamId, teamName, color, section);
  1020. /*
  1021. if (col_lb != '') {
  1022. //tag, col_lb, col_map, col_name);
  1023. } else {
  1024. delete this.teamInfos[tag];
  1025. }
  1026. */
  1027. }
  1028.  
  1029. removeTeam(teamId) {
  1030. delete this.teamInfos[teamId];
  1031. }
  1032.  
  1033. getPropOrDefault(teamId, propName, defaultValue) {
  1034. //if(tag == '') tag = '@NOTAG';
  1035. var info = this.teamInfos[teamId];
  1036. if(!info) {
  1037. info = this.fallbackInfo;
  1038. }
  1039. return info ? info[propName] : defaultValue;
  1040. }
  1041.  
  1042. getColor(teamId) {
  1043. return this.getPropOrDefault(teamId, 'color', "#FFFFFF");
  1044. }
  1045.  
  1046. getTeamName(teamId) {
  1047. return this.getPropOrDefault(teamId, 'teamName', '');
  1048. }
  1049.  
  1050. getTeamSection(teamId) {
  1051. return this.getPropOrDefault(teamId, 'section', '');
  1052. }
  1053. }
  1054.  
  1055. // getLeaderboardColor(tag){
  1056. // return this.getPropOrDefault(tag, 'col_lb', "#FFFFFF");
  1057. // }
  1058. //
  1059. // getMapColor(tag){
  1060. // return this.getPropOrDefault(tag, 'col_map', "#FFFFFF");
  1061. // }
  1062. //
  1063. // getNameColor(tag){
  1064. // return this.getPropOrDefault(tag, 'col_name', "#FFFFFF");
  1065. // }
  1066.  
  1067. var teamManager = new TeamInfoManager();
  1068.  
  1069.  
  1070.  
  1071.  
  1072. const ElementFallbackColor = { r: 128, g: 128, b: 128 };
  1073.  
  1074. class PlayerEntryInfo {
  1075. constructor(cid, name, team, skinUrl, isBot, teamId, token, skinUrl2) { //team, skinUrl, isBot, code){
  1076. this.cid = cid;
  1077. this.name = name;
  1078. this.team = team;
  1079. this.skinUrl = skinUrl;
  1080. this.isBot = isBot;
  1081. //this.color = ElementFallbackColor;
  1082. //this.code = code;
  1083. this.teamId = teamId;
  1084. this.userToken = token;
  1085. this.skinUrl2 = skinUrl2;
  1086. }
  1087. }
  1088.  
  1089. class PlayerManager {
  1090. constructor() {
  1091. this.entries = {};
  1092. this.selfClientId = -1;
  1093. }
  1094.  
  1095. addPlayer(cid, name, team, skinUrl, isBot, teamId, token, skinUrl2) { //team, skinUrl, isBot, code){
  1096. var deadName = 'dead';
  1097. if(!isBot && cid != this.selfClientId && gconfig_ex.UseNoSkinFallbackSkin && name != deadName){
  1098. if(!skinUrl) skinUrl = gconfig_ex.NoSkinFallBackSkinUrl;
  1099. if(!skinUrl2) skinUrl = gconfig_ex.NoSkinFallBackSkinUrl;
  1100. }
  1101.  
  1102. if(this.entries[cid]) {
  1103. var e = this.entries[cid];
  1104. e.cid = cid;
  1105. e.name = name;
  1106. e.team = team;
  1107. e.skinUrl = skinUrl;
  1108. e.isBot = isBot;
  1109. e.teamId = teamId;
  1110. e.userToken = token;
  1111. e.skinUrl2 = skinUrl2;
  1112. //e.code = code;
  1113. } else {
  1114. this.entries[cid] = new PlayerEntryInfo(cid, name, team, skinUrl, isBot, teamId, token, skinUrl2); //team, skinUrl, isBot, code);
  1115. //console.log('teamId:' + teamId);
  1116. }
  1117.  
  1118. }
  1119.  
  1120. checkIsTeammate(cid) {
  1121. var a = this.entries[this.selfClientId];
  1122. var b = this.entries[cid];
  1123. if(gconfig.isolateBlankTagPlayers && a && a.team == '') {
  1124. return cid == this.selfClientId; //空タグは自分のみチーãƒ
  1125. }
  1126. //return a && b && a.team == b.team && a.code == b.code;
  1127. return a && b && a.teamId === b.teamId;
  1128. }
  1129.  
  1130. checkIsInEatableSection(cid) {
  1131. var a = this.entries[this.selfClientId];
  1132. var b = this.entries[cid];
  1133. if(!a || !b) return false;
  1134. var sectA = teamManager.getTeamSection(a.teamId);
  1135. var sectB = teamManager.getTeamSection(b.teamId);
  1136. return (sectA == '**' || sectB == '**' || sectA == sectB);
  1137. }
  1138.  
  1139. checkIsBot(cid) {
  1140. var info = this.entries[cid];
  1141. return info && info.isBot;
  1142. }
  1143.  
  1144. removePlayer(cid) {
  1145. delete this.entries[cid];
  1146. }
  1147.  
  1148. getFullName(cid) {
  1149. var info = this.entries[cid];
  1150. if(!info) return '';
  1151. if(info.isBot) return info.name;
  1152. var fullName = AddTeamTagPrefixForPlayerName ? (info.team + info.name) : info.name;
  1153. if(fullName == '') fullName = gconfig.nameForUnnamedCell;
  1154. return fullName;
  1155. //return info.isBot ? info.name : info.team + info.name;
  1156. }
  1157.  
  1158. getName(cid) {
  1159. var info = this.entries[cid];
  1160. return info ? info.name : '';
  1161. }
  1162.  
  1163. getTeam(cid) {
  1164. var info = this.entries[cid];
  1165. return info ? info.team : '';
  1166. }
  1167.  
  1168. getTeamId(cid) {
  1169. var info = this.entries[cid];
  1170. return info ? info.teamId : '';
  1171. }
  1172.  
  1173. getSkinUrl(cid) {
  1174. var info = this.entries[cid];
  1175. return info ? info.skinUrl : '';
  1176. }
  1177.  
  1178. getSkinUrl2(cid) {
  1179. var info = this.entries[cid];
  1180. return info ? info.skinUrl2 : '';
  1181. }
  1182.  
  1183. getUserToken(cid) {
  1184. var info = this.entries[cid];
  1185. return info ? info.userToken : '';
  1186. }
  1187.  
  1188. setSelfClientId(cid) {
  1189. this.selfClientId = cid;
  1190. }
  1191.  
  1192. getSelfClientId() {
  1193. return this.selfClientId;
  1194. }
  1195. }
  1196.  
  1197. var playerManager = new PlayerManager();
  1198.  
  1199. class PlayerCoreInfo {
  1200. constructor(pid, cid, r, g, b, skinIndex) {
  1201. this.pid = pid;
  1202. this.cid = cid;
  1203. this.color = { r, g, b};
  1204. this.skinIndex = skinIndex;
  1205. }
  1206. }
  1207.  
  1208.  
  1209. class PlayerCoreInfoManager {
  1210.  
  1211. constructor() {
  1212. this.entries = {};
  1213. }
  1214.  
  1215. setPlayerCoreInfo(pid, cid, _r, _g, _b, skinIndex) {
  1216. var info = this.entries[pid];
  1217. if(info) {
  1218. info.color = { r: _r, g: _g, b: _b }
  1219. info.cid = cid;
  1220. info.skinIndex = skinIndex;
  1221. } else {
  1222. info = new PlayerCoreInfo(pid, cid, _r, _g, _b, skinIndex);
  1223. this.entries[pid] = info;
  1224. }
  1225. }
  1226.  
  1227. getPlayerColor(pid) {
  1228. var info = this.entries[pid];
  1229. return info ? info.color : ElementFallbackColor;
  1230. }
  1231.  
  1232. getSkinIndex(pid) {
  1233. var info = this.entries[pid];
  1234. return info ? info.skinIndex : 0;
  1235. }
  1236.  
  1237. getCid(pid) {
  1238. var info = this.entries[pid];
  1239. return info ? info.cid : 0;
  1240. }
  1241. }
  1242.  
  1243. var playerCoreManager = new PlayerCoreInfoManager();
  1244.  
  1245.  
  1246.  
  1247. var leaderBoardList = [];
  1248.  
  1249. var gPlayerEntryData = {
  1250. nick: '',
  1251. team: '',
  1252. skinUrl: ''
  1253. };
  1254.  
  1255. // function clearPlayerSelfEntryData(){
  1256. // gPlayerEntryData = {
  1257. // nick : '',
  1258. // team : '',
  1259. // skinUrl: ''
  1260. // };
  1261. // }
  1262.  
  1263. var gIsPlaying = false;
  1264. //var gIsSpectate = false;
  1265. var gIsSpectate = true;
  1266. //var FieldSize = 14142.13562373095;
  1267. //var FieldSizeHalf = FieldSize / 2;
  1268.  
  1269. // function setIsPlaying(val){
  1270. // gIsPlaying = val;
  1271. // console.log('gIsPlaying:' + gIsPlaying);
  1272. // }
  1273.  
  1274. //var extendedWebSocketDataHandlerProc = null;
  1275.  
  1276. var testingVal = 29,
  1277. //testingCount = 0,
  1278. //testingInd = 0,
  1279. spectateMode;
  1280.  
  1281. var PRIVATE_SERVER_IP = '__';
  1282. var i18n_lang = 'en';
  1283. var i18n_dict = {
  1284. en: {
  1285. connecting: 'Connecting',
  1286. connect_help: 'If you cannot connect to the servers, check if you have some anti virus or firewall blocking the connection.',
  1287. play: 'Play',
  1288. spectate: 'Spectate',
  1289. login_and_play: 'Login and play',
  1290. play_as_guest: 'Play as guest',
  1291. share: 'Share',
  1292. advertisement: 'Advertisement',
  1293. privacy_policy: 'Privacy Policy',
  1294. terms_of_service: 'Terms of Service',
  1295. changelog: 'Changelog',
  1296. instructions_mouse: 'Move your mouse to control your cell',
  1297. instructions_space: 'Press <b>Space</b> to split',
  1298. instructions_w: 'Press <b>W</b> to eject some mass',
  1299. gamemode_ffa: 'FFA',
  1300. gamemode_teams: 'Teams',
  1301. gamemode_experimental: 'Experimental',
  1302. region_select: ' -- Select a Region -- ',
  1303. region_us_east: 'US East',
  1304. region_us_west: 'US West',
  1305. region_north_america: 'North America',
  1306. region_south_america: 'South America',
  1307. region_europe: 'Europe',
  1308. region_turkey: 'Turkey',
  1309. region_poland: 'Poland',
  1310. region_east_asia: 'East Asia',
  1311. region_russia: 'Russia',
  1312. region_china: 'China',
  1313. region_oceania: 'Oceania',
  1314. region_australia: 'Australia',
  1315. region_players: 'players',
  1316. option_no_skins: 'No skins',
  1317. option_no_names: 'No names',
  1318. option_dark_theme: 'Dark theme',
  1319. option_no_colors: 'No colors',
  1320. option_show_mass: 'Show mass',
  1321. leaderboard: 'Leaderboard',
  1322. unnamed_cell: 'An unnamed cell',
  1323. last_match_results: 'Last match results',
  1324. score: 'Score',
  1325. leaderboard_time: 'Leaderboard Time',
  1326. mass_eaten: 'Mass Eaten',
  1327. top_position: 'Top Position',
  1328. position_1: 'First',
  1329. position_2: 'Second',
  1330. position_3: 'Third',
  1331. position_4: 'Fourth',
  1332. position_5: 'Fifth',
  1333. position_6: 'Sixth',
  1334. position_7: 'Seventh',
  1335. position_8: 'Eighth',
  1336. position_9: 'Ninth',
  1337. position_10: 'Tenth',
  1338. player_cells_eaten: 'Player Cells Eaten',
  1339. survival_time: 'Survival Time',
  1340. games_played: 'Games played',
  1341. highest_mass: 'Highest mass',
  1342. total_cells_eaten: 'Total cells eaten',
  1343. total_mass_eaten: 'Total mass eaten',
  1344. longest_survival: 'Longest survival',
  1345. logout: 'Logout',
  1346. stats: 'Stats',
  1347. shop: 'Shop',
  1348. party: 'Party',
  1349. party_description: 'Play with your friends in the same map',
  1350. create_party: 'Create',
  1351. creating_party: 'Creating party...',
  1352. join_party: 'Join',
  1353. back_button: 'Back',
  1354. joining_party: 'Joining party...',
  1355. joined_party_instructions: 'You are now playing with this party:',
  1356. party_join_error: 'There was a problem joining that party, please make sure the code is correct, or try creating another party',
  1357. login_tooltip: 'Login with Facebook and get:<br/><br /><br />Start the game with more mass!<br />Level up to get even more starting mass!',
  1358. create_party_instructions: 'Give this link to your friends:',
  1359. join_party_instructions: 'Your friend should have given you a code, type it here:',
  1360. "\x63\x6F\x6E\x74\x69\x6E\x75\x65": 'Continue',
  1361. option_skip_stats: 'Skip stats',
  1362. stats_food_eaten: 'food eaten',
  1363. stats_highest_mass: 'highest mass',
  1364. stats_time_alive: 'time alive',
  1365. stats_leaderboard_time: 'leaderboard time',
  1366. stats_cells_eaten: 'cells eaten',
  1367. stats_top_position: 'top position',
  1368. "": ''
  1369. }
  1370. };
  1371. var i18n = i18n_dict[i18n_lang];
  1372.  
  1373. var MOVING = true;
  1374. //var myApp,
  1375. var nodeList = [],
  1376. chatRoom = null,
  1377. minimap = null,
  1378. socket = null,
  1379. currentIP = '',
  1380. //teamname = 'HKG',
  1381. //defaultTeamname = 'HKG',
  1382. //socketRetryInterval, isSocketReady = 0,
  1383. //isChangeName = 0,
  1384. //conn = null,
  1385. //reconnectCount = 0,
  1386. updateLBCount = 0,
  1387. tmpTeamname = '';
  1388.  
  1389. var defaultImage = new Image;
  1390. defaultImage.src = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNi4yLjEsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB3aWR0aD0iNTEycHgiIGhlaWdodD0iNTEycHgiIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8Zz4NCgk8Zz4NCgkJPHBhdGggZD0iTTI1Niw0OEMxNDEuMSw0OCw0OCwxNDEuMSw0OCwyNTZzOTMuMSwyMDgsMjA4LDIwOGMxMTQuOSwwLDIwOC05My4xLDIwOC0yMDhTMzcwLjksNDgsMjU2LDQ4eiBNMjU2LDQ0Ni43DQoJCQljLTEwNS4xLDAtMTkwLjctODUuNS0xOTAuNy0xOTAuN2MwLTEwNS4xLDg1LjUtMTkwLjcsMTkwLjctMTkwLjdjMTA1LjEsMCwxOTAuNyw4NS41LDE5MC43LDE5MC43DQoJCQlDNDQ2LjcsMzYxLjEsMzYxLjEsNDQ2LjcsMjU2LDQ0Ni43eiIvPg0KCTwvZz4NCjwvZz4NCjxnPg0KCTxnPg0KCQk8cGF0aCBkPSJNMjU2LDk2Yy04OC40LDAtMTYwLDcxLjYtMTYwLDE2MGMwLDg4LjQsNzEuNiwxNjAsMTYwLDE2MGM4OC40LDAsMTYwLTcxLjYsMTYwLTE2MEM0MTYsMTY3LjYsMzQ0LjQsOTYsMjU2LDk2eiIvPg0KCTwvZz4NCjwvZz4NCjwvc3ZnPg0K';
  1391.  
  1392. var customSkin = { "": defaultImage };
  1393.  
  1394. var announcementTxt = '';
  1395. var Action = {
  1396. COPY: 'HKGAGARTOOLCOPY',
  1397. IMAGE: 'HKGAGARTOOLIMAGE',
  1398. FINISH: 'HKGAGARTOOLFINISH'
  1399. };
  1400. var isJoinedGame = 0,
  1401. hotkeyConfig = {},
  1402. hotkeyMapping = {},
  1403. //teammateIdt = {},
  1404. defaultHotkeyMapping = {},
  1405. selectedHotkeyRow, chatCommand = {},
  1406. isWindowFocus = 1,
  1407. skinDownloadQueue = [],
  1408. skinDownloadFail = {},
  1409. toastQueue = [],
  1410. defaultSkin = '';
  1411. //gm;
  1412.  
  1413. var defaultHotkeyMessageSend = {
  1414. input_hk_send_msg1: gtexts_common.msg1,
  1415. input_hk_send_msg2: gtexts_common.msg2,
  1416. input_hk_send_msg3: gtexts_common.msg3,
  1417. input_hk_send_msg4: gtexts_common.msg4,
  1418. input_hk_send_msg5: gtexts_common.msg5,
  1419. input_hk_send_msg6: gtexts_common.msg6,
  1420. input_hk_send_msg7: gtexts_common.msg7,
  1421. input_hk_send_msg8: gtexts_common.msg8,
  1422. input_hk_send_msg9: gtexts_common.msg9,
  1423. input_hk_send_msg10: gtexts_common.msg10,
  1424. };
  1425.  
  1426. //var defaultHotkeyMessageSend = {
  1427. // input_hk_send_msg1: 'æ´è­·ã‚’é ¼ã‚€!',
  1428. // input_hk_send_msg2: '誰か味方になって!',
  1429. // input_hk_send_msg3: 'やつをポップしろ!',
  1430. // input_hk_send_msg4: '逃げるぞ!',
  1431. // input_hk_send_msg5: '母体式!',
  1432. // input_hk_send_msg6: 'さあ餌だよ! ',
  1433. // input_hk_send_msg7: 'いれて!',
  1434. // input_hk_send_msg8: 'えさくれ!',
  1435. // input_hk_send_msg9: 'そこの棘を撃ってくれ!',
  1436. // input_hk_send_msg10: '了解です!'
  1437. //};
  1438. var hkgIcon = {}, selected_profile_index = 0;
  1439.  
  1440.  
  1441. var skinUrlListNormal = [
  1442. null, null,
  1443. 'http://agar-network.com/skins/ring.png',
  1444. 'http://agar-network.com/skins/circles.png',
  1445. 'http://agar-network.com/skins/w.png',
  1446. 'http://agar-network.com/skins/magatama.png',
  1447. 'http://agar-network.com/skins/wolf.png',
  1448. 'http://agar-network.com/skins/ring.png',
  1449. 'http://agar-network.com/skins/ring.png',
  1450. 'http://agar-network.com/skins/ring.png',
  1451. 'http://agar-network.com/skins/ring.png',
  1452. ];
  1453.  
  1454. var skinUrlListIx = [
  1455. null, null,
  1456. 'http://agar-network.com/skins/ring.png',
  1457. 'http://ixagar.net/skins/k461.png',
  1458. 'http://ixagar.net/skins/k147.png',
  1459. 'http://ixagar.net/skins/k124.png',
  1460. 'http://ixagar.net/skins/k121.png',
  1461. 'http://ixagar.net/skins/k684.png',
  1462. 'http://ixagar.net/skins/k341.png',
  1463. 'http://ixagar.net/skins/k134.png',
  1464. 'http://ixagar.net/skins/k546.png',
  1465. ];
  1466.  
  1467. var isIx = location.hostname == 'ixagar.net';
  1468. //console.log('isIx:' + isIx);
  1469. var skinUrlList = isIx ? skinUrlListIx : skinUrlListNormal;
  1470.  
  1471. var player_profile = function() {
  1472. return [{
  1473. name: 'Profile 1',
  1474. team: CommonTeamName,
  1475. skinurl: defaultSkin,
  1476. partycode: ''
  1477. }, {
  1478. name: 'Profile 2',
  1479. team: CommonTeamName,
  1480. skinurl: skinUrlList[2],
  1481. skinurl2: skinUrlList[2],
  1482. partycode: ''
  1483. }, {
  1484. name: 'Profile 3',
  1485. team: CommonTeamName,
  1486. skinurl: skinUrlList[3],
  1487. skinurl2: skinUrlList[3],
  1488. partycode: ''
  1489. }, {
  1490. name: 'Profile 4',
  1491. team: CommonTeamName,
  1492. skinurl: skinUrlList[4],
  1493. skinurl2: skinUrlList[4],
  1494. partycode: ''
  1495. }, {
  1496. name: 'Profile 5',
  1497. team: CommonTeamName,
  1498. skinurl: skinUrlList[5],
  1499. skinurl2: skinUrlList[5],
  1500. partycode: ''
  1501. }, {
  1502. name: 'Profile 6',
  1503. team: CommonTeamName,
  1504. skinurl: skinUrlList[6],
  1505. skinurl2: skinUrlList[6],
  1506. partycode: ''
  1507. }, {
  1508. name: 'Profile 7',
  1509. team: CommonTeamName,
  1510. skinurl: skinUrlList[7],
  1511. skinurl2: skinUrlList[7],
  1512. partycode: ''
  1513. }, {
  1514. name: 'Profile 8',
  1515. team: CommonTeamName,
  1516. skinurl: skinUrlList[8],
  1517. skinurl2: skinUrlList[8],
  1518. partycode: ''
  1519. }, {
  1520. name: 'Profile 9',
  1521. team: CommonTeamName,
  1522. skinurl: skinUrlList[9],
  1523. skinurl2: skinUrlList[9],
  1524. partycode: ''
  1525. }, {
  1526. name: 'Profile 10',
  1527. team: CommonTeamName,
  1528. skinurl: skinUrlList[10],
  1529. skinurl2: skinUrlList[10],
  1530. partycode: ''
  1531. }];
  1532. }();
  1533.  
  1534. var escapeHtml = function() {
  1535. var va = {
  1536. "\x22": '&quot;',
  1537. "\x26": '&amp;',
  1538. "\x3C": '&lt;',
  1539. "\x3E": '&gt;'
  1540. };
  1541. return function(vb) {
  1542. return vb.replace(/[\"&<>]/g, function(vb) {
  1543. return va[vb]
  1544. })
  1545. }
  1546. }();
  1547. function getHotkeyById(va) {
  1548. for(var vb in hotkeyMapping) {
  1549. if(hotkeyMapping[vb] == va) {
  1550. return vb
  1551. }
  1552. }
  1553. ;
  1554. return ''
  1555. }
  1556.  
  1557. function modifyUrlForLocalhostConnection(uri) {
  1558. var parts = uri.split(":");
  1559. var protocol = parts[0];
  1560. var host = parts[1];
  1561. var port = parts[2];
  1562. /*
  1563. regex(url, /^([^\:]\:\/\/)([^\:])\:([0-9]+));
  1564. var protocol = $0;
  1565. var host = $1;
  1566. var port = $2;
  1567. */
  1568.  
  1569. if(location.search === "?localhost=1") {
  1570. host = '//localhost';
  1571. //var port = uri.split(":")[2];
  1572. //uri = "ws://localhost:" + port;
  1573. }
  1574. if(port) {
  1575. return protocol + ':' + host + ':' + port;
  1576. } else {
  1577. return protocol + ':' + host;
  1578. }
  1579. }
  1580.  
  1581. function setIntervalEx(proc, ms) {
  1582. function intervalProc() {
  1583. proc();
  1584. setTimeout(intervalProc, ms);
  1585. }
  1586. setTimeout(intervalProc, ms);
  1587. }
  1588.  
  1589. class DataFrameWriter {
  1590. constructor() {
  1591. this.bytes = [];
  1592. }
  1593.  
  1594. writeUint8(val) {
  1595. this.bytes.push(val);
  1596. }
  1597.  
  1598. writeUint16(val) {
  1599. this.bytes.push(val & 0xFF);
  1600. this.bytes.push(val >> 8 & 0xFF);
  1601. }
  1602.  
  1603. writeUint32(val) {
  1604. this.bytes.push(val & 0xFF);
  1605. this.bytes.push(val >> 8 & 0xFF);
  1606. this.bytes.push(val >> 16 & 0xFF);
  1607. this.bytes.push(val >> 24 & 0xFF);
  1608. }
  1609.  
  1610. // writeString(str){
  1611. // for(var i = 0; i < str.length; i++){
  1612. // this.writeUint16(str.charCodeAt(i));
  1613. // }
  1614. // }
  1615.  
  1616. writeStringEx(str) {
  1617. this.writeUint16(str.length);
  1618. for(var i = 0; i < str.length; i++) {
  1619. this.writeUint16(str.charCodeAt(i));
  1620. }
  1621. }
  1622.  
  1623. // writeCode(s){
  1624. // this.writeUint8(s.charCodeAt(0));
  1625. // }
  1626.  
  1627. getBuffer() {
  1628. return this.bytes;
  1629. }
  1630.  
  1631. getArrayBuffer() {
  1632. return new Uint8Array(this.bytes).buffer;
  1633. }
  1634.  
  1635. // getArrayBuffer(){
  1636. // return new Uint8Array(this.buf).buffer;
  1637. // }
  1638.  
  1639. /*
  1640. getDataView(){
  1641. var ar = getArrayBuffer();
  1642. var view = new DataView(ar.length);
  1643. for(var i = 0; i < len; i++){
  1644.  
  1645. }
  1646. }*/
  1647. }
  1648. class DataFrameReader {
  1649. constructor(buf) {
  1650. this.bytes = buf;
  1651. this.pos = 0;
  1652. }
  1653.  
  1654. readUint8() {
  1655. return this.bytes[this.pos++];
  1656. }
  1657.  
  1658. readUint16() {
  1659. var a = this.readUint8();
  1660. var b = this.readUint8();
  1661. return a | b << 8;
  1662. }
  1663.  
  1664. readSint16() {
  1665. var val = this.readUint16();
  1666. if(val >= 32768) val -= 65536;
  1667. return val;
  1668. }
  1669.  
  1670. readUint32() {
  1671. var a = this.readUint8();
  1672. var b = this.readUint8();
  1673. var c = this.readUint8();
  1674. var d = this.readUint8();
  1675. return d << 24 | c << 16 | b << 8 | a;
  1676. }
  1677.  
  1678. readStringEx() {
  1679. var len = this.readUint16();
  1680. var str = '';
  1681. for(var i = 0; i < len; i++) {
  1682. str += String.fromCharCode(this.readUint16());
  1683. }
  1684. return str;
  1685. }
  1686.  
  1687. // readCode(){
  1688. // var c = readUint8();
  1689. // return String.fromCharCode(c);
  1690. // }
  1691. }
  1692.  
  1693. class ConnectionHub_OgarMap {
  1694. constructor() {
  1695.  
  1696. }
  1697.  
  1698. sendWebSocketData(bytes) {
  1699. var socket = window.webSocket;
  1700. if(socket && socket.readyState == 1) {
  1701. socket.send(new Uint8Array(bytes).buffer);
  1702. }
  1703. }
  1704.  
  1705. setChatListenerProc(proc) {
  1706. this.chatListenerProc = proc;
  1707. }
  1708.  
  1709. setMapListenerProc(proc) {
  1710. this.mapListenerProc = proc;
  1711. }
  1712.  
  1713. setStatsListenerProc(proc) {
  1714. this.statsListenerProc = proc;
  1715. }
  1716.  
  1717. setLeaderboardListenerProc(proc) {
  1718. this.leaderboardListenerProc = proc;
  1719. }
  1720.  
  1721. setTeamRanksListenerProc(proc) {
  1722. this.teamRanksListenerProc = proc;
  1723. }
  1724.  
  1725. checkLatencyAsync(proc) {
  1726. this.latencyCheckResponseProc = proc;
  1727. var fb = new DataFrameWriter();
  1728. fb.writeUint8(130);
  1729. this.sendWebSocketData(fb.getBuffer());
  1730. }
  1731.  
  1732. sendChatMessage(player_id, sender, message) {
  1733. if(utils.CheckValidString(message) && message.length < 80) {
  1734. /*var messageOnExChat = gconfig.useExtendedChatSystem;
  1735. if(!chatAppModel.isAvailable){
  1736. if(
  1737. }
  1738. */
  1739. var msgDist = 0;
  1740. if(gUseChatApp && gconfig.useExtendedChatSystem){
  1741. if(chatAppModel.isAvailable){
  1742. msgDist = 2;
  1743. }else{
  1744. if(gconfig_ex.UseFallbackGameChat){
  1745. msgDist = 1;
  1746. }
  1747. }
  1748. }else{
  1749. msgDist = 1;
  1750. }
  1751.  
  1752. if(msgDist == 2){
  1753. chatAppModel.SendMessageOnGameChatSession(message);
  1754. }else if(msgDist == 1){
  1755. var fb = new DataFrameWriter();
  1756. fb.writeUint8(128); //opcode
  1757. fb.writeUint16(player_id)
  1758. fb.writeStringEx(sender);
  1759. fb.writeStringEx(message);
  1760. this.sendWebSocketData(fb.getBuffer());
  1761. }
  1762. }
  1763. }
  1764.  
  1765. //xdec
  1766. decodeMessage(view) {
  1767.  
  1768. var ar = utils.ByteArrayFromDataView(view);
  1769. var bb = new DataFrameReader(ar);
  1770. var opcode = bb.readUint8();
  1771. switch(opcode) {
  1772. case 41:
  1773. //ãƒŸãƒ‹ãƒžãƒƒãƒ—åº§æ¨™æƒ…å ±
  1774. var mapData = {};
  1775. var n = bb.readUint16();
  1776. for(var i = 0; i < n; i++) {
  1777. var _pid = bb.readUint16();
  1778. var _px = bb.readSint16();
  1779. var _py = bb.readSint16();
  1780. var _mass = bb.readUint16();
  1781.  
  1782. //utils.confirm(_px >= 0);
  1783. //utils.confirm(_py >= 0);
  1784. //this.mapListenerProc(id, px, py, mass, false);
  1785. var data = {
  1786. id: _pid,
  1787. px: _px,
  1788. py: _py,
  1789. mass: _mass
  1790. };
  1791. mapData[_pid] = data;
  1792. }
  1793. this.mapListenerProc(mapData);
  1794. break;
  1795. case 42:
  1796. //ãƒ—ãƒ¬ã‚¤ãƒ¤å‚åŠ æƒ…å ±
  1797. var n = bb.readUint16();
  1798. for(var i = 0; i < n; i++) {
  1799. var cid = bb.readUint16();
  1800. var name = bb.readStringEx();
  1801. var team = bb.readStringEx();
  1802. var skinUrl = bb.readStringEx();
  1803. var isBot = bb.readUint8();
  1804. var teamId = bb.readUint16();
  1805. var token = bb.readStringEx();
  1806. var skinUrl2 = bb.readStringEx();
  1807. //var code = bb.readStringEx();
  1808. //this.skinListenerProc(id, name, team, skinUrl, isBot);
  1809. playerManager.addPlayer(cid, name, team, skinUrl, isBot, teamId, token, skinUrl2); //team, skinUrl, isBot, code);
  1810. }
  1811. break;
  1812. case 43:
  1813. //プレイヤID受信
  1814. var cid = bb.readUint16();
  1815. playerManager.setSelfClientId(cid);
  1816. break;
  1817. case 39:
  1818. //プレイヤ色受信
  1819. var num = bb.readUint16();
  1820. for(var i = 0; i < num; i++) {
  1821. var pid = bb.readUint16();
  1822. var cid = bb.readUint16();
  1823. var r = bb.readUint8();
  1824. var g = bb.readUint8();
  1825. var b = bb.readUint8();
  1826. var skinIndex = bb.readUint8();
  1827. playerCoreManager.setPlayerCoreInfo(pid, cid, r, g, b, skinIndex);
  1828. }
  1829. break;
  1830. case 45:
  1831. //ãƒ—ãƒ¬ã‚¤ãƒ¤é€€å‡ºæƒ…å ±
  1832. var num = bb.readUint16();
  1833. for(var i = 0; i < num; i++) {
  1834. var cid = bb.readUint16();
  1835. playerManager.removePlayer(cid);
  1836. }
  1837. break;
  1838. // case 38:
  1839. // //ãƒãƒ¼ãƒ è‰²æƒ…å ±
  1840. // var num = bb.readUint16();
  1841. // for(var i = 0; i < num; i++){
  1842. // var tag = bb.readStringEx();
  1843. // var col = bb.readStringEx();
  1844. // //var lb = bb.readStringEx();
  1845. // //var map = bb.readStringEx();
  1846. // //var name = bb.readStringEx();
  1847. // //console.log(`${tag} ${lb} ${map} ${name}`);
  1848. // if(tag.startsWith('//')) continue;
  1849. // teamManager.addTeam(tag, col, col, col); //lb, map, name);
  1850. // }
  1851. // break;
  1852. case 47:
  1853. //leaderboard, idのみ
  1854. var num = bb.readUint8();
  1855. var lb = [];
  1856. for(var i = 0; i < num; i++) {
  1857. var _pid = bb.readUint16();
  1858. var _score = bb.readUint32();
  1859. lb.push({ pid: _pid, score: _score });
  1860. }
  1861. this.leaderboardListenerProc(lb);
  1862. break;
  1863. case 46:
  1864. //var serverTotalMass = bb.readUint32();
  1865. var num = bb.readUint8();
  1866. var teamRanks = [];
  1867. for(var i = 0; i < num; i++) {
  1868. //var _tag = bb.readStringEx();
  1869. var id = bb.readUint16();
  1870. //var rate = bb.readFloat32();
  1871. var rate = bb.readUint16() * 0.01; //0.0__100.0
  1872. teamRanks.push({ id, rate }); //tag:_tag, rate:_rate});
  1873. }
  1874. this.teamRanksListenerProc(teamRanks);
  1875. break;
  1876. case 91:
  1877. //サーバステータス
  1878. var s = {};
  1879. s.clients = bb.readUint16();
  1880. s.players = bb.readUint16();
  1881. s.bots = bb.readUint16();
  1882. s.spectators = bb.readUint16();
  1883. s.max_clients = bb.readUint16();
  1884. s.gamemode = bb.readStringEx();
  1885. s.start_time = bb.readUint32();
  1886. this.statsListenerProc(s);
  1887. break;
  1888. case 128:
  1889. //チャットメッセージを受信
  1890. //console.log("chat message received");
  1891. var cid = bb.readUint16();
  1892. var sender = bb.readStringEx();
  1893. var message = bb.readStringEx();
  1894. this.chatListenerProc(cid, sender, message);
  1895. break;
  1896. /*
  1897. case 129:
  1898. //ä»–ã®ãƒ—ãƒ¬ã‚¤ãƒ¤ã®åº§æ¨™æƒ…å ±ã‚’å—ä¿¡
  1899. //deprecated
  1900. var player_id = bb.readStringEx();
  1901. var name = bb.readStringEx();
  1902. var x = bb.readUint16();
  1903. var y = bb.readUint16();
  1904. var mass = bb.readUint16();
  1905. var dead = bb.readUint8() == 1;
  1906. //this.mapListenerProc(player_id, name, x, y, mass, dead);
  1907. break;
  1908. case 130:
  1909. //他のプレイヤのスキンURLを受信
  1910. //var player_id = bb.readUint32();
  1911. //var live_id = bb.readStringEx();
  1912. var player_id = bb.readStringEx();
  1913. var name = bb.readStringEx();
  1914. var skin_url = bb.readStringEx();
  1915. var respond_req = opcode == 130;
  1916. //this.skinListenerProc(player_id, name, skin_url);
  1917. break;
  1918. case 132:
  1919. //他のプレイヤからのスキン要求
  1920. this.skinRequestedProc();
  1921. break;
  1922. */
  1923. case 133:
  1924. //サーバからのデバッグメッセージ
  1925. var message = bb.readStringEx();
  1926. console.log(message);
  1927. break;
  1928. case 36:
  1929. //ãƒãƒ¼ãƒ è‰²æƒ…å ±è¿½åŠ
  1930. var num = bb.readUint16();
  1931. for(var i = 0; i < num; i++) {
  1932. var id = bb.readUint16();
  1933. var teamName = bb.readStringEx();
  1934. //var code = bb.readStringEx();
  1935. var col = bb.readStringEx();
  1936. //console.log(`${tag} ${lb} ${map} ${name}`);
  1937. //if(tag.startsWith('//')) continue;
  1938. var section = bb.readStringEx();
  1939. teamManager.addTeam(id, teamName, col, section); //tag, col, col, col); //lb, map, name);
  1940. }
  1941. break;
  1942. case 35:
  1943. //ãƒãƒ¼ãƒ è‰²æƒ…å ±å‰Šé™¤
  1944. var num = bb.readUint16();
  1945. for(var i = 0; i < num; i++) {
  1946. var id = bb.readUint16();
  1947. teamManager.removeTeam(id);
  1948. }
  1949. break;
  1950. case 200:
  1951. //クライアント設定JSON受信
  1952. var str = bb.readStringEx();
  1953. var obj = JSON.parse(str);
  1954. Object.keys(obj).forEach(k => {
  1955. if(gconfig.hasOwnProperty(k)) {
  1956. gconfig[k] = obj[k];
  1957. }
  1958. });
  1959.  
  1960. gConfigChangedHandlerProc();
  1961.  
  1962. break;
  1963. case 201:
  1964. //サーバ説明テキスト受信
  1965. var str = bb.readStringEx();
  1966.  
  1967. //禁止タグをdivに置き換える
  1968. str = str.replace(/script>/g, 'div>').replace(/object>/g, 'div>').replace(/media>/g, 'div>');
  1969. var badTags = ['script', 'object', 'media', 'iframe', 'embed'];
  1970. badTags.forEach(tag => {
  1971. var reg = new RegExp(`${tag}>/g`);
  1972. str = str.replace(reg, 'div>');
  1973. });
  1974. //javascriptを実行するイベントを排除
  1975. str = str.replace(/([Oo][Nn].*)\s?\=\s?\"(.*)\"/g, '__$1__ = "$2"');
  1976. //console.log(str);
  1977. $('#server_instruction_text').html(str); //str.replace(/\r?\n/g, '<br>'));
  1978. break;
  1979. //case 34:
  1980.  
  1981. //break;
  1982. case 131:
  1983. if(this.latencyCheckResponseProc) {
  1984. this.latencyCheckResponseProc();
  1985. }
  1986. break;
  1987. case 202:
  1988. //サーバディスプレイメッセージ受信
  1989. var str = bb.readStringEx();
  1990. $('#server_message_box').html(str);
  1991. break;
  1992. case 29:
  1993. // myApp.onDead();
  1994. // console.log('29-onDead');
  1995. // $("#overlays").show();
  1996. // $("#stats").show();
  1997. break;
  1998. case 15:
  1999. //active turn player id
  2000. var pid = bb.readUint16();
  2001. gActiveTurnPlayerId = pid;
  2002. break;
  2003. case 203:
  2004. var str = bb.readStringEx();
  2005. $("#server_debug_status_texts_box").html(str.replace(/\r\n/g, "<br />\r\n"));
  2006. break;
  2007. ;
  2008. }
  2009. }
  2010. }
  2011.  
  2012. var MapDrawingInterval = 33; //ms
  2013. var MapDataInterval = 1000; //ms
  2014. class MapNode {
  2015. constructor(pid) {
  2016. this.pid = pid;
  2017. this.name = '';
  2018. this.team = '';
  2019. this.mass = 200;
  2020. this.tick = 0;
  2021.  
  2022. this.xpos = 0;
  2023. this.ypos = 0;
  2024. this.xpos1 = 0;
  2025. this.ypos1 = 0;
  2026. //this.frame = 0;
  2027. //this.dead = false;
  2028. this.first = true;
  2029.  
  2030. this.active = true;
  2031. }
  2032.  
  2033. handleMapData(name, team, mass, xpos, ypos) {
  2034. this.name = name;
  2035. this.team = team;
  2036. this.mass = mass;
  2037. this.xpos1 = xpos;
  2038. this.ypos1 = ypos;
  2039. if(this.first) {
  2040. this.xpos = xpos;
  2041. this.ypos = ypos;
  2042. this.first = false;
  2043. }
  2044. this.active = true;
  2045. //this.tick = 0;
  2046. //this.frame = 0;
  2047. }
  2048.  
  2049. updateInFrame() {
  2050. //this.tick++;
  2051. //this.frame++;
  2052. var D = 0.96;
  2053. this.xpos = nums.easyFilter(this.xpos, this.xpos1, D);
  2054. this.ypos = nums.easyFilter(this.ypos, this.ypos1, D);
  2055. }
  2056.  
  2057. }
  2058.  
  2059. class Minimap2 {
  2060. constructor(sz) {
  2061. this.mapNodesDict = {};
  2062.  
  2063. $('body')['append']("<canvas id='minimapNode'>");
  2064. $('body')['append']("<canvas id='minimap' >");
  2065. var canvas = document.getElementById('minimap');
  2066. var ctx = canvas.getContext('2d');
  2067. canvas.width = sz;
  2068. canvas.height = sz;
  2069. ctx.scale(1, 1);
  2070. ctx.strokeStyle = '#333';
  2071. ctx.fillStyle = '#000000';
  2072. ctx.globalAlpha = 0.5;
  2073. ctx.lineWidth = 2;
  2074. ctx.strokeRect(0, 0, canvas.width, canvas.height);
  2075. ctx.fillRect(0, 0, canvas.width, canvas.height);
  2076. ctx.textAlign = 'center';
  2077. ctx.textBaseline = 'middle';
  2078. ctx.globalAlpha = 0.2;
  2079. ctx.font = '18px Verdana';
  2080. ctx.fillStyle = '#FFFFFF';
  2081. var width = canvas.width;
  2082. var height = canvas.height;
  2083. var csz = sz / 5 / 2;
  2084. for(var i = 0; i < 25; i++) {
  2085. var ix = parseInt(i / 5);
  2086. var iy = i % 5;
  2087. var label = String.fromCharCode('A'.charCodeAt(0) + iy) + (ix + 1);
  2088. ctx.fillText(label, csz * (ix * 2 + 1), csz * (iy * 2 + 1));
  2089. }
  2090. var canvas2 = document.getElementById('minimapNode');
  2091. ctx = canvas2.getContext('2d');
  2092. canvas2.width = sz;
  2093. canvas2.height = sz;
  2094. ctx.globalAlpha = 1;
  2095. ctx.scale(1, 1);
  2096. ctx.textAlign = 'center';
  2097. ctx.textBaseline = 'middle';
  2098. ctx.font = 'bold 12px Ubuntu';
  2099. this.hide();
  2100.  
  2101. this.canvas = canvas;
  2102. this.canvas2 = canvas2;
  2103. this.ctx = ctx;
  2104.  
  2105. this.playerActive = false;
  2106. }
  2107.  
  2108. start() {
  2109. //var self = this;
  2110. /*
  2111. setIntervalEx(function(){
  2112. self.drawNodes();
  2113. self.updateNodesInFrame();
  2114. }, MapDrawingInterval);
  2115. */
  2116. setIntervalEx(this.updateFrame.bind(this), MapDrawingInterval);
  2117. //setIntervalEx(this.uploadSelfPosition.bind(this), MapDataInterval);
  2118.  
  2119. /*
  2120. function minimapDrawTimerProc() {
  2121. self.drawNodes();
  2122. self.updateNodesInFrame();
  2123. setTimeout(minimapDrawTimerProc, MapDrawingInterval);
  2124. }
  2125. minimapDrawTimerProc();
  2126.  
  2127. function uploadSelfPositionTimerProc() {
  2128. self.uploadSelfPosition();
  2129. setTimeout(uploadSelfPositionTimerProc, MapDataInterval); //1E3)
  2130. }
  2131. uploadSelfPositionTimerProc();
  2132. */
  2133. }
  2134.  
  2135. updateFrame() {
  2136. this.drawNodes();
  2137. this.updateNodesInFrame();
  2138. }
  2139.  
  2140. updateNodesInFrame() {
  2141. //var delKeys = [];
  2142. for(var pid in this.mapNodesDict) {
  2143. var node = this.mapNodesDict[pid];
  2144. node.updateInFrame();
  2145. // node.tick++;
  2146. // node.frame++;
  2147. // var D = 0.96;
  2148. // node.xpos0 = nums.easyFilter(node.xpos0, node.xpos1, D);
  2149. // node.ypos0 = nums.easyFilter(node.ypos0, node.ypos1, D);
  2150. /*
  2151. if(node.tick > 80) {
  2152. node.dead = true;
  2153. }
  2154.  
  2155. if(node.dead){
  2156. // //console.log('teammate connection broken');
  2157. //var deleted =
  2158. delete this.mapNodesDict[k];
  2159. //console.log(deleted);
  2160. //delKeys.push(k);
  2161. }
  2162. */
  2163. }
  2164. /*
  2165. for(var i in delKeys){
  2166. var key = delKeys[i];
  2167. delete this.mapNodes[key];
  2168. }*/
  2169.  
  2170. //this.mapNodesDict = this.mapNodesDict.filter(function(x){ return !x.dead});
  2171. }
  2172.  
  2173. /*
  2174. posToShortVal(a) {
  2175. var D = 14142.0 / 2;
  2176. return parseInt(utils.vmap(a, -D, D, 0, 65535));
  2177. }
  2178.  
  2179. posFromShortVal(a) {
  2180. var D = 14142.0 / 2;
  2181. return utils.vmap(a, 0, 65535, -D, D)
  2182. }
  2183.  
  2184. uploadSelfPosition() {
  2185. var dying = this.playerActive && !gIsPlaying;
  2186. this.playerActive = gIsPlaying;
  2187. //if(dying) console.log('dying');
  2188.  
  2189. if(this.playerActive || dying){
  2190. //console.log(gPlayerSignature); //'up');
  2191. var mass = gSelfMass;
  2192. //var id = gLocalPlayerIdPerConnection;
  2193. var id = gPlayerSignature;
  2194. var name = myApp.getNameEx();
  2195. var cx = getCurrentX();
  2196. var cy = getCurrentY();
  2197. if(cx != 0 && cy != 0) {
  2198. var xpos = this.posToShortVal(cx);
  2199. var ypos = this.posToShortVal(cy);
  2200. //trace(getCurrentX() + ',' + getCurrentY());
  2201. //trace(xpos + ',' + ypos);
  2202. conn2.sendCoord(id, name, xpos, ypos, mass, dying);
  2203. }
  2204. //}
  2205. }
  2206. }
  2207. */
  2208.  
  2209. removeNode(pid) {
  2210. this.mapNodeDict[pid];
  2211. }
  2212.  
  2213. updateNode(mapData) {
  2214. function filterArrayElements(src, sub) {
  2215. return src.filter(function(x) { return !sub.includes(x) });
  2216. }
  2217. var mapNodesDict = this.mapNodesDict;
  2218. var prevIds = Object.getOwnPropertyNames(mapNodesDict);
  2219. var nextIds = Object.getOwnPropertyNames(mapData);
  2220. var addIds = filterArrayElements(nextIds, prevIds);
  2221. var removeIds = filterArrayElements(prevIds, nextIds);
  2222. addIds.forEach(function(pid) {
  2223. if(!mapNodesDict[pid]) {
  2224. mapNodesDict[pid] = new MapNode(pid);
  2225. }
  2226. //mapNodesDict[id].active = true;
  2227. //console.log(`map data for ${id} generated`);
  2228. });
  2229. removeIds.forEach(function(pid) {
  2230. if(mapNodesDict[pid]) {
  2231. //mapNodeDict[id].Disactive();
  2232. mapNodesDict[pid].active = false;
  2233. }
  2234. //delete mapNodesDict[id];
  2235. //playerManager.removePlayer(id);
  2236. //console.log(`map data for ${id} removed`);
  2237. });
  2238. nextIds.forEach(function(pid) {
  2239. var d = mapData[pid];
  2240. var cid = playerCoreManager.getCid(pid);
  2241. var name = playerManager.getName(cid);
  2242. var team = playerManager.getTeam(cid);
  2243. var xpos = d.px;// - FieldSizeHalf;
  2244. var ypos = d.py;// - FieldSizeHalf;
  2245. var mass = d.mass;
  2246. mapNodesDict[pid].handleMapData(name, team, mass, xpos, ypos);
  2247. //console.log(`map pos for ${id}: ${xpos} ${ypos}`);
  2248. });
  2249. }
  2250.  
  2251. /*
  2252. updateNodeOne(id, _xpos, _ypos, mass, dead) {
  2253.  
  2254. if(dead){
  2255. if(this.mapNodesDict[id]){
  2256. delete this.mapNodesDict[id];
  2257. console.log('teammate died');
  2258. return;
  2259. }
  2260. }
  2261.  
  2262. //var newXpos = this.posFromShortVal(_xpos);
  2263. //var newYpos = this.posFromShortVal(_ypos);
  2264. var newXpos = _xpos - FieldSizeHalf;
  2265. var newYpos = _ypos - FieldSizeHalf;
  2266.  
  2267. if(!this.mapNodesDict[id] && !dead) {
  2268. this.mapNodesDict[id] = new MapNode(id, '', '', newXpos, newYpos);
  2269. }
  2270.  
  2271. var node = this.mapNodesDict[id];
  2272. var info = gPlayerInfoDict[id];
  2273. if(info){
  2274. node.name = info.name;
  2275. node.team = info.team;
  2276. }
  2277.  
  2278. //node.name = name;
  2279. //node.xpos0 = node.xpos1;
  2280. //node.ypos0 = node.ypos1;
  2281. node.xpos1 = newXpos;
  2282. node.ypos1 = newYpos;
  2283. node.mass = mass;
  2284. node.tick = 0;
  2285. node.frame = 0;
  2286. node.dead = dead;
  2287. }
  2288. */
  2289.  
  2290. drawNodes() {
  2291. var ctx = this.ctx;
  2292. var canvas2 = this.canvas2;
  2293. ctx.save();
  2294. ctx.clearRect(0, 0, canvas2.width, canvas2.height);
  2295.  
  2296. //è¦–ç•Œé ˜åŸŸçŸ©å½¢è¡¨ç¤º
  2297. {
  2298. var D = gSiteArea.field_sz;
  2299. var px = utils.scale(gSiteArea.x, D, canvas2.width);
  2300. var py = utils.scale(gSiteArea.y, D, canvas2.height);
  2301. var xd = gSiteArea.scw / gSiteArea.scale;
  2302. var yd = gSiteArea.sch / gSiteArea.scale;
  2303. var xdr = utils.scale(xd, D, canvas2.width) / 2;
  2304. var ydr = utils.scale(yd, D, canvas2.height) / 2;
  2305. ctx.fillStyle = utils.makeColor(0x1FFF);
  2306. ctx.beginPath();
  2307. ctx.rect(px - xdr, py - ydr, xdr * 2, ydr * 2);
  2308. ctx.fill();
  2309. }
  2310.  
  2311. for(var i in this.mapNodesDict) {
  2312. var node = this.mapNodesDict[i];
  2313. if(!node.active) continue;
  2314.  
  2315. var cid = playerCoreManager.getCid(node.pid);
  2316. var isTeammate = playerManager.checkIsTeammate(cid)
  2317. var isBot = playerManager.checkIsBot(cid);
  2318.  
  2319. var shown = !gconfig.enableTeamMapSeparation;
  2320. shown |= gconfig.enableTeamMapSeparation && isTeammate && !isBot;
  2321. shown |= gconfig.enableAllMapShownWhileSpectating && gIsSpectate;
  2322. shown |= gconfig.showBotsAllwaysInMap && isBot;
  2323. if(!shown) continue;
  2324.  
  2325. var mass = node.mass;
  2326. //if(mass == 0) continue;
  2327.  
  2328. var isSelf = playerManager.getSelfClientId() == cid; //node.id;
  2329.  
  2330.  
  2331. var fullName = playerManager.getFullName(cid); //node.id); // node.team + node.name;
  2332.  
  2333. if(isBot || isSelf) fullName = '';
  2334.  
  2335. //var col = utils.makeColor(0xF00);
  2336. //var col = 'rgba(160, 160, 160, 0.8)';
  2337. //var txt_col = 'rgba(192, 192, 192, 1)';
  2338. //var col = 'rgba(255, 255, 255, 0.8)';
  2339. //var txt_col = 'rgba(255, 255, 255, 1)';
  2340.  
  2341. //var col = utils.makeColor(0xCFFF);
  2342. //var txt_col = utils.makeColor(0xCFFF);
  2343. var teamId = playerManager.getTeamId(cid); ///node.id);
  2344. var col = teamManager.getColor(teamId);
  2345.  
  2346. if(gIsPlaying && gconfig.useCommonMapColorWhilePlaying && !isBot) {
  2347. col = "#FFFFFF";
  2348. }
  2349.  
  2350. var txt_col = col;
  2351.  
  2352. // if(fullName.startsWith('【先輩】')) {
  2353. // col = 'rgba(0,160,255,0.8)';
  2354. // txt_col = 'rgba(160, 192, 255, 1)';
  2355. // }
  2356.  
  2357. // if(fullName.startsWith('【敵】')) {
  2358. // col = 'rgba(255,0,128,0.8)';
  2359. // txt_col = 'rgba(255, 160, 192, 1)';
  2360. // }
  2361. var D = gSiteArea.field_sz;// / 2; // 14142.0 / 2;
  2362. var sc = D / 14142;
  2363. var radius = Math.sqrt(mass * 100) * 0.011 / sc;
  2364. if(radius < 3) radius = 3;
  2365.  
  2366. if(!gconfig.showPlayerMassInMap) radius = 4;
  2367.  
  2368.  
  2369. var frameMax = parseInt(MapDataInterval / MapDrawingInterval);
  2370. //var xpos = utils.vmap(node.frame, 0, frameMax, node.xpos0, node.xpos1);
  2371. //var ypos = utils.vmap(node.frame, 0, frameMax, node.ypos0, node.ypos1);
  2372. var xpos = node.xpos;
  2373. var ypos = node.ypos;
  2374. var px = utils.vmap(xpos, 0, D, 0, canvas2.width);
  2375. var py = utils.vmap(ypos, 0, D, 0, canvas2.height);
  2376. ctx.font = '12px メイリオ, arial';
  2377. ctx.font
  2378. ctx.fillStyle = col;
  2379. ctx.globalAlpha = 0.8;
  2380. ctx.beginPath();
  2381. ctx.arc(px, py, radius, 0, 2 * Math.PI, false);
  2382. ctx.strokeStyle = 'rgba(51,51,51,0.5)';
  2383. ctx.lineWidth = 1;
  2384. ctx.fill();
  2385. ctx.stroke();
  2386.  
  2387. ctx.fillStyle = txt_col;
  2388. //ctx.globalAlpha = 1.0;
  2389. ctx.fillText(fullName, px, py - 10);
  2390.  
  2391. if(isSelf) {
  2392. //ring
  2393. ctx.strokeStyle = "#FFFF00";
  2394. ctx.lineWidth = 1;
  2395. ctx.beginPath();
  2396. ctx.arc(px, py, radius + 4, 0, 2 * Math.PI, false);
  2397. ctx.stroke();
  2398. //cross line
  2399. var w = canvas2.width;
  2400. var h = canvas2.height;
  2401. ctx.strokeStyle = utils.makeColor(0x4888);
  2402. ctx.beginPath();
  2403. ctx.moveTo(px, 0);
  2404. ctx.lineTo(px, h);
  2405. ctx.stroke();
  2406. ctx.beginPath();
  2407. ctx.moveTo(0, py);
  2408. ctx.lineTo(w, py);
  2409. ctx.stroke();
  2410. }
  2411. }
  2412.  
  2413. ctx.restore();
  2414. }
  2415.  
  2416. hide() {
  2417. $('#minimap')['hide']();
  2418. $('#minimapNode')['hide']()
  2419. }
  2420.  
  2421. show() {
  2422. $('#minimap')['show']();
  2423. $('#minimapNode')['show']()
  2424. }
  2425.  
  2426. setDeadPosition(va) {
  2427. //vn = va ? va : {}
  2428. }
  2429. }
  2430.  
  2431. conn2 = new ConnectionHub_OgarMap();
  2432.  
  2433. //チャット表示, 150
  2434. function ChatRoom() {
  2435. this.container = '';
  2436. this.isShow = 1;
  2437. this.lastMsg = '';
  2438. this.width = 340;
  2439. this.height = 350;
  2440. var va = this,
  2441. vb = 0;
  2442.  
  2443. this.createChatBox = function() {
  2444.  
  2445. $(this.container)['append']("<div id='chatroom'></div>");
  2446. $('#overlays2')['append']("<div id='chatboxArea2'><input id='input_box2' type='text'></input></div>");
  2447. this.hide();
  2448. $('#chatboxArea2')['hide']();
  2449. $('#chatroom')['mouseup'](function() {
  2450. va.resize()
  2451. })
  2452. };
  2453. va.resize = function() {
  2454. ($('#chatroom')['width']() != this.width || $('#chatroom')['height']() != this.height) && $('#chatroom')['perfectScrollbar'] && $('#chatroom')['perfectScrollbar']('update')
  2455. };
  2456. this.setContainer = function(va) {
  2457. this.container = va
  2458. };
  2459.  
  2460. //メッセージを送信
  2461. this.sendMessage = function(str) {
  2462. var cid = playerManager.getSelfClientId();
  2463. conn2.sendChatMessage(cid, myApp.getNameEx(), str);
  2464. };
  2465.  
  2466. /*
  2467. this.decodeMessage = function(view) {
  2468. //console.log("chat message received");
  2469. var ar = Utils.ByteArrayFromDataView(view);
  2470. var bb = new DataFrameReader(ar);
  2471. bb.readUint8(); //opcode
  2472. var sender = bb.readStringEx();
  2473. var message = bb.readStringEx();
  2474. this.receiveMessage(sender, message);
  2475. };
  2476. */
  2477.  
  2478. this.enter = function() {
  2479. this.isFocus() ? (this.sendMessage($('#input_box2')['val']()), $('#input_box2')['val'](''), $('#input_box2')['blur'](), $('#chatboxArea2')['hide']()) : this.focus()
  2480. };
  2481. this.popup = function(va) {
  2482. myApp.isEnableChatpopup && !this.isShow && ($['toast'] ? $['toast'](va) : toastQueue.push(va))
  2483. };
  2484. this.popupInfo = function(va) {
  2485. this.popup({
  2486. text: escapeHtml(va),
  2487. showHideTransition: 'slide',
  2488. icon: 'info',
  2489. bgColor: 'rgba(10, 10, 10, 0.8)',
  2490. allowToastClose: 0,
  2491. hideAfter: 15E3,
  2492. stack: 10
  2493. })
  2494. };
  2495. this.popupWarning = function(va) {
  2496. this.popup({
  2497. text: escapeHtml(va),
  2498. showHideTransition: 'slide',
  2499. icon: 'warning',
  2500. bgColor: 'rgba(10, 10, 10, 0.8)',
  2501. allowToastClose: 0,
  2502. hideAfter: 15E3,
  2503. stack: 10
  2504. })
  2505. };
  2506. this.popupChat = function(va, vb) {
  2507. var vh = escapeHtml(va),
  2508. vd = this.replaceHKGIcon(escapeHtml(vb));
  2509. '荳咲蕗蜷・[slick]' == va && (vh = this.replaceHKGIcon(vh));
  2510. this.popup({
  2511. heading: '<span class="toast_sender">' + vh + ': </span>',
  2512. text: '<span class="toast_chatmsg">' + vd + '</span>',
  2513. showHideTransition: 'fade',
  2514. bgColor: 'rgba(10, 10, 10, 0.8)',
  2515. allowToastClose: 0,
  2516. hideAfter: 15E3,
  2517. stack: 10
  2518. })
  2519. };
  2520. this.showSystemMessage = function(va) {
  2521. this.showSystemMessageImpl(va);
  2522. this.popupInfo(va)
  2523. };
  2524. this.showSystemWarning = function(va) {
  2525. this.showSystemMessageImpl(va);
  2526. this.popupWarning(va)
  2527. };
  2528. this.showSystemMessageImpl = function(va) {
  2529. myApp.showSystemMessage() && ($('#chatroom')['append']($('<div/>')['append']($("<span class='system'/>")['text'](this.getTimeStr() + va))), this.scrollDown())
  2530. };
  2531.  
  2532. this.clearMessages = function(){
  2533. $('#chatroom').html('');
  2534. }
  2535. this.getTimeStr = function() {
  2536. var va = new Date,
  2537. vb = va.getMinutes(),
  2538. vb = 10 > vb ? '0' + vb : vb;
  2539. return va.getHours() + ':' + vb + ' '
  2540. };
  2541.  
  2542.  
  2543.  
  2544. //メッセージを受信したときのハンドラ
  2545. this.receiveMessage = function(cid, sender_name, message) {
  2546. //console.log('chat_ ' + player_id);
  2547. if(gconfig.enableTeamChatSeparation && !playerManager.checkIsTeammate(cid) && cid !== 0) return;
  2548.  
  2549. var sender_name2 = playerManager.getFullName(cid);
  2550.  
  2551. if(gconfig.addUserTokenToChatSenderName) {
  2552. var userToken = playerManager.getUserToken(cid);
  2553. sender_name2 = `${sender_name2} (${userToken})`;
  2554. }
  2555. this.receiveMessageCore(sender_name2, message)
  2556.  
  2557. };
  2558.  
  2559. this.receiveMessageCore = function(name, message) {
  2560. var vh = $('<div/>'),
  2561. vd = $("<span class='time'>")['text'](this.getTimeStr()),
  2562. ve = $("<span class='sender'>")['text'](name + ' : ');
  2563. '荳咲蕗蜷・[slick]' == name && ve.html(this.replaceHKGIcon(ve.html()));
  2564. vh.append(vd);
  2565. vh.append(ve);
  2566. vd = $("<span class='msg'>")['text'](message);
  2567. vd.html(this.replaceHKGIcon(vd.html()));
  2568. vh.append(vd);
  2569. $('#chatroom')['append'](vh);
  2570. this.scrollDown();
  2571. this.popupChat(name, message);
  2572. }
  2573.  
  2574.  
  2575. /*
  2576. //メッセージを受信したときのハンドラ
  2577. this.receiveMessage = function(cid, sender_name, message) {
  2578. //console.log('chat_ ' + player_id);
  2579. if(gconfig.enableTeamChatSeparation && !playerManager.checkIsTeammate(cid) && cid !== 0) return;
  2580.  
  2581. var sender_name2 = playerManager.getFullName(cid);
  2582.  
  2583. if(gconfig.addUserTokenToChatSenderName) {
  2584. var userToken = playerManager.getUserToken(cid);
  2585. sender_name2 = `${sender_name2} (${userToken})`;
  2586. }
  2587.  
  2588. var vh = $('<div/>'),
  2589. vd = $("<span class='time'>")['text'](this.getTimeStr()),
  2590. ve = $("<span class='sender'>")['text'](sender_name2 + ' : ');
  2591. '荳咲蕗蜷・[slick]' == sender_name2 && ve.html(this.replaceHKGIcon(ve.html()));
  2592. vh.append(vd);
  2593. vh.append(ve);
  2594. vd = $("<span class='msg'>")['text'](message);
  2595. vd.html(this.replaceHKGIcon(vd.html()));
  2596. vh.append(vd);
  2597. $('#chatroom')['append'](vh);
  2598. this.scrollDown();
  2599. this.popupChat(sender_name2, message)
  2600. };
  2601. */
  2602.  
  2603. this.replaceHKGIcon = function(va) {
  2604. for(var vb in hkgIcon) {
  2605. va = va.replace(new RegExp(escapeRegex(vb), 'g'), '<img alt="$1" src="' + hkgIcon[vb] + '">')
  2606. };
  2607. for(var vh = $('img[alt="$1"]'), vd = 0; vd < vh.length; vd++) {
  2608. for(vb in hkgIcon) {
  2609. if(vh[vd]['src'] == hkgIcon[vb]) {
  2610. $(vh[vd])['attr']('alt', vb);
  2611. break
  2612. }
  2613. }
  2614. };
  2615. return va
  2616. };
  2617. this.scrollDown = function() {
  2618. $('#chatroom')['perfectScrollbar'] && ($('#chatroom')['scrollTop']($('#chatroom')['prop']('scrollHeight')), $('#chatroom')['perfectScrollbar']('update'))
  2619. };
  2620. this.show = function() {
  2621. $('#chatroom')['show']();
  2622. this.isShow = 1;
  2623. this.scrollDown()
  2624. };
  2625. this.hide = function() {
  2626. $('#chatroom')['hide']();
  2627. this.isShow = 0
  2628. };
  2629. this.isFocus = function() {
  2630. return $('#input_box2')['is'](':focus')
  2631. };
  2632. this.focus = function() {
  2633. $('#chatboxArea2')['show']();
  2634. $('#input_box2')['focus']()
  2635. };
  2636. this.createScrollBar = function() {
  2637. $('#chatroom')['perfectScrollbar']({
  2638. minScrollbarLength: 50,
  2639. suppressScrollX: 0
  2640. })
  2641. }
  2642. }
  2643.  
  2644. //アプリケーション本体, 1200
  2645. function MyApp() {
  2646.  
  2647. //console.log("SAO_160518_A100");
  2648.  
  2649.  
  2650. function onNicknameChanged() {
  2651. $('#nick')['val'](myApp.getName());
  2652. if(nodeList[0][1] == myApp.getName()) {
  2653. return 0
  2654. };
  2655. nodeList[0][1] = myApp.getName();
  2656. setLocalStorage('nick', $('#nick')['val']());
  2657. player_profile[selected_profile_index]['name'] = myApp.getName();
  2658. storePlayerProfile();
  2659. return 1
  2660. }
  2661.  
  2662. function onTreamNameChanged() {
  2663. var teamName = myApp.getTeamName();
  2664. $('#team_name')['val'](teamName);
  2665. if(tmpTeamname == teamName) {
  2666. return 0
  2667. };
  2668. nodeList[0][15] = teamName;
  2669. setLocalStorage('opt_teamname', teamName);
  2670. player_profile[selected_profile_index]['team'] = teamName;
  2671. storePlayerProfile();
  2672. return 1;
  2673. }
  2674.  
  2675. function onPartyCodeChanged() {
  2676. var token = $('.partyToken').val();
  2677. setLocalStorage('partycode', token);
  2678. player_profile[selected_profile_index]['partycode'] = token;
  2679. storePlayerProfile();
  2680. }
  2681.  
  2682. function loadCurrentProfile() {
  2683. setLocalStorage('selected_profile', selected_profile_index);
  2684. tmpTeamname = myApp.getTeamName();
  2685. $('#nick')['val'](player_profile[selected_profile_index]['name']);
  2686. $('#team_name')['val'](player_profile[selected_profile_index]['team']);
  2687. $('#skin_url')['val'](player_profile[selected_profile_index]['skinurl'])['trigger']('change');
  2688. $('#skin_url2')['val'](player_profile[selected_profile_index]['skinurl2'])['trigger']('change');
  2689. var code = player_profile[selected_profile_index]['partycode'];
  2690. $('.partyToken').val(code);
  2691. onTreamNameChanged() ? (nodeList[0][1] = myApp.getName(), setLocalStorage('nick', myApp.getName())) : onNicknameChanged()
  2692. onPartyCodeChanged();
  2693. }
  2694.  
  2695. function storePlayerProfile() {
  2696. setLocalStorage('player_profile', player_profile)
  2697. }
  2698. this.version = 'v_2.0.0';
  2699. var vh = 0.88;
  2700. this.getZoomSpeed = function() {
  2701. return vh
  2702. };
  2703. this.getZoomLimit = function() {
  2704. return 0.05
  2705. };
  2706. this.isEnableHideFood = this.isEnableGridline = this.isEnableBorder = this.isEnableMapGrid = this.isEnableCursorLine = this.isEnableZoom = this.isStopMovement = this.isShowBallTotal = this.isShowSTE = this.isShowScroll = 0;
  2707. this.isEnableShowAllMass = 1;
  2708. this.isEnableSimpleDrawing = 0;
  2709. this.isEnableAutoStart = 1;
  2710. this.isEnableMouseW = 0;
  2711. this.isEnableLockZoom = this.isEnableCustomSkin = 1;
  2712. this.isEnableAttackRange = 0;
  2713. this.isEnableTeammateIndicator = 1;
  2714. this.isEnableChatpopup = 0;
  2715. this.attackRangeRadius = 655;
  2716. this.cellColor = '';
  2717. this.cellColorAry = 'red #76FF03 blue yellow #8207ff #2196F3 '['split'](' ');
  2718. this.doubleSpace = this.quickSpace = this.autoW = 0;
  2719. this.doubleSpaceCount = this.quickSpaceCount = 0;
  2720. this.lockZoomG;
  2721. this.teammateIndicatorPosition = 40;
  2722. this.teammateIndicatorSize = 50;
  2723. this.teammateIndicatorShowSize = 200;
  2724. this.teammateIndicator;
  2725. this.specTeammate;
  2726. this.isSpecTeammate = 0;
  2727. this.massTextSize = 0.8;
  2728. this.isSpectating = 0;
  2729. this.isSameColorFood = 1;
  2730. this.isEnableSplitInd = this.isShowTextStrokeLine = this.isAutoHideName = this.isAutoHideMass = this.isShowFPS = this.isTransparentCell = 0;
  2731. //this.isEnableOtherSkinSupport = 1;
  2732. this.isEnableOtherSkinSupport = 0;
  2733. this.isShowPacketIO = this.isEnableShareFb = this.isEnableSound = this.isHideSelfName = this.testing = 0;
  2734.  
  2735. this.isHideSelfName = 0;
  2736.  
  2737. this.isEnableMouseControl = 0;
  2738. this.swapMouseButtonsLR = 0;
  2739. this.showChatAtBottom = 0;
  2740. //this.showCenterCrosshair = 0;
  2741. this.showSplitOrderMarker = 0;
  2742. this.showCursorCrosshair = 0;
  2743. this.showActiveTurnMarker = 0;
  2744. this.emphasisCursorLine = 0;
  2745. //init
  2746. this.init = function() {
  2747.  
  2748. //$('body')['append']("<canvas id='canvas'>");
  2749. //$('body')['append']('<link id="favicon" rel="icon" type="image/png">');
  2750. //$('body')['append']("<div id = 'overlays2'></div>");
  2751.  
  2752.  
  2753. //$('#overlays2')['append']("<div id = 'div_lb'><div class='header' id='lb_caption'>" + 'leaderboard' + "</div></div>");
  2754. //$('#div_lb')['append']("<div id='lb_detail'></div>");
  2755.  
  2756. //$('#overlays2')['append']("<div id = 'div_lb2'><div class='header'>" + 'team ranks' + "</div></div>");
  2757. //$('#div_lb2')['append']("<div id='lb_detail2'></div>");
  2758.  
  2759. //$('#overlays2')['append']("<div id = 'div_score'></div>");
  2760. //$('#overlays2')['append']("<div id = 'pinfo'></div>");
  2761.  
  2762. var va = document.getElementById('canvas');
  2763. va.getContext('2d');
  2764.  
  2765. va.mozOpaque = 1;
  2766.  
  2767. if(navigator.userAgent.indexOf('Firefox') >= 0){
  2768. //firefoxではcanvasãŒé€éŽã›ãšãƒ†ãƒ¼ãƒžã®èƒŒæ™¯è‰²ãŒåæ˜ ã•ã‚Œãªã„å•é¡ŒãŒã‚ã‚‹ãŸã‚ã€mozOpaqueを指定しない
  2769. va.mozOpaque = 0;
  2770. }
  2771. window.setLocalStorage = function(va, vb) {
  2772. 'string' == typeof vb ? localStorage.setItem(va, vb) : localStorage.setItem(va, JSON.stringify(vb))
  2773. };
  2774. window.getLocalStorage = function(va) {
  2775. return localStorage.getItem(va)
  2776. };
  2777. getLocalStorage('selected_profile') && (selected_profile_index = getLocalStorage('selected_profile'));
  2778. getLocalStorage('player_profile') ?
  2779. player_profile = JSON.parse(getLocalStorage('player_profile')) :
  2780. (getLocalStorage('nick') && (player_profile[selected_profile_index]['name'] = getLocalStorage('nick')),
  2781. getLocalStorage('opt_teamname') && (player_profile[selected_profile_index]['team'] = getLocalStorage('opt_teamname')),
  2782. getLocalStorage('skin_url') && (player_profile[selected_profile_index]['skinurl'] = getLocalStorage('skin_url')),
  2783. getLocalStorage('skin_url2') && (player_profile[selected_profile_index]['skinurl2'] = getLocalStorage('skin_url2')),
  2784. getLocalStorage('partycode') && (player_profile[selected_profile_index]['partycode'] = getLocalStorage('partycode'))
  2785. );
  2786.  
  2787. for(va = 0; va < player_profile.length; va++) {
  2788. window.postMessage({
  2789. action: Action.IMAGE,
  2790. data: player_profile[va]['skinurl']
  2791. }, '*')
  2792. };
  2793. $('body')['attr']('oncontextmenu', 'return false;');
  2794. $('#overlays2')['append']("<div id='teammate_menu'></div>");
  2795. $('#teammate_menu')['hide']();
  2796. $('#teammate_menu')['click'](function(va) {
  2797. va.stopPropagation()
  2798. });
  2799. $('#overlays2')['click'](function() {
  2800. $('#teammate_menu')['hide']()
  2801. });
  2802. nodeList[0] = ['me', getLocalStorage('nick'), null, null, 'yellow'];
  2803. nodeList[1] = ['top1', '', null, null, 'white'];
  2804. nodeList[0][8] = Date.now();
  2805. nodeList[1][8] = Date.now();
  2806.  
  2807. //チャット初期化
  2808. chatRoom = new ChatRoom;
  2809. chatRoom.setContainer('#overlays2');
  2810. chatRoom.createChatBox();
  2811. $('#btn_connect')['click'](function() {
  2812. $('#btn_connect')['text']('Connecting');
  2813. $('#connect_error_div')['hide']()
  2814. });
  2815.  
  2816. if(gUseChatApp){
  2817. chatAppModel.gameChatMessageReceiverProc = chatRoom.receiveMessageCore.bind(chatRoom);
  2818. }
  2819.  
  2820. //マップ初期化
  2821. minimap = new Minimap2(200);
  2822.  
  2823. var va = document.createElement('canvas'),
  2824. vb = va.getContext('2d');
  2825. vb.beginPath();
  2826. vb.lineWidth = 10;
  2827. vb.moveTo(0, 0);
  2828. vb.lineTo(100, 0);
  2829. vb.lineTo(50, 50);
  2830. vb.closePath();
  2831. vb.strokeStyle = 'white';
  2832. vb.fillStyle = 'white';
  2833. vb.stroke();
  2834. vb.fill();
  2835. this.teammateIndicator = va;
  2836. };
  2837. this.newGame = function() {
  2838. //$('#nick')['prop']('disabled', 1);
  2839. $('.btn-spectate')['prop']('disabled', 1);
  2840. isJoinedGame = 1;
  2841. myApp.isStopMovement = 0;
  2842. myApp.isSpectating = 0;
  2843. myApp.cellColor = '';
  2844. myApp.newGameImpl();
  2845. spectateMode = 0;
  2846. nodeList[1][2] = null;
  2847. nodeList[1][3] = null
  2848. };
  2849. this.afterGameLogicLoaded = function() {
  2850. myApp.setupOption();
  2851. myApp.setupHotKey();
  2852. myApp.restoreSetting();
  2853. myApp.setUpHotKeyConfigPage();
  2854. myApp.replaceTos();
  2855. myApp.setupHints();
  2856. myApp.checkVersion();
  2857. myApp.downloadSkin();
  2858. $('#btn_info')['click'](function() {
  2859. myApp.showAnnouncement()
  2860. });
  2861. $('#game_info')['click'](function() {
  2862. myApp.copyGameInfo()
  2863. });
  2864. $('#nick')['change'](function() {
  2865. onNicknameChanged()
  2866. });
  2867. $('#team_name')['change'](function() {
  2868. onTreamNameChanged()
  2869. })['focus'](function() {
  2870. tmpTeamname = myApp.getTeamName()
  2871. });
  2872.  
  2873. $('.partyToken').change(() => {
  2874. onPartyCodeChanged();
  2875. });
  2876.  
  2877. //$("skin_url").change
  2878. $('#skin_url')['change'](function() {
  2879. var va = getLocalStorage('skin_url'),
  2880. vb = myApp.getCustomSkinUrl();
  2881. $('#skin_url')['val'](vb);
  2882. va != vb && (va = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/i, 'DEFAULT' == vb || va.test(vb) ? (setLocalStorage('skin_url', vb), nodeList[0][5] = vb, player_profile[selected_profile_index]['skinurl'] = myApp.getCustomSkinUrl(), storePlayerProfile(), customSkin[vb] ? myApp.changePreviewImage(customSkin[vb]['src']) : skinDownloadQueue.push(vb)) : (console.log('Not valid URL'), $('#skin_url')['val']('')))
  2883. });
  2884. $('#skin_url2')['change'](function() {
  2885. var va = getLocalStorage('skin_url2'),
  2886. vb = myApp.getCustomSkinUrl2();
  2887. $('#skin_url2')['val'](vb);
  2888. va != vb && (va = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/i, 'DEFAULT' == vb || va.test(vb) ? (setLocalStorage('skin_url2', vb), nodeList[0][5] = vb, player_profile[selected_profile_index]['skinurl2'] = myApp.getCustomSkinUrl2(), storePlayerProfile(), customSkin[vb] ? myApp.changePreviewImage2(customSkin[vb]['src']) : skinDownloadQueue.push(vb)) : (console.log('Not valid URL'), $('#skin_url2')['val']('')))
  2889. });
  2890.  
  2891. $('.nav2.arrow-left')['click'](function() {
  2892. selected_profile_index = (player_profile.length + selected_profile_index - 1) % player_profile.length;
  2893. loadCurrentProfile()
  2894. });
  2895. $('.nav2.arrow-right')['click'](function() {
  2896.  
  2897. selected_profile_index = (selected_profile_index + 1) % player_profile.length;
  2898. loadCurrentProfile()
  2899. });
  2900. storePlayerProfile()
  2901. };
  2902. this.spectate = function(va) {
  2903. //conn.joinRoom(myApp.getRoom());
  2904. va && 0 != va.length || (myApp.isSpectating = 1)
  2905. };
  2906. this.newGameImpl = function() {
  2907. //trace('newGameImpl');
  2908. var va = 1,
  2909. vb = getCell();
  2910. vb && 0 != vb.length || (va = 0);
  2911. //va ? (nodeList[0][6] = vb[0]['color'], conn.joinRoom(myApp.getRoom())) : setTimeout(myApp.newGameImpl, 100)
  2912. gIsPlaying = true;
  2913. gIsSpectate = false;
  2914. };
  2915. this.onDead = function() {
  2916. //trace('onDead');
  2917. isJoinedGame = 0;
  2918. $('.btn-spectate')['prop']('disabled', 0);
  2919. //$('#nick')['prop']('disabled', 0);
  2920. $('.nav')['show']();
  2921. //conn.leaveRoom(myApp.getRoom());
  2922. gIsPlaying = false;
  2923. };
  2924. this.afterGameLoaded = function() {
  2925. myApp.isSpectating = 0;
  2926. updateLBCount = -1;
  2927. $('#nick')['prop']('disabled', 0);
  2928. $('#current_ip')['text']('Server: ' + myApp.getCurrentIP());
  2929. $('#ip_info')['text']('Server: ' + myApp.getCurrentIP());
  2930. $('#region_info')['text']('Region: ' + $('#region option:selected')['text']()['split'](' ')[0]);
  2931. $('#gamemode_info')['text']('Mode: ' + $('#gamemode option:selected')['text']());
  2932. $('#party_code_info')['text']('Party: ' + myApp.getCurrentPartyCode());
  2933. $('#btn_connect')['text']('Connect');
  2934. moveTo(null, null);
  2935. myApp.specTeammate = null;
  2936. myApp.isStopMovement = 0;
  2937. minimap.setDeadPosition(null);
  2938. //conn.joinRoom(myApp.getRoom())
  2939. };
  2940.  
  2941. //room signatureを取得
  2942. //team name + server ip or
  2943. //team name + party code
  2944. this.getRoom = function() {
  2945. //return 'N/A' == myApp.getCurrentPartyCode() ? myApp.getTeamName() + myApp.getCurrentIP() : myApp.getTeamName() + myApp.getCurrentPartyCode()
  2946. return myApp.getTeamName();
  2947. };
  2948. this.restoreSetting = function() {
  2949. if(getLocalStorage('opt_teamname') == null && getLocalStorage('nick') == null) {
  2950. //初回起動時,名前/ãƒãƒ¼ãƒ åã®ãƒªã‚½ãƒ¼ã‚¹ãŒãªã„å ´åˆ, Profile1を設定
  2951. var pp = player_profile[0];
  2952. setLocalStorage('opt_teamname', pp.team);
  2953. setLocalStorage('nick', pp.name);
  2954. setLocalStorage('skin_url', pp.skinurl);
  2955. setLocalStorage('skin_url2', pp.skinurl);
  2956. setLocalStorage('partycode', pp.partycode);
  2957. }
  2958.  
  2959. getLocalStorage('opt_teamname') && $('#team_name')['val'](getLocalStorage('opt_teamname'));
  2960. getLocalStorage('nick') && '' != getLocalStorage('nick')['trim']() ? $('#nick')['val'](getLocalStorage('nick', myApp.getName())) : ($('#nick')['val'](myApp.getName()), setLocalStorage('nick', myApp.getName()));
  2961. getLocalStorage('partycode') && $('.partyToken').val(getLocalStorage('partycode'));
  2962. nodeList[0][1] = myApp.getName();
  2963. nodeList[0][15] = myApp.getTeamName();
  2964. getLocalStorage('opt_zoom_speed') && (vh = getLocalStorage('opt_zoom_speed'), $('#opt_zoom_speed')['val'](vh), $('#txt_zoom_speed')['text'](vh));
  2965. var va = getLocalStorage('skin_url');
  2966. va && '' != va || (setLocalStorage('skin_url', defaultSkin), va = defaultSkin);
  2967. va && '' != va && ($('#skin_url')['val'](getLocalStorage('skin_url')), nodeList[0][5] = va, customSkin[va] ? myApp.changePreviewImage(customSkin[va]['src']) : skinDownloadQueue.push(getLocalStorage('skin_url')));
  2968.  
  2969. va = getLocalStorage('skin_url2');
  2970. va && '' != va || (setLocalStorage('skin_url2', defaultSkin), va = defaultSkin);
  2971. va && '' != va && ($('#skin_url2')['val'](getLocalStorage('skin_url2')), nodeList[0][5] = va, customSkin[va] ? myApp.changePreviewImage2(customSkin[va]['src']) : skinDownloadQueue.push(getLocalStorage('skin_url2')));
  2972.  
  2973.  
  2974. if(getLocalStorage('hotkeyMapping')) {
  2975. hotkeyMapping = JSON.parse(getLocalStorage('hotkeyMapping'))
  2976. } else {
  2977. for(var cfg in hotkeyConfig) {
  2978. hotkeyConfig[cfg]['defaultHotkey'] && '' != hotkeyConfig[cfg]['defaultHotkey'] && (hotkeyMapping[hotkeyConfig[cfg]['defaultHotkey']] = cfg)
  2979. };
  2980. setLocalStorage('hotkeyMapping', hotkeyMapping)
  2981. };
  2982. getLocalStorage('chatCommand') ? chatCommand = JSON.parse(getLocalStorage('chatCommand')) : (chatCommand = defaultHotkeyMessageSend, setLocalStorage('chatCommand', chatCommand))
  2983. };
  2984. this.replaceTos = function() {
  2985. $('.tosBox')['remove']()
  2986. };
  2987. this.setupOption = function() {
  2988. var optNum0 = 13;
  2989. var optNum1 = 12;
  2990.  
  2991. var options = {
  2992.  
  2993.  
  2994. opt_hzoom: {
  2995. text: gtexts.stFastZoom,
  2996. "\x64\x65\x66\x61\x75\x6C\x74": 0,
  2997. handler: function(va) {
  2998. if(va) {
  2999. setLocalStorage('opt_zoom_speed', vh = 0.82);
  3000. } else {
  3001. setLocalStorage('opt_zoom_speed', vh = 0.94);
  3002. }
  3003. }
  3004. },
  3005.  
  3006. opt_self_name: {
  3007. text: gtexts.stHideMyName,
  3008. "\x64\x65\x66\x61\x75\x6C\x74": 0,
  3009. handler: function(va) {
  3010. myApp.isHideSelfName = va
  3011. }
  3012. },
  3013. opt_name: {
  3014. text: gtexts.stHideNames,
  3015. handler: function(va) {
  3016. setNames(!va)
  3017. }
  3018. },
  3019. opt_color: {
  3020. text: gtexts.stHideBlobColors,
  3021. handler: function(va) {
  3022. setColors(va)
  3023. }
  3024. },
  3025. opt_mass: {
  3026. text: gtexts.stShowMass,
  3027. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3028. handler: function(va) {
  3029. setShowMass(va)
  3030. }
  3031. },
  3032. opt_stats: {
  3033. text: gtexts.stSkipStats,
  3034. disabled: 1,
  3035. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3036. handler: function(va) {
  3037. setSkipStats(va)
  3038. }
  3039. },
  3040. opt_mapgrid: {
  3041. text: gtexts.stGridLocations,
  3042. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3043. handler: function(va) {
  3044. myApp.isEnableMapGrid = va
  3045. }
  3046. },
  3047. opt_cursorline: {
  3048. text: gtexts.stCursorLine,
  3049. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3050. handler: function(va) {
  3051. myApp.isEnableCursorLine = va
  3052. }
  3053. },
  3054. opt_zoom: {
  3055. text: gtexts.stZoom,
  3056. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3057. handler: function(va) {
  3058. myApp.isEnableZoom = va
  3059. }
  3060. },
  3061. opt_food: {
  3062. text: gtexts.stHidePellets,
  3063. handler: function(va) {
  3064. myApp.isEnableHideFood = va
  3065. }
  3066. },
  3067. opt_gridline: {
  3068. text: gtexts.stGridLines,
  3069. handler: function(va) {
  3070. myApp.isEnableGridline = va
  3071. }
  3072. },
  3073. opt_simple_drawing: {
  3074. text: gtexts.stSimpleDrawing,
  3075. "\x64\x65\x66\x61\x75\x6C\x74": 0,
  3076. handler: function(va) {
  3077. myApp.isEnableSimpleDrawing = va
  3078. }
  3079. },
  3080. opt_score: {
  3081. text: gtexts.stScore,
  3082. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3083. handler: function(va) {
  3084. myApp.isShowScroll = va
  3085. }
  3086. },
  3087. opt_ste: {
  3088. text: gtexts.stSte,
  3089. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3090. handler: function(va) {
  3091. myApp.isShowSTE = va
  3092. }
  3093. },
  3094. opt_ball_total: {
  3095. text: gtexts.stBallTotal,
  3096. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3097. handler: function(va) {
  3098. myApp.isShowBallTotal = va
  3099. }
  3100. },
  3101. opt_minimap: {
  3102. text: gtexts.stMinimap,
  3103. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3104. handler: function(va) {
  3105. va ? minimap.show() : minimap.hide()
  3106. }
  3107. },
  3108. //opt_mousew: {
  3109. // text: 'マウスで餌',
  3110. // disabled: 1,
  3111. // handler: function (va) {
  3112. // myApp.isEnableMouseW = va
  3113. // }
  3114. //},
  3115. opt_same_food_color: {
  3116. text: gtexts.stRainbowColor,
  3117. handler: function(va) {
  3118. myApp.isSameColorFood = !va
  3119. }
  3120. },
  3121. opt_transparent_cell: {
  3122. text: gtexts.stTransparentBlobs,
  3123. handler: function(va) {
  3124. myApp.isTransparentCell = va
  3125. }
  3126. },
  3127. opt_fps: {
  3128. text: gtexts.stFps,
  3129. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3130. handler: function(va) {
  3131. myApp.isShowFPS = va
  3132. }
  3133. },
  3134. opt_packetIO: {
  3135. text: gtexts.stPacktIo,
  3136. disabled: 1,
  3137. handler: function(va) {
  3138. myApp.isShowPacketIO = va
  3139. }
  3140. },
  3141. opt_auto_hide_mass: {
  3142. text: gtexts.stAutoHideMass,
  3143. "\x64\x65\x66\x61\x75\x6C\x74": 0,
  3144. handler: function(va) {
  3145. myApp.isAutoHideMass = va
  3146. }
  3147. },
  3148. opt_auto_hide_name: {
  3149. text: gtexts.stAutoHideNames,
  3150. "\x64\x65\x66\x61\x75\x6C\x74": 0,
  3151. handler: function(va) {
  3152. myApp.isAutoHideName = va
  3153. }
  3154. },
  3155. opt_show_text_stroke_line: {
  3156. text: gtexts.stTextShadows,
  3157. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3158. handler: function(va) {
  3159. myApp.isShowTextStrokeLine = va
  3160. }
  3161. },
  3162. opt_lock_zoom: {
  3163. text: gtexts.stAutoZoom,
  3164. handler: function(va) {
  3165. myApp.isEnableLockZoom = !va
  3166. }
  3167. },
  3168. opt_split_ind: {
  3169. text: gtexts.stSplitIndicators,
  3170. "\x64\x65\x66\x61\x75\x6C\x74": 0,
  3171. handler: function(va) {
  3172. myApp.isEnableSplitInd = va
  3173. }
  3174. },
  3175. opt_custom_skin: {
  3176. text: gtexts.stCustomSkins,
  3177. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3178. handler: function(va) {
  3179. myApp.isEnableCustomSkin = va
  3180. }
  3181. },
  3182. opt_other_skin: {
  3183. text: gtexts.stYinSkins,
  3184. disabled: 1,
  3185. handler: function(va) {
  3186. myApp.isEnableOtherSkinSupport = va
  3187. }
  3188. },
  3189. opt_chatbox: {
  3190. text: gtexts.stChatBox,
  3191. disabled: 0,
  3192. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3193. handler: function(va) {
  3194. va ? chatRoom.show() : chatRoom.hide()
  3195. }
  3196. },
  3197. opt_chatpopup: {
  3198. text: gtexts.stChatPopup,
  3199. disabled: 1,
  3200. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3201. handler: function(va) {
  3202. myApp.isEnableChatpopup = va
  3203. }
  3204. },
  3205.  
  3206. opt_mousecontrol: {
  3207. text: gtexts.stEnableMouseControl,
  3208. "\x64\x65\x66\x61\x75\x6C\x74": 1,
  3209. handler: function(s) {
  3210. myApp.isEnableMouseControl = s;
  3211. }
  3212. },
  3213.  
  3214. opt_mouse_button_swap: {
  3215. text: gtexts.stInvertMouseButtons,
  3216. handler: function(s) {
  3217. myApp.swapMouseButtonsLR = s;
  3218. }
  3219. },
  3220.  
  3221. opt_chatbox_location: {
  3222. text: gtexts.stChatBoxLocation,
  3223. handler: function(s) {
  3224. myApp.showChatAtBottom = s;
  3225. }
  3226. },
  3227.  
  3228. opt_split_order_marker: {
  3229. text: gtexts.stSplitOrderMarker,
  3230. "\x64\x65\x66\x61\x75\x6C\x74": 0,
  3231. handler: function(s) {
  3232. myApp.showSplitOrderMarker = s;
  3233. }
  3234. },
  3235.  
  3236. opt_show_cursor_crosshair: {
  3237. text: gtexts.stAimCrosshair,
  3238. //disabled: 1,
  3239. "\x64\x65\x66\x61\x75\x6C\x74": 0,
  3240. handler: function(s) {
  3241. myApp.showCursorCrosshair = s;
  3242. }
  3243. },
  3244.  
  3245. opt_active_turn_marker: {
  3246. text: gtexts.stActiveTurnMarker,
  3247. "\x64\x65\x66\x61\x75\x6C\x74": 0,
  3248. handler: function(s) {
  3249. myApp.showActiveTurnMarker = s;
  3250. }
  3251. },
  3252.  
  3253. opt_emphasis_cursor_line: {
  3254. text: gtexts.stEmphasisCursorLine,
  3255. "\x64\x65\x66\x61\x75\x6C\x74": 0,
  3256. handler: function(s) {
  3257. myApp.emphasisCursorLine = s;
  3258. }
  3259. },
  3260.  
  3261. };
  3262. window.setYinSkinSupport = function(vb) {
  3263. options.opt_other_skin['handler'](vb);
  3264. setLocalStorage('opt_other_skin', vb)
  3265. };
  3266. var configs = [],
  3267. vf;
  3268. for(vf in options) {
  3269. //options[vf]['disabled'] || configs.push('<input id="' + vf + '" type="checkbox"> ' + options[vf]['text'] + '<br>')
  3270. if(!options[vf]['disabled']){
  3271. //configs.push('<input id="' + vf + '" type="checkbox"> ' + options[vf]['text'] + '<br>');
  3272. configs.push('<div><input id="' + vf + '" type="checkbox"> ' + options[vf]['text'] + '</div>');
  3273. }
  3274. };
  3275.  
  3276. var cfg0 = configs.splice(0, optNum0);
  3277. for(var i = 0; i < cfg0.length; i++) {
  3278. $('.firstSettings')['append'](cfg0[i])
  3279. };
  3280.  
  3281. var cfg1 = configs.splice(0, optNum1);
  3282. for(i = 0; i < cfg1.length; i++) {
  3283. $('.secondSettings')['append'](cfg1[i])
  3284. };
  3285.  
  3286. var cfg2 = configs; //['splice'](0, 1);
  3287. for(i = 0; i < cfg2.length; i++) {
  3288. $('.extraSettings')['append'](cfg2[i])
  3289. };
  3290.  
  3291. $('input:checkbox')['change'](function() {
  3292. var vb = $(this)['prop']('checked'),
  3293. ve = $(this)['prop']('id');
  3294. setLocalStorage(ve, vb);
  3295. options[ve] && options[ve]['handler'](vb)
  3296. });
  3297. for(vf in options) {
  3298. getLocalStorage(vf) ? 'true' == getLocalStorage(vf) && ('opt_other_skin' == vf ? setYinSkinSupport(1) : $('#' + vf)['click']()) : options[vf]['default'] && $('#' + vf)['click']()
  3299. };
  3300.  
  3301.  
  3302. /*
  3303. $('.zoomSpeed')['append']('Zoom Speed: <span id="txt_zoom_speed">0.97</span></div><input oninput="$(#txt_zoom_speed).text(this.value);" style="width:100%;" type="range" id="opt_zoom_speed" name="opt_zoom_speed" min="0.88" max="0.99" step="0.01" value="0.9">');
  3304. $('#opt_zoom_speed')['change'](function () {
  3305. vh = $('#opt_zoom_speed')['val']();
  3306. setLocalStorage('opt_zoom_speed', vh)
  3307. })*/
  3308. };
  3309. this.scoreInfo = function(va) {
  3310. if(!va || !va.length) {
  3311. return ''
  3312. };
  3313. var vb = '';
  3314. myApp.isShowSTE && (vb += ' STE: ' + this.getSTE(va));
  3315. myApp.isShowBallTotal && (vb += ' [' + va.length + '/16]');
  3316. return vb
  3317. };
  3318. this.scoreTxt = function(va) {
  3319. return myApp.isShowScroll ? va : ''
  3320. };
  3321. this.isShowScoreInfo = function() {
  3322. return myApp.isShowScroll || myApp.isShowSTE || myApp.isShowBallTotal
  3323. };
  3324. this.showSystemMessage = function() {
  3325. return 0
  3326. };
  3327. this.getSTE = function(va) {
  3328. for(var vb = 0, vf = 0; vf < va.length; vf++) {
  3329. va[vf] && va[vf]['I'] && va[vf]['I']['lb_w_text'] && va[vf]['I']['lb_w_text'] > vb && (vb = va[vf]['I']['lb_w_text'])
  3330. };
  3331. return ~~(0.375 * vb)
  3332. };
  3333. this.createGameInfoBox = function() {
  3334. //$('.gameinfo')['prepend']("<div id='game_info' class='agario-panel'><p id='ip_info'></p><p id='region_info'></p><p id='gamemode_info'></p><p id='party_code_info'></p><p id='lb_info'></p></div>");
  3335. //$('#game_info')['append']('<button id ="btn_copy_gameinfo" class="btn btn-warning btn-hotkeys" type="button">Copy</button>')
  3336. };
  3337. this.updateLBInfo = function() {
  3338. var va = '',
  3339. vb = myApp.getLeaderBoard();
  3340. if(vb) {
  3341. for(var vf = 0; vf < vb.length; vf++) {
  3342. va += '<div>' + (vf + 1) + '. ' + escapeHtml(vb[vf]) + '</div>'
  3343. }
  3344. };
  3345. $('#lb_info')['html'](va)
  3346. };
  3347. this.isPrivateServer = function() {
  3348. return PRIVATE_SERVER_IP == currentIP
  3349. };
  3350. this.getCurrentIP = function() {
  3351. return this.isPrivateServer() ? '----------' : currentIP.substring(5, currentIP.length)
  3352. };
  3353. this.getRegion = function() {
  3354. return $('#region option:selected')['text']()['split'](' ')[0]
  3355. };
  3356. this.getGameMode = function() {
  3357. return this.isPrivateServer() ? '----------' : $('#gamemode option:selected')['text']()
  3358. };
  3359. this.getTeamName = function() {
  3360. return ('' == $('#team_name')['val']() ? '' : $('#team_name')['val']())['trim']()
  3361. };
  3362. this.getCustomSkinUrl = function() {
  3363. var va = ($('#skin_url')['val']() + '')['trim']();
  3364. return '' == va ? '' : va
  3365. };
  3366. this.getCustomSkinUrl2 = function() {
  3367. var va = ($('#skin_url2')['val']() + '')['trim']();
  3368. return '' == va ? '' : va
  3369. };
  3370.  
  3371. this.getCurrentPartyCode = function() {
  3372. return $('.partyToken')['val']()
  3373. };
  3374. this.showMessage = function(va, vb) {
  3375. 0 == $('#message_dialog')['length'] && myApp.createMessageDialog();
  3376. $('#message_dialog_title')['text'](va);
  3377. $('#message_dialog_content')['html'](vb);
  3378. $('#message_dialog')['modal']({
  3379. show: 'true'
  3380. })
  3381. };
  3382. this.getName = function() {
  3383. var name = $('#nick')['val']()['trim'](); -1 != name.indexOf() && (name = '');
  3384. return /*this.getTeamName() + */'' == name ? '' : name
  3385. };
  3386. this.getNameEx = function() {
  3387. return this.getTeamName() + this.getName();
  3388. }
  3389. this.getLeaderBoard = function() {
  3390. var va = [],
  3391. entries = getLB();
  3392. if(entries) {
  3393. for(var vf = 0; vf < entries.length; vf++) {
  3394. va[va.length] = '' == entries[vf].name ? 'An unnamed cell' : escapeHtml(entries[vf].name)
  3395. }
  3396. };
  3397. return va
  3398. };
  3399. this.setupHotKey = function() {
  3400. hotkeyConfig = {
  3401. hk_start_new_game: {
  3402. defaultHotkey: 'N',
  3403. name: gtexts.hkStartNewGame,
  3404. keyDown: function() {
  3405. //var team = document.getElementById('team_name').value;
  3406. //setNick(myApp.getName(), myApp.getTeamName())
  3407. setNickA();
  3408. },
  3409. type: 'NORMAL'
  3410. },
  3411. hk_cheatw: {
  3412. defaultHotkey: 'E',
  3413. name: gtexts.hkMacroW,
  3414. keyDown: function() {
  3415. myApp.autoW = 1;
  3416. handleQuickW()
  3417. },
  3418. keyUp: function() {
  3419. myApp.autoW = 0
  3420. },
  3421. type: 'NORMAL'
  3422. },
  3423. hk_quick_space: {
  3424. defaultHotkey: 'T',
  3425. name: gtexts.hkQuickSpace,
  3426. keyDown: function() {
  3427. myApp.quickSpace || (myApp.quickSpace = 1, quickSpace())
  3428. },
  3429. keyUp: function() {
  3430. myApp.quickSpace = 0
  3431. },
  3432. type: 'NORMAL'
  3433. },
  3434. hk_double_space: {
  3435. defaultHotkey: 'G',
  3436. name: gtexts.hkDoubleSpace,
  3437. keyDown: function() {
  3438. myApp.doubleSpace || (myApp.doubleSpace = 1, doubleSpace())
  3439. //trace("double Space");
  3440. },
  3441. keyUp: function() {
  3442. myApp.doubleSpace = 0
  3443. },
  3444. type: 'NORMAL'
  3445. },
  3446. hk_stop_movement_toggle: {
  3447. defaultHotkey: 'ALT_S',
  3448. name: gtexts.hkStopMovementToggle,
  3449. keyDown: function() {
  3450. myApp.isStopMovement = !myApp.isStopMovement;
  3451. myApp.specTeammate = null
  3452. //trace("isStopMovement:" + myApp.isStopMovement);
  3453. MOVING = !MOVING;
  3454. },
  3455. type: 'NORMAL'
  3456. },
  3457. hk_stop_movement: {
  3458. defaultHotkey: 'S',
  3459. name: gtexts.hkStopMovementTemporary,
  3460. keyDown: function() {
  3461. myApp.isStopMovement = 1;
  3462. myApp.specTeammate = null;
  3463. moveTo(null, null)
  3464. //trace("isStopMovement:" + myApp.isStopMovement);
  3465. MOVING = false;
  3466.  
  3467. },
  3468. keyUp: function() {
  3469. myApp.isStopMovement = 0
  3470. //trace("isStopMovement:" + myApp.isStopMovement);
  3471. MOVING = true;
  3472. },
  3473. type: 'NORMAL'
  3474. },
  3475. hk_split_ind: {
  3476. defaultHotkey: 'I',
  3477. name: gtexts.hkOnOffSplitIndicator,
  3478. keyDown: function() {
  3479. $('#opt_split_ind')['click']()
  3480. },
  3481. type: 'NORMAL'
  3482. },
  3483. hk_lock_zoom: {
  3484. defaultHotkey: 'L',
  3485. name: gtexts.hkOnOffAutoZoom,
  3486. keyDown: function() {
  3487. $('#opt_lock_zoom')['click']()
  3488. },
  3489. type: 'NORMAL'
  3490. },
  3491. hk_attack_range: {
  3492. defaultHotkey: 'A',
  3493. name: gtexts.hkShowAttackRangeTemporary,
  3494. keyDown: function() {
  3495. myApp.isEnableAttackRange = 1
  3496. },
  3497. keyUp: function() {
  3498. myApp.isEnableAttackRange = 0
  3499. },
  3500. type: 'NORMAL'
  3501. },
  3502. hk_attack_range_toggle: {
  3503. defaultHotkey: 'ALT_A',
  3504. name: gtexts.hkShowAttackRangeToggle,
  3505. keyDown: function() {
  3506. myApp.isEnableAttackRange = !myApp.isEnableAttackRange
  3507. },
  3508. type: 'NORMAL'
  3509. },
  3510. hk_spec_teammate: {
  3511. defaultHotkey: 'V',
  3512. name: gtexts.hkSpectateTeammate,
  3513. keyDown: function() { },
  3514. type: 'NORMAL'
  3515. },
  3516. hk_custom_skin: {
  3517. defaultHotkey: '',
  3518. name: gtexts.hkOnOffCustomSkin,
  3519. keyDown: function() {
  3520. $('#opt_custom_skin')['click']()
  3521. },
  3522. type: 'NORMAL'
  3523. },
  3524. hk_skin: {
  3525. defaultHotkey: '',
  3526. name: gtexts.hkShowHideSkins,
  3527. keyDown: function() {
  3528. $('#opt_skin')['click']()
  3529. },
  3530. type: 'NORMAL'
  3531. },
  3532. hk_same_food_color: {
  3533. defaultHotkey: '',
  3534. name: gtexts.hkOnOffRainbowColor,
  3535. keyDown: function() {
  3536. $('#opt_same_food_color')['click']()
  3537. },
  3538. type: 'NORMAL'
  3539. },
  3540. hk_transparent_cell: {
  3541. defaultHotkey: '',
  3542. name: gtexts.hkOnOffTransparentCell,
  3543. keyDown: function() {
  3544. $('#opt_transparent_cell')['click']()
  3545. },
  3546. type: 'NORMAL'
  3547. },
  3548. hk_fps: {
  3549. defaultHotkey: '',
  3550. name: gtexts.hkShowHideFpsCounter,
  3551. keyDown: function() {
  3552. $('#opt_fps')['click']()
  3553. },
  3554. type: 'NORMAL'
  3555. },
  3556. hk_zoom_a: {
  3557. defaultHotkey: '1',
  3558. name: gtexts.hkZoomLevel1,
  3559. keyDown: function() {
  3560. myApp.isEnableLockZoom || hotkeyConfig.hk_lock_zoom['keyDown']();
  3561. setZoomLevel(0.75)
  3562. },
  3563. type: 'NORMAL'
  3564. },
  3565. hk_zoom_b: {
  3566. defaultHotkey: '2',
  3567. name: gtexts.hkZoomLevel2,
  3568. keyDown: function() {
  3569. myApp.isEnableLockZoom || hotkeyConfig.hk_lock_zoom['keyDown']();
  3570. setZoomLevel(0.3)
  3571. },
  3572. type: 'NORMAL'
  3573. },
  3574. hk_zoom_c: {
  3575. defaultHotkey: '3',
  3576. name: gtexts.hkZoomLevel3,
  3577. keyDown: function() {
  3578. myApp.isEnableLockZoom || hotkeyConfig.hk_lock_zoom['keyDown']();
  3579. setZoomLevel(0.15)
  3580. },
  3581. type: 'NORMAL'
  3582. },
  3583. hk_zoom_d: {
  3584. defaultHotkey: '4',
  3585. name: gtexts.hkZoomLevel4,
  3586. keyDown: function() {
  3587. myApp.isEnableLockZoom || hotkeyConfig.hk_lock_zoom['keyDown']();
  3588. setZoomLevel(0.08)
  3589. },
  3590. type: 'NORMAL'
  3591. },
  3592. hk_zoom_e: {
  3593. defaultHotkey: '5',
  3594. name: gtexts.hkZoomLevel5,
  3595. keyDown: function() {
  3596. myApp.isEnableLockZoom || hotkeyConfig.hk_lock_zoom['keyDown']();
  3597. setZoomLevel(0.05)
  3598. },
  3599. type: 'NORMAL'
  3600. },
  3601. hk_name: {
  3602. defaultHotkey: 'ALT_N',
  3603. name: gtexts.hkShowHideNames,
  3604. keyDown: function() {
  3605. $('#opt_name')['click']()
  3606. },
  3607. type: 'NORMAL'
  3608. },
  3609. hk_self_name: {
  3610. defaultHotkey: '',
  3611. name: gtexts.hkShowHideOwnName,
  3612. keyDown: function() {
  3613. $('#opt_self_name')['click']()
  3614. },
  3615. type: 'NORMAL'
  3616. },
  3617. hk_color: {
  3618. defaultHotkey: '',
  3619. name: gtexts.hkShowHideColors,
  3620. keyDown: function() {
  3621. $('#opt_color')['click']()
  3622. },
  3623. type: 'NORMAL'
  3624. },
  3625. hk_mass: {
  3626. defaultHotkey: '',
  3627. name: gtexts.hkShowHideMass,
  3628. keyDown: function() {
  3629. $('#opt_mass')['click']()
  3630. },
  3631. type: 'NORMAL'
  3632. },
  3633. hk_stat: {
  3634. defaultHotkey: '',
  3635. name: gtexts.hkOnOffSkipStats,
  3636. keyDown: function() {
  3637. $('#opt_stats')['click']()
  3638. },
  3639. type: 'NORMAL'
  3640. },
  3641. hk_zoom: {
  3642. defaultHotkey: 'ALT_Z',
  3643. name: gtexts.hkOnOffZoom,
  3644. keyDown: function() {
  3645. $('#opt_zoom')['click']()
  3646. },
  3647. type: 'NORMAL'
  3648. },
  3649. hk_food: {
  3650. defaultHotkey: 'F',
  3651. name: gtexts.hkShowHidePellets,
  3652. keyDown: function() {
  3653. $('#opt_food')['click']()
  3654. },
  3655. type: 'NORMAL'
  3656. },
  3657. hk_gridline: {
  3658. defaultHotkey: 'ALT_G',
  3659. name: gtexts.hkShowHideGridline,
  3660. keyDown: function() {
  3661. $('#opt_gridline')['click']()
  3662. },
  3663. type: 'NORMAL'
  3664. },
  3665. hk_border: {
  3666. defaultHotkey: 'B',
  3667. name: gtexts.hkResetBorder,
  3668. keyDown: function() { },
  3669. type: 'NORMAL'
  3670. },
  3671. hk_simple_draw: {
  3672. defaultHotkey: '',
  3673. name: gtexts.hkOnOffSimpleDraw,
  3674. keyDown: function() {
  3675. $('#opt_simple_drawing')['click']()
  3676. },
  3677. type: 'NORMAL'
  3678. },
  3679. hk_score: {
  3680. defaultHotkey: '',
  3681. name: gtexts.hkShowHideScore,
  3682. keyDown: function() {
  3683. $('#opt_score')['click']()
  3684. },
  3685. type: 'NORMAL'
  3686. },
  3687. hk_ste: {
  3688. defaultHotkey: '',
  3689. name: gtexts.hkShowHideSte,
  3690. keyDown: function() {
  3691. $('#opt_ste')['click']()
  3692. },
  3693. type: 'NORMAL'
  3694. },
  3695. hk_n16: {
  3696. defaultHotkey: '',
  3697. name: gtexts.hkShowHideN16,
  3698. keyDown: function() {
  3699. $('#opt_ball_total')['click']()
  3700. },
  3701. type: 'NORMAL'
  3702. },
  3703. hk_auto_hide_mass: {
  3704. defaultHotkey: '',
  3705. name: gtexts.hkOnOffAutoHideMass,
  3706. keyDown: function() {
  3707. $('#opt_auto_hide_mass')['click']()
  3708. },
  3709. type: 'NORMAL'
  3710. },
  3711. hk_auto_hide_name: {
  3712. defaultHotkey: '',
  3713. name: gtexts.hkOnOffAutoHideName,
  3714. keyDown: function() {
  3715. $('#opt_auto_hide_name')['click']()
  3716. },
  3717. type: 'NORMAL'
  3718. },
  3719. hk_show_text_stroke_line: {
  3720. defaultHotkey: '',
  3721. name: gtexts.hkShowHideTextShadow,
  3722. keyDown: function() {
  3723. $('#opt_show_text_stroke_line')['click']()
  3724. },
  3725. type: 'NORMAL'
  3726. },
  3727. hk_minimap: {
  3728. defaultHotkey: 'ALT_M',
  3729. name: gtexts.hkShowHideMinimap,
  3730. keyDown: function() {
  3731. $('#opt_minimap')['click']()
  3732. },
  3733. type: 'NORMAL'
  3734. },
  3735. //hk_mousew: {
  3736. // defaultHotkey: '',
  3737. // name: 'マウスでのwをon/off',
  3738. // keyDown: function () {
  3739. // $('#opt_mousew')['click']()
  3740. // },
  3741. // type: 'NORMAL'
  3742. //},
  3743. hk_send_msg: {
  3744. defaultHotkey: 'ENTER',
  3745. name: gtexts.hkChatboxSendMessage,
  3746. keyDown: function() {
  3747. chatRoom.enter()
  3748. },
  3749. type: 'NORMAL'
  3750. },
  3751. hk_send_msg1: {
  3752. defaultHotkey: 'ALT_1',
  3753. name: gtexts.hkChatboxSendMessage1,
  3754. keyDown: function() {
  3755. console.log('CHAT MESSAGE');
  3756. chatRoom.sendMessage(chatCommand.input_hk_send_msg1)
  3757. },
  3758. type: 'TEXT'
  3759. },
  3760. hk_send_msg2: {
  3761. defaultHotkey: 'ALT_2',
  3762. name: gtexts.hkChatboxSendMessage2,
  3763. keyDown: function() {
  3764. chatRoom.sendMessage(chatCommand.input_hk_send_msg2)
  3765. },
  3766. type: 'TEXT'
  3767. },
  3768. hk_send_msg3: {
  3769. defaultHotkey: 'ALT_3',
  3770. name: gtexts.hkChatboxSendMessage3,
  3771. keyDown: function() {
  3772. chatRoom.sendMessage(chatCommand.input_hk_send_msg3)
  3773. },
  3774. type: 'TEXT'
  3775. },
  3776. hk_send_msg4: {
  3777. defaultHotkey: 'ALT_4',
  3778. name: gtexts.hkChatboxSendMessage4,
  3779. keyDown: function() {
  3780. chatRoom.sendMessage(chatCommand.input_hk_send_msg4)
  3781. },
  3782. type: 'TEXT'
  3783. },
  3784. hk_send_msg5: {
  3785. defaultHotkey: 'ALT_5',
  3786. name: gtexts.hkChatboxSendMessage5,
  3787. keyDown: function() {
  3788. chatRoom.sendMessage(chatCommand.input_hk_send_msg5)
  3789. },
  3790. type: 'TEXT'
  3791. },
  3792. hk_send_msg6: {
  3793. defaultHotkey: 'ALT_6',
  3794. name: gtexts.hkChatboxSendMessage6,
  3795. keyDown: function() {
  3796. chatRoom.sendMessage(chatCommand.input_hk_send_msg6)
  3797. },
  3798. type: 'TEXT'
  3799. },
  3800. hk_send_msg7: {
  3801. defaultHotkey: 'ALT_7',
  3802. name: gtexts.hkChatboxSendMessage7,
  3803. keyDown: function() {
  3804. chatRoom.sendMessage(chatCommand.input_hk_send_msg7)
  3805. },
  3806. type: 'TEXT'
  3807. },
  3808. hk_send_msg8: {
  3809. defaultHotkey: 'ALT_8',
  3810. name: gtexts.hkChatboxSendMessage8,
  3811. keyDown: function() {
  3812. chatRoom.sendMessage(chatCommand.input_hk_send_msg8)
  3813. },
  3814. type: 'TEXT'
  3815. },
  3816. hk_send_msg9: {
  3817. defaultHotkey: 'ALT_9',
  3818. name: gtexts.hkChatboxSendMessage9,
  3819. keyDown: function() {
  3820. chatRoom.sendMessage(chatCommand.input_hk_send_msg9)
  3821. },
  3822. type: 'TEXT'
  3823. },
  3824. hk_send_msg10: {
  3825. defaultHotkey: 'ALT_0',
  3826. name: gtexts.hkChatboxSendMessage10,
  3827. keyDown: function() {
  3828. chatRoom.sendMessage(chatCommand.input_hk_send_msg10)
  3829. },
  3830. type: 'TEXT'
  3831. }
  3832. }
  3833. };
  3834.  
  3835. //this.setupMouseConfig = function() {
  3836. // mouseConfig = {
  3837. // mk_enable_mouse_control: {
  3838.  
  3839.  
  3840. // }
  3841.  
  3842. // }
  3843. //}
  3844.  
  3845. this.createMessageDialog = function() {
  3846. var va, vb;
  3847. vb = $("<div class='modal-footer'>");
  3848. vb.append("<button type='button' class='btn btn-default' data-dismiss='modal'>OK</button>");
  3849. va = $("<div class='modal-content'/>");
  3850. va.append($("<div class='modal-header'/>")['append']("<button type='button' class='close' data-dismiss='modal'>&times;</button><h4 id='message_dialog_title' class='modal-title'></h4>"));
  3851. va.append($("<div id='message_dialog_content' class='modal-body'>"));
  3852. va.append(vb);
  3853. va = $("<div id='message_dialog' class='modal fade' role='dialog'/>")['append']("<div class='modal-dialog'/>")['append'](va);
  3854. $('body')['append'](va);
  3855. $('#message_dialog')['modal']({
  3856. backdrop: 'static',
  3857. keyboard: 0
  3858. });
  3859. $(document)['on']('shown.bs.modal', '#message_dialog', function() {
  3860. var va = $('#message_dialog>.modal-content')['outerHeight'](),
  3861. vb = $(document)['outerHeight']();
  3862. va > vb ? $('#message_dialog')['css']('overflow', 'auto') : $('#message_dialog')['css']('margin-top', vb / 2 - va / 2 - 40)
  3863. });
  3864. $(document)['on']('hide.bs.modal', '#message_dialog', function() { })
  3865. };
  3866. this.setUpHotKeyConfigPage = function() {
  3867. //$('.left-side > div:nth-child(2)')['after']('<div class="agario-panel agario-side-panel agarioProfilePanel level" style="display: block !important;text-align:center"><button type="button" class="btn btn-success btn-hotkey" data-toggle="modal" data-target="#hotkeys_setting">Hotkeys</button></div>');
  3868. var va, vb;
  3869. vb = $('<div class="modal-footer" style="background: #222;">');
  3870. vb.append("<button onclick='resetDefaultHotkey();' type='button' class='btn btn-blue' style='float:left;'>" + gtexts.hkResetToDefault + "</button>");
  3871. vb.append("<button type='button' class='btn btn-red' data-dismiss='modal'>" + gtexts.hkCancel + "</button>");
  3872. vb.append("<button id='btn_save_hotkey' onclick='saveHotkeys();' type='button' class='btn btn-green' data-dismiss='modal'>" + gtexts.hkSave + "</button>");
  3873. va = $("<div class='modal-content' style='background: #222;'/>");
  3874. va.append($("<div class='modal-header'/>")['append']("<button type='button' class='close' data-dismiss='modal'>&times;</button><h4 class='modal-title'>" + gtexts.hkHotkeySetup + "</h4>"));
  3875. va.append($("<div id='hotkey_modal_body' class='modal-body'>")['append'](myApp.getHotkeyDivHtml()));
  3876. va.append(vb);
  3877. va = $("<div id='hotkeys_setting' class='modal fade' role='dialog'/>")['append']("<div class='modal-dialog'/>")['append'](va);
  3878. $('body')['append'](va);
  3879. $(document)['on']('hide.bs.modal', '#hotkeys_setting', function() {
  3880. selectedHotkeyRow && selectedHotkeyRow.removeClass('table-row-selected');
  3881. selectedHotkeyRow = null;
  3882. myApp.refreshHotkeySettingPage()
  3883. });
  3884. $('#hotkey_table .row')['not']('.header')['click'](function() {
  3885. selectedHotkeyRow && selectedHotkeyRow.removeClass('table-row-selected');
  3886. selectedHotkeyRow = $(this);
  3887. selectedHotkeyRow.addClass('table-row-selected')
  3888. })
  3889. };
  3890. window.saveHotkeys = function() {
  3891. var va = $('.hotkey');
  3892. hotkeyMapping = {};
  3893. for(var vb = 0; vb < va.length; vb++) {
  3894. hotkeyMapping[$(va[vb])['text']()] = $(va[vb])['attr']('data-hotkeyid')
  3895. };
  3896. setLocalStorage('hotkeyMapping', hotkeyMapping);
  3897. for(var vf in chatCommand) {
  3898. chatCommand[vf] = $('#' + vf)['val']()
  3899. };
  3900. setLocalStorage('chatCommand', chatCommand)
  3901. };
  3902. this.copyGameInfo = function() {
  3903. var va;
  3904. va = 'Current IP = ' + myApp.getCurrentIP();
  3905. va += '\nRegion : ' + $('#region option:selected')['text']()['split'](' ')[0];
  3906. va += '\nGame mode : ' + $('#gamemode option:selected')['text']();
  3907. va += '\nParty Code : ' + myApp.getCurrentPartyCode();
  3908. var vb = myApp.getLeaderBoard();
  3909. if(vb && 0 != vb.length) {
  3910. for(var vf = 0; vf < vb.length; vf++) {
  3911. va += '\n' + (vf + 1) + '. ' + vb[vf]
  3912. }
  3913. };
  3914. copyToClipboard(va)
  3915. };
  3916. window.resetDefaultHotkey = function() {
  3917. var va;
  3918. va = hotkeyMapping;
  3919. defaultHotkeyMapping = {};
  3920. for(var vb in hotkeyConfig) {
  3921. hotkeyConfig[vb]['defaultHotkey'] && '' != hotkeyConfig[vb]['defaultHotkey'] && (defaultHotkeyMapping[hotkeyConfig[vb]['defaultHotkey']] = vb)
  3922. };
  3923. hotkeyMapping = defaultHotkeyMapping;
  3924. myApp.refreshHotkeySettingPage();
  3925. hotkeyMapping = va;
  3926. defaultHotkeyMapping = null;
  3927. for(var vf in defaultHotkeyMessageSend) {
  3928. $('#' + vf)['val'](defaultHotkeyMessageSend[vf])
  3929. }
  3930. };
  3931. this.refreshHotkeySettingPage = function() {
  3932. for(var va = $('.hotkey'), vb = 0; vb < va.length; vb++) {
  3933. $(va[vb])['text'](' ')
  3934. };
  3935. for(var vf in hotkeyMapping) {
  3936. $('[data-hotkeyid=' + hotkeyMapping[vf] + ']')['text'](vf)
  3937. };
  3938. for(var vg in chatCommand) {
  3939. $('#' + vg)['val'](chatCommand[vg])
  3940. }
  3941. };
  3942. this.getHotkeyDivHtml = function() {
  3943. var va = '',
  3944. vb = $("<div id='hotkey_setting'></div>"),
  3945. vf = $("<div id='hotkey_table' class='table'></div>"),
  3946. vg = $("<div class='row header'></div>");
  3947. vg.append($("<div class='cell' style='width:170px;'>" + gtexts.hkHotkey + "</div>"));
  3948. vg.append($("<div class='cell' style='width:222px;'>" + gtexts.hkFunction + "</div>"));
  3949. vg.append($("<div class='cell'>" + gtexts.hkMessage + "</div>"));
  3950. vf.append(vg);
  3951. var vg = null,
  3952. vh;
  3953. for(vh in hotkeyConfig) {
  3954. vg = $("<div class='row'></div>"), vg.append($("<div data-hotkeyId='" + vh + "' class='cell hotkey'>" + getHotkeyById(vh) + '</div>')), vg.append($("<div class='cell'>" + hotkeyConfig[vh]['name'] + '</div>')), 'TEXT' == hotkeyConfig[vh]['type'] ? vg.append($("<div class='cell'><input id='input_" + vh + "' maxlength='200' style='width:100%;color:black;' type='text' value='" + chatCommand['input_' + vh] + "'></input></div>")) : vg.append($("<div class='cell'> / </div>")), vf.append(vg)
  3955. };
  3956. vb.append(vf);
  3957. va += $(`<p>${gtexts.hkInst0}</p>`)[0]['outerHTML'];
  3958. va += $(`<p>${gtexts.hkInst1}</p>`)[0]['outerHTML'];
  3959. va += $(`<p>${gtexts.hkInst2}</p>`)[0]['outerHTML'];
  3960. va += $(`<p>${gtexts.hkInst3}</p>`)[0]['outerHTML'];
  3961. va += $('<br></br>')[0]['outerHTML'];
  3962. va += vb[0]['outerHTML'];
  3963. return $('<div/>')['append'](va)['html']()
  3964. };
  3965. this.checkVersion = function() {
  3966. var va = getLocalStorage('lastestVersion');
  3967. va && va == myApp.version || (myApp.applyNewUpdate(), setLocalStorage('lastestVersion', myApp.version))
  3968. };
  3969. this.showAnnouncement = function() { };
  3970. this.applyNewUpdate = function() { };
  3971. this.setupHints = function() { };
  3972. this.setupHintsImpl = function(va, vb) {
  3973. va.addClass('hint--bottom hint--rounded');
  3974. va.attr('data-hint', vb)
  3975. };
  3976. this.ajax = function(va, vb, vf, vg) {
  3977. vg = null;
  3978. var vh;
  3979. try {
  3980. vh = new XMLHttpRequest
  3981. } catch(l) {
  3982. try {
  3983. vh = new ActiveXObject('Msxml2.XMLHTTP')
  3984. } catch(L) {
  3985. try {
  3986. vh = new ActiveXObject('Microsoft.XMLHTTP')
  3987. } catch(B) {
  3988. return alert('Your browser does not support Ajax.'), 0
  3989. }
  3990. }
  3991. };
  3992. vh.onreadystatechange = function() {
  3993. 4 == vh.readyState && vf(vh)
  3994. };
  3995. vh.open(vb, va, 1);
  3996. vh.send(vg);
  3997. return vh
  3998. };
  3999. this.getSkinImage = function(va) {
  4000. if(!va || '' == va) {
  4001. return null
  4002. };
  4003. if(customSkin[va]) {
  4004. return customSkin[va]
  4005. }; -1 == skinDownloadQueue.indexOf(va) && skinDownloadQueue.push(va);
  4006. return null
  4007. };
  4008. this.downloadSkin = function() {
  4009. if(0 != skinDownloadQueue.length) {
  4010. var va = skinDownloadQueue.shift();
  4011. customSkin[va] || (skinDownloadFail[va] && 5 < skinDownloadFail[va] ? myApp.getCustomSkinUrl() === va && $('#skin_url')['val']('')['trigger']('change') : window.postMessage({
  4012. action: Action.IMAGE,
  4013. data: va
  4014. }, '*'))
  4015.  
  4016. customSkin[va] || (skinDownloadFail[va] && 5 < skinDownloadFail[va] ? myApp.getCustomSkinUrl2() === va && $('#skin_url2')['val']('')['trigger']('change') : window.postMessage({
  4017. action: Action.IMAGE,
  4018. data: va
  4019. }, '*'))
  4020.  
  4021. };
  4022. setTimeout(myApp.downloadSkin, 2E3)
  4023. };
  4024. this.changePreviewImage = function(va) {
  4025. $('#preview-img')['fadeOut'](315, function() {
  4026. $(this)['attr']('src', va)['bind']('onreadystatechange load', function() {
  4027. this.complete && $(this)['fadeIn'](315)
  4028. })
  4029. })
  4030. }
  4031.  
  4032. this.changePreviewImage2 = function(va) {
  4033. $('#preview-img2')['fadeOut'](315, function() {
  4034. $(this)['attr']('src', va)['bind']('onreadystatechange load', function() {
  4035. this.complete && $(this)['fadeIn'](315)
  4036. })
  4037. })
  4038. }
  4039. }
  4040.  
  4041. var myApp = new MyApp();
  4042. myApp.init();
  4043.  
  4044. var playerDetailsByIdentifier = {},
  4045. playerDetailsByNick = {},
  4046. announcementSent = 0;
  4047.  
  4048. //全体エントリ, 2000
  4049. function loadGameCore(_win, _jquery) {
  4050.  
  4051. /*
  4052. var gameobject_index = 0;
  4053. function next_go_index(obj){
  4054. gameobject_index++;
  4055. console.log('gameobject_index:' + gameobject_index);
  4056. obj.go_index = gameobject_index;
  4057. }*/
  4058.  
  4059. //GameObject
  4060. function GameObject(_idx, _x, _y, _size, _col, _name, pID, cID, cellType) {
  4061. this.id = _idx;
  4062. this.o = this.x = _x;
  4063. this.p = this.y = _y;
  4064. this.n = this.size = _size;
  4065. this.prevSize = _size;
  4066. this.color = _col;
  4067. this.a = [];
  4068. this.go_Q();
  4069. this.setGameObjectName(_name)
  4070.  
  4071. //gameobject_index++;
  4072. //this.go_index = gameobject_index;
  4073. //next_go_index(this);
  4074. this.debug_val = -1;
  4075. this.can_split = false;
  4076. this.pID = pID;
  4077. this.cID = cID;
  4078. this.cellType = cellType;
  4079. }
  4080. GameObject.prototype = {
  4081. id: 0, //index?
  4082. a: null,
  4083. name: null,
  4084. k: null,
  4085. I: null,
  4086. x: 0,
  4087. y: 0,
  4088. size: 0,
  4089. o: 0,
  4090. p: 0,
  4091. n: 0,
  4092. go_C_x: 0, //x
  4093. go_C_y: 0, //y
  4094. m: 0,
  4095. T: 0,
  4096. K: 0,
  4097. W: 0,
  4098. A: 0,
  4099. f: 0, //isVirus?
  4100. j: 0,
  4101. L: 1,
  4102. go_S_frameTick: 0, //frameTick
  4103. V: null,
  4104. go_index: 0,
  4105. debug_val: -1,
  4106. can_split: false,
  4107. pID: -1,
  4108. cID: -1,
  4109. cellType: -1,
  4110. go_R_remove: function() {
  4111. //remove?
  4112. var va;
  4113. for(va = 0; va < gameObjects.length; va++) {
  4114. if(gameObjects[va] == this) {
  4115. gameObjects.splice(va, 1);
  4116. break
  4117. }
  4118. };
  4119. delete v_74[this.id];
  4120. va = selfOwnedCells.indexOf(this); -1 != va && (v_8d = 1, selfOwnedCells.splice(va, 1));
  4121. va = selfNodeIdList.indexOf(this.id); -1 != va && selfNodeIdList.splice(va, 1);
  4122. this.A = 1
  4123. },
  4124. go_i: function() {
  4125. //getTextSize
  4126. return Math.max(~~(0.32 * this.size), 24)
  4127. //return Math.max(~~(0.35 * this.size), 24)
  4128. //return Math.max(~~(0.4 * this.size), 24);
  4129. },
  4130. getTextColor: function() {
  4131. if(this.f) {
  4132. return "#FFFFFF";//棘
  4133. }
  4134. //var name = this.name;
  4135. //var textCol = "#FFFFFF";
  4136. //if(name.startsWith('【先輩】')) textCol = "#88CCFF";
  4137. //if(name.startsWith('【先輩】')) textCol = "#F0F0FF";
  4138. //if(name.startsWith('【先輩】')) textCol = "#FFFFFF";
  4139. //if(name.startsWith('【敵】')) textCol = "#FF6666";
  4140. //if(name.startsWith('【敵】')) textCol = "#FF8866";
  4141.  
  4142. //return textCol;
  4143. var teamId = playerManager.getTeamId(this.cID);
  4144. return teamManager.getColor(teamId);
  4145. },
  4146.  
  4147. setGameObjectName: function(name) {
  4148. //makeNameLabel
  4149.  
  4150. //var textCol = "#888888";
  4151. //if(name.startsWith('【先輩】')) textCol = "#6666FF";
  4152. //if(name.startsWith('【敵】')) textCol = "#FF4444";
  4153.  
  4154. //var edgeCol = "#FFFFFF";
  4155. //var edgeCol = "#000000";
  4156.  
  4157. var vb = name.match(/\u0001([\u0002-\uffff]|[\u0002-\uffff]\uffff)$/g),
  4158. vd = 0;
  4159. vb && (vd = vb[0]['split']('')[1], 1 < vd.length && (this.img = vd.charCodeAt(0) + 65534));
  4160. if(this.name = name) {
  4161. var textCol = this.getTextColor();
  4162. null == this.k ? (this.k = new DrawingLabel(this.go_i(), textCol, 1, "#000000"), this.k['v'] = Math.ceil(10 * v_88_zoom) / 10) : this.k.G(this.go_i()), this.k.lb_u_setText(this.name)
  4163. }
  4164. },
  4165. go_Q: function() {
  4166. for(var va = this.go_B() ; this.a['length'] > va;) {
  4167. var vb = ~~(Math.random() * this.a['length']);
  4168. this.a['splice'](vb, 1)
  4169. };
  4170. for(0 == this.a['length'] && 0 < va && this.a['push'](new VWWWW(this, this.x, this.y, this.size, Math.random() - 0.5)) ; this.a['length'] < va;) {
  4171. vb = ~~(Math.random() * this.a['length']), vb = this.a[vb], this.a['push'](new VWWWW(this, vb.x, vb.y, vb.g, vb.b))
  4172. }
  4173. },
  4174. go_B: function() {
  4175. var va = 10;
  4176. 20 > this.size && (va = 0);
  4177. this.f && (va = 30);
  4178. var vb = this.size;
  4179. this.f || (vb *= v_88_zoom);
  4180. vb *= v_ba;
  4181. this.T & 32 && (vb *= 0.25);
  4182. return ~~Math.max(vb, va)
  4183. },
  4184. go_da: function() {
  4185. this.go_Q();
  4186. for(var va = this.a, vb = va.length, vd = 0; vd < vb; ++vd) {
  4187. var ve = va[(vd - 1 + vb) % vb]['b'],
  4188. vf = va[(vd + 1) % vb]['b'];
  4189. va[vd]['b'] += (Math.random() - 0.5) * (this.j ? 3 : 1);
  4190. va[vd]['b'] *= 0.7;
  4191. 10 < va[vd]['b'] && (va[vd]['b'] = 10); -10 > va[vd]['b'] && (va[vd]['b'] = -10);
  4192. va[vd]['b'] = (ve + vf + 8 * va[vd]['b']) / 10
  4193. };
  4194. for(var vi = this, vj = this.f ? 0 : (this.id / 1E3 + v_7d / 1E4) % (2 * Math.PI), vd = 0; vd < vb; ++vd) {
  4195. var vh = va[vd]['g'],
  4196. ve = va[(vd - 1 + vb) % vb]['g'],
  4197. vf = va[(vd + 1) % vb]['g'];
  4198. if(15 < this.size && null != v_6e && 20 < this.size * v_88_zoom && 0 < this.id) {
  4199. var vg = 0,
  4200. vk = va[vd]['x'],
  4201. vl = va[vd]['y'];
  4202. v_6e.ea(vk - 5, vl - 5, 10, 10, function(va) {
  4203. va.P != vi && 25 > (vk - va.x) * (vk - va.x) + (vl - va.y) * (vl - va.y) && (vg = 1)
  4204. });
  4205. !vg && (va[vd]['x'] < fieldLeft || va[vd]['y'] < fieldTop || va[vd]['x'] > fieldRight || va[vd]['y'] > fieldBottom) && (vg = 1);
  4206. vg && (0 < va[vd]['b'] && (va[vd]['b'] = 0), --va[vd]['b'])
  4207. };
  4208. vh += va[vd]['b'];
  4209. 0 > vh && (vh = 0);
  4210. vh = this.j ? (19 * vh + this.size) / 20 : (12 * vh + this.size) / 13;
  4211. va[vd]['g'] = (ve + vf + 8 * vh) / 10;
  4212. ve = 2 * Math.PI / vb;
  4213. vf = this.a[vd]['g'];
  4214. this.f && 0 == vd % 2 && (vf += 5);
  4215. va[vd]['x'] = this.x + Math.cos(ve * vd + vj) * vf;
  4216. va[vd]['y'] = this.y + Math.sin(ve * vd + vj) * vf
  4217. }
  4218. },
  4219. go_J: function() {
  4220. if(0 >= this.id) {
  4221. return 1
  4222. };
  4223. var d;
  4224. d = (v_7d - this.K) / 220;
  4225. d = 0 > d ? 0 : 1 < d ? 1 : d;
  4226. var vb = 0 > d ? 0 : 1 < d ? 1 : d;
  4227. this.go_i();
  4228. if(this.A && 1 <= vb) {
  4229. var vd = v_76.indexOf(this); -1 != vd && v_76.splice(vd, 1)
  4230. };
  4231. this.x = d * (this.go_C_x - this.o) + this.o;
  4232. this.y = d * (this.go_C_y - this.p) + this.p;
  4233. this.size = vb * (this.m - this.n) + this.n;
  4234. return vb
  4235. },
  4236. go_H: function() {
  4237. return 0 >= this.id ? 1 : this.x + this.size + 40 < v_70_fieldPosX - _screenWidth / 2 / v_88_zoom || this.y + this.size + 40 < v_71_fieldPosY - _screenHeight / 2 / v_88_zoom || this.x - this.size - 40 > v_70_fieldPosX + _screenWidth / 2 / v_88_zoom || this.y - this.size - 40 > v_71_fieldPosY + _screenHeight / 2 / v_88_zoom ? 0 : 1
  4238. },
  4239. drawGameObject: function(ctx) {
  4240. //if(this.x > gSiteArea.field_sz || this.y > gSiteArea.field_sz) return;
  4241.  
  4242. //draw
  4243. if(this.go_H()) {
  4244. var vb = myApp.isEnableSimpleDrawing;
  4245. if(15 > this.size) {
  4246. myApp.isEnableHideFood || (myApp.isSameColorFood ? v_af.push({
  4247. x: this.x,
  4248. y: this.y,
  4249. size: this.size
  4250. }) : (ctx.beginPath(), ctx.fillStyle = this.color, ctx.arc(this.x, this.y, this.size + 5, 0, 2 * Math.PI, 0), ctx.fill()))
  4251. } else {
  4252. ++this.go_S_frameTick;
  4253. var vd = 0 < this.id && !this.f && !this.j && 0.4 > v_88_zoom;
  4254. 5 > this.go_B() && 0 < this.id && (vd = 1);
  4255. if(this.L && !vd) {
  4256. for(var ve = 0; ve < this.a['length']; ve++) {
  4257. this.a[ve]['g'] = this.size
  4258. }
  4259. }
  4260. ;
  4261. this.L = vd;
  4262. ctx.save();
  4263.  
  4264.  
  4265.  
  4266.  
  4267. this.W = v_7d;
  4268. ve = this.go_J();
  4269. this.A && (ctx.globalAlpha *= 1 - ve);
  4270. ctx.lineWidth = 10;
  4271. ctx.lineCap = 'round';
  4272. ctx.lineJoin = this.f ? 'miter' : 'round';
  4273. var ve = !this.f && 0 < this.id && 15 <= this.size && !this.j ? 1 : 0,
  4274. vf = 0,
  4275. _skin = null,
  4276. _va;
  4277. _va = this.name + this.color;
  4278. _va = _va in playerDetailsByIdentifier ? playerDetailsByIdentifier[_va] : void (0);
  4279. if(ve) {
  4280. myApp.isTransparentCell && (ctx.globalAlpha = 0.8);
  4281.  
  4282. var isInEatableSection = playerManager.checkIsInEatableSection(this.cID);
  4283. if(!isInEatableSection && this.cellType == 0 && gIsPlaying) {
  4284. ctx.globalAlpha = 0.3;
  4285. }
  4286. for(var vj = 0; vj < selfNodeIdList.length; vj++) {
  4287. this.id === selfNodeIdList[vj] && (vf = 1)
  4288. }
  4289. ;
  4290.  
  4291. if(vf) {
  4292. //myApp.isEnableCursorLine && (ctx.save(), ctx.strokeStyle = this.can_split ? '#0066FF' : '#E3F2FD', ctx.lineWidth = this.can_split ? 12 : 4, ctx.lineCap = 'round', ctx.lineJoin = 'round', ctx.globalAlpha = 0.8, ctx.beginPath(), ctx.moveTo(this.x, this.y), ctx.lineTo(refPositionX, refPositionY), ctx.stroke(), ctx.restore());
  4293. myApp.isEnableAttackRange && (ctx.beginPath(), ctx.strokeStyle = v_8f ? 'white' : 'black', ctx.arc(this.x, this.y, this.size + myApp.attackRangeRadius, 0, 2 * Math.PI, 0), ctx.stroke(), ctx.closePath());
  4294. myApp.isEnableCustomSkin && (_skin = myApp.getSkinImage(nodeList[0][5]));
  4295. }
  4296. };
  4297.  
  4298. v_8c ? (ctx.fillStyle = '#FFFFFF', ctx.strokeStyle = '#AAAAAA') : (ctx.fillStyle = this.color, ctx.strokeStyle = this.color);
  4299. vb && this.f && (ctx.fillStyle = '#6e6e6e', ctx.globalAlpha = 0.8, ctx.lineWidth = 10, ctx.strokeStyle = '#FFFFFF');
  4300. if(vb || vd) {
  4301. ctx.beginPath(), ctx.arc(this.x, this.y, this.size + 5, 0, 2 * Math.PI, 0), myApp.isEnableSplitInd && ve && !vf && (this.name || 38 < this.size) && (this.cellType == 0) && extraCellsPosSizes.push({
  4302. x: this.x,
  4303. y: this.y,
  4304. size: this.size
  4305. })
  4306. } else {
  4307. this.go_da();
  4308. ctx.beginPath();
  4309. var label = this.go_B();
  4310. ctx.moveTo(this.a[0]['x'], this.a[0]['y']);
  4311. for(ve = 1; ve <= label; ++ve) {
  4312. vj = ve % label, ctx.lineTo(this.a[vj]['x'], this.a[vj]['y'])
  4313. }
  4314. };
  4315. ctx.closePath();
  4316.  
  4317. // ve = this.name['toLowerCase']();
  4318. // vj = this.img ? 'http://upload.happyfor.me/getimg.php?id=' + this.img + '&_t=' + Math.random() : 'skins/' + ve + '.png';
  4319. // _skin || this.j || !v_8a && !myApp.isEnableOtherSkinSupport || ':teams' == v_94 ? label = null : (label = this.V, null == label ? label = null : ':' == label[0] ? (v_bf.hasOwnProperty(label) || (v_bf[label] = new Image, v_bf[label]['src'] = label.slice(1)), label = 0 != v_bf[label]['width'] && v_bf[label]['complete'] ? v_bf[label] : null) : label = null, label || (-1 != v_bd.indexOf(ve) && v_8a || this.img ? ($['hasOwnProperty'](ve) || ($[ve] = new Image, $[ve]['src'] = vj), label = 0 != $[ve]['width'] && $[ve]['complete'] ? $[ve] : null) : label = null));
  4320. // vj = label;
  4321. // vd || !vb || !this.f || ctx.stroke();
  4322. //ctx.stroke();
  4323. ctx.fill();
  4324.  
  4325. var __skin__;
  4326. //var _va0 = this.pID;
  4327. //__skin__ = (_va0 && gPlayerInfoDict[_va0]) ? gPlayerInfoDict[_va0].skinUrl : null; //OgarMap
  4328. if(this.cellType == 0 && this.cID > 0) {
  4329.  
  4330. var skinIndex = playerCoreManager.getSkinIndex(this.pID);
  4331.  
  4332. if(skinIndex == 0) {
  4333. __skin__ = playerManager.getSkinUrl(this.cID);
  4334. } else if(skinIndex == 1) {
  4335. __skin__ = playerManager.getSkinUrl2(this.cID);
  4336. }
  4337. }
  4338.  
  4339. // if(skinIndex >= 1){
  4340. // //todo: 2スキン実装
  4341. // __skin__ = null;
  4342. // }
  4343.  
  4344.  
  4345. var shown = !gconfig.enableTeamSkinSeparation;
  4346. shown |= gconfig.enableTeamSkinSeparation && playerManager.checkIsTeammate(this.cID);
  4347. shown |= gconfig.enableAllSkinShownWhileSpectating && gIsSpectate;
  4348. if(!shown) {
  4349. __skin__ = null;
  4350. }
  4351.  
  4352. if(!myApp.isEnableCustomSkin) {
  4353. __skin__ = null;
  4354. }
  4355.  
  4356. if(myApp.isEnableCustomSkin &&
  4357. //(label = null, _skin = 0, _va && (_skin = _va.url),
  4358. (label = null, _skin = 0, __skin__ && (_skin = __skin__), //gPlayerInfoDict[_va0]),
  4359. _skin && (v_bc.hasOwnProperty(_skin) ||
  4360. (_va = new Image, _va.src = _skin, v_bc[_skin] = _va),
  4361. v_bc[_skin]['width'] && v_bc[_skin]['complete'] && (label = v_bc[_skin])), vj = label, null != vj)) {
  4362. var vk = Math.min(vj.width, vj.height),
  4363. vl = (vj.width - vk) / 2,
  4364. vm = (vj.height - vk) / 2,
  4365. v_53 = this.size + 5;
  4366. null != vj && (ctx.save(), ctx.clip(), ctx.drawImage(vj, vl, vm, vk, vk, this.x - v_53, this.y - v_53, 2 * v_53, 2 * v_53), ctx.restore());
  4367. }
  4368.  
  4369.  
  4370. if(this.cellType == 0 && selfOwnedCells.indexOf(this) >= 0) {
  4371.  
  4372.  
  4373. if(myApp.showSplitOrderMarker) {
  4374. //ctx.save();
  4375. ctx.globalAlpha = 0.6;
  4376. ctx.strokeStyle = this.can_split ? 'rgba(0, 255, 0, 1)' : 'rgba(255, 255, 255, 1)';
  4377. var lw = this.size * 0.16;
  4378. ctx.lineWidth = lw;
  4379. ctx.beginPath();
  4380. ctx.arc(this.x, this.y, this.size - lw / 2, 0, TWO_PI, 0);
  4381. ctx.stroke();
  4382. }
  4383.  
  4384. if(gconfig.enableDualUnitOperation && myApp.showActiveTurnMarker) {
  4385. ctx.globalAlpha = 0.8;
  4386. //selfOwnedCells.forEach(cell => {
  4387. var isActive = this.pID == gActiveTurnPlayerId;
  4388. ctx.strokeStyle = isActive ? '#F0F' : '#FFF'; //'rgba(0, 128, 255, 1'
  4389. var lw = this.size * 0.10;
  4390. ctx.lineWidth = lw;
  4391. ctx.beginPath();
  4392. ctx.arc(this.x, this.y, this.size - lw / 2, 0, TWO_PI, 0);
  4393. ctx.stroke();
  4394. //});
  4395. }
  4396.  
  4397.  
  4398. }
  4399.  
  4400.  
  4401. vb || ((v_8c || 15 < this.size) && !vd && (ctx.strokeStyle = '#000000', ctx.globalAlpha *= 0.1, ctx.stroke()), ctx.globalAlpha = 1);
  4402. label = -1 != selfOwnedCells.indexOf(this);
  4403. vd = ~~this.y;
  4404. vb = this.f || 315 < this.size || 18 < this.size * v_88_zoom;
  4405. if(!(vf && myApp.isHideSelfName || myApp.isAutoHideName && !vb) && 0 != this.id && (v_8b || label) && this.name && this.k && (null == vj || -1 == v_be.indexOf(ve))) {
  4406. vj = this.k;
  4407. //var team = '';
  4408. //var pID = this.pID;
  4409. // var info = gPlayerInfoDict[pID];
  4410. // if(info){
  4411. // team = info.team;
  4412. // }
  4413. //var team = playerManager.getTeam(this.cID);
  4414. var fullName = playerManager.getFullName(this.cID);
  4415.  
  4416. if(gconfig.addUserTokenToPlayerCellName) {
  4417. var token = playerManager.getUserToken(this.cID);
  4418. var isBot = playerManager.checkIsBot(this.cID);
  4419. if(!isBot) {
  4420. fullName += `(${token})`;
  4421. }
  4422. }
  4423.  
  4424. vj.lb_u_setText(fullName); //team + this.name);
  4425. vj.G(this.go_i() / 0.9);
  4426. ve = 0 >= this.id ? 1 : Math.ceil(10 * v_88_zoom) / 10;
  4427. vj.U(ve);
  4428. var vj = vj.lb_F_render(),
  4429. vn = ~~(vj.width / ve),
  4430. vo = ~~(vj.height / ve);
  4431. ctx.drawImage(vj, ~~this.x - ~~(vn / 2), vd - ~~(vo / 2), vn, vo);
  4432. vd += vj.height / 2 / ve + 4
  4433. }
  4434. ;
  4435.  
  4436. var mass = (this.size * this.size / 100);
  4437.  
  4438. //this.debug_val = this.id;
  4439.  
  4440. var textCol = this.getTextColor();
  4441. //var textCol = teamManager.getNameColor(team);
  4442.  
  4443. myApp.isAutoHideMass && !vb || !myApp.isEnableShowAllMass ||
  4444. 0 < this.id && v_90 && 38 < this.size && (this.cellType == 0 || this.cellType == 2) &&
  4445. (null == this.I && (this.I = new DrawingLabel(this.go_i() / 2, textCol, 1, '#000000')),
  4446. label = this.I, label.G(this.go_i() / 0.8),
  4447. label.lb_u_setText(~~(this.size * this.size / 100)),
  4448.  
  4449. //label.lb_u_setText(~~this.id), //debug
  4450. //label.lb_u_setText(~~this.pID), //debug
  4451.  
  4452. ve = Math.ceil(10 * v_88_zoom) / 10, label.U(ve), vj = label.lb_F_render(), vn = ~~(vj.width / ve), vo = ~~(vj.height / ve),
  4453. ctx.drawImage(vj, ~~this.x - ~~(vn / 2), vd - ~~(vo / 2.7), vn, vo));
  4454.  
  4455. ctx.restore();
  4456. if(this.I) this.I.setFillColor(textCol);
  4457. if(this.k) {
  4458. this.k.setFillColor(textCol);
  4459. //var fullName = playerManager.getFullName(this.cID);
  4460. //this.k.lb_u_setText(fullName);
  4461. }
  4462. }
  4463. }
  4464. //var textCol = this.getTextColor();
  4465. //if (this.I) this.I.lb_M_fillColor = textCol;
  4466. //if (this.k)this.k.lb_M_fillColor = textCol;
  4467.  
  4468. }
  4469. };
  4470.  
  4471. //DrawingLabel
  4472. function DrawingLabel(va, col, vd, ve) {
  4473. va && (this.lb_q_size = va); //size?
  4474. col && (this.lb_M_fillColor = col); //fillColor
  4475. this.O = !!vd;
  4476. ve && (this.lb_r_strokeColor = ve) //strokeColor
  4477. }
  4478. DrawingLabel.prototype = {
  4479. lb_w_text: '',
  4480. lb_M_fillColor: '#000000',
  4481. O: 0,
  4482. lb_r_strokeColor: '#000000',
  4483. lb_q_size: 16,
  4484. l: null,
  4485. N: null,
  4486. h: 0,
  4487. v: 1,
  4488. G: function(va) {
  4489. 5 < Math.abs(va - this.lb_q_size) && this.lb_q_size != va && (this.lb_q_size = va, this.h = 1)
  4490. },
  4491. U: function(va) {
  4492. this.v != va && (this.v = va, this.h = 1)
  4493. },
  4494. setStrokeColor: function(va) {
  4495. this.lb_r_strokeColor != va && (this.lb_r_strokeColor = va, this.h = 1)
  4496. },
  4497. setFillColor: function(col) {
  4498. if(col != this.lb_M_fillColor) {
  4499. this.lb_M_fillColor = col;
  4500. this.h = 1;
  4501. }
  4502. },
  4503. lb_u_setText: function(va) {
  4504. //setText?
  4505. var vb;
  4506. !isNaN(va) && !isNaN(this.lb_w_text) && 0 != this.lb_w_text && 0 != va && this.lb_w_text != va && 0.012 > Math.abs((va - this.lb_w_text) / this.lb_w_text) && (vb = this.lb_w_text, this.lb_w_text = va);
  4507. va != this.lb_w_text && (this.lb_w_text = va, this.h = 1);
  4508. vb && (this.lb_w_text = vb)
  4509. },
  4510. lb_F_render: function() {
  4511. null == this.l && (this.l = document.createElement('canvas'), this.N = this.l['getContext']('2d'));
  4512. if(this.h) {
  4513. this.h = 0;
  4514. var canvas = this.l,
  4515. ctx = this.N,
  4516. text = this.lb_w_text,
  4517. ve = this.v,
  4518. size = this.lb_q_size,
  4519. //vi = 'bold ' + vf + 'px Ubuntu';
  4520. //vi = 'bold ' + size + 'px メイリオ';
  4521. vi = 'bolder ' + (size * 0.8) + 'px メイリオ, arial';
  4522. ctx.font = vi;
  4523. var vj = ~~(0.2 * size);
  4524. //var vj = ~~(0.2 * size);
  4525. canvas.width = (ctx.measureText(text)['width'] + 6) * ve;
  4526. canvas.height = (size + vj) * ve;
  4527. ctx.font = vi;
  4528. ctx.scale(ve, ve);
  4529. ctx.globalAlpha = 1;
  4530. //ctx.globalAlpha = 0.8;
  4531. ctx.fillStyle = this.lb_M_fillColor;
  4532.  
  4533. //ctx.fillStyle = '#FF00FF';
  4534. myApp.isShowTextStrokeLine && (ctx.lineWidth = Math.max(size * 0.12, 5), ctx.strokeStyle = this.lb_r_strokeColor, this.O && ctx.strokeText(text, 3, size - vj / 2));
  4535.  
  4536. ctx.fillText(text, 3, size - vj / 2); //draw label
  4537. };
  4538. return this.l
  4539. }
  4540. };
  4541.  
  4542. function VWWWW(va, vb, vd, ve, vf) {
  4543. this.P = va;
  4544. this.x = vb;
  4545. this.y = vd;
  4546. this.g = ve;
  4547. this.b = vf
  4548. }
  4549. VWWWW.prototype = {
  4550. P: null,
  4551. x: 0,
  4552. y: 0,
  4553. g: 0,
  4554. b: 0
  4555. };
  4556.  
  4557.  
  4558. function vf() {
  4559. v_96 = 1;
  4560. vj();
  4561. setInterval(vj, 18E4);
  4562. v_6b = v_6a = document.getElementById('canvas');
  4563. document.getElementById('overlays2')['onmousemove'] = function(v_4f) {
  4564. clientMouseX = v_4f.clientX;
  4565. clientMouseY = v_4f.clientY;
  4566. onClientMousePositionChanged()
  4567. //trace("mx:" + clientMouseX);
  4568. //trace("my:" + clientMouseY);
  4569. };
  4570. ctx = v_6b.getContext('2d');
  4571.  
  4572. //console.log(navigator.userAgent);
  4573.  
  4574. function vg(e) {
  4575. //var delta = e.deltaY ? -(e.deltaY) : e.wheelDelta ? e.wheelDelta : -(e.detail);
  4576. if(myApp.isEnableZoom){
  4577. var delta = e.wheelDelta / -120 || e.detail / 3 || 0;
  4578. //console.log('delta:' + delta);
  4579. v_a1_zoomLevel *= Math.pow(myApp.getZoomSpeed(), delta); //e.wheelDelta / -120 || e.detail || 0);
  4580. myApp.getZoomLimit() > v_a1_zoomLevel && (v_a1_zoomLevel = myApp.getZoomLimit());
  4581. v_a1_zoomLevel > 1 / v_88_zoom && (v_a1_zoomLevel = 1 / v_88_zoom);
  4582. }
  4583. }
  4584.  
  4585. if(navigator.userAgent.indexOf('Firefox') >= 0){
  4586. //console.log('isFirefox: true');
  4587. document.body.addEventListener('DOMMouseScroll', vg, false);
  4588. }else{
  4589. document.body.onmousewheel = vg;
  4590. }
  4591. //document.body['onmousewheel'] = vg;
  4592. //$(document).on('mousewheel DOMMouseScroll', vg);
  4593.  
  4594. //var mouse_wheel_event_name = 'DOMMouseScroll';//onwheel' in document
  4595. //if('onwheel' in document) mouse_wheel_event_name = 'wheel';
  4596. //document.body.addEventListener(mouse_wheel_event_name, vg, false);
  4597.  
  4598. var keySpace = 32;
  4599. var keyQ = 81;
  4600. var keyW = 87;
  4601.  
  4602. var holdSpace = 0;
  4603. var holdQ = 0;
  4604. var holdW = 0;
  4605.  
  4606. _win.onkeydown = function(e) {
  4607. var key = e.keyCode;
  4608.  
  4609. //keySpace != e.keyCode || chatRoom.isFocus() || v_4f || (_MOVE(), v_58(17), v_4f = 1);
  4610. if(key == keySpace && !chatRoom.isFocus() && !holdSpace) {
  4611. _MOVE();
  4612. SendPlayerAction(17);
  4613. holdSpace = 1;
  4614. if(selfOwnedCells.length < 16) {
  4615. gSplitTimingTick = gSplitTimingDuration;
  4616. }
  4617. }
  4618.  
  4619. //keyQ != e.keyCode || vd || (v_58(18), vd = 1);
  4620. if(key == keyQ && !holdQ) {
  4621. SendPlayerAction(18);
  4622. holdQ = 1;
  4623. }
  4624.  
  4625. //keyW != e.keyCode || chatRoom.isFocus() || v_50 || (_MOVE(), v_58(21), v_50 = 1);
  4626.  
  4627. if(key == keyW && !chatRoom.isFocus() && !holdW) {
  4628. //MOVING = true;
  4629. if(MOVING) {
  4630. _MOVE();
  4631. SendPlayerAction(21);
  4632. } else {
  4633. //静止中の餌だし
  4634. MOVING = true;
  4635. _MOVE(true);
  4636. SendPlayerAction(21);
  4637. // setTimeout(function () {
  4638. // SendPlayerAction(21);
  4639. // MOVING = false;
  4640. // }, 1);
  4641. }
  4642.  
  4643. holdW = 1;
  4644. //trace("w");
  4645.  
  4646. }
  4647.  
  4648.  
  4649. /*
  4650. if (key == keyW && !chatRoom.isFocus() && !holdW) {
  4651. _MOVE();
  4652. SendPlayerAction(21);
  4653. holdW = 1;
  4654. }
  4655. */
  4656. isJoinedGame && !$('#overlays')['is'](':visible') || spectateMode ? 27 == e.keyCode && (e.preventDefault(), vi(300)) : 27 == e.keyCode && (e.preventDefault(), $('.btn-play')['trigger']('click'))
  4657. };
  4658. _win.onkeyup = function(e) {
  4659. var key = e.keyCode;
  4660.  
  4661. //keySpace == e.keyCode && (v_4f = 0);
  4662. if(key == keySpace) holdSpace = 0;
  4663.  
  4664. //keyQ == e.keyCode && (v_50 = 0);
  4665. if(key == keyQ) holdQ = 0;
  4666.  
  4667. //keyW == e.keyCode && vd && (v_58(19), vd = 0)
  4668. if(key == keyW && holdW) {
  4669. SendPlayerAction(19);
  4670. holdW = 0;
  4671. }
  4672.  
  4673. };
  4674. _win.onblur = function() {
  4675. SendPlayerAction(19);
  4676. holdW = holdQ = holdSpace = 0
  4677. };
  4678. _win.onresize = windowOnResize;
  4679. _win.requestAnimationFrame(animationFrameFuncRoot);
  4680.  
  4681. //setInterval(_MOVE, 42);
  4682.  
  4683. function moveProc() {
  4684. _MOVE();
  4685. setTimeout(moveProc, 42);
  4686. }
  4687. setTimeout(moveProc, 42);
  4688.  
  4689. v_89 && _jquery('#region')['val'](v_89);
  4690. vr();
  4691. vk(_jquery('#region')['val']());
  4692. 0 == v_a4 && v_89 && vl();
  4693. vi(0);
  4694. windowOnResize();
  4695. _win.location['hash'] && 6 <= _win.location['hash']['length'] && v_62(_win.location['hash'])
  4696. }
  4697.  
  4698. function CreatePlayerEntryData(_action) {
  4699. var id = null;
  4700. 0 < v_68.playerCells()['length'] && (id = v_68.playerCells()[0], id = id.name + id.color);
  4701. var vd = _jquery('#skin_url')['val']();
  4702. if(-1 != vd.indexOf('!!')) {
  4703. try {
  4704. atob(vd.slice(2))
  4705. } catch(ve) { }
  4706. };
  4707. return {
  4708. displayName: _jquery('#nick')['val'](),
  4709. action: _action,
  4710. socketRoom: myApp.getRoom(),
  4711. identifier: id,
  4712. url: myApp.getCustomSkinUrl(),
  4713. nick: _jquery('#nick')['val'](),
  4714. team: _jquery('#team_name')['val'](),
  4715. token: myApp.getCurrentPartyCode()
  4716. }
  4717. }
  4718.  
  4719. /*
  4720. function EnterPlayer() {
  4721. if(!announcementSent) {
  4722. if(0 < v_68.playerCells()['length']) {
  4723. announcementSent = 1;
  4724.  
  4725. if(!UseOgarMapImpl) {
  4726. var data = CreatePlayerEntryData('join');
  4727. playerDetailsByIdentifier[data.identifier] = data;
  4728. playerDetailsByNick[data.nick] = data;
  4729. conn.emit('playerEntered', data);
  4730. } else {
  4731. var cell = v_68.playerCells()[0];
  4732. gPlayerSignature = cell.name + cell.color; //cell.id + cell.name;
  4733. skinProvider.sendSkinInfo();
  4734. skinProvider.requestBroadcastSkins();
  4735. }
  4736. } else {
  4737. setTimeout(EnterPlayer, 100)
  4738. }
  4739. }
  4740. }
  4741. */
  4742.  
  4743. function onClientMousePositionChanged() {
  4744. //フィールド上でのカーソル座標
  4745. refPositionX = (clientMouseX - _screenWidth / 2) / v_88_zoom + v_70_fieldPosX;
  4746. refPositionY = (clientMouseY - _screenHeight / 2) / v_88_zoom + v_71_fieldPosY;
  4747. /*
  4748. if (myApp.isStopMovement) {
  4749. refPositionX = stopPositionX;
  4750. refPositionY = stopPositionY;
  4751.  
  4752. //trace("refPositionX:" + refPositionX);
  4753.  
  4754. } else {
  4755.  
  4756. }
  4757. */
  4758. //trace("LR:" + fieldLeft + "," + fieldRight);
  4759. //trace("refPositionX:" + refPositionX);
  4760. }
  4761.  
  4762. function vj() {
  4763. null == v_b2 && (v_b2 = {}, _jquery('#region')['children']()['each'](function() {
  4764. var v_4f = _jquery(this),
  4765. va = v_4f.val();
  4766. va && (v_b2[va] = v_4f.text())
  4767. }));
  4768.  
  4769. //http://m.gar.io/infoã‹ã‚‰æƒ…å ±å–å¾—
  4770. //vb.get('http://m.agar.io/info', function(v_4f) {
  4771. // var va = {},
  4772. // vd;
  4773. // for(vd in v_4f.regions) {
  4774. // var ve = vd.split(':')[0];
  4775. // va[ve] = va[ve] || 0;
  4776. // va[ve] += v_4f.regions[vd]['numPlayers']
  4777. // };
  4778. // for(vd in va) {
  4779. // vb('#region option[value="' + vd + '"]')['text'](v_b2[vd] + ' (' + va[vd] + ' players)')
  4780. // }
  4781. //}, 'json')
  4782. }
  4783.  
  4784. function vn() {
  4785. _jquery('#overlays')['hide']();
  4786. _jquery('#stats')['hide']();
  4787. v_c6 = v_a3 = 0;
  4788. vr()
  4789. }
  4790.  
  4791. function vk(v_4f) {
  4792. 'gathering' == _jquery('#region')['val']() ? connect(PRIVATE_SERVER_IP, '') : v_4f && v_4f != v_89 && (_jquery('#region')['val']() != v_4f && _jquery('#region')['val'](v_4f), v_89 = _win.localStorage['location'] = v_4f, _jquery('.region-message')['hide'](), _jquery('.region-message.' + v_4f)['show'](), _jquery('.btn-needs-server')['prop']('disabled', 0), v_96 && vl())
  4793. }
  4794.  
  4795. function vi(v_4f) {
  4796. v_a3 || v_c6 || (game_playername_sending = null, 1E3 > v_4f && (v_a2 = 1), v_a3 = 1, _jquery('#mainPanel')['show'](), _jquery('#overlays')['show']())
  4797. }
  4798.  
  4799. function vz(v_4f) {
  4800. _jquery('#helloContainer')['attr']('data-gamemode', v_4f);
  4801. v_94 = v_4f;
  4802. _jquery('#gamemode')['val'](v_4f)
  4803. }
  4804.  
  4805. function vr() {
  4806. _jquery('#region')['val']() ? _win.localStorage['location'] = _jquery('#region')['val']() : _win.localStorage['location'] && _jquery('#region')['val'](_win.localStorage['location']);
  4807. _jquery('#region')['val']() ? _jquery('#locationKnown')['append'](_jquery('#region')) : _jquery('#locationUnknown')['append'](_jquery('#region'))
  4808. }
  4809.  
  4810. function vm(v_4f) {
  4811. return _win.i18n[v_4f] || _win.i18n_dict['en'][v_4f] || v_4f
  4812. }
  4813.  
  4814. function vp() {
  4815. var v_4f = ++v_a4;
  4816. console.log('Find ' + v_89 + v_94);
  4817. _jquery.ajax('http://m.agar.io/findServer', {
  4818. error: function() {
  4819. setTimeout(vp, 1E3)
  4820. },
  4821. success: function(va) {
  4822. '' != v_a6 && va.ip != v_a6 ? vp() : v_4f == v_a4 && (va.alert && alert(va.alert), connectToGameServer('ws://' + va.ip, va.token))
  4823. },
  4824. dataType: 'json',
  4825. method: 'POST',
  4826. cache: 0,
  4827. crossDomain: 1,
  4828. data: (v_89 + v_94 || '?') + '\n154669603'
  4829. })
  4830. }
  4831.  
  4832. function vl() {
  4833. v_96 && v_89 && (_jquery('#connecting')['show'](), vp())
  4834. }
  4835.  
  4836. function disconnectGameServer() {
  4837. var ws = window.webSocket;
  4838. if(ws) {
  4839. ws.onopen = null;
  4840. ws.onmessage = null;
  4841. ws.onclose = null;
  4842. ws.close();
  4843. window.webSocket = null;
  4844. }
  4845. }
  4846.  
  4847. function connectToGameServer(v_4f, va) {
  4848. currentIP = v_4f;
  4849. if(webSocket) {
  4850. webSocket.onopen = null;
  4851. webSocket.onmessage = null;
  4852. webSocket.onclose = null;
  4853. try {
  4854. webSocket.close()
  4855. } catch(vb) { };
  4856. webSocket = null
  4857. };
  4858. v_a5.ip && (v_4f = 'ws://' + v_a5.ip);
  4859. if(null != v_b3) {
  4860. var vd = v_b3;
  4861. v_b3 = function() {
  4862. vd(va)
  4863. }
  4864. };
  4865. /*
  4866. if(v_69) {
  4867. var ve = v_4f.split(':');
  4868. v_4f = ve[0] + 's://ip-' + ve[1]['replace'](/\./g, '-')['replace'](/\//g, '') + '.tech.agar.io:' + (+ve[2] + 2E3)
  4869. };
  4870. */
  4871. selfNodeIdList = [];
  4872. selfOwnedCells = [];
  4873. v_74 = {};
  4874. gameObjects = [];
  4875. v_76 = [];
  4876. leaderBoardList = [];
  4877. v_b9 = v_95 = null;
  4878. highest_score = 0;
  4879. v_9f = 0;
  4880. $('#server_message_box').html('');
  4881.  
  4882.  
  4883. //console.log('connecting to game server,' + v_4f);
  4884. console.log('connecting to game server');// + v_4f);
  4885.  
  4886. var m = v_4f.match('ws://(.*):(.*)');
  4887. //var host = m[1];
  4888. //var port = m[2];
  4889. window.GameServerHost = m[1];
  4890. window.GameServerPort = parseInt(m[2]);
  4891. //console.log(window.GameServerHost + ',' + window.GameServerPort);
  4892.  
  4893. webSocket = new WebSocket(v_4f);
  4894.  
  4895. window.webSocket = webSocket;
  4896. webSocket.binaryType = 'arraybuffer';
  4897. webSocket.onopen = function() {
  4898.  
  4899. //gLocalPlayerIdPerConnection = Math.floor(Math.random() * 65535);
  4900. //trace("local_id:" + gLocalPlayerIdPerConnection);
  4901.  
  4902. //var msg;
  4903. console.log('socket opened');
  4904.  
  4905. chatRoom.clearMessages();
  4906.  
  4907.  
  4908. // selfNodeIdList = [];
  4909. // selfOwnedCells = [];
  4910. // v_74 = {};
  4911. // gameObjects = [];
  4912. // v_76 = [];
  4913. // leaderBoardList = [];
  4914. // v_b9 = v_95 = null;
  4915. // highest_score = 0;
  4916. // v_9f = 0;
  4917.  
  4918.  
  4919. /*
  4920. msg = CreateDataView(5);
  4921. msg.setUint8(0, 254);
  4922. msg.setUint32(1, 5, 1);
  4923. SendDataFrame(msg);
  4924. msg = CreateDataView(5);
  4925. msg.setUint8(0, 255);
  4926. msg.setUint32(1, 154669603, 1);
  4927. SendDataFrame(msg);
  4928. */
  4929.  
  4930. /*
  4931. {
  4932. //init, old
  4933. var fb = new DataFrameWriter();
  4934. fb.writeUint8(255);
  4935. fb.writeStringEx(CommunicationVersionKey2);
  4936. SendDataFrame(new Uint8Array(fb.getArrayBuffer()));
  4937.  
  4938. fb = new DataFrameWriter();
  4939. fb.writeUint8(253);
  4940. fb.writeStringEx(gUserId);
  4941. SendDataFrame(new Uint8Array(fb.getArrayBuffer()));
  4942. //clearPlayerSelfEntryData();
  4943. }
  4944. */
  4945.  
  4946. {
  4947. //init, new
  4948. var fb = new DataFrameWriter();
  4949. fb.writeUint8(252);
  4950. fb.writeStringEx(CommunicationVersionKey2);
  4951. fb.writeStringEx(gUserId);
  4952. SendDataFrame(new Uint8Array(fb.getArrayBuffer()));
  4953. }
  4954.  
  4955. gGameServerAddress = v_4f;
  4956. gIsConnected = true;
  4957. gIsPlaying = false;
  4958.  
  4959. //clearNickEntryCash();
  4960. //setNickB();
  4961.  
  4962.  
  4963. //UserToken周り,プラベ鯖ではUserTokenを扱っていないためエラー?
  4964. //.lengthが定義されていないというエラーが出るのを回避
  4965. //v_4f = CreateDataView(1 + va.length);
  4966. //v_4f.setUint8(0, 80);
  4967. //for (var vb = 0; vb < va.length; ++vb) {
  4968. // v_4f.setUint8(vb + 1, va.charCodeAt(vb))
  4969. //};
  4970. //SendDataFrame(v_4f);
  4971.  
  4972. //v_59();
  4973. //4 < va.length && 6 >= va.length ? v_63('/#' + va) : v_63('/');
  4974. //if (void (0) !== window.userToken) {
  4975. // for (var vb = [8, 1, 18, userToken.length + 25, 1, 8, 10, 82, userToken.length + 20, 1, 10, 13, 8, 5, 18, 5, 49, 46, 52, 46, 57, 24, 0, 32, 0, 16, 2, 26, userToken.length, 1], vd = 0; vd <= userToken.length - 1; vd++) {
  4976. // vb.push(userToken.charCodeAt(vd))
  4977. // };
  4978. // v_4f = new DataView(new ArrayBuffer(1 + vb.length));
  4979. // v_4f.setUint8(0, 102);
  4980. // for (vd = 0; vd < vb.length; vd++) {
  4981. // v_4f.setUint8(1 + vd, vb[vd])
  4982. // };
  4983. // webSocket.send(v_4f.buffer)
  4984. //} else {
  4985. // setTimeout(function () {
  4986. // for (var v_4f = [8, 1, 18, userToken.length + 25, 1, 8, 10, 82, userToken.length + 20, 1, 10, 13, 8, 5, 18, 5, 49, 46, 52, 46, 57, 24, 0, 32, 0, 16, 2, 26, userToken.length, 1], va = 0; va <= userToken.length - 1; va++) {
  4987. // v_4f.push(userToken.charCodeAt(va))
  4988. // };
  4989. // var vb = new DataView(new ArrayBuffer(1 + v_4f.length));
  4990. // vb.setUint8(0, 102);
  4991. // for (va = 0; va < v_4f.length; va++) {
  4992. // vb.setUint8(1 + va, v_4f[va])
  4993. // };
  4994. // webSocket.send(vb.buffer)
  4995. // }, 5E3)
  4996. //}
  4997. };
  4998. webSocket.onmessage = onMessage;
  4999. webSocket.onclose = onClose;
  5000. webSocket.onerror = function() {
  5001. console.log('socket error')
  5002. }
  5003. }
  5004.  
  5005. function CreateDataView(n) {
  5006. return new DataView(new ArrayBuffer(n))
  5007. }
  5008.  
  5009. function SendDataFrame(msg) {
  5010. frameSendQueueCount++;
  5011. webSocket.send(msg.buffer)
  5012. //ws.send(msg.buffer);
  5013. }
  5014.  
  5015. function onClose(e) {
  5016. v_9f && (v_b4 = 500);
  5017. console.log('socket closed,' + e.reason);
  5018. setTimeout(vl, v_b4);
  5019. v_b4 *= 2
  5020. var msg = e.reason;
  5021. if(msg && msg.startsWith('serverMaxConnections')){
  5022. $('#server_instruction_text').html('Server is full house. Please access after a while.</br>満員です。しばらく時間をおいてからアクセスしてください。');
  5023. }
  5024. }
  5025.  
  5026. function onMessage(v_4f) {
  5027. var view = new DataView(v_4f.data);
  5028. decodeMessage(view)
  5029. conn2.decodeMessage(view);
  5030. }
  5031.  
  5032. function decodeMessage(msg) {
  5033. function getString() {
  5034. for(var vd = ''; ;) {
  5035. var v_51 = msg.getUint16(vb, 1);
  5036. vb += 2;
  5037. if(0 == v_51) {
  5038. break
  5039. };
  5040. vd += String.fromCharCode(v_51)
  5041. };
  5042. return vd
  5043. }
  5044. v_ab++;
  5045. var vb = 0;
  5046. 240 == msg.getUint8(vb) && (vb += 5);
  5047. var opcode = msg.getUint8(vb++);
  5048. if(opcode != 16) {
  5049. //console.log('opcode: ' + opcode);
  5050. }
  5051. switch(opcode) {
  5052. case 16:
  5053. updateBlobInfo(msg, vb);
  5054. break;
  5055. //case 14:
  5056. // updateBlobInfo2(msg, vb);
  5057. // break;
  5058. case 17:
  5059. stopPositionX = msg.getFloat32(vb, 1);
  5060.  
  5061. //utils.confirm(!isNaN(stopPositionX));
  5062. vb += 4;
  5063. stopPositionY = msg.getFloat32(vb, 1);
  5064. var vb = vb + 4,
  5065. num = msg.getFloat32(vb, 1);
  5066. v_aa = num;
  5067. myApp.isEnableLockZoom || (v_93 = num);
  5068. vb += 4;
  5069.  
  5070. //gSiteArea.x = stopPositionX;
  5071. //gSiteArea.y = stopPositionY;
  5072. //gSiteArea.zoom = num;
  5073. break;
  5074. case 18:
  5075. //console.log('gIsPlaying:' + gIsPlaying);
  5076. selfNodeIdList = [];
  5077. selfOwnedCells = [];
  5078. v_74 = {};
  5079. gameObjects = [];
  5080. break;
  5081. case 20:
  5082. selfOwnedCells = [];
  5083. selfNodeIdList = [];
  5084. break;
  5085. case 21:
  5086. v_98 = msg.getInt16(vb, 1);
  5087. vb += 2;
  5088. v_99 = msg.getInt16(vb, 1);
  5089. vb += 2;
  5090. v_97 || (v_97 = 1, v_9a = v_98, v_9b = v_99);
  5091. break;
  5092. case 32:
  5093. selfNodeIdList.push(msg.getUint32(vb, 1));
  5094. vb += 4;
  5095. break;
  5096. case 49:
  5097. if(null != v_95) {
  5098. break
  5099. };
  5100. num = msg.getUint32(vb, 1);
  5101. vb += 4;
  5102. leaderBoardList = [];
  5103. for(var i = 0; i < num; ++i) {
  5104. var _id = msg.getUint32(vb, 1),
  5105. vb = vb + 4;
  5106. leaderBoardList.push({
  5107. id: _id,
  5108. name: getString()
  5109. })
  5110. };
  5111. break;
  5112. case 50:
  5113. v_95 = [];
  5114. num = msg.getUint32(vb, 1);
  5115. vb += 4;
  5116. for(i = 0; i < num; ++i) {
  5117. v_95.push(msg.getFloat32(vb, 1)), vb += 4
  5118. };
  5119. vq_updateLeaderboard_for_team();
  5120. break;
  5121. // case 64:
  5122. // var num = msg.getFloat64(vb, 1),
  5123. // vb = vb + 8,
  5124. // i = msg.getFloat64(vb, 1),
  5125. // vb = vb + 8,
  5126. // _id = msg.getFloat64(vb, 1),
  5127. // vb = vb + 8,
  5128. // vi = msg.getFloat64(vb, 1),
  5129. // vb = vb + 8;
  5130. // //v_55(vf - vd, vi - ve) ? (fieldLeft = vd, fieldTop = ve, fieldRight = vf, fieldBottom = vi) : (v_55(vd, v_84) && (0.01 < vf - v_86 || -0.01 > vf - v_86) && (fieldLeft = vd, fieldRight = vd + 14142.135623730952), (0.01 < vd - v_84 || -0.01 > vd - v_84) && v_55(vf, v_86) && (fieldRight = vf, fieldLeft = vf - 14142.135623730952), (0.01 < ve - v_85 || -0.01 > ve - v_85) && v_55(vi, v_87) && (fieldBottom = vi, fieldTop = vi - 14142.135623730952), v_55(ve, v_85) && (0.01 < vi - v_87 || -0.01 > vi - v_87) && (fieldTop = ve, fieldBottom = ve + 14142.135623730952), vd < fieldLeft && (fieldLeft = vd, fieldRight = vd + 14142.135623730952), vf > fieldRight && (fieldRight = vf, fieldLeft = vf - 14142.135623730952), ve < fieldTop && (fieldTop = ve, fieldBottom = ve + 14142.135623730952), vi > fieldBottom && (fieldBottom = vi, fieldTop = vi - 14142.135623730952), v_84 = vd, v_85 = ve, v_87 = vi, v_86 = vf);
  5131. // fieldLeft = 0;
  5132. // fieldTop = 0;
  5133. // fieldRight = 14142.13562373095;
  5134. // fieldBottom = 14142.13562373095;
  5135. // myApp.afterGameLoaded();
  5136. // break;
  5137. case 65:
  5138. var num = msg.getFloat32(vb, 1),
  5139. vb = vb + 4,
  5140. i = msg.getFloat32(vb, 1),
  5141. vb = vb + 4,
  5142. _id = msg.getFloat32(vb, 1),
  5143. vb = vb + 4,
  5144. vi = msg.getFloat32(vb, 1),
  5145. vb = vb + 4;
  5146.  
  5147. //fieldLeft = 0;
  5148. //fieldTop = 0;
  5149. //fieldRight = 14142.13562373095;
  5150. //fieldBottom = 14142.13562373095;
  5151. fieldLeft = num;
  5152. fieldTop = i;
  5153. fieldRight = _id;
  5154. fieldBottom = vi;
  5155. gSiteArea.field_sz = fieldRight;
  5156. //サーバ側でspectate時にtop, bottomがおかしいバグ?があり、それを回避
  5157. //fieldTop = fieldLeft;
  5158. //fieldBottom = fieldRight;
  5159. myApp.afterGameLoaded();
  5160. break;
  5161. case 81:
  5162. var vj = msg.getUint32(vb, 1),
  5163. vb = vb + 4,
  5164. vh = msg.getUint32(vb, 1),
  5165. vb = vb + 4,
  5166. vk = msg.getUint32(vb, 1),
  5167. vb = vb + 4;
  5168. setTimeout(function() {
  5169. v_5e({
  5170. d: vj,
  5171. e: vh,
  5172. c: vk
  5173. })
  5174. }, 1200);
  5175. break;
  5176. // case 128:
  5177. // chatRoom.decodeMessage(msg);
  5178. // break;
  5179. }
  5180. }
  5181.  
  5182. function updateBlobInfo(data, pos) {
  5183. //blobæƒ…å ±æ›´æ–°ï¼Ÿ
  5184. function getStringU() {
  5185. for(var vb = ''; ;) {
  5186. var ve = data.getUint16(pos, 1);
  5187. pos += 2;
  5188. if(0 == ve) {
  5189. break
  5190. };
  5191. vb += String.fromCharCode(ve)
  5192. };
  5193. return vb
  5194. }
  5195.  
  5196. function getStringB() {
  5197.  
  5198. for(var vb = ''; ;) {
  5199. var vd = data.getUint8(pos++);
  5200. if(0 == vd) {
  5201. break
  5202. };
  5203. vb += String.fromCharCode(vd)
  5204. };
  5205. return vb
  5206. }
  5207.  
  5208. function getRandomColor() {
  5209. var colorRGB = [0xFF, (Math.random() * 100) >> 0, (Math.random() * 256) >> 0];
  5210. colorRGB.sort(function() {
  5211. return 0.5 - Math.random();
  5212. });
  5213. return {
  5214. r: colorRGB[0],
  5215. g: colorRGB[1],
  5216. b: colorRGB[2]
  5217. };
  5218. };
  5219.  
  5220.  
  5221. v_a0 = v_7d = Date.now();
  5222. v_9f || (v_9f = 1, vc_resendNickname());
  5223. v_8d = 0;
  5224. var vf = data.getUint16(pos, 1);
  5225. pos += 2;
  5226. for(var vj = 0; vj < vf; ++vj) {
  5227. var killer = v_74[data.getUint32(pos, 1)],
  5228. node = v_74[data.getUint32(pos + 4, 1)];
  5229. //console.log('destoy node:' + node.id);
  5230. pos += 8;
  5231.  
  5232. //if(killer) {
  5233. killer && node && (node.go_R_remove(), node.o = node.x, node.p = node.y, node.n = node.size, node.go_C_x = killer.x, node.go_C_y = killer.y, node.m = node.size, node.K = v_7d, v_64(killer, node))
  5234. //}else{
  5235. // console.log('no killer');
  5236. // node && (node.go_R_remove(), node.o = node.x, node.p = node.y, node.n = node.size, node.go_C_x = node.x, node.go_C_y = node.y, node.m = node.size, node.K = v_7d) //, v_64(killer, node))
  5237. //}
  5238. };
  5239. for(vj = 0; ;) {
  5240. vf = data.getUint32(pos, 1);
  5241. pos += 4;
  5242. if(0 == vf) {
  5243. break
  5244. };
  5245. ++vj;
  5246. var vk, vh = data.getInt32(pos, 1);
  5247. pos += 4;
  5248. node = data.getInt32(pos, 1);
  5249. pos += 4;
  5250. vk = data.getInt16(pos, 1);
  5251. pos += 2;
  5252.  
  5253. // var obj = data.getUint8(pos++),
  5254. // vl = data.getUint8(pos++),
  5255. // vm = data.getUint8(pos++),
  5256. // vl = vx(obj << 16 | vl << 8 | vm),
  5257. //vm = data.getUint8(pos++),
  5258. var obj;
  5259.  
  5260. var vm = 0,
  5261. v_53 = !!(vm & 1),
  5262. vn = !!(vm & 16),
  5263. vo = null;
  5264.  
  5265. var pID = data.getUint16(pos, 1);
  5266. pos += 2;
  5267. //var pID = 0;
  5268. //var cID = data.getUint16(pos, 1);
  5269. //pos += 2;
  5270. var cID = 0;
  5271. if(pID > 0) {
  5272. cID = playerCoreManager.getCid(pID);
  5273. }
  5274.  
  5275. var cellType = data.getUint8(pos++);
  5276.  
  5277. vm = (cellType == 2) ? 1 : 0;
  5278. v_53 = !!(vm & 1);
  5279. vn = !!(vm & 16);
  5280.  
  5281. var col = playerCoreManager.getPlayerColor(pID); //cID);
  5282.  
  5283. if(cellType == 1) {
  5284. //pellet
  5285. col = getRandomColor();
  5286. }
  5287. vl = vx(col.r << 16 | col.g << 8 | col.b);
  5288.  
  5289. if(cellType == 2) {
  5290. //virtus
  5291. vl = vx(0x00FF00);
  5292. }
  5293.  
  5294. /*
  5295. vm & 2 && (pos += 4 + data.getUint32(pos, 1));
  5296. vm & 4 && (vo = getStringB());
  5297. var _name = getStringU(),
  5298. obj = null;
  5299. */
  5300. var _name = playerManager.getFullName(cID);
  5301.  
  5302. if(cellType != 0) _name = '';
  5303.  
  5304. var obj = null;
  5305. v_74.hasOwnProperty(vf) ? (obj = v_74[vf], obj.go_J(), obj.o = obj.x, obj.p = obj.y, obj.n = obj.size, obj.color = vl) : (obj = new GameObject(vf, vh, node, vk, vl, _name, pID, cID, cellType), gameObjects.push(obj), v_74[vf] = obj, obj.ia = vh, obj.ja = node);
  5306. /*
  5307. if(obj.size <= obj.prevSize * 0.9){
  5308. next_go_index(obj);
  5309. }
  5310. obj.prevSize = obj.size;
  5311. */
  5312. obj.f = v_53;
  5313. obj.j = vn;
  5314. obj.go_C_x = vh;
  5315. obj.go_C_y = node;
  5316. obj.m = vk;
  5317. obj.K = v_7d;
  5318. obj.T = vm;
  5319.  
  5320. //utils.confirm(obj != null);
  5321.  
  5322. //obj.pID = pID;
  5323. vo && (obj.V = vo);
  5324. _name && obj.setGameObjectName(_name);
  5325.  
  5326. // if(obj.cID == playerManager.selfClientId){
  5327. // //debugger;
  5328. // var x = 100;
  5329. // }
  5330.  
  5331. if(selfNodeIdList.indexOf(vf) != -1 && selfOwnedCells.indexOf(obj) == -1){
  5332. //console.log('add self cell');
  5333. selfOwnedCells.push(obj);
  5334. if(selfOwnedCells.length == 1){
  5335. v_70_fieldPosX = obj.x;
  5336. v_71_fieldPosY = obj.y;
  5337. onWindowLoadedJQ();
  5338. document.getElementById('overlays')['style']['display'] = 'none';
  5339. v_c3 = [];
  5340. v_c4 = 0;
  5341. v_c5 = selfOwnedCells[0]['color'];
  5342. v_c7 = 1;
  5343. v_c8 = Date.now();
  5344. v_cc = v_cb = v_ca = 0;
  5345. }
  5346. }
  5347. //utils.confirm(!isNaN(v_70_fieldPosX));
  5348. };
  5349. killer = data.getUint32(pos, 1);
  5350. pos += 4;
  5351. for(vj = 0; vj < killer; vj++) {
  5352. vf = data.getUint32(pos, 1), pos += 4, obj = v_74[vf], null != obj && obj.go_R_remove()
  5353. };
  5354.  
  5355. v_8d && 0 == selfOwnedCells.length && (myApp.onDead(), 1) && (v_c9 = Date.now(), v_c7 = 0, v_a3 || v_c6 || (v_cd ? (v_67(), v_c6 = 1, _jquery('#overlays')['show'](), _jquery('#stats')['show']()) : vi(1500)))
  5356. }
  5357.  
  5358. function vc_resendNickname() {
  5359. v_a6 = '';
  5360. _jquery('#connecting')['hide']();
  5361. SendGameNickName();
  5362. v_b3 && (v_b3(), v_b3 = null);
  5363. null != v_b5 && clearTimeout(v_b5);
  5364. v_b5 = setTimeout(function() {
  5365. _win.ga && (++v_b6, _win.ga('set', 'dimension2', v_b6))
  5366. }, 1E4)
  5367. }
  5368.  
  5369. function SendAimPoint(px, py) {
  5370. if(!IsDocumentReady()) return;
  5371.  
  5372. if(!(gIsPlaying || gIsSpectate)) return;
  5373. var msg = CreateDataView(13);
  5374. msg.setUint8(0, 16);
  5375. msg.setInt32(1, px, 1);
  5376. msg.setInt32(5, py, 1);
  5377. msg.setUint32(9, 0, 1);
  5378. SendDataFrame(msg);
  5379. }
  5380.  
  5381. function SendAimCursor() {
  5382. SendAimPoint(refPositionX, refPositionY);
  5383. }
  5384.  
  5385. function SendAimCenter() {
  5386. SendAimPoint(stopPositionX, stopPositionY);
  5387. }
  5388.  
  5389. function _MOVE(forceAim) {
  5390. try {
  5391. if(forceAim == null) {
  5392. forceAim = false;
  5393. }
  5394.  
  5395. //trace("_MOVE");
  5396.  
  5397. /*
  5398. if (!myApp.isStopMovement && IsDocumentReady()) {
  5399. //trace("Moving");
  5400. //var px = clientMouseX - _screenCenterX / 2;
  5401. //var py = clientMouseY - _screenCenterY / 2;
  5402.  
  5403. //var isNear = px * px + py * py < 64;
  5404. //var diffX = Math.abs(bPositionX - refPositionX);
  5405. //var diffY = Math.abs(bPositionY - refPositionY);
  5406. //var th = 0.01;
  5407. //var xNear = Math.abs(bPositionX - refPositionX) < 0.01;
  5408. //var yNear = Math.abs(bPositionY - refPositionY) < 0.01;
  5409.  
  5410.  
  5411. //&&, ||
  5412. // (64 > px * px + py * py) || (0.01 > Math.abs(bPositionX - refPositionX) && 0.01 > Math.abs(bPositionY - refPositionY))
  5413. // || (bPositionX = refPositionX, bPositionY = refPositionY,
  5414. // px = v_22(13), px.setUint8(0, 16), px.setInt32(1, refPositionX, 1), px.setInt32(5, refPositionY, 1), px.setUint32(9, 0, 1), v_23(px))
  5415.  
  5416. //if(isNear){
  5417. // (diffX < th && diffY < th)){
  5418. //var msg = "";
  5419.  
  5420. //var A = 64 > px * px + py * py;
  5421. //var go_B = (0.01 > Math.abs(bPositionX - refPositionX) && (0.01 > Math.abs(bPositionY - refPositionY)));
  5422. //if(A || go_B){
  5423.  
  5424. bPositionX = refPositionX;
  5425. bPositionY = refPositionY;
  5426.  
  5427. var msg  = v_22(13);
  5428. msg.setUint8(0, 16);
  5429. msg.setInt32(1, refPositionX, 1);
  5430. msg.setInt32(5, refPositionY, 1);
  5431. msg.setUint32(9, 0, 1);
  5432. v_23(msg);
  5433. //};
  5434.  
  5435. }
  5436. */
  5437.  
  5438. //SendAimCursor();
  5439.  
  5440.  
  5441. if(MOVING || forceAim) {
  5442. //SendAimPoint(refPositionX, refPositionY);
  5443. SendAimCursor();
  5444. } else {
  5445. //SendAimPoint(stopPositionX, stopPositionY);
  5446. SendAimCenter();
  5447. }
  5448.  
  5449.  
  5450.  
  5451. /*
  5452. //var moving = !myApp.isStopMovement;
  5453. var moving = MOVING;
  5454.  
  5455. var px = refPositionX;
  5456. var py = refPositionY;
  5457.  
  5458. if (!MOVING) {
  5459. px = stopPositionX;
  5460. py = stopPositionY;
  5461. }
  5462. */
  5463. /*
  5464. bPositionX = px;
  5465. bPositionY = py;
  5466. } else {
  5467. px = bPositionX;
  5468. py = bPositionY;
  5469. }
  5470. */
  5471.  
  5472. //SendAimPoint(px, py);
  5473. //}
  5474.  
  5475. //trace("moving:" + moving);
  5476. //}
  5477. } catch(e) {
  5478. console.log(e);
  5479. }
  5480. }
  5481.  
  5482. function v_55(v_4f, va) {
  5483. return 0.01 > v_4f - va && -0.01 < v_4f - va
  5484. }
  5485.  
  5486. var nickEntryCash = null;
  5487.  
  5488. function clearNickEntryCash() {
  5489. nickEntryCash = null;
  5490. }
  5491. _win.clearNickEntryCash = clearNickEntryCash;
  5492.  
  5493. function sendGameNickNameCore() {
  5494. if(gIsPlaying && !gconfig.allowChangesPlayerInfoWhilePlaying) return;
  5495. var c = nickEntryCash;
  5496. var e = gPlayerEntryData;
  5497. var same = (c && c.name == e.name && c.team == e.team && c.skinUrl == e.skinUrl && c.code == e.code && c.skinUrl2 == e.skinUrl2);
  5498. if(!same) {
  5499. var fb = new DataFrameWriter();
  5500. fb.writeUint8(30);
  5501. fb.writeStringEx(e.name);
  5502. fb.writeStringEx(e.team);
  5503. fb.writeStringEx(e.skinUrl);
  5504. fb.writeStringEx(e.code);
  5505. fb.writeStringEx(e.skinUrl2);
  5506. SendDataFrame(new Uint8Array(fb.getBuffer()));
  5507.  
  5508. //chatAppModel.ShowVersion();
  5509. if(gUseChatApp){
  5510. var profile_index = localStorage.getItem('selected_profile');
  5511. chatAppModel.SetUserEntryInfo(e.name, e.team, e.code, e.skinUrl, profile_index);
  5512. }
  5513. nickEntryCash = e;
  5514. }
  5515. }
  5516.  
  5517. function SendGameNickName() {
  5518. if(IsDocumentReady() && v_9f && null != game_playername_sending) {
  5519.  
  5520. if(false) {
  5521. //ノーマル
  5522. var msg = CreateDataView(1 + 2 * game_playername_sending.length);
  5523. msg.setUint8(0, 0);
  5524. for(var va = 0; va < game_playername_sending.length; ++va) {
  5525. msg.setUint16(1 + 2 * va, game_playername_sending.charCodeAt(va), 1)
  5526. }
  5527. ;
  5528. SendDataFrame(msg);
  5529. game_playername_sending = null
  5530. } else {
  5531. //æ‹¡å¼µ
  5532. sendGameNickNameCore();
  5533. }
  5534. }
  5535. }
  5536.  
  5537. function SendGameStart() {
  5538. if(IsDocumentReady()) {
  5539. var fb = new DataFrameWriter();
  5540. fb.writeUint8(31);
  5541. SendDataFrame(new Uint8Array(fb.getBuffer()));
  5542. }
  5543. }
  5544.  
  5545. function IsDocumentReady() {
  5546. return null != webSocket && webSocket.readyState == webSocket.OPEN
  5547. }
  5548.  
  5549. //var prevSplitTimeStampMs = 0;
  5550. //var prevSplitMx = -1;
  5551. //var prevSplitMy = -1;
  5552. function SendPlayerAction(op) {
  5553. if(IsDocumentReady()) {
  5554. /*
  5555. if(op == 17){
  5556. //dualagarで、分裂時に視点が動いてロケパンが折れる問題を回避
  5557. //2連打分裂を検出したときに以前のAIM点を送る
  5558. //-->サーバ側で対処
  5559. //分裂の間でセルが移動してしまっているのでダメ
  5560. var ms = Date.now();
  5561. var dur = ms - prevSplitTimeStampMs;
  5562. if(dur < 180){
  5563. console.log(`double split, ${dur}`);
  5564. if(prevSplitMx != -1){
  5565. SendAimPoint(prevSplitMx, prevSplitMy);
  5566. }
  5567. }
  5568. prevSplitTimeStampMs = ms;
  5569. prevSplitMx = refPositionX;
  5570. prevSplitMy = refPositionY;
  5571. }
  5572. */
  5573. var msg = CreateDataView(1);
  5574. msg.setUint8(0, op);
  5575. SendDataFrame(msg)
  5576. }
  5577. }
  5578.  
  5579. function v_59() {
  5580. if(IsDocumentReady() && null != window.userToken) {
  5581. var msg = CreateDataView(2 + userToken.length);
  5582. msg.setUint8(0, 82);
  5583. msg.setUint8(1, 1);
  5584. for(var vb = 0; vb < window.userToken['length']; ++vb) {
  5585. msg.setUint8(vb + 2, window.userToken['charCodeAt'](vb))
  5586. };
  5587. SendDataFrame(msg)
  5588. }
  5589. }
  5590.  
  5591. function windowOnResize() {
  5592. _screenWidth = 1 * _win.innerWidth;
  5593. _screenHeight = 1 * _win.innerHeight;
  5594. v_6a.width = v_6b.width = _screenWidth;
  5595. v_6a.height = v_6b.height = _screenHeight;
  5596. var v_4f = _jquery('#helloContainer');
  5597. v_4f.css('transform', 'none');
  5598. var vd = v_4f.height(),
  5599. ve = _win.innerHeight;
  5600. vd > ve / 1.1 ? v_4f.css('transform', 'translate(-50%, -50%) scale(' + ve / vd / 1.1 + ')') : v_4f.css('transform', 'translate(-50%, -50%)');
  5601. updateFrame()
  5602. }
  5603.  
  5604. function v_5b() {
  5605. return 1 * Math.max(_screenHeight / 1080, _screenWidth / 1920) * v_a1_zoomLevel
  5606. }
  5607.  
  5608. function vt() {
  5609. if(0 != selfOwnedCells.length) {
  5610. if(myApp.isEnableLockZoom) {
  5611. va = v_5b()
  5612. } else {
  5613. for(var va = 0, i = 0; i < selfOwnedCells.length; i++) {
  5614. va += selfOwnedCells[i]['size']
  5615. };
  5616. va = Math.pow(Math.min(64 / va, 1), 0.4) * v_5b()
  5617. };
  5618. v_88_zoom = (9 * v_88_zoom + va) / 10
  5619. }
  5620. }
  5621.  
  5622. function updateFrame() {
  5623. var va, vb = Date.now();
  5624. ++v_7c;
  5625. v_7d = vb;
  5626. if(0 < selfOwnedCells.length) {
  5627. vt();
  5628. for(var vd = va = 0, vf = 0; vf < selfOwnedCells.length; vf++) {
  5629. selfOwnedCells[vf].go_J(), va += selfOwnedCells[vf]['x'] / selfOwnedCells.length, vd += selfOwnedCells[vf]['y'] / selfOwnedCells.length
  5630. };
  5631. stopPositionX = va;
  5632. stopPositionY = vd;
  5633. v_93 = v_88_zoom;
  5634.  
  5635. //myApp.testing ? (v_70_fieldPosX = (testingVal * v_70_fieldPosX + stopPositionX) / (testingVal + 1), v_71_fieldPosY = (testingVal * v_71_fieldPosY + stopPositionY) / (testingVal + 1), console.log(testingVal + 1)) : (v_70_fieldPosX = (v_70_fieldPosX + va) / 2, v_71_fieldPosY = (v_71_fieldPosY + vd) / 2)
  5636.  
  5637.  
  5638. if(myApp.testing){
  5639. v_70_fieldPosX = (testingVal * v_70_fieldPosX + stopPositionX) / (testingVal + 1);
  5640. v_71_fieldPosY = (testingVal * v_71_fieldPosY + stopPositionY) / (testingVal + 1);
  5641. console.log(testingVal + 1);
  5642. }else{
  5643. //v_70_fieldPosX = (v_70_fieldPosX + va) / 2;
  5644. //v_71_fieldPosY = (v_71_fieldPosY + vd) / 2;
  5645. var K = 0.92;
  5646. v_70_fieldPosX = nums.easyFilter(v_70_fieldPosX, va, K);
  5647. v_71_fieldPosY = nums.easyFilter(v_71_fieldPosY, vd, K);
  5648. }
  5649.  
  5650. } else {
  5651. v_70_fieldPosX = (29 * v_70_fieldPosX + stopPositionX) / 30, v_71_fieldPosY = (29 * v_71_fieldPosY + stopPositionY) / 30, v_88_zoom = (9 * v_88_zoom + v_93 * v_5b()) / 10
  5652.  
  5653. //utils.confirm(!isNaN(v_70_fieldPosX));
  5654.  
  5655. };
  5656.  
  5657. //console.log('len:' + selfOwnedCells.length);
  5658.  
  5659. //セルの分裂可能判定
  5660. var sortedCells = selfOwnedCells.slice(0); //concat();
  5661. sortedCells.sort(function(a, b) {
  5662. return a.id - b.id;
  5663. });
  5664. var num_splitable = Math.min(8, (8 - sortedCells.length / 2) * 2);
  5665. for(var i = 0; i < sortedCells.length; i++) {
  5666. var cell = sortedCells[i];
  5667. cell.can_split = i < num_splitable && (cell.size * cell.size * 0.01 >= 36);
  5668. }
  5669.  
  5670. v_6e = null;
  5671. onClientMousePositionChanged();
  5672. v_9e || ctx.clearRect(0, 0, _screenWidth, _screenHeight);
  5673. v_9e ? (ctx.fillStyle = v_8f ? '#111111' : '#F2FBFF', ctx.globalAlpha = 0.05, ctx.fillRect(0, 0, _screenWidth, _screenHeight), ctx.globalAlpha = 1) : v_5c();
  5674. gameObjects.sort(function(va, player) {
  5675. return va.size == player.size ? va.id - player.id : va.size - player.size
  5676. });
  5677.  
  5678. gSiteArea.x = v_70_fieldPosX;
  5679. gSiteArea.y = v_71_fieldPosY;
  5680. gSiteArea.scale = v_88_zoom;
  5681. gSiteArea.scw = _screenWidth;
  5682. gSiteArea.sch = _screenHeight;
  5683. gSiteArea.field_sz = fieldRight;
  5684.  
  5685. ctx.save();
  5686. ctx.translate(_screenWidth / 2, _screenHeight / 2);
  5687. ctx.scale(v_88_zoom, v_88_zoom);
  5688. ctx.translate(-v_70_fieldPosX, -v_71_fieldPosY);
  5689. va = [fieldLeft, fieldTop, fieldRight, fieldBottom];
  5690. v_60(va, ctx);
  5691. myApp.isEnableMapGrid && v_61(va, ctx);
  5692.  
  5693. // ctx.lineWidth = 8;
  5694. // ctx.strokeStyle = "#888";
  5695. // ctx.strokeRect(0, 0, fieldRight, fieldBottom);
  5696.  
  5697. for(vf = 0; vf < v_76.length; vf++) {
  5698. v_76[vf].drawGameObject(ctx)
  5699. };
  5700. for(vf = 0; vf < gameObjects.length; vf++) {
  5701. gameObjects[vf].drawGameObject(ctx); //draw player object
  5702. };
  5703. if(0 < v_af.length) {
  5704. ctx.fillStyle = $('#pelletColor')['minicolors']('value');
  5705. ctx.beginPath();
  5706. for(va = 0; va < v_af.length; va++) {
  5707. vd = v_af[va], ctx.moveTo(vd.x, vd.y), ctx.arc(vd.x, vd.y, vd.size + 5, 0, TWO_PI, 0)
  5708. };
  5709. ctx.fill();
  5710. v_af = []
  5711. };
  5712. if(selfOwnedCells.length && myApp.isEnableSplitInd) {
  5713. ctx.globalAlpha = 0.7;
  5714. vd = ~~Math.min(5 / v_88_zoom, 50);
  5715. ctx.lineWidth = vd;
  5716. vf = [];
  5717. for(va = 0; va < selfOwnedCells.length; va++) {
  5718. vf.push({
  5719. x: selfOwnedCells[va]['x'],
  5720. y: selfOwnedCells[va]['y'],
  5721. size: selfOwnedCells[va]['size']
  5722. })
  5723. };
  5724. vf.sort(function(va, v_4f) {
  5725. return va.size - v_4f.size
  5726. });
  5727. for(va = 0; va < extraCellsPosSizes.length; va++) {
  5728. for(var vi = extraCellsPosSizes[va]['size'] * extraCellsPosSizes[va]['size'], vj = 0; vj < vf.length; vj++) {
  5729. var vh = vf[vj]['size'] * vf[vj]['size'],
  5730. vg = Math.sqrt(Math.pow(vf[vj]['x'] - extraCellsPosSizes[va]['x'], 2) + Math.pow(vf[vj]['y'] - extraCellsPosSizes[va]['y'], 2)),
  5731. vk = vf[vj]['size'] + 655,
  5732. vl = extraCellsPosSizes[va]['size'] + 655;
  5733. if(4 >= vf.length && 0.375 * vh * 0.37 > vi && 2 * vk - 10 > vg) {
  5734. extraCellsPosSizes[va]['type'] = 4;
  5735. break
  5736. };
  5737. if(8 >= vf.length && 0.37 * vh > vi && vk > vg) {
  5738. extraCellsPosSizes[va]['type'] = 2;
  5739. break
  5740. };
  5741. if(0.73 * vh > vi && vk > vg) {
  5742. extraCellsPosSizes[va]['type'] = 1;
  5743. break
  5744. };
  5745. if(0.37 * vi > vh && vl > vg) {
  5746. extraCellsPosSizes[va]['type'] = -2;
  5747. break
  5748. };
  5749. if(0.73 * vi > vh && vl > vg) {
  5750. extraCellsPosSizes[va]['type'] = -1;
  5751. break
  5752. }
  5753. }
  5754. };
  5755. for(vf = 0; vf < splitIndicatorColors.length; vf++) {
  5756. ctx.strokeStyle = splitIndicatorColors[vf]['color'];
  5757. ctx.beginPath();
  5758. for(va = 0; va < extraCellsPosSizes.length; va++) {
  5759. extraCellsPosSizes[va]['type'] && extraCellsPosSizes[va]['type'] == splitIndicatorColors[vf]['type'] && (vi = extraCellsPosSizes[va]['size'] + vd + 8 + 2 / v_88_zoom, ctx.moveTo(extraCellsPosSizes[va]['x'] + vi, extraCellsPosSizes[va]['y']), ctx.arc(extraCellsPosSizes[va]['x'], extraCellsPosSizes[va]['y'], vi, 0, TWO_PI, 0))
  5760. };
  5761. ctx.stroke()
  5762. }
  5763. };
  5764.  
  5765. //分裂セルマーカー
  5766. //if (true) {
  5767. /*
  5768. if(myApp.showSplitOrderMarker) {
  5769. //ctx.save();
  5770. ctx.globalAlpha = 0.6;
  5771. for(var i = 0; i < selfOwnedCells.length; i++) {
  5772. var cell = selfOwnedCells[i];
  5773.  
  5774. ctx.strokeStyle = cell.can_split ? 'rgba(0, 255, 0, 1)' : 'rgba(255, 255, 255, 1)';
  5775. //ctx.strokeStyle = cell.can_split ? 'rgba(0, 96, 255, 1)' : 'rgba(255, 255, 255, 1)';
  5776. //if(cell.can_split){
  5777. //var alpha = Math.max(1.0 - i / 5.0, 0.0);
  5778.  
  5779.  
  5780. //var vd = ~~(Math.min(5 / v_88, 50) * 1.8);
  5781. //var vd = ~~(5 / v_88 * 1.8);
  5782. //ctx.lineWidth = vd;
  5783. //var vi = cell.size + vd + 8 + 2 / v_88;
  5784. var lw = cell.size * 0.16;
  5785. //var lw = cell.size * 0.13;
  5786. //var lw = cell.size * 0.08;
  5787. ctx.lineWidth = lw;
  5788. ctx.beginPath();
  5789. //ctx.moveTo(cell.x + vi, cell.y);
  5790. ctx.arc(cell.x, cell.y, cell.size - lw / 2, 0, TWO_PI, 0);
  5791. ctx.stroke();
  5792. //}
  5793. }
  5794. //ctx.restore();
  5795. }
  5796. */
  5797.  
  5798. //if(myApp.showActiveTurnMarker) {
  5799. // ctx.globalAlpha = 0.75;
  5800. // selfOwnedCells.forEach(cell => {
  5801. // var isActive = cell.pID == gActiveTurnPlayerId;
  5802. // ctx.strokeStyle = isActive ? '#F0F' : '#FFF'; //'rgba(0, 128, 255, 1'
  5803. // var lw = cell.size * 0.10;
  5804. // ctx.lineWidth = lw;
  5805. // ctx.beginPath();
  5806. // ctx.arc(cell.x, cell.y, cell.size - lw / 2, 0, TWO_PI, 0);
  5807. // ctx.stroke();
  5808. // });
  5809. //}
  5810.  
  5811.  
  5812. extraCellsPosSizes = [];
  5813.  
  5814. //v_97 = 1;
  5815. //if (v_97) {
  5816. // カーソルライン
  5817. if(myApp.isEnableCursorLine) {
  5818. //v_9a = (3 * v_9a + v_98) / 4;
  5819. //v_9b = (3 * v_9b + v_99) / 4;
  5820. var px = refPositionX;
  5821. var py = refPositionY;
  5822. //ctx.save();
  5823. ctx.strokeStyle = '#FFAAAA';
  5824. ctx.lineCap = 'round';
  5825. ctx.lineJoin = 'round';
  5826.  
  5827. //var mode = 1;
  5828. if(!myApp.emphasisCursorLine){
  5829. //narrow
  5830. ctx.globalAlpha = 0.6;
  5831. ctx.lineWidth = 4;
  5832. ctx.strokeStyle = "rgba(255, 255, 255, 0.8)";// ""#CCCCCC";
  5833. }else{
  5834. //thick
  5835. ctx.globalAlpha = 0.8;
  5836. ctx.lineWidth = 10;
  5837. //ctx.strokeStyle = "#0F0";
  5838. ctx.strokeStyle = "#08F"; //"rgba(, 128, 255, 0.8)";// ""#CCCCCC";
  5839. }
  5840. ctx.beginPath();
  5841. for(vf = 0; vf < selfOwnedCells.length; vf++) {
  5842. var cell = selfOwnedCells[vf];
  5843. var isActive = cell.pID == gActiveTurnPlayerId;
  5844. if(isActive) {
  5845. ctx.moveTo(cell.x, cell.y), ctx.lineTo(refPositionX, refPositionY);
  5846. }
  5847. }
  5848. ctx.stroke();
  5849. //ctx.restore()
  5850. }
  5851.  
  5852. if(gSplitTimingTick > 0) {
  5853. gSplitTimingTick--;
  5854. }
  5855.  
  5856. //AIMクロスヘア
  5857. if(myApp.showCursorCrosshair) {
  5858. var px = refPositionX;
  5859. var py = refPositionY;
  5860. ctx.strokeStyle = (gSplitTimingTick > 0) ? '#FF8800' : '#00FF00';
  5861. ctx.lineCap = 'round';
  5862. ctx.lineJoin = 'round';
  5863. ctx.lineWidth = 8;
  5864. ctx.globalAlpha = 0.6;
  5865. ctx.beginPath();
  5866. var R1 = 120;
  5867. var R2 = 200;
  5868. ctx.arc(px, py, R1, 0, TWO_PI, 0);
  5869. ctx.moveTo(px - R2, py); ctx.lineTo(px + R2, py);
  5870. ctx.moveTo(px, py - R2); ctx.lineTo(px, py + R2);
  5871. ctx.stroke();
  5872. }
  5873.  
  5874. ctx.restore();
  5875.  
  5876. //中心線
  5877. if(myApp.showCursorCrosshair) {
  5878. var scx = _screenWidth / 2;
  5879. var scy = _screenHeight / 2;
  5880.  
  5881. ctx.save();
  5882. ctx.lineWidth = 1;
  5883. ctx.globalAlpha = 0.2;
  5884. ctx.strokeStyle = "#999999"; //rgba(192, 192, 192, 0.4)";// ""#CCCCCC";
  5885. ctx.beginPath();
  5886. ctx.moveTo(scx, 0); ctx.lineTo(scx, scy * 2);
  5887. ctx.moveTo(0, scy); ctx.lineTo(scx * 2, scy);
  5888. ctx.stroke();
  5889. ctx.restore();
  5890. }
  5891.  
  5892.  
  5893.  
  5894. ':teams' == v_94 && v_b9 && v_b9.width && ctx.drawImage(v_b9, _screenWidth - v_b9.width - 10, 10);
  5895. highest_score = Math.max(highest_score, calcCurrentScore());
  5896. vb = Date.now() - vb;
  5897. vb > 1E3 / 60 ? v_ba -= 0.01 : vb < 1E3 / 65 && (v_ba += 0.01);
  5898. 0.4 > v_ba && (v_ba = 0.4);
  5899. 1 < v_ba && (v_ba = 1);
  5900. vb = v_7d - v_7e;
  5901. !IsDocumentReady() || v_a3 || v_c6 ? (v_a2 += vb / 2E3, 1 < v_a2 && (v_a2 = 1)) : (v_a2 -= vb / 300, 0 > v_a2 && (v_a2 = 0));
  5902. v_7e = v_7d
  5903.  
  5904. gSelfMass = calcCurrentScore() / 100;
  5905. //v53 = null;
  5906. //delete v53;
  5907. }
  5908.  
  5909. function v_5c() {
  5910. if(myApp.isEnableGridline) {
  5911. ctx.save();
  5912. ctx.strokeStyle = v_8f ? '#AAAAAA' : '#000000';
  5913. ctx.globalAlpha = 0.2 * v_88_zoom;
  5914. ctx.beginPath();
  5915. for(var va = _screenWidth / v_88_zoom, vb = _screenHeight / v_88_zoom, vd = (-v_70_fieldPosX + va / 2) % 50; vd < va; vd += 50) {
  5916. ctx.moveTo(vd * v_88_zoom - 0.5, 0), ctx.lineTo(vd * v_88_zoom - 0.5, vb * v_88_zoom)
  5917. };
  5918. for(vd = (-v_71_fieldPosY + vb / 2) % 50; vd < vb; vd += 50) {
  5919. ctx.moveTo(0, vd * v_88_zoom - 0.5), ctx.lineTo(va * v_88_zoom, vd * v_88_zoom - 0.5)
  5920. };
  5921. ctx.stroke();
  5922. ctx.restore()
  5923. }
  5924. }
  5925.  
  5926. function calcCurrentScore() {
  5927. for(var va = 0, i = 0; i < selfOwnedCells.length; i++) {
  5928. va += selfOwnedCells[i]['m'] * selfOwnedCells[i]['m']
  5929. };
  5930. //console.log(selfOwnedCells.length);
  5931. return va;
  5932. }
  5933.  
  5934. function vq_updateLeaderboard_for_team() {
  5935. v_b9 = null;
  5936. if(null != v_95 || 0 != leaderBoardList.length) {
  5937. if(null != v_95 || v_8b) {
  5938. v_b9 = document.createElement('canvas');
  5939. var ctx = v_b9.getContext('2d'),
  5940. vb = 60,
  5941. vb = null == v_95 ? vb + 24 * leaderBoardList.length : vb + 180,
  5942. vd = Math.min(200, 0.3 * _screenWidth) / 200;
  5943. v_b9.width = 200 * vd;
  5944. v_b9.height = vb * vd;
  5945. ctx.scale(vd, vd);
  5946. ctx.globalAlpha = 0.4;
  5947. ctx.fillStyle = '#000000';
  5948. ctx.fillRect(0, 0, 200, vb);
  5949. ctx.globalAlpha = 1;
  5950. ctx.fillStyle = '#FFFFFF';
  5951. vd = vm('leaderboard');
  5952. ctx.font = '30px Ubuntu';
  5953. ctx.fillText(vd, 100 - ctx.measureText(vd)['width'] / 2, 40);
  5954. if(null == v_95) {
  5955. for(ctx.font = '20px Ubuntu', vb = 0; vb < leaderBoardList.length; ++vb) {
  5956. vd = leaderBoardList[vb]['name'] || vm('unnamed_cell'), v_8b || (vd = vm('unnamed_cell')), -1 != selfNodeIdList.indexOf(leaderBoardList[vb]['id']) ? (selfOwnedCells[0]['name'] && (vd = selfOwnedCells[0]['name']), ctx.fillStyle = '#FFAAAA') : ctx.fillStyle = '#FFFFFF', vd = vb + 1 + '. ' + vd, ctx.fillText(vd, 100 - ctx.measureText(vd)['width'] / 2, 70 + 24 * vb)
  5957. }
  5958. } else {
  5959. for(vb = vd = 0; vb < v_95.length; ++vb) {
  5960. var ve = vd + v_95[vb] * Math.PI * 2;
  5961. ctx.fillStyle = lb_colors[vb + 1];
  5962. ctx.beginPath();
  5963. ctx.moveTo(100, 140);
  5964. ctx.arc(100, 140, 80, vd, ve, 0);
  5965. ctx.fill();
  5966. vd = ve
  5967. }
  5968. }
  5969. }
  5970. }
  5971. }
  5972. //setIntervalEx(vq_updateLeaderboard, 1000);
  5973.  
  5974.  
  5975. function vx(va) {
  5976. for(va = va.toString(16) ; 6 > va.length;) {
  5977. va = '0' + va
  5978. };
  5979. return '#' + va
  5980. }
  5981.  
  5982.  
  5983.  
  5984. function v_5d(va) {
  5985. for(var vb = va.length, vd, ve; 0 < vb;) {
  5986. ve = Math.floor(Math.random() * vb), vb--, vd = va[vb], va[vb] = va[ve], va[ve] = vd
  5987. }
  5988. }
  5989.  
  5990. function v_5e(v_4f, vd) {
  5991. console.log(v_4f);
  5992. console.log('b: ' + vd);
  5993. var ve = '1' == _jquery('#helloContainer')['attr']('data-has-account-data');
  5994. _jquery('#helloContainer')['attr']('data-has-account-data', '1');
  5995. if(null == vd && _win.localStorage[v_c1]) {
  5996. var vf = JSON.parse(_win.localStorage[v_c1]);
  5997. vf.xp = v_4f.e;
  5998. vf.xpNeeded = v_4f.c;
  5999. vf.level = v_4f.d;
  6000. _win.localStorage[v_c1] = JSON.stringify(vf)
  6001. };
  6002. if(ve) {
  6003. var vi = +_jquery('.agario-exp-bar .progress-bar-text')['first']()['text']()['split']('/')[0],
  6004. ve = +_jquery('.agario-exp-bar .progress-bar-text')['first']()['text']()['split']('/')[1]['split'](' ')[0],
  6005. vf = _jquery('.agario-profile-panel .progress-bar-star')['first']()['text']();
  6006. if(vf != v_4f.d) {
  6007. v_5e({
  6008. e: ve,
  6009. c: ve,
  6010. d: vf
  6011. }, function() {
  6012. _jquery('.agario-profile-panel .progress-bar-star')['text'](v_4f.d);
  6013. _jquery('.agario-exp-bar .progress-bar')['css']('width', '100%');
  6014. _jquery('.progress-bar-star')['addClass']('animated tada')['one']('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() {
  6015. _jquery('.progress-bar-star')['removeClass']('animated tada')
  6016. });
  6017. setTimeout(function() {
  6018. _jquery('.agario-exp-bar .progress-bar-text')['text'](v_4f.c + '/' + v_4f.c + ' XP');
  6019. v_5e({
  6020. e: 0,
  6021. c: v_4f.c,
  6022. d: v_4f.d
  6023. }, function() {
  6024. v_5e(v_4f, vd)
  6025. })
  6026. }, 1E3)
  6027. })
  6028. } else {
  6029. var vj = Date.now(),
  6030. vh = function() {
  6031. var ve;
  6032. ve = (Date.now() - vj) / 1E3;
  6033. ve = 0 > ve ? 0 : 1 < ve ? 1 : ve;
  6034. ve = ve * ve * (3 - 2 * ve);
  6035. _jquery('.agario-exp-bar .progress-bar-text')['text'](~~(vi + (v_4f.e - vi) * ve) + '/' + v_4f.c + ' XP');
  6036. _jquery('.agario-exp-bar .progress-bar')['css']('width', (88 * (vi + (v_4f.e - vi) * ve) / v_4f.c)['toFixed'](2) + '%');
  6037. 1 > ve ? _win.requestAnimationFrame(vh) : vd && vd()
  6038. };
  6039. _win.requestAnimationFrame(vh)
  6040. }
  6041. } else {
  6042. _jquery('.agario-profile-panel .progress-bar-star')['text'](v_4f.d), _jquery('.agario-exp-bar .progress-bar-text')['text'](v_4f.e + '/' + v_4f.c + ' XP'), _jquery('.agario-exp-bar .progress-bar')['css']('width', (88 * v_4f.e / v_4f.c)['toFixed'](2) + '%'), vd && vd()
  6043. }
  6044. }
  6045.  
  6046. function v_5f(v_4f) {
  6047. 'connected' == v_4f.status && (window.userToken = v_4f.authResponse['accessToken'], v_59(), _win.FB['api']('/me/picture?width=180&height=180', function(v_4f) {
  6048. _win.localStorage['fbPictureCache'] = v_4f.data['url'];
  6049. _jquery('.agario-profile-picture')['attr']('src', v_4f.data['url'])
  6050. }), _jquery('#helloContainer')['attr']('data-logged-in', '1'))
  6051. }
  6052.  
  6053. function v_60(va, vb) {
  6054. vb.save();
  6055. vb.beginPath();
  6056. vb.strokeStyle = $('#borderColor')['minicolors']('value');
  6057. var vd = vb.lineWidth = 40;
  6058. vb.strokeRect(va[0] - vd / 2, va[1] - vd / 2, va[2] - va[0] + vd, va[3] - va[1] + vd);
  6059. vb.restore()
  6060. }
  6061.  
  6062. function v_61(va, vb) {
  6063. var vd = Math.round(va[0]) + 40,
  6064. ve = Math.round(va[1]) + 40,
  6065. vf = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'['split'](''),
  6066. vi = (Math.round(va[2]) - 40 - vd) / 5,
  6067. vj = (Math.round(va[3]) - 40 - ve) / 5;
  6068. vb.save();
  6069. vb.beginPath();
  6070. vb.lineWidth = 20;
  6071. vb.textAlign = 'center';
  6072. vb.textBaseline = 'middle';
  6073. vb.font = 0.6 * vi + 'px Ubuntu';
  6074. vb.fillStyle = '#1A1A1A';
  6075. for(var vh = 0; 5 > vh; vh++) {
  6076. for(var vg = 0; 5 > vg; vg++) {
  6077. vb.fillText(vf[vh] + (vg + 1), vd + vi * vg + vi / 2, ve + vj * vh + vj / 2)
  6078. }
  6079. };
  6080. vb.lineWidth = 100;
  6081. vb.strokeStyle = '#1A1A1A';
  6082. for(vh = 0; 5 > vh; vh++) {
  6083. for(vg = 0; 5 > vg; vg++) {
  6084. vb.strokeRect(vd + vi * vg, ve + vj * vh, vi, vj)
  6085. }
  6086. };
  6087. vb.stroke();
  6088. vb.restore()
  6089. }
  6090.  
  6091. function v_62(v_4f) {
  6092. //vz(':party');
  6093. //_jquery('#helloContainer')['attr']('data-party-state', '4');
  6094. //v_4f = decodeURIComponent(v_4f)['replace'](/.*#/gim, '');
  6095. //v_63('#' + _win.encodeURIComponent(v_4f));
  6096. //_jquery.ajax('http://m.agar.io/getToken', {
  6097. // error: function() {
  6098. // _jquery('#helloContainer')['attr']('data-party-state', '6');
  6099. // _jquery('#connect_error_div')['show']()
  6100. // },
  6101. // success: function(vd) {
  6102. // vd = vd.split('\n');
  6103. // _jquery('.partyToken')['val'](_win.encodeURIComponent(v_4f));
  6104. // _jquery('#helloContainer')['attr']('data-party-state', '5');
  6105. // vz(':party');
  6106. // connectToGameServer('ws://' + vd[0], v_4f);
  6107. // isJoinedGame = 0
  6108. // },
  6109. // dataType: 'text',
  6110. // method: 'POST',
  6111. // cache: 0,
  6112. // crossDomain: 1,
  6113. // data: v_4f
  6114. //});
  6115. //$('.btn-spectate')['prop']('disabled', 0)
  6116. }
  6117.  
  6118. function v_63(vb) {
  6119. _win.history && _win.history['replaceState'] && _win.history['replaceState']({}, _win.document['title'], vb)
  6120. }
  6121.  
  6122. function v_64(va, vb) {
  6123. var vd = -1 != selfNodeIdList.indexOf(va.id),
  6124. ve = -1 != selfNodeIdList.indexOf(vb.id),
  6125. vf = 30 > vb.size;
  6126. vd && vf && ++v_c4;
  6127. vf || !vd || ve || ++v_cb
  6128. }
  6129.  
  6130. function v_65(va) {
  6131. va = ~~va;
  6132. var vb = (va % 60).toString();
  6133. va = (~~(va / 60)).toString();
  6134. 2 > vb.length && (vb = '0' + vb);
  6135. return va + ':' + vb
  6136. }
  6137.  
  6138. function v_66() {
  6139. if(null == leaderBoardList) {
  6140. return 0
  6141. };
  6142. for(var va = 0; va < leaderBoardList.length; ++va) {
  6143. if(-1 != selfNodeIdList.indexOf(leaderBoardList[va]['id'])) {
  6144. return va + 1
  6145. }
  6146. };
  6147. return 0
  6148. }
  6149.  
  6150. function v_67() {
  6151. _jquery('.stats-food-eaten')['text'](v_c4);
  6152. _jquery('.stats-time-alive')['text'](v_65((v_c9 - v_c8) / 1E3));
  6153. _jquery('.stats-leaderboard-time')['text'](v_65(v_ca));
  6154. _jquery('.stats-highest-mass')['text'](~~(highest_score / 100));
  6155. _jquery('.stats-cells-eaten')['text'](v_cb);
  6156. _jquery('.stats-top-position')['text'](0 == v_cc ? ':(' : v_cc);
  6157. var va = document.getElementById('statsGraph');
  6158. if(va) {
  6159. var vd = va.getContext('2d'),
  6160. ve = va.width,
  6161. va = va.height;
  6162. vd.clearRect(0, 0, ve, va);
  6163. if(2 < v_c3.length) {
  6164. for(var vf = 200, vi = 0; vi < v_c3.length; vi++) {
  6165. vf = Math.max(v_c3[vi], vf)
  6166. };
  6167. vd.lineWidth = 3;
  6168. vd.lineCap = 'round';
  6169. vd.lineJoin = 'round';
  6170. vd.strokeStyle = v_c5;
  6171. vd.fillStyle = v_c5;
  6172. vd.beginPath();
  6173. vd.moveTo(0, va - v_c3[0] / vf * (va - 10) + 10);
  6174. for(vi = 1; vi < v_c3.length; vi += Math.max(~~(v_c3.length / ve), 1)) {
  6175. for(var vj = vi / (v_c3.length - 1) * ve, vh = [], vg = -20; 20 >= vg; ++vg) {
  6176. 0 > vi + vg || vi + vg >= v_c3.length || vh.push(v_c3[vi + vg])
  6177. };
  6178. vh = vh.reduce(function(va, vb) {
  6179. return va + vb
  6180. }) / vh.length / vf;
  6181. vd.lineTo(vj, va - vh * (va - 10) + 10)
  6182. };
  6183. vd.stroke();
  6184. vd.globalAlpha = 0.5;
  6185. vd.lineTo(ve, va);
  6186. vd.lineTo(0, va);
  6187. vd.fill();
  6188. vd.globalAlpha = 1
  6189. }
  6190. }
  6191. }
  6192. var v_68 = {
  6193. context: function() {
  6194. return g_context
  6195. },
  6196. playerCellIds: function() {
  6197. return g_playerCellIds
  6198. },
  6199. playerCells: function() {
  6200. return selfOwnedCells
  6201. },
  6202. cellsById: function() {
  6203. return g_cellsById
  6204. },
  6205. cells: function() {
  6206. return g_cells
  6207. }
  6208. };
  6209.  
  6210. /*
  6211. if(!UseOgarMapImpl) {
  6212. //ä»–ã®ãƒ—ãƒ¬ã‚¤ãƒ¤ãƒ¼æƒ…å ±ã‚’å—ã‘å–ã‚‹ãƒãƒ³ãƒ‰ãƒ©
  6213. socket.on('playerUpdated', function(data) {
  6214. //actionがupdateã§ãªã„å ´åˆå†é€ä¿¡
  6215. ('join' == data.action || 'spectate' == data.action) && 0 < v_68.playerCells()['length'] && conn.emit('playerUpdated', CreatePlayerEntryData('update'));
  6216.  
  6217. //è¾žæ›¸ã«ãƒ—ãƒ¬ã‚¤ãƒ¤ãƒ¼æƒ…å ±ã‚’æ ¼ç´
  6218. data.identifier && (playerDetailsByIdentifier[data.identifier] = data, playerDetailsByNick[data.nick] = data)
  6219. });
  6220. } else {
  6221.  
  6222. }
  6223. */
  6224.  
  6225. //移動?
  6226. _win.moveTo = function(va, vb) {
  6227. //va && vb && (myApp.isStopMovement = 1)
  6228. };
  6229.  
  6230. _win.setPosition = function(va, vb) {
  6231. if(IsDocumentReady()) {
  6232. var vd = CreateDataView(13);
  6233. vd.setUint8(0, 16);
  6234. vd.setInt32(1, va, 1);
  6235. vd.setInt32(5, vb, 1);
  6236. vd.setUint32(9, 0, 1);
  6237. SendDataFrame(vd)
  6238. }
  6239. };
  6240. window.handleQuickW = function() {
  6241. if(myApp.autoW) {
  6242. var va = CreateDataView(1);
  6243. va.setUint8(0, 21);
  6244. SendDataFrame(va);
  6245. setTimeout(handleQuickW, 142)
  6246. }
  6247. };
  6248. if(!_win.agarioNoInit) {
  6249. /*
  6250. var v_69 = 'https:' == _win.location['protocol'];
  6251. if(v_69 && -1 == _win.location['search']['indexOf']('fb')) {
  6252. _win.location['href'] = 'http://agar.io/'
  6253. } else
  6254. */
  6255. {
  6256. var v_6a, ctx, v_6b, _screenWidth, _screenHeight, v_6e = null,
  6257. webSocket = null,
  6258. v_70_fieldPosX = 0,
  6259. v_71_fieldPosY = 0,
  6260. selfNodeIdList = [],
  6261. selfOwnedCells = [],
  6262. v_74 = {},
  6263. gameObjects = [],
  6264. v_76 = [],
  6265. //leaderBoardList = [],
  6266. clientMouseX = 0,
  6267. clientMouseY = 0,
  6268. refPositionX = -1,
  6269. refPositionY = -1,
  6270. v_7c = 0,
  6271. v_7d = 0,
  6272. v_7e = 0,
  6273. game_playername_sending = null,
  6274. fieldLeft = -7071.067811865476,
  6275. fieldTop = -7071.06781186547,
  6276. fieldRight = 7071.067811865476,
  6277. fieldBottom = 7071.067811865476,
  6278. //fieldLeft = 0,
  6279. //fieldTop = 0,
  6280. //fieldRight = 14142.13562373095,
  6281. //fieldBottom = 14142.13562373095,
  6282. v_84 = 0,
  6283. v_85 = 0,
  6284. v_86 = 0,
  6285. v_87 = 0,
  6286. v_88_zoom = 1,
  6287. v_89 = null,
  6288. v_8a = 1,
  6289. v_8b = 1,
  6290. v_8c = 0,
  6291. v_8d = 0,
  6292. highest_score = 0,
  6293. v_8f = 1,
  6294. v_90 = 0,
  6295. stopPositionX = v_70_fieldPosX = ~~((fieldLeft + fieldRight) / 2),
  6296. stopPositionY = v_71_fieldPosY = ~~((fieldTop + fieldBottom) / 2),
  6297. v_93 = 1,
  6298. v_94 = '',
  6299. v_95 = null,
  6300. v_96 = 0,
  6301. v_97 = 0,
  6302. v_98 = 0,
  6303. v_99 = 0,
  6304. v_9a = 0,
  6305. v_9b = 0,
  6306. v_9c = 0,
  6307. lb_colors = ['#333333', '#FF3333', '#33FF33', '#3333FF'],
  6308. v_9e = 0,
  6309. v_9f = 0,
  6310. v_a0 = 0,
  6311. v_a1_zoomLevel = 1,
  6312. v_a2 = 1,
  6313. v_a3 = 0,
  6314. v_a4 = 0,
  6315. v_a5 = {},
  6316. v_a6 = '',
  6317. v_a7 = 0,
  6318. extraCellsPosSizes = [],
  6319. TWO_PI = 2 * Math.PI,
  6320. v_aa = 0,
  6321. v_ab = 0,
  6322. frameSendQueueCount = 0,
  6323. v_ad = 0,
  6324. v_ae = 0,
  6325. v_af = [],
  6326. splitIndicatorColors = [{
  6327. type: 1,
  6328. color: '#d3d3d3'
  6329. }, {
  6330. type: 2,
  6331. color: '#76FF03'
  6332. }, {
  6333. type: 4,
  6334. color: '#2196F3'
  6335. }, {
  6336. type: -1,
  6337. color: '#FF9800'
  6338. }, {
  6339. type: -2,
  6340. color: '#FD0000'
  6341. }, {
  6342. type: -4,
  6343. color: 'white'
  6344. }];
  6345. //stopPositionX = v_70_fieldPosX = ~~((fieldLeft + fieldRight) / 2);
  6346. //stopPositionY = v_71_fieldPosY = ~~((fieldTop + fieldBottom) / 2);
  6347. //refPositionX = -1;
  6348. //refPositionY = -1;
  6349.  
  6350. setInterval(function() {
  6351. v_ad = v_ab;
  6352. v_ab = 0;
  6353. v_ae = frameSendQueueCount;
  6354. frameSendQueueCount = 0
  6355. }, 1E3);
  6356. (function() {
  6357. var vb = _win.location['search'];
  6358. '?' == vb.charAt(0) && (vb = vb.slice(1));
  6359. for(var vb = vb.split('&'), vd = 0; vd < vb.length; vd++) {
  6360. var ve = vb[vd]['split']('=');
  6361. v_a5[ve[0]] = ve[1]
  6362. }
  6363. })();
  6364. var v_b1 = document.createElement('canvas');
  6365. if('undefined' == typeof console || 'undefined' == typeof DataView || 'undefined' == typeof WebSocket || null == v_b1 || null == v_b1.getContext || null == _win.localStorage) {
  6366. alert('You browser does not support this game, we recommend you to use Firefox to play this')
  6367. } else {
  6368. var v_b2 = null;
  6369. _win.setNick = function(_name, _team, _skinUrl, _code, _skinUrl2) {
  6370. //_win.ga && _win.ga('send', 'event', 'Nick', _name.toLowerCase());
  6371. vn();
  6372. game_playername_sending = _team + _name;
  6373.  
  6374. gPlayerEntryData = {
  6375. name: _name,
  6376. team: _team,
  6377. skinUrl: _skinUrl,
  6378. code: _code,
  6379. skinUrl2: _skinUrl2
  6380. };
  6381. //game_playername_sending = _name;
  6382. SendGameNickName();
  6383. SendGameStart();
  6384. highest_score = 0;
  6385. myApp.newGame();
  6386. setLocalStorage('nick', _name);
  6387. announcementSent = 0;
  6388. //EnterPlayer()
  6389. };
  6390.  
  6391. function getInputTeamTag() {
  6392. var uiType = gconfig.teamInputUiType;
  6393. if(uiType == 'none') {
  6394. return '';
  6395. } else if(uiType == 'text') {
  6396. return $('#team_name').val();
  6397. } else if(uiType == 'duel') {
  6398. var teams = gconfig.duelTeamEntries.split(',');
  6399. return teams[gDuelTeamInputIndex] || '-';
  6400. //var teamB = teams[1] || '-';
  6401. //gTeamTagOverride =
  6402. //return ( == 0) ? teamA : teamB; // "【紅】" : "【白】";
  6403. } else if(uiType == 'combo') {
  6404. //var teams = gconfig.duelTeamEntries.split(',');
  6405. //return teams[gComboTeamInputIndex] || '-';
  6406. var val = $('#team_combo_box').val();
  6407. localStorage.setItem('teamComboBoxVal', val);
  6408. return val;
  6409. }
  6410. return ''; //gTeamTagOverride || '';
  6411. }
  6412.  
  6413. _win.setNickA = function() {
  6414. if(!gIsConnected) return;
  6415. var team = getInputTeamTag();
  6416. var name = $('#nick').val();
  6417. var skinUrl = $('#skin_url').val();
  6418. var skinUrl2 = $('#skin_url2').val();
  6419. var code = $('.partyToken').val();
  6420. if(!gconfig.enablePartyCode) code = '';
  6421. setNick(name, team, skinUrl, code, skinUrl2);
  6422. }
  6423.  
  6424. _win.setNickB = function() {
  6425. if(!gIsConnected) return;
  6426. var team = getInputTeamTag();
  6427. var name = $('#nick').val();
  6428. var skinUrl = $('#skin_url').val();
  6429. var skinUrl2 = $('#skin_url2').val();
  6430. var code = $('.partyToken').val();
  6431. if(!gconfig.enablePartyCode) code = '';
  6432. gPlayerEntryData = {
  6433. name: name,
  6434. team: team,
  6435. skinUrl: skinUrl,
  6436. code: code,
  6437. skinUrl2: skinUrl2
  6438. };
  6439. sendGameNickNameCore();
  6440. }
  6441. _win.setRegion = vk;
  6442. _win.setSkins = function(va) {
  6443. v_8a = va
  6444. };
  6445. _win.setNames = function(va) {
  6446. v_8b = va
  6447. };
  6448. _win.setDarkTheme = function(va) {
  6449. v_8f = va
  6450. };
  6451. _win.setColors = function(va) {
  6452. v_8c = va
  6453. };
  6454. _win.setShowMass = function(va) {
  6455. v_90 = va
  6456. };
  6457. _win.connectIP = function(va) {
  6458. var vd = va.trim();
  6459. _jquery('#opt_connect_ip')['val'](vd);
  6460. vd || ':party' != _jquery('#gamemode option:selected')['val']() ? 0 != vd.length && 6 >= vd.length ? v_62(va) : (console.log('connecting IP = ' + va), v_a6 = va, vl()) : createParty()
  6461. };
  6462. _win.getCurrentX = function() {
  6463. return selfOwnedCells.length ? v_70_fieldPosX - (fieldRight - 7071.067811865476) : ''
  6464. };
  6465. _win.getCurrentY = function() {
  6466. return selfOwnedCells.length ? v_71_fieldPosY - (fieldBottom - 7071.067811865476) : ''
  6467. };
  6468. _win.getTop1X = function() {
  6469. return stopPositionX
  6470. };
  6471. _win.getTop1Y = function() {
  6472. return stopPositionY
  6473. };
  6474. _win.getLengthX = function() {
  6475. return 14142.135623730952
  6476. };
  6477. _win.getLengthY = function() {
  6478. return 14142.135623730952
  6479. };
  6480. _win.getLB = function() {
  6481. return leaderBoardList
  6482. };
  6483. _win.getSelfIDs = function() {
  6484. return selfNodeIdList
  6485. };
  6486. _win.getCell = function() {
  6487. return selfOwnedCells
  6488. };
  6489. _win.getHighestScore = function() {
  6490. return highest_score
  6491. };
  6492. _win.quickSpace = function() {
  6493. 0 != selfOwnedCells.length && (SendPlayerAction(17), setTimeout(function() {
  6494. SendPlayerAction(17)
  6495. }, 40), setTimeout(function() {
  6496. SendPlayerAction(17)
  6497. }, 80), setTimeout(function() {
  6498. SendPlayerAction(17)
  6499. }, 120), setTimeout(function() {
  6500. SendPlayerAction(17)
  6501. }, 160))
  6502. };
  6503. _win.doubleSpace = function() {
  6504. setTimeout(function() {
  6505. SendPlayerAction(17)
  6506. }, 50);
  6507. setTimeout(function() {
  6508. SendPlayerAction(17)
  6509. }, 100)
  6510. };
  6511. _win.getFPS = function() {
  6512. return v_a7
  6513. };
  6514. _win.getPacketIO = function() {
  6515. return [v_ad, v_ae]
  6516. };
  6517. _win.spectate = function() {
  6518. if(!gIsConnected) return;
  6519.  
  6520. isJoinedGame = 0;
  6521. spectateMode = 1;
  6522. gIsSpectate = true;
  6523. game_playername_sending = null;
  6524. SendPlayerAction(1);
  6525. vn();
  6526. myApp.spectate(selfOwnedCells);
  6527. //var va = CreatePlayerEntryData('spectate');
  6528. //conn.emit('playerEntered', va);
  6529. //skinProvider.requestBroadcastSkins();
  6530. };
  6531. _win.setGameMode = function(va) {
  6532. va != v_94 && (':party' == v_94 && _jquery('#helloContainer')['attr']('data-party-state', '0'), vz(va), ':party' != va && vl())
  6533. };
  6534. _win.setZoomLevel = function(va) {
  6535. v_a1_zoomLevel = va
  6536. };
  6537. _win.isFreeSpec = function() {
  6538. return myApp.isSpectating && 0.25 === v_aa
  6539. };
  6540. _win.setAcid = function(va) {
  6541. v_9e = va
  6542. };
  6543. null != _win.localStorage && (null == _win.localStorage['AB9'] && (_win.localStorage['AB9'] = 0 + ~~(100 * Math.random())), v_9c = +_win.localStorage['AB9'], _win.ABGroup = v_9c);
  6544. var v_b3 = null;
  6545. _win.connect = connectToGameServer;
  6546. _win.disconnect = disconnectGameServer;
  6547.  
  6548. //gConnectionProc = connectToGameServer;
  6549. var v_b4 = 500,
  6550. v_b5 = null,
  6551. v_b6 = 0,
  6552. bPositionX = -1,
  6553. bPositionY = -1,
  6554. v_b9 = null,
  6555. v_ba = 1,
  6556. animationFrameFuncRoot = function() {
  6557. Date.now();
  6558. var vb = 0,
  6559. vd = Date.now();
  6560. return function() {
  6561. try {
  6562. _win.requestAnimationFrame(animationFrameFuncRoot);
  6563. var ve = Date.now();
  6564. myApp.isShowFPS && (1E3 < vb ? (vd = ve, vb = 0, v_a7 = v_7c, v_7c = 0) : vb = ve - vd);
  6565. (!IsDocumentReady() || 240 > Date.now() - v_a0) && updateFrame();
  6566. v_c2()
  6567. } catch(e) {
  6568. console.log(e);
  6569. }
  6570. }
  6571. }(),
  6572. v_bc = {},
  6573. v_bd = 'poland;usa;china;russia;canada;australia;spain;brazil;germany;ukraine;france;sweden;chaplin;north korea;south korea;japan;united kingdom;earth;greece;latvia;lithuania;estonia;finland;norway;cia;maldivas;austria;nigeria;reddit;yaranaika;confederate;9gag;indiana;4chan;italy;bulgaria;tumblr;2ch.hk;hong kong;portugal;jamaica;german empire;mexico;sanik;switzerland;croatia;chile;indonesia;bangladesh;thailand;iran;iraq;peru;moon;botswana;bosnia;netherlands;european union;taiwan;pakistan;hungary;satanist;qing dynasty;matriarchy;patriarchy;feminism;ireland;texas;facepunch;prodota;cambodia;steam;piccolo;ea;india;kc;denmark;quebec;ayy lmao;sealand;bait;tsarist russia;origin;vinesauce;stalin;belgium;luxembourg;stussy;prussia;8ch;argentina;scotland;sir;romania;belarus;wojak;doge;nasa;byzantium;imperial japan;french kingdom;somalia;turkey;mars;pokerface;8;irs;receita federal;facebook;putin;merkel;tsipras;obama;kim jong-un;dilma;hollande;berlusconi;cameron;clinton;hillary;venezuela;blatter;chavez;cuba;fidel;merkel;palin;queen;boris;bush;trump'['split'](';'),
  6574. v_be = '8;nasa;putin;merkel;tsipras;obama;kim jong-un;dilma;hollande;berlusconi;cameron;clinton;hillary;blatter;chavez;fidel;merkel;palin;queen;boris;bush;trump'['split'](';'),
  6575. v_bf = {};
  6576.  
  6577.  
  6578.  
  6579. Date.now || (Date.now = function() {
  6580. return (new Date)['getTime']()
  6581. });
  6582.  
  6583. (function() {
  6584. for(var vb = ['ms', 'moz', 'webkit', 'o'], vd = 0; vd < vb.length && !_win.requestAnimationFrame; ++vd) {
  6585. _win.requestAnimationFrame = _win[vb[vd] + 'RequestAnimationFrame'], _win.cancelAnimationFrame = _win[vb[vd] + 'CancelAnimationFrame'] || _win[vb[vd] + 'CancelRequestAnimationFrame']
  6586. };
  6587. _win.requestAnimationFrame || (_win.requestAnimationFrame = function(va) {
  6588. return setTimeout(va, 1E3 / 60)
  6589. }, _win.cancelAnimationFrame = function(va) {
  6590. clearTimeout(va)
  6591. })
  6592. })();
  6593. var onWindowLoadedJQ = function() {
  6594. var va = new GameObject(0, 0, 0, 32, '#ED1C24', ''),
  6595. canvas = document.createElement('canvas');
  6596. canvas.width = 32;
  6597. canvas.height = 32;
  6598. var ctx = canvas.getContext('2d');
  6599. return function() {
  6600. 0 < selfOwnedCells.length && (va.color = selfOwnedCells[0]['color'], va.setGameObjectName(selfOwnedCells[0]['name']));
  6601. ctx.clearRect(0, 0, 32, 32);
  6602. ctx.save();
  6603. ctx.translate(16, 16);
  6604. ctx.scale(0.4, 0.4);
  6605. va.drawGameObject(ctx);
  6606. ctx.restore();
  6607. var fvc = document.getElementById('favicon'),
  6608. ve = fvc.cloneNode(1);
  6609. fvc.parentNode['replaceChild'](ve, fvc)
  6610. }
  6611. }();
  6612. _jquery(function() {
  6613. onWindowLoadedJQ()
  6614. });
  6615. var v_c1 = 'loginCache3';
  6616. _jquery(function() {
  6617. if(+_win.localStorage['wannaLogin']) {
  6618. if(_win.localStorage[v_c1]) {
  6619. var vd = _win.localStorage[v_c1];
  6620. 'string' == typeof vd && (vd = JSON.parse(vd));
  6621. Date.now() + 18E5 > vd.expires ? _jquery('#helloContainer')['attr']('data-logged-in', '0') : (_win.localStorage[v_c1] = JSON.stringify(vd), _jquery('.agario-profile-name')['text'](vd.name), v_59(), v_5e({
  6622. e: vd.xp,
  6623. c: vd.xpNeeded,
  6624. d: vd.level
  6625. }), _jquery('#helloContainer')['attr']('data-logged-in', '1'))
  6626. };
  6627. _win.localStorage['fbPictureCache'] && _jquery('.agario-profile-picture')['attr']('src', _win.localStorage['fbPictureCache'])
  6628. }
  6629. });
  6630. _win.facebookLogin = function() {
  6631. _win.localStorage['wannaLogin'] = 1
  6632. };
  6633. _win.fbAsyncInit = function() {
  6634. function vb() {
  6635. _win.localStorage['wannaLogin'] = 1;
  6636. null == _win.FB ? alert('You seem to have something blocking Facebook on your browser, please check for any extensions') : _win.FB['login'](function(va) {
  6637. console.log(va);
  6638. v_5f(va)
  6639. }, {
  6640. scope: 'public_profile, email'
  6641. })
  6642. }
  6643. _win.FB['init']({
  6644. appId: '677505792353827',
  6645. cookie: 1,
  6646. xfbml: 1,
  6647. status: 1,
  6648. version: 'v_2.2'
  6649. });
  6650. _win.FB['Event']['subscribe']('auth.statusChange', function(vd) {
  6651. +_win.localStorage['wannaLogin'] && ('connected' == vd.status ? v_5f(vd) : vb())
  6652. });
  6653. _win.facebookLogin = vb
  6654. };
  6655. _win.logout = function() {
  6656. _jquery('#helloContainer')['attr']('data-logged-in', '0');
  6657. _jquery('#helloContainer')['attr']('data-has-account-data', '0');
  6658. delete _win.localStorage['wannaLogin'];
  6659. delete _win.localStorage[v_c1];
  6660. delete _win.localStorage['fbPictureCache'];
  6661. vl();
  6662. $('.btn-spectate')['prop']('disabled', 0)
  6663. };
  6664. var v_c2 = function() {
  6665. function va(vb, vd, ve, vf, vi) {
  6666. var vj = vd.getContext('2d'),
  6667. v_4f = vd.width;
  6668. vd = vd.height;
  6669. vb.color = vi;
  6670. vb.setGameObjectName(ve);
  6671. vb.size = vf;
  6672. vj.save();
  6673. vj.translate(v_4f / 2, vd / 2);
  6674. vb.drawGameObject(vj);
  6675. vj.restore()
  6676. }
  6677. for(var vd = new GameObject(-1, 0, 0, 32, '#5bc0de', ''), ve = new GameObject(-1, 0, 0, 32, '#5bc0de', ''), vf = '#0791ff #5a07ff #ff07fe #ffa507 #ff0774 #077fff #3aff07 #ff07ed #07a8ff #ff076e #3fff07 #ff0734 #07ff20 #ff07a2 #ff8207 #07ff0e'['split'](' '), vi = [], vj = 0; vj < vf.length; ++vj) {
  6678. var angle = vj / vf.length * 12,
  6679. dist = 30 * Math.sqrt(vj / vf.length);
  6680. vi.push(new GameObject(-1, Math.cos(angle) * dist, Math.sin(angle) * dist, 10, vf[vj], ''))
  6681. };
  6682. v_5d(vi);
  6683. var vk = document.createElement('canvas');
  6684. vk.getContext('2d');
  6685. vk.width = vk.height = 70;
  6686. va(ve, vk, '', 26, '#ebc0de');
  6687. return function() {
  6688. _jquery('.cell-spinner')['filter'](':visible')['each'](function() {
  6689. var ve = _jquery(this),
  6690. vf = Date.now(),
  6691. vi = this.width,
  6692. vj = this.height,
  6693. vg = this.getContext('2d');
  6694. vg.clearRect(0, 0, vi, vj);
  6695. vg.save();
  6696. vg.translate(vi / 2, vj / 2);
  6697. for(var vh = 0; 10 > vh; ++vh) {
  6698. vg.drawImage(vk, (0.1 * vf + 80 * vh) % (vi + 140) - vi / 2 - 70 - 35, vj / 2 * Math.sin((0.001 * vf + vh) % Math.PI * 2) - 35, 70, 70)
  6699. };
  6700. vg.restore();
  6701. (ve = ve.attr('data-itr')) && (ve = vm(ve));
  6702. va(vd, this, ve || '', +_jquery(this)['attr']('data-size'), '#5bc0de')
  6703. });
  6704. _jquery('#statsPellets')['filter'](':visible')['each'](function() {
  6705. _jquery(this);
  6706. var vd = this.width,
  6707. ve = this.height;
  6708. this.getContext('2d')['clearRect'](0, 0, vd, ve);
  6709. for(vd = 0; vd < vi.length; vd++) {
  6710. va(vi[vd], this, '', vi[vd]['size'], vi[vd]['color'])
  6711. }
  6712. })
  6713. }
  6714. }();
  6715. _win.createParty = function() {
  6716. vz(':party');
  6717. v_b3 = function(vd) {
  6718. v_63('/#' + _win.encodeURIComponent(vd));
  6719. _jquery('.partyToken')['val'](_win.encodeURIComponent(vd));
  6720. _jquery('#helloContainer')['attr']('data-party-state', '1')
  6721. };
  6722. vl();
  6723. isJoinedGame = 0;
  6724. $('.btn-spectate')['prop']('disabled', 0)
  6725. };
  6726. _win.joinParty = v_62;
  6727. _win.cancelParty = function() {
  6728. v_63('/');
  6729. _jquery('#helloContainer')['attr']('data-party-state', '0');
  6730. vz('');
  6731. vl()
  6732. };
  6733. var v_c3 = [],
  6734. v_c4 = 0,
  6735. v_c5 = '#000000',
  6736. v_c6 = 0,
  6737. v_c7 = 0,
  6738. v_c8 = 0,
  6739. v_c9 = 0,
  6740. v_ca = 0,
  6741. v_cb = 0,
  6742. v_cc = 0,
  6743. v_cd = 1;
  6744. setInterval(function() {
  6745. v_c7 && v_c3.push(calcCurrentScore() / 100)
  6746. }, 1E3 / 60);
  6747. setInterval(function() {
  6748. var va = v_66();
  6749. 0 != va && (++v_ca, 0 == v_cc && (v_cc = va), v_cc = Math.min(v_cc, va))
  6750. }, 1E3);
  6751. _win.closeStats = function() {
  6752. v_c6 = 0;
  6753. _jquery('#stats')['hide']();
  6754. vi(0)
  6755. };
  6756. _win.setSkipStats = function(va) {
  6757. v_cd = !va
  6758. };
  6759. _jquery(function() {
  6760. _jquery(vf)
  6761. })
  6762. }
  6763. }
  6764. }
  6765. };
  6766. loadGameCore(window, window.jQuery);
  6767.  
  6768. myApp.afterGameLogicLoaded();
  6769.  
  6770. conn2.setChatListenerProc(chatRoom.receiveMessage.bind(chatRoom));
  6771. conn2.setMapListenerProc(minimap.updateNode.bind(minimap));
  6772.  
  6773.  
  6774.  
  6775. class TeamRankingChart{
  6776. constructor(){
  6777. var canvas = document.getElementById('lb_canvas_chart');
  6778. this.ctx = canvas.getContext('2d');
  6779. this.sz = 150;
  6780. var _canvas = $('#lb_canvas_chart');
  6781. _canvas.attr('width', this.sz);
  6782. _canvas.attr('height', this.sz);
  6783. _canvas.css('opacity', 0.8);
  6784. // _canvas.css('background-color', 'rgba(255,255,255,0.5)');
  6785. }
  6786.  
  6787. normAngleToChartAngle(norm_angle){
  6788. var pi = Math.PI;
  6789. return -pi * 0.5 + norm_angle * pi * 2;
  6790. }
  6791.  
  6792. update(ranks){
  6793. var ctx = this.ctx;
  6794. //ctx.fillStyle = 'red';
  6795. //ctx.fillRect(10, 20, 50, 50);
  6796.  
  6797. var cp = this.sz / 2;
  6798. var r = this.sz / 2;
  6799. var hr = r / 2;
  6800. var pi = Math.PI;
  6801.  
  6802. var fontSize = 16;
  6803. ctx.font = fontSize + "px メイリオ, arial";
  6804.  
  6805. ctx.fillStyle = '#CCC';
  6806. ctx.beginPath();
  6807. ctx.arc(cp, cp, r, 0, pi * 2, false);
  6808. ctx.fill();
  6809.  
  6810. //var pi2 = pi * 2;
  6811. var angle = 0.0;
  6812. for(var rank of ranks){
  6813. var teamId = rank.id;
  6814. var rate = rank.rate * 0.01;
  6815. //var rate = 0.2;
  6816. var col = teamManager.getColor(teamId);
  6817. var teamName = teamManager.getTeamName(teamId);
  6818. //ctx.strokeStyle = 'blue';
  6819. ctx.fillStyle = col;
  6820. ctx.beginPath();
  6821. var a0 = this.normAngleToChartAngle(angle);
  6822. var a1 = this.normAngleToChartAngle(angle + rate);
  6823. ctx.moveTo(cp, cp);
  6824. ctx.lineTo(cp + Math.cos(a0) * r, cp + Math.sin(a0) * r);
  6825. ctx.arc(cp, cp, r, a0, a1, false);
  6826. ctx.lineTo(cp, cp);
  6827. ctx.stroke();
  6828. ctx.fill();
  6829. if(rate > 0.05){
  6830. var a2 = (a0 + a1) / 2;
  6831. var tw = ctx.measureText(teamName).width;
  6832. ctx.fillStyle = 'black';
  6833. ctx.fillText(teamName, cp + Math.cos(a2) * hr - tw/2, cp + Math.sin(a2) * hr + fontSize/4);
  6834. }
  6835. angle += rate;
  6836. }
  6837. //ctx.strokeStyle = 'black';
  6838. ctx.beginPath();
  6839. ctx.arc(cp, cp, r, 0, pi * 2, false);
  6840. ctx.stroke();
  6841. }
  6842. }
  6843. var teamRankingChart = new TeamRankingChart();
  6844.  
  6845. function updateTeamRankView(ranks) {
  6846. //var num = Math.min(ranks.length, 5);
  6847. var num = ranks.length;
  6848. var block = '';
  6849. for(var i = 0; i < num; i++) {
  6850. var teamId = ranks[i].id;
  6851. //var rate = Math.round(ranks[i].rate * 10) * 0.1;
  6852. var teamName = teamManager.getTeamName(teamId);
  6853. var col = teamManager.getColor(teamId);
  6854. //var tag = ranks[i].tag;
  6855. var rate = parseInt(ranks[i].rate * 10.0) / 10.0;
  6856. //var col = teamManager.getLeaderboardColor(tag);
  6857. //if(tag == '@BOT') tag= 'BOT';
  6858. block += `<div style="color:${col}">${i + 1}.${teamName} -- ${rate}%</div>`;
  6859. }
  6860. $('#lb_detail2').html(block);
  6861.  
  6862. if(GamePresetConfig.EnableTeamRankingChart){
  6863. teamRankingChart.update(ranks);
  6864. }
  6865. }
  6866.  
  6867. conn2.setTeamRanksListenerProc(updateTeamRankView);
  6868.  
  6869. //300
  6870. function initialize_misc() {
  6871.  
  6872. $(document)['keydown'](function(va) {
  6873. if('input' != va.target['tagName']['toLowerCase']() && 'textarea' != va.target['tagName']['toLowerCase']() || 13 == va.keyCode) {
  6874. var vb = '';
  6875. isValidHotKey(va) && (vb = getPressedKey(va));
  6876. 18 == va.keyCode && va.preventDefault();
  6877. if(selectedHotkeyRow) {
  6878. if(46 == va.keyCode) {
  6879. va.preventDefault(), selectedHotkeyRow.find('.hotkey')['text'](vb)
  6880. } else {
  6881. if('' != vb) {
  6882. va.preventDefault();
  6883. for(var vf = $('.hotkey'), vg = 0; vg < vf.length; vg++) {
  6884. if($(vf[vg])['text']() == vb) {
  6885. return
  6886. }
  6887. }
  6888. ;
  6889. selectedHotkeyRow.find('.hotkey')['text'](vb);
  6890. selectedHotkeyRow.removeClass('table-row-selected');
  6891. selectedHotkeyRow = null
  6892. }
  6893. }
  6894. }
  6895. ;
  6896. '' != vb && hotkeyMapping[vb] && (va.preventDefault(), hotkeyConfig[hotkeyMapping[vb]] && hotkeyConfig[hotkeyMapping[vb]]['keyDown'] && hotkeyConfig[hotkeyMapping[vb]]['keyDown']())
  6897. }
  6898. });
  6899.  
  6900.  
  6901. $(document)['keyup'](function(va) {
  6902. if('input' != va.target['tagName']['toLowerCase']() && 'textarea' != va.target['tagName']['toLowerCase']() || 13 == va.keyCode) {
  6903. var vb = '';
  6904. isValidHotKey(va) && (vb = getPressedKey(va));
  6905. '' != vb && hotkeyMapping[vb] && (va.preventDefault(), hotkeyConfig[hotkeyMapping[vb]] && hotkeyConfig[hotkeyMapping[vb]]['keyUp'] && hotkeyConfig[hotkeyMapping[vb]]['keyUp']())
  6906. }
  6907. });
  6908.  
  6909.  
  6910. $('#overlays2')['mousedown'](function(va) {
  6911. 0 === va.button ? !myApp.isEnableMouseW || 'input' == va.target['tagName']['toLowerCase']() && 'textarea' == va.target['tagName']['toLowerCase']() || (myApp.autoW = 1, handleQuickW(), va.preventDefault()) : 2 === va.button && $('#opt_chatbox__INVALID_TAG_FOR_DISABLE_STATEMENT__')['click']()
  6912. });
  6913.  
  6914.  
  6915. $('#overlays2')['mouseup'](function(va) {
  6916. 0 === va.button && myApp.isEnableMouseW && 'input' != va.target['tagName']['toLowerCase']() && 'textarea' != va.target['tagName']['toLowerCase']() && (myApp.autoW = 0, va.preventDefault())
  6917. });
  6918.  
  6919. function isValidHotKey(va) {
  6920. return 48 <= va.keyCode && 57 >= va.keyCode || 65 <= va.keyCode && 90 >= va.keyCode || 9 == va.keyCode || 13 == va.keyCode ? 1 : 0
  6921. }
  6922.  
  6923. function getPressedKey(va) {
  6924. var vb = '';
  6925. va.ctrlKey && (vb += 'CTRL_');
  6926. va.altKey && (vb += 'ALT_');
  6927. return vb = 9 == va.keyCode ? vb + 'TAB' : 13 == va.keyCode ? vb + 'ENTER' : vb + String.fromCharCode(va.keyCode)
  6928. }
  6929.  
  6930. function copyToClipboard(va) {
  6931. window.postMessage({
  6932. action: Action.COPY,
  6933. data: va
  6934. }, '*')
  6935. }
  6936.  
  6937. window.onbeforeunload = function() {
  6938. if(gIsPlaying) return 'You are leaving Agar.io.';
  6939. //return 'You are leaving Agar.io.'
  6940. };
  6941.  
  6942. function escapeRegex(va) {
  6943. return va.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\$&')
  6944. }
  6945.  
  6946. var disconnectTimeout;
  6947. $(window)['focus'](function() {
  6948. isWindowFocus = 1;
  6949. disconnectTimeout && clearTimeout(disconnectTimeout)
  6950. })['blur'](function() {
  6951. isWindowFocus = 0
  6952. });
  6953. jQuery.cachedScript = function(va, vb) {
  6954. vb = $['extend'](vb || {}, {
  6955. dataType: 'script',
  6956. cache: 1,
  6957. url: va
  6958. });
  6959. return jQuery.ajax(vb)
  6960. };
  6961.  
  6962. minimap.start();
  6963.  
  6964. /*
  6965. function drawMinimapNodes() {
  6966. minimap.uploadSelfPosition();
  6967. setTimeout(drawMinimapNodes, 1000); //1E3)
  6968. }
  6969.  
  6970. if(UseOgarMapImpl){
  6971.  
  6972. }else{
  6973. drawMinimapNodes();
  6974. }
  6975. */
  6976.  
  6977. updateGameInfoDiv();
  6978.  
  6979. function updateGameInfoDiv() {
  6980. $('#overlays')['is'](':visible') && myApp.updateLBInfo();
  6981. setTimeout(updateGameInfoDiv, 1E3)
  6982. }
  6983.  
  6984. clearOldNodesData();
  6985.  
  6986. function clearOldNodesData() {
  6987. for(var va = 1; va < nodeList.length; va++) {
  6988. var vb = nodeList[va][8];
  6989. vb && 5E3 < Date.now() - vb && (2 > va ? (nodeList[va][2] = null, nodeList[va][3] = null) : nodeList[va][0] = 'del')
  6990. }
  6991. ;
  6992. setTimeout(clearOldNodesData, 5E3)
  6993. }
  6994.  
  6995. //updateLbDiv();
  6996.  
  6997. var leaderboardTeamColors = {
  6998. '【先輩】': '#FFFFFF',
  6999. '【敵】': '#FF88AA',
  7000. '【異世界】': '#CC66FF',
  7001. '〖ƝǤ〗': '#FF0000',
  7002. '〖ҬƓӃ〗': '#FFF0F5',
  7003. '▽ŇⒼ▲': '#00EE00',
  7004. '♠♥♦♣': '#FFEC8B',
  7005. 'ζΘŤΓ☀': '#91c5ff',
  7006. '【νιρ】': '#FFFF00',
  7007. '【龙天】': '#EE00EE',
  7008. '【锋芒】': '#D1EEEE',
  7009. '▕龑▏': '#9400D3',
  7010. '❤.+[☣☠]': '#7FFF00',
  7011. '安逸☢': '#8B008B',
  7012. '园逸☢': '#8B008B',
  7013. '【♕】': '#00FF00',
  7014. '【♛】': '#00FF00',
  7015. '【✯】': '#00FF00',
  7016. 'ჯH.F.Lჯ': '#00FF00',
  7017. 'ჯ閃靈獵手': '#00FF00',
  7018. '【匿名Å】': '#941AE6',
  7019. 'Rstar': '#B23AEE',
  7020. 'æ°·': '#6A5ACD',
  7021. 'ѤӖ*': '#6A5ACD',
  7022. '✖抱歉': '#801288',
  7023. '++': '#FF00FF',
  7024. '★★': '#FFD700',
  7025. '●●': '#FF2200',
  7026. '☆☆': '#FFFF00',
  7027. '☣.+☠': '#FF0000',
  7028. '○〇⃝❍ㅇx2': '#4444FF',
  7029. '・・': '#00FF00',
  7030. 'â—Žâ—Ž': '#00FFFF',
  7031. '??': '#FF6600',
  7032. '❖,◆': '#FF0000',
  7033. '□□,ㅁㅁ': '#CCCCCC',
  7034. '🔰': '#AAFFAA',
  7035. 'ヴぃp': '#FFD700',
  7036. '高登,HKG': '#FF6666',
  7037. 'RTHK': '#FF6666',
  7038. 'ç¿ å¦‚bb': '#FF6666',
  7039. '貓肉球': '#FF6666',
  7040. '【烎】': '#56ffff',
  7041. 'ǺǤℂ✿': '#FF1493',
  7042. '✿': '#FF1493',
  7043. '푸,린딩': '#FF1493',
  7044. '한국': '#FF1493',
  7045. '연연,맹합': '#FF1493',
  7046. '܁̸̶ا١̸ּ': '#FF1493',
  7047. '11일,11TV': '#FF1493',
  7048. 'S8': '#00FF00',
  7049. 'V{OÔố}Z': '#66FF66',
  7050. '{TV}ắ{IUT}': '#66FF66',
  7051. '[vbt][ui]{aệ}': '#66FF66',
  7052. 'GS': '#66FF66',
  7053. '台臺,TW,湾灣': '#EE7621',
  7054. 'AUS': '#98d98e',
  7055. '少しだるいさ': '#ce12ce',
  7056. '★': '#eeee11',
  7057. 'SG': '#FF6600',
  7058. };
  7059.  
  7060. /*
  7061. function updateLbDiv() {
  7062. if($('#div_lb')['is'](':visible')) {
  7063. var lbs = getLB(),
  7064. vb = getSelfIDs(),
  7065. vf = '';
  7066. if(lbs) {
  7067. for(var i = 0; i < lbs.length; i++) {
  7068. for(var vh = 0, vd = 0; vd < vb.length; vd++) {
  7069. if(vb[vd] == lbs[i]['id']) {
  7070. vh = 1;
  7071. break
  7072. }
  7073. }
  7074. ;
  7075.  
  7076. //vd = lbs[i]['name'] ? escapeHtml(lbs[i]['name']) : 'An unnamed cell';
  7077. var pID = lbs[i].id;
  7078. var info = gPlayerInfoDict[pID];
  7079. vd = '';
  7080. if(info){
  7081. vd = info.team + info.name;
  7082. }
  7083. if(vd == ''){
  7084. vd = 'An unnamed cell';
  7085. }
  7086.  
  7087. //var team = info ? info.team : '';
  7088. //var name = info ? info.name : '';
  7089. //vd = team + name;
  7090.  
  7091.  
  7092. if(EnableLeaderboardTeamColoring){
  7093. var col = "#FFFFFF";
  7094. var name = vd;
  7095. for(var key in leaderboardTeamColors){
  7096. if(name.startsWith(key)){
  7097. col = leaderboardTeamColors[key];
  7098. }
  7099. }
  7100. //var col = 'red';
  7101. //vf = vh ? vf + "<div class='self'>" :
  7102. vf = vf + '<div style="color:' + col + '">';
  7103. }else{
  7104. vf = vh ? vf + "<div class='self'>" : vf + '<div>';
  7105. }
  7106.  
  7107. vf += i + 1 + '. ' + vd + '</div>'
  7108. }
  7109. }
  7110. ;
  7111. document.getElementById('lb_detail')['innerHTML'] = vf
  7112. }
  7113. ;
  7114. //setTimeout(updateLbDiv, 1E3)
  7115. }
  7116. */
  7117.  
  7118. function updateLbDiv2(lbs) {
  7119. var block = '';
  7120.  
  7121. leaderBoardList = [];
  7122. for(var i = 0; i < lbs.length; i++) {
  7123. var pid = lbs[i].pid;
  7124. var score = lbs[i].score;
  7125. //var info = gPlayerInfoDict[id];
  7126. //var txt = info ? (info.team + info.name) : '#ERR';
  7127. var cid = playerCoreManager.getCid(pid);
  7128. var fullName = playerManager.getFullName(cid);
  7129. leaderBoardList.push({
  7130. cid: cid,
  7131. name: fullName
  7132. })
  7133. }
  7134.  
  7135. for(var i = 0; i < lbs.length; i++) {
  7136. var pid = lbs[i].pid;
  7137. var score = lbs[i].score;
  7138. //var info = gPlayerInfoDict[id];
  7139. //var txt = info ? (info.team + info.name) : '#ERR';
  7140. var cid = playerCoreManager.getCid(pid);
  7141. var txt = playerManager.getFullName(cid);
  7142. //block += '<div>' + (i + 1) + '.' + txt + '</div>';
  7143. //block += sform('<div>%o.%o</div>', i + 1, txt);
  7144. //var team = playerManager.getTeam(id);
  7145.  
  7146. //var col = teamManager.getColor(team);
  7147. txt = txt.replace(/\<.*?\>/g, '');
  7148.  
  7149. var teamId = playerManager.getTeamId(cid);
  7150. var team = teamManager.getTeamName(teamId);
  7151. var col = teamManager.getColor(teamId);
  7152. if(gconfig.showPlayerMassInLeaderBoard) {
  7153. block += `<div style="color:${col}">${i + 1}.${txt} -- ${score}</div>`;
  7154. } else {
  7155. block += `<div style="color:${col}">${i + 1}.${txt}</div>`;
  7156. }
  7157. }
  7158. $('#lb_detail').html(block);
  7159. }
  7160.  
  7161. function formatString() {
  7162. var str = arguments[0];
  7163. var args = arguments.slice(1, arguments.length);
  7164.  
  7165. //var pos = 0;
  7166. for(var i = 0; i < args.length; i++) {
  7167. //pos = str.indexOf('%o', pos);
  7168. //str.
  7169. str = str.replace('%o', args[i]);
  7170. }
  7171.  
  7172. }
  7173.  
  7174. conn2.setLeaderboardListenerProc(updateLbDiv2);
  7175.  
  7176. updateScoreDiv();
  7177.  
  7178. function updateScoreDiv() {
  7179. var score = getHighestScore(),
  7180. cell = getCell(),
  7181. vf = [];
  7182. 0 != score && (myApp.isShowScroll && vf.push('Score: ' + ~~(score / 100)), cell && 0 < cell.length && (myApp.isShowSTE && (score = myApp.getSTE(cell), vf.push('STE: ' + score)), myApp.isShowBallTotal && vf.push('[' + cell.length + '/16]')));
  7183. myApp.isShowFPS && (cell = getFPS(), 50 >= cell ? cell += 8 : 45 >= cell ? cell += 10 : 40 >= cell && (cell += 15), vf.push('FPS: ' + cell));
  7184. isFreeSpec() && myApp.specTeammate && myApp.isStopMovement && nodeList[myApp.specTeammate] && vf.push('SPEC: ' + nodeList[myApp.specTeammate][1]);
  7185. myApp.testing && vf.push('*** TESTING ***');
  7186. 0 < vf.length ? ($('#div_score')['is'](':visible') || $('#div_score')['show'](), document.getElementById('div_score')['innerHTML'] = vf.join('&nbsp;&nbsp;&nbsp;')['trim']()) : $('#div_score')['hide']();
  7187. setTimeout(updateScoreDiv, 500)
  7188. }
  7189.  
  7190. //$['cachedScript']('https://cdnjs.cloudflare.com/ajax/libs/jquery.perfect-scrollbar/0.6.8/js/min/perfect-scrollbar.jquery.min.js')['done'](function (va, vb) {
  7191. $['cachedScript']('lib/perfect-scrollbar.jquery.min.js')['done'](function(va, vb) {
  7192. chatRoom.createScrollBar()
  7193. });
  7194.  
  7195. //$['cachedScript']('http://extension.agarplus.io/jquery.toast.min.js')['done'](function (va, vb) {
  7196. $['cachedScript']('lib/jquery.toast.min.js')['done'](function(va, vb) {
  7197. for(var vf; vf = toastQueue.shift() ;) {
  7198. chatRoom.popup(vf)
  7199. }
  7200. });
  7201. $('#gamemode')['parent']()['append']('<div id="testing_div"> <div id="lbl_testing" style="height:20px;">Testing : </div><input value="' + testingVal + '" type="text" id="testing" class="form-control" placeholder="Testing data"></div>');
  7202. $('#testing')['change'](function() {
  7203. testingVal = Number($('#testing')['val']());
  7204. console.log('testingVal=' + testingVal)
  7205. });
  7206. $('#testing_div')['hide']();
  7207. $('.agario-profile-picture')['hide']();
  7208. $('.agario-profile-name-container')['hide']();
  7209. $('.agario-profile-panel')['click'](function() {
  7210. $('.agario-profile-picture')['is'](':visible') ? ($('.agario-profile-picture')['hide'](), $('.agario-profile-name-container')['hide']()) : ($('.agario-profile-picture')['show'](), $('.agario-profile-name-container')['show']())
  7211. });
  7212. var handleResource = function(a, b) {
  7213. q
  7214. if(!a || !b) {
  7215. console.log(' ** null in download object url, return;')
  7216. } else {
  7217. if(!customSkin[a]) {
  7218. var img = new Image;
  7219. img.onload = function() {
  7220. customSkin[a] = this;
  7221. myApp.getCustomSkinUrl() == a && myApp.changePreviewImage(this.src)
  7222. };
  7223. img.onerror = function() {
  7224. window.URL['revokeObjectURL'](b);
  7225. skinDownloadFail[a] = skinDownloadFail[a] ? skinDownloadFail[a] + 1 : 1;
  7226. console.log('Load image error')
  7227. };
  7228. img.src = b
  7229. }
  7230. }
  7231. };
  7232. $('#backgroundColor')['minicolors']({
  7233. defaultValue: getLocalStorage('backgroundColor') || '#000000',
  7234. change: function(va, vb) {
  7235. setLocalStorage('backgroundColor', va);
  7236. $('body')['css']('background-color', va);
  7237. //console.log('bgcol:' + va);
  7238. }
  7239. });
  7240. $('body')['css']('background-color', getLocalStorage('backgroundColor') || '#000000');
  7241. $('#borderColor')['minicolors']({
  7242. defaultValue: getLocalStorage('borderColor') || '#ffffff',
  7243. change: function(va, vb) {
  7244. setLocalStorage('borderColor', va)
  7245. }
  7246. });
  7247. $('#pelletColor')['minicolors']({
  7248. defaultValue: getLocalStorage('pelletColor') || '#0849d4',
  7249. change: function(va, vb) {
  7250. setLocalStorage('pelletColor', va);
  7251. $('.sender')['css']('color', va);
  7252. $('.toast_sender')['css']('color', va);
  7253. $('#div_lb .header')['css']('color', va)
  7254. }
  7255. });
  7256. $('.sender')['css']('color', getLocalStorage('pelletColor') || '#0849d4');
  7257. $('.toast_sender')['css']('color', getLocalStorage('pelletColor') || '#0849d4');
  7258. $('#div_lb .header')['css']('color', getLocalStorage('pelletColor') || '#0849d4');
  7259. }
  7260. initialize_misc();
  7261.  
  7262. //マウス操作補助機能のセットアップ, 400
  7263. function initialize_mouse_support() {
  7264. "use strict";
  7265.  
  7266. //デバッグ表示
  7267. function trace(s) {
  7268. console.log(s);
  7269. }
  7270.  
  7271. //右クリックによるコンテキストメニュー表示を抑止
  7272. function setup_prevent_contextmenu() {
  7273. $(document).on("contextmenu", function(event) {
  7274. event.preventDefault();
  7275. });
  7276. }
  7277.  
  7278. //仮想キーイベントを生成
  7279. function raise_virtual_key_event(char, is_press) {
  7280. var type = is_press ? "keydown" : "keyup";
  7281. var code = char.charCodeAt(0);
  7282. $("body").trigger($.Event(type, { keyCode: code }));
  7283. }
  7284.  
  7285. //仮想キーストロークを生成
  7286. function raise_virtual_key_stroke(char) {
  7287. raise_virtual_key_event(char, true);
  7288. raise_virtual_key_event(char, false);
  7289. }
  7290.  
  7291. //マウスによる操作
  7292. function setup_mouse_handlers() {
  7293. //マウスボタン定数
  7294. var MouseButtonLeft = 1;
  7295. var MouseButtonMiddle = 2;
  7296. var MouseButtonRight = 3;
  7297.  
  7298.  
  7299.  
  7300. //トリガ発行後、周期的に一定回数キーを連打するクラス
  7301. class FixedCountKeyRepeater {
  7302. constructor(target_key, interval_ms, num_fires) {
  7303. this.target_key = target_key;
  7304. this.interval_ms = interval_ms;
  7305. this.num_fires = num_fires;
  7306. }
  7307.  
  7308. trigger() {
  7309. var count = 0;
  7310. var self = this;
  7311. var ti = setInterval(function() {
  7312. raise_virtual_key_stroke(self.target_key);
  7313. if(++count >= self.num_fires) {
  7314. clearInterval(ti);
  7315. }
  7316. }, this.interval_ms);
  7317. }
  7318. }
  7319.  
  7320. //初回ディレイと周期を設定し、継続的にキーを連打するクラス
  7321. class SlowStartKeyRepeater {
  7322. constructor(target_key, first_delay_ms, interval_ms) {
  7323. this.target_key = target_key;
  7324. this.first_delay_ms = first_delay_ms;
  7325. this.interval_ms = interval_ms;
  7326.  
  7327. this.timer0 = null;
  7328. this.timer1 = null;
  7329. }
  7330.  
  7331. start() {
  7332. var self = this;
  7333. var fire = function() {
  7334. raise_virtual_key_stroke(self.target_key);
  7335. }
  7336.  
  7337. this.timer0 = setTimeout(function() {
  7338. self.timer1 = setInterval(fire, self.interval_ms);
  7339. }, this.first_delay_ms);
  7340. fire();
  7341. }
  7342.  
  7343. stop() {
  7344. if(this.timer0 !== null) {
  7345. clearTimeout(this.timer0);
  7346. this.timer0 = null;
  7347. }
  7348. if(this.timer1 !== null) {
  7349. clearInterval(this.timer1);
  7350. this.timer1 = null;
  7351. }
  7352. }
  7353. }
  7354.  
  7355. function is_overlays_visible() {
  7356. return $("#overlays").css("display") === "block";
  7357. }
  7358.  
  7359.  
  7360.  
  7361. //操作を行うボタンの割り当て
  7362. var btSplit = MouseButtonLeft;
  7363. var btFeed = MouseButtonRight;
  7364. var btQuickSplit = MouseButtonMiddle;
  7365. /*
  7366. if(SwapMouseButtonsLR) {
  7367. btSplit = MouseButtonRight;
  7368. btFeed = MouseButtonLeft;
  7369. }
  7370. */
  7371.  
  7372. //if(MouseSupportEnabled) {
  7373. //餌,キー連打機能インスタンス
  7374. var krFeeding = new SlowStartKeyRepeater('W', 250, 5); //キー,初期ディレイ[ms],周期[ms]
  7375.  
  7376. //16分裂,キー連打機能インスタンス
  7377. var krQuickSplit = new FixedCountKeyRepeater(' ', 30, 10); //キー,周期[ms],回数
  7378.  
  7379. var Feed_flg = 0;
  7380.  
  7381. $(document).mousedown(function(ev) {
  7382. if(is_overlays_visible()) return;
  7383.  
  7384. var enabled = myApp.isEnableMouseControl;
  7385. if(!enabled) return;
  7386.  
  7387. //ボタン割り当て更新
  7388. var swapLR = myApp.swapMouseButtonsLR;
  7389. btSplit = MouseButtonLeft;
  7390. btFeed = MouseButtonRight;
  7391. if(swapLR) {
  7392. btSplit = MouseButtonRight;
  7393. btFeed = MouseButtonLeft;
  7394. }
  7395.  
  7396. var bt = ev.which;
  7397. if(bt == btSplit) {
  7398. //分裂
  7399. raise_virtual_key_stroke(" ");
  7400. } else if(bt == btFeed) {
  7401. //餌
  7402. if(!Feed_flg) {
  7403. krFeeding.start();
  7404. Feed_flg = 1;
  7405. }
  7406. //ev.preventDefault();
  7407. var selection = window.getSelection();
  7408. selection.collapse(document.body, 0);
  7409.  
  7410. } else if(bt == btQuickSplit) {
  7411. //16分裂
  7412. //krQuickSplit.trigger();
  7413. window.quickSpace();
  7414. }
  7415.  
  7416. /*
  7417. if(bt == MouseButtonRight) {
  7418. //右クリック時に,チャット表示がon/offするのを常に表示で固定
  7419. $("#chatbox, #chatroom").css("display", "block");
  7420. }*/
  7421. });
  7422.  
  7423. $(document).mouseup(function(ev) {
  7424. var bt = ev.which;
  7425. if(bt == btFeed) {
  7426. krFeeding.stop();
  7427. Feed_flg = 0;
  7428. }
  7429. ev.preventDefault();
  7430. });
  7431.  
  7432. $(document).on("dragend", function(e) {
  7433. krFeeding.stop();
  7434. });
  7435.  
  7436. $(document).on("dragstart", function(e) {
  7437. setTimeout(function() {
  7438. var selection = window.getSelection();
  7439. selection.collapse(document.body, 0);
  7440. }, 10);
  7441. });
  7442. //}
  7443. }
  7444.  
  7445. //画面中心にクロスヘアを表示
  7446. function setup_center_crosshair() {
  7447. //ゲーム画面の描画が乱れるバグがあるため現在未使用
  7448.  
  7449. var update_crosshair_canvas = function() {
  7450. var canvas = $("#frontCanvas").get(0);
  7451. canvas.width = window.innerWidth;
  7452. canvas.height = window.innerHeight;
  7453.  
  7454. var ctx = canvas.getContext('2d');
  7455. var cx = canvas.width / 2;
  7456. var cy = canvas.height / 2;
  7457. var d = 100;
  7458. ctx.strokeStyle = "#888";
  7459. ctx.beginPath();
  7460. ctx.moveTo(cx, cy - d);
  7461. ctx.lineTo(cx, cy + d);
  7462. ctx.moveTo(cx - d, cy);
  7463. ctx.lineTo(cx + d, cy);
  7464. ctx.closePath();
  7465. ctx.stroke();
  7466. };
  7467.  
  7468. if(ShowCenterCrosshair) {
  7469. $("body").append('<canvas id="frontCanvas" style="zposition: absolute; z-index:222; top : 0; pointer-events:none"/>');
  7470. $("#frontCanvas").css("-webkit-user-select", "none");
  7471.  
  7472. window.onresize = update_crosshair_canvas;
  7473. update_crosshair_canvas();
  7474. }
  7475. }
  7476.  
  7477. //チャットボックスを左上に小さく表示
  7478. function update_chatbox_leftsmall() {
  7479. //function update_chatroom_view() {
  7480. var croom = $("#chatroom");
  7481. croom.css("display", "block");
  7482. croom.css("width", "150px");
  7483. croom.css("height", "150px");
  7484. croom.css("top", "50px");
  7485. croom.css("left", "15px");
  7486. //var span = $("#chatroom span");
  7487. //span.css("font-size", "12px");
  7488. //}
  7489.  
  7490. //update_chatroom_view();
  7491. //window.onresize = update_chatroom_view;
  7492. //setInterval(update_chatroom_view, 1000);
  7493. }
  7494.  
  7495. //チャットボックスを下に横長に表示
  7496. function update_chatbox_bottom_horizontal() {
  7497.  
  7498. //var croom = $("#chatbox, #chatroom");
  7499. //croom.css("width", "750px");
  7500. //croom.css("height", "100px");
  7501. //function update_chatroom_view() {
  7502. var cr_width = 750;
  7503. var cr_height = 100;
  7504. var chatroom = $("#chatbox, #chatroom");
  7505. chatroom.css("width", cr_width + "px");
  7506. chatroom.css("height", cr_height + "px");
  7507. chatroom.css("display", "block");
  7508. chatroom.css("min-height", "10px");
  7509. chatroom.css("left", (window.innerWidth - cr_width) / 2);
  7510. chatroom.css("top", window.innerHeight - cr_height - 25);
  7511.  
  7512. //var span = $("#chatroom span");
  7513. //span.css("font-size", "12px");
  7514. //}
  7515. //window.onresize = update_chatroom_view;
  7516. //update_chatroom_view();
  7517. //setInterval(update_chatroom_view, 100);
  7518. }
  7519.  
  7520. //チャットボックスの表示を調整
  7521. function setup_chatbox_customized() {
  7522. /*
  7523. if(ChatDisplayMode === "Normal") {
  7524.  
  7525. } else if(ChatDisplayMode === "LeftSmall") {
  7526. setup_chatbox_leftsmall();
  7527. } else if(ChatDisplayMode === "BottomHorizontal") {
  7528. setup_chatbox_bottom_horizontal();
  7529. }
  7530. */
  7531.  
  7532. //myApp.showChatAtBottom = false;
  7533. var isBottom = myApp.showChatAtBottom;
  7534.  
  7535. function arrange_chatroom_view() {
  7536. if(isBottom) {
  7537. update_chatbox_bottom_horizontal();
  7538. } else {
  7539. update_chatbox_leftsmall();
  7540. }
  7541. }
  7542.  
  7543. setInterval(function() {
  7544. if(myApp.showChatAtBottom !== isBottom) {
  7545. isBottom = myApp.showChatAtBottom;
  7546. arrange_chatroom_view();
  7547. }
  7548. }, 100);
  7549.  
  7550. $(window).resize(function() {
  7551. arrange_chatroom_view();
  7552. //trace("resized");
  7553. });
  7554. arrange_chatroom_view();
  7555. }
  7556.  
  7557. //ダブルクリック時のマップの選択を抑止
  7558. function setup_disable_user_select() {
  7559. setInterval(function() {
  7560. $("#minimap, #minimapNode").css("-webkit-user-select", "none");
  7561. }, 1000);
  7562. }
  7563.  
  7564. //プライベートサーバーに接続
  7565. function connect_to_private_server() {
  7566. //setNickA();
  7567. //var uri = modifyUrlForLocalhostConnection(gGameServerAddress);
  7568. //connect(uri);
  7569. connect(gGameServerAddress);
  7570. }
  7571.  
  7572. //キーボードによる操作
  7573. function setup_key_handlers() {
  7574. $(document).on('keydown', function(e) {
  7575. var keyTab = 9;
  7576. var keyF9 = 120;
  7577. //var keyF2 = 113;
  7578. var keyF4 = 115;
  7579. //var keyF7 = 118;
  7580. if(e.keyCode === keyF9) {
  7581. //プライベートサーバーに接続
  7582. //連打はやめましょう
  7583. if(gIsPlaying) {
  7584. myApp.onDead();
  7585. }
  7586. disconnect();
  7587. setTimeout(() => {
  7588. //setTimeout(() => {
  7589. $("#overlays").show();
  7590. connect_to_private_server();
  7591. //}, 500);
  7592. }, 3000);
  7593. }
  7594.  
  7595. // if(e.keyCode == keyF4) {
  7596. // var fb = new DataFrameWriter();
  7597. // fb.writeUint8(32);
  7598. // conn2.sendWebSocketData(fb.getArrayBuffer());
  7599. // }
  7600.  
  7601. if(e.keyCode == keyTab) {
  7602. var fb = new DataFrameWriter();
  7603. fb.writeUint8(22);
  7604. conn2.sendWebSocketData(fb.getArrayBuffer());
  7605. e.preventDefault();
  7606. return false;
  7607. }
  7608. });
  7609. }
  7610.  
  7611. //メインパネル,プロファイルパネルの調整
  7612. function setup_panel_customize() {
  7613. //パーティートークン生成ボタンをプライベートサーバー接続ボタンに変更
  7614. //{
  7615. // $(".createParty").remove();
  7616. // $(".agarioProfilePanel").append("<button id='btConnect'></button>");
  7617. // var bt = $("#btConnect");
  7618. // bt.addClass("btn btn-primary");
  7619. // bt.css("margin-bottom", "5px");
  7620. // bt.css("font-family", "メイリオ");
  7621. // bt.css("letter-spacing", "0px");
  7622. // bt.css("height", "35px");
  7623. // bt.text("プライベートサーバーに接続");
  7624. // bt.on("click", function() {
  7625. // connect_to_private_server();
  7626. // });
  7627. //}
  7628.  
  7629.  
  7630. //$(".createParty").remove();
  7631. //$(".btConnect").remove();
  7632.  
  7633. //$(".agarioProfilePanel").css("padding-bottom", "45px");
  7634.  
  7635. //リージョンを非選択にする
  7636. //$("#gamemode").val(":party");
  7637.  
  7638. //サーバ,ゲームモードの選択セレクタを削除
  7639. //$("#region").remove();
  7640. //$("#gamemode").remove();
  7641.  
  7642. //Joinボタンを削除
  7643. //$(".joinParty").remove();
  7644.  
  7645. //画面真ん中の広告を削除
  7646. //$(".adsbygoogle").remove();
  7647.  
  7648. //コードを入力
  7649. //$(".partyToken").val(FixedPartyCode);
  7650. //$(".btn-login").remove();
  7651.  
  7652. //$(".btn-spectate").css("width", "100%");
  7653. }
  7654.  
  7655.  
  7656. //スキンがプレビュー表示されない問題の対策
  7657. function setup_skin_preview_fix() {
  7658. //オリジンがAgar.ioä»¥å¤–ã®å ´åˆã«å•é¡ŒãŒãŠã“ã‚‹(?)
  7659. //XMLHttpRequestを使わず、直接URL指定で表示するように調整
  7660.  
  7661. function update_skin_preview() {
  7662. var ref_img = localStorage.getItem("skin_url");
  7663. var img = $("#preview-img")[0];
  7664. if(img.src !== ref_img) {
  7665. img.src = ref_img;
  7666. }
  7667. }
  7668.  
  7669. function update_skin_preview2() {
  7670. var ref_img2 = localStorage.getItem("skin_url2");
  7671. var img2 = $("#preview-img2")[0];
  7672. if(img2.src !== ref_img2) {
  7673. img2.src = ref_img2;
  7674. }
  7675. }
  7676.  
  7677. //$(window).bind("storage", function(e) {
  7678. // trace(e.originalEvent.key, e.originalEvent.newValue);
  7679. // update_skin_preview();
  7680. // //console.log(e.)
  7681. //});
  7682.  
  7683. //setInterval(function() {
  7684. // update_skin_preview();
  7685. //}, 200);
  7686.  
  7687. //$("#profile-pic div.nav2").on("click", function() {
  7688. // update_skin_preview();
  7689. //});
  7690.  
  7691. $("#skin_url").on("change", function() {
  7692. update_skin_preview();
  7693. });
  7694.  
  7695. $("#skin_url2").on("change", function() {
  7696. update_skin_preview2();
  7697. });
  7698. update_skin_preview();
  7699. update_skin_preview2();
  7700. }
  7701.  
  7702. //function setup_remote_console() {
  7703. // function openRemoteConsoleWindow() {
  7704. // //trace('open remote console');
  7705. // window.GameServerAddress = modifyUrlForLocalhostConnection(GameServerAddress);
  7706. // window.open('remote_console.html', 'remote console', 'width=600, height=600, menubar=no, toolbar=no, scrollbars=no');
  7707. // }
  7708. // $(window).on('keydown', function(e) {
  7709. // var key = e.keyCode;
  7710. // var kF10 = 121;
  7711. // //var kEnter = 13;
  7712. // if(e.shiftKey && key == kF10 && RemoteConsoleEnabled) {
  7713. // openRemoteConsoleWindow();
  7714. // }
  7715. // });
  7716. //}
  7717.  
  7718. function setup_players_count_view() {
  7719. /*
  7720. function XMLHttpRequestCreate(){
  7721. try{
  7722. return new XMLHttpRequest();
  7723. }catch(e){}
  7724. try{
  7725. return new ActiveXObject('MSXML2.XMLHTTP.6.0');
  7726. }catch(e){}
  7727. try{
  7728. return new ActiveXObject('MSXML2.XMLHTTP.3.0');
  7729. }catch(e){}
  7730. try{
  7731. return new ActiveXObject('MSXML2.XMLHTTP');
  7732. }catch(e){}
  7733.  
  7734. return null;
  7735. }
  7736. var xhr = XMLHttpRequestCreate();
  7737. xhr.onreadystatechange = function (){
  7738.  
  7739. switch(xhr.readyState){
  7740. case 4:
  7741. if(xhr.status != 0){
  7742. if((200 <= xhr.status && xhr.status < 300) || (xhr.status == 304)){
  7743. var Data = JSON.parse(xhr.responseText);
  7744. document.getElementById('pinfo')['innerHTML'] = "<center>"+Data.current_players + "/" + Data.max_players + " (play=" + Data.alive + " + spec=" + Data.spectators + ") " + "</center>";
  7745. }
  7746. }
  7747. break;
  7748. }
  7749. };
  7750.  
  7751. setInterval(function(){
  7752. var uri = modifyUrlForLocalhostConnection(StatusServerAddress);
  7753. xhr.open('POST', uri);
  7754. /*
  7755. if( window.location.search == "?localhost=1" ){
  7756. var port = Status_Server.split(":",2)[1];
  7757. xhr.open("POST" ,"http://localhost:" + port);
  7758. }else{
  7759. xhr.open("POST" ,"http://" + Status_Server);
  7760. }
  7761.  
  7762. xhr.send();
  7763. }, 3000);
  7764. */
  7765.  
  7766. conn2.setStatsListenerProc(function(s) {
  7767. var text = `<center> ${s.clients} / ${s.max_clients} (play:${s.players}, spec:${s.spectators}), bot:${s.bots} </center>`;
  7768. //document.getElementById('pinfo')['innerHTML'] = "<center>"+s.current_players + "/" + s.max_players + " (play=" + s.alive + " + spec=" + s.spectators + ") " + "</center>";
  7769. $('#pinfo').html(text);
  7770. });
  7771. }
  7772.  
  7773.  
  7774. //trace("agar.io mouse support tool, v1_160512_A127");
  7775. setup_prevent_contextmenu();
  7776. setup_mouse_handlers();
  7777. setup_key_handlers();
  7778. setup_disable_user_select();
  7779.  
  7780. setup_chatbox_customized();
  7781.  
  7782. //setup_center_crosshair();
  7783. setup_panel_customize();
  7784. //connect_to_private_server();
  7785.  
  7786. setup_skin_preview_fix();
  7787.  
  7788. //document.title = WebPageTitle;
  7789.  
  7790. //setup_remote_console();
  7791. setup_players_count_view();
  7792. }
  7793. initialize_mouse_support();
  7794.  
  7795.  
  7796. function initialize_team_buttons() {
  7797. var bt0 = $('#btTeam1');
  7798. var bt1 = $('#btTeam2');
  7799.  
  7800. function activateDuelTeamButton(idx) {
  7801. if(idx == 0) {
  7802. bt0.addClass('active');
  7803. bt1.removeClass('active');
  7804. } else {
  7805. bt1.addClass('active');
  7806. bt0.removeClass('active');
  7807. }
  7808. gDuelTeamInputIndex = idx;
  7809. //setNickB();
  7810. }
  7811.  
  7812. bt0.on('click', function(e) {
  7813. activateDuelTeamButton(0);
  7814. return false;
  7815. });
  7816.  
  7817. bt1.on('click', function(e) {
  7818. activateDuelTeamButton(1);
  7819. return false;
  7820. });
  7821.  
  7822. var rr = Math.random();
  7823. var idx = rr < 0.5 ? 0 : 1;
  7824. activateDuelTeamButton(idx);
  7825. //setTimeout(setNickB, 500);
  7826. //setNickB();
  7827. }
  7828.  
  7829.  
  7830.  
  7831.  
  7832. gConfigChangedHandlerProc = () => {
  7833.  
  7834. $('#lb_caption').html(gconfig.leaderboardCaption);
  7835. $('#lb_caption2').html(gconfig.teamRankingCaption);
  7836.  
  7837. var uiNickContainer = $('#nickContainer');
  7838. var uiTeamNameContainer = $('#teamNameContainer');
  7839.  
  7840. var uiDivTeamText = $('#divTeamText');
  7841. var uiDivTeamButtons = $('#divTeamButtons');
  7842. var uiDivTeamCombo = $('#divTeamCombo');
  7843.  
  7844. //var uiTeamName = $('team_name');
  7845. //var uiBtTeam1 = $('btTeam1');
  7846. //var uiBtTeam2 = $('btTeam2');
  7847.  
  7848. var teamUiType = gconfig.teamInputUiType;
  7849.  
  7850. if(teamUiType == 'none') {
  7851. uiTeamNameContainer.hide();
  7852. uiNickContainer.css('width', '100%');
  7853. uiNickContainer.css('float', 'left');
  7854. } else {
  7855. uiTeamNameContainer.show();
  7856. uiNickContainer.css('width', '69%');
  7857. uiNickContainer.css('float', 'right');
  7858. }
  7859.  
  7860. if(teamUiType == 'text') {
  7861. uiDivTeamText.show();
  7862. uiDivTeamButtons.hide();
  7863. uiDivTeamCombo.hide();
  7864. } else if(teamUiType == 'duel') {
  7865. uiDivTeamText.hide();
  7866. uiDivTeamButtons.show();
  7867. uiDivTeamCombo.hide();
  7868.  
  7869. var teams = gconfig.duelTeamEntries.split(',');
  7870. $('#btTeam1').html((teams[0] || '-').replace(/[【】]/g, ''));
  7871. $('#btTeam2').html((teams[1] || '-').replace(/[【】]/g, ''));
  7872. } else if(teamUiType == 'combo') {
  7873. uiDivTeamText.hide();
  7874. uiDivTeamButtons.hide();
  7875. uiDivTeamCombo.show();
  7876.  
  7877. var teams = gconfig.comboTeamEntries.split(',');
  7878. $('#team_combo_box > option').remove();
  7879. for(var team of teams) {
  7880. $('#team_combo_box').append($('<option>').html(team).val(team));
  7881. }
  7882. var refVal = localStorage.getItem('teamComboBoxVal');
  7883. if(teams.indexOf(refVal) == -1) {
  7884. refVal = teams[0];
  7885. }
  7886. $('#team_combo_box').val(refVal);
  7887. }
  7888.  
  7889. if(gconfig.enablePartyCode) {
  7890. $('.partyToken').show();
  7891. } else {
  7892. $('.partyToken').hide();
  7893. $(".partyToken").val("");
  7894. }
  7895.  
  7896. if(gconfig.enableTeamRankingBoard) {
  7897. $('#div_lb2').show();
  7898. } else {
  7899. $('#div_lb2').hide();
  7900. }
  7901.  
  7902. if(gconfig.enableDualSkinInput) {
  7903. $('#preview-img-area2').show();
  7904. $('#skin_url2').show();
  7905. // $('#opt_active_turn_marker').show();
  7906. } else {
  7907. $('#preview-img-area2').hide();
  7908. $('#skin_url2').hide();
  7909. // $('#opt_active_turn_marker').hide();
  7910. }
  7911.  
  7912. if(gconfig.showServerDebugStatusTexts) {
  7913. $("#server_debug_status_texts_box").show();
  7914. } else {
  7915. $("#server_debug_status_texts_box").hide();
  7916. }
  7917.  
  7918. if(gconfig.useExtendedChatSystem || gconfig_ex.ForceChatIconShow){
  7919. $("#ex_chat_icon").show();
  7920. $("#ex_chat_badge").css('opacity', 1);
  7921. }else{
  7922. $("#ex_chat_icon").hide();
  7923. $("#ex_chat_badge").css('opacity', 0);
  7924. }
  7925.  
  7926. if(GamePresetConfig.EnableTeamRankingChart){
  7927. $("#lb_canvas_chart").show();
  7928. }else{
  7929. $("#lb_canvas_chart").hide();
  7930. }
  7931.  
  7932. window.clearNickEntryCash();
  7933. window.setNickB();
  7934. }
  7935.  
  7936.  
  7937. //if(gconfig.teamInputUiType == 'duel'){
  7938. initialize_team_buttons();
  7939. //}
  7940.  
  7941. // if(ShowExternalServerLinks){
  7942. // $('#ex_server_links').show();
  7943. // }
  7944.  
  7945. //setTimeout(() =>{
  7946. // window.clearNickEntryCash();
  7947. // window.setNickB();
  7948. // console.log('name set');
  7949. //}, 2000);
  7950.  
  7951. function adjustTexts() {
  7952. $('#theme_bg_color').text(gtexts.tmBackground);
  7953. $('#theme_border_color').text(gtexts.tmBorder);
  7954. $('#theme_pellet_color').text(gtexts.tmPellet);
  7955.  
  7956. $('#tab_home').html(gtexts.tabHome);
  7957. $('#tab_settings').html(gtexts.tabSettings);
  7958. $('#tab_theme').html(gtexts.tabTemes);
  7959. $('#tab_hotkeys').html(gtexts.tabKeybinds);
  7960. $('#tab_extended').html(gtexts.tabExtended);
  7961.  
  7962. $('.btn-play').text(gtexts.btPlay);
  7963. $('.btn-spectate').text(gtexts.btSpectate);
  7964.  
  7965. $('#full_list_link').html(gtexts.lnkServerFullList);
  7966. $('#server_program').html(gtexts.lnkServerProgram);
  7967. $('#link_user_form').html(gtexts.lnkUserForum);
  7968. var sz = (glang == 'en') ? '13px' : '14px';
  7969. $('.nav-tabs > li > a').css('font-size', sz);
  7970. }
  7971. adjustTexts();
  7972.  
  7973. function setupLatencyChecker() {
  7974. setIntervalEx(() => {
  7975. if(!gIsConnected) return;
  7976. var startTime = new Date();
  7977. conn2.checkLatencyAsync(() => {
  7978. var endTime = new Date();
  7979. var dur = Math.floor(endTime - startTime);
  7980. //console.log();
  7981. $('#latency_box').html(`latency: ${dur} ms`);
  7982. });
  7983. }, 1000);
  7984. }
  7985. setupLatencyChecker();
  7986.  
  7987. //SetupConnection();
  7988.  
  7989. }
Add Comment
Please, Sign In to add comment