WoTExtendedStat

Adds some usable fields for MMO game World of Tanks user's page

当前为 2016-07-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @author Elf__X
  3. // @name WoTExtendedStat
  4. // @namespace http://forum.worldoftanks.ru/index.php?/topic/717208-
  5. // @version 0.9.15.4
  6. // @description Adds some usable fields for MMO game World of Tanks user's page
  7. // @match http://worldoftanks.ru/*/accounts/*
  8. // @match http://worldoftanks.eu/*/accounts/*
  9. // @match http://worldoftanks.com/*/accounts/*
  10. // @match http://worldoftanks.asia/*/accounts/*
  11. // @match http://worldoftanks.kr/*/accounts/*
  12. // @include http://worldoftanks.ru/*/accounts/*
  13. // @include http://worldoftanks.eu/*/accounts/*
  14. // @include http://worldoftanks.com/*/accounts/*
  15. // @include http://worldoftanks.asia/*/accounts/*
  16. // @include http://worldoftanks.kr/*/accounts/*
  17. // @connect wnefficiency.net
  18. // @connect armor.kiev.ua
  19. // @connect noobmeter.com
  20. // @connect wot-noobs.ru
  21. // @connect elf.on.ufanet.ru
  22. // @connect worldoftanks.ru
  23. // @connect worldoftanks.eu
  24. // @connect worldoftanks.com
  25. // @connect worldoftanks.asia
  26. // @connect worldoftanks.kr
  27. // @grant GM_xmlhttpRequest
  28. // ==/UserScript==
  29. var lang,
  30. scriptVersion = '0.9.15.4',
  31. tanksarr = [],
  32. gServ, api_key;
  33.  
  34. if (document.location.host.indexOf(".ru") !== -1) {
  35. api_key = "895d3dafdd87af03e1e515befcd83882";
  36. gServ = "ru";
  37. } else if (document.location.host.indexOf(".eu") !== -1) {
  38. api_key = "d0a293dc77667c9328783d489c8cef73";
  39. gServ = "eu";
  40. } else if (document.location.host.indexOf(".com") !== -1) {
  41. api_key = "16924c431c705523aae25b6f638c54dd";
  42. gServ = "com";
  43. }
  44.  
  45. var rangD = ['Виртуоз (>99%)', 'Мастер-танкист (>95%)',
  46. 'Танкист 1-го класса (>80%)', 'Танкист 2-го класса (>60%)',
  47. 'Танкист 3-го класса (>45%)', 'Оленевод 3-го класса (>30%)',
  48. 'Оленевод 2-го класса (>20%)', 'Оленевод 1-го класса (>10%)',
  49. 'Мастер-оленевод (>10%)'],
  50. rangDE = ['>99%', '>95%', '>80%', '>60%', '>45%', '>30%', '>20%',
  51. '>10%', '>10%'],
  52. rangA = ['cv', 'cm', 'c1', 'c2', 'c3', 'd3', 'd2', 'd1', 'dm'];
  53.  
  54. /* Requires _opera-xdr-engine.js to handle script-based requests in Opera*/
  55. var xdr = {
  56. reqId: 0,
  57. req: {},
  58. prepareUrl: function (url) {
  59. return url;
  60. },
  61. xget: function (url, onDone) {
  62. url = this.prepareUrl(url);
  63. if (window.opera && window.opera.defineMagicVariable) {
  64. this.scriptTransport(url, onDone);
  65. } else if (/Chrome/.test(navigator.userAgent) && chrome && chrome.extension) {
  66. this.xhrTransport(url, onDone);
  67. } else if (GM_xmlhttpRequest) {
  68. this.GMTransport(url, onDone);
  69. } else {
  70. var currentReqId = this.reqId++;
  71. this.req[currentReqId].handleJSONP = onDone;
  72.  
  73. this.JSONPTransport(url, "xdr.req[" + currentReqId
  74. + "].handleJSONP");
  75. }
  76. },
  77. scriptTransport: function (url, onDone) {
  78. var t = document.createElement("script");
  79. t.src = url;
  80. t._callback = onDone;
  81. document.body.appendChild(t);
  82. },
  83. xhrTransport: function (url, onDone) {
  84. var req = new XMLHttpRequest();
  85. req.open("GET", url, true);
  86. req.onreadystatechange = function () {
  87. if (req.readyState == 4) {
  88. if (req.status == 200) {
  89. onDone(req.responseText);
  90. }
  91. }
  92. };
  93. req.send();
  94. },
  95. GMTransport: function (url, onDone) {
  96. setTimeout(function () {
  97. GM_xmlhttpRequest({
  98. method: "GET",
  99. url: url,
  100. onload: function (x) {
  101. var o = x.responseText;
  102. if (onDone) {
  103. onDone(o);
  104. }
  105. }
  106. });
  107. }, 0);
  108.  
  109. },
  110. JSONPTransport: function (url, callbackName) {
  111. if (callbackName && typeof callbackName === "string") {
  112. url += "&callback=" + callbackName;
  113. }
  114. var t = document.createElement("script");
  115. t.src = url;
  116. document.body.appendChild(t);
  117. }
  118. };
  119.  
  120.  
  121. if (document.title.indexOf("Профиль игрока") > -1)
  122. lang = "ru";
  123. if (window.location.host.indexOf("worldoftanks") > -1
  124. && window.location.href.indexOf("accounts") > -1) {
  125. var scr = localStorage.getItem("flot");
  126. if (scr) {
  127. addScript(scr);
  128. } else {
  129. xdr.xget("http://www.flotcharts.org/flot/jquery.flot.js", addScript);
  130. }
  131. }
  132.  
  133. function addScript(response) {
  134. var script = document.createElement("script");
  135. script.type = "text/javascript";
  136. script.textContent = response;
  137. document.body.appendChild(script);
  138. if (!localStorage.getItem("flot"))
  139. localStorage.setItem("flot", response);
  140. var scr = localStorage.getItem("flot_time");
  141. if (scr) {
  142. addScript2(scr);
  143. } else {
  144. xdr.xget("http://www.flotcharts.org/flot/jquery.flot.time.js",
  145. addScript2);
  146. }
  147. }
  148.  
  149. function addScript2(response) {
  150. var script = document.createElement("script");
  151. script.type = "text/javascript";
  152. script.textContent = response;
  153. document.body.appendChild(script);
  154. if (!localStorage.getItem("flot_time"))
  155. localStorage.setItem("flot_time", response);
  156. main();
  157. }
  158.  
  159. function main() {
  160. var UserId = window.location.href.match(/\/(\d+)/)[1];
  161. var uskeys = [];
  162. for (var key in localStorage) {
  163. if (key.indexOf('daystat') !== -1) {
  164. var uskey = key.split('_')[1];
  165. if (uskeys.indexOf(uskey) === -1)
  166. uskeys.push(uskey);
  167. }
  168. }
  169. var d1 = document.createElement("div");
  170. d1.setAttribute('id', "dialog-overlay");
  171. document.body.appendChild(d1);
  172. var d2 = document.createElement("div");
  173. d2.setAttribute('id', "dialog-box");
  174. d2.setAttribute('style', "position: fixed; top: 40%; left: 40%; z-index: 100000;");
  175. d2.innerHTML = '<div class="dialog-content"><div id="dialog-message"></div><a href="#" class="button">Close</a></div>';
  176. document.body.appendChild(d2);
  177. var dtext =
  178. '<style>'
  179. + ' #dialog-overlay { /* set it to fill the whil screen */ width:100%; height:100%; /* transparency for different browsers */ filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity: 0.5; background:#000; /* make sure it appear behind the dialog box but above everything else */ position:absolute; top:0; left:0; z-index:3000; /* hide it by default */ display:none;}'
  180. + ' #dialog-box { /* css3 drop shadow */ -webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); -moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); /* css3 border radius */ -moz-border-radius: 5px; -webkit-border-radius: 5px; background:#eee; /* styling of the dialog box, i have a fixed dimension for this demo */ width:328px; /* make sure it has the highest z-index */ position:absolute; z-index:5000; /* hide it by default */ display:none;}'
  181. + ' #dialog-box .dialog-content { /* style the content */ text-align:left; padding:10px; margin:13px; color:#666; font-family:arial; font-size:11px; }'
  182. + ' a.button { /* styles for button */ margin:10px auto 0 auto; text-align:center; background-color: #e33100; display: block; width:50px; padding: 5px 10px 6px; color: #fff; text-decoration: none; font-weight: bold; line-height: 1; /* css3 implementation :) */ -moz-border-radius: 5px; -webkit-border-radius: 5px; -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.5); -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.5); text-shadow: 0 -1px 1px rgba(0,0,0,0.25); border-bottom: 1px solid rgba(0,0,0,0.25); position: relative; cursor: pointer; }'
  183. + ' a.button:hover { background-color: #c33100; }'
  184. + '/* extra styling */'
  185. + '#dialog-box .dialog-content p { font-weight:700; margin:0;}'
  186. + '#dialog-box .dialog-content ul { margin:10px 0 10px 20px; padding:0; height:50px;}'
  187. + '#us-set-table td{border: 1px dashed; text-align: center; padding: 3px;}'
  188. + '#us-set-table {width: 100%;}'
  189. + '#us-set-table th {color: white;}'
  190. + '</style>'
  191. + '<div id="us-settings-block" class="ui-dialog ui-draggable no-jquery-buttons" tabindex="-1" style="display:none; z-index: 1004; top: 10%; left: 30%; position: absolute;">' +
  192. '<div class="ui-dialog-titlebar ui-widget-header ui-corner-all" tabindex="-1"><span class="ui-dialog-title">' + (lang === "ru" ? "Настройки скрипта расширенной статистики" : "Extended statistic script settings ") + '</span>'
  193. + '<a href="#" class="ui-dialog-titlebar-close ui-corner-all us-close-settings" tabindex="-1"><span class="ui-icon ui-icon-closethick">close</span></a></div>' +
  194. '<div class="ui-dialog-content ui-widget-content" style="display: block; width: auto; height: auto;"><div class="js-dialog-content b-dialog-content"><div class="h-popup-content" style="background: rgb(31, 31, 31);">'
  195. + '<div style="border: 1px solid; border-radius: 10px; -webkit-border-radius: 10px; padding: 5px;"><h5 style="text-align: center; margin: 0; color: #f25322;">' + (lang === "ru" ? "Настройки блоков" : "Block settings") + '</h5><br><table id="us-set-table"><thead><tr><th width="60%">' + (lang === "ru" ? 'Блок' : 'Block') + '</th><th width="20%">' + (lang === "ru" ? 'Свернуть' : 'Collapse') + '</th><th width="20%">' + (lang === "ru" ? 'Удалить' : 'Remove') + '</th></tr></thead><tbody>'
  196. + '<tr class="us-set-block" btype="newBat" cur-pos="0"><td>' + (lang === "ru" ? 'Новые бои' : 'New battles') + '<div style="width: 30px; height: 12px; overflow:hidden; top: 4px; margin: auto; position: relative; float: right;"><a class="b-vertical-arrow settings-row b-vertical-arrow__open" style="visibility:hidden;" href="#"><span class="b-fake-link">&nbsp;</span></a><a class="b-vertical-arrow settings-row" href="#">&nbsp;</a></div></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>'
  197. + '<tr class="us-set-block" btype="efRat" cur-pos="1"><td>' + (lang === "ru" ? 'Рейтинги эффективности' : 'Eff. ratings') + '<div style="width: 30px; height: 12px; overflow:hidden; top: 4px; margin: auto; position: relative; float: right;"><a class="b-vertical-arrow settings-row b-vertical-arrow__open" href="#"><span class="b-fake-link">&nbsp;</span></a><a class="b-vertical-arrow settings-row" href="#">&nbsp;</a></div></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>'
  198. + '<tr class="us-set-block" btype="plComp" cur-pos="2"><td>' + (lang === "ru" ? 'Сравнение игроков' : 'Players compare') + '<div style="width: 30px; height: 12px; overflow:hidden; top: 4px; margin: auto; position: relative; float: right;"><a class="b-vertical-arrow settings-row b-vertical-arrow__open" href="#"><span class="b-fake-link">&nbsp;</span></a><a class="b-vertical-arrow settings-row" href="#">&nbsp;</a></div></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>'
  199. + '<tr class="us-set-block" btype="pers" cur-pos="3"><td>' + (lang === "ru" ? 'Личные данные' : 'Personal') + '<div style="width: 30px; height: 12px; overflow:hidden; top: 4px; margin: auto; position: relative; float: right;"><a class="b-vertical-arrow settings-row b-vertical-arrow__open" href="#"><span class="b-fake-link">&nbsp;</span></a><a class="b-vertical-arrow settings-row" href="#">&nbsp;</a></div></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>'
  200. + '<tr class="us-set-block" btype="speed" cur-pos="4"><td>' + (lang === "ru" ? 'Спидометры' : 'speedometers') + '<div style="width: 30px; height: 12px; overflow:hidden; top: 4px; margin: auto; position: relative; float: right;"><a class="b-vertical-arrow settings-row b-vertical-arrow__open" href="#"><span class="b-fake-link">&nbsp;</span></a><a class="b-vertical-arrow settings-row" href="#">&nbsp;</a></div></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>'
  201. + '<tr class="us-set-block" btype="fame" cur-pos="5"><td>' + (lang === "ru" ? 'Аллея славы' : 'Hall of fame') + '<div style="width: 30px; height: 12px; overflow:hidden; top: 4px; margin: auto; position: relative; float: right;"><a class="b-vertical-arrow settings-row b-vertical-arrow__open" href="#"><span class="b-fake-link">&nbsp;</span></a><a class="b-vertical-arrow settings-row" href="#">&nbsp;</a></div></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>'
  202. + '<tr class="us-set-block" btype="achiev" cur-pos="6"><td>' + (lang === "ru" ? 'Достижения' : 'Achievements') + '<div style="width: 30px; height: 12px; overflow:hidden; top: 4px; margin: auto; position: relative; float: right;"><a class="b-vertical-arrow settings-row b-vertical-arrow__open" href="#"><span class="b-fake-link">&nbsp;</span></a><a class="b-vertical-arrow settings-row" href="#">&nbsp;</a></div></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>'
  203. + '<tr class="us-set-block" btype="common" cur-pos="7"><td>' + (lang === "ru" ? 'Общее' : 'Common') + '<div style="width: 30px; height: 12px; overflow:hidden; top: 4px; margin: auto; position: relative; float: right;"><a class="b-vertical-arrow settings-row b-vertical-arrow__open" href="#"><span class="b-fake-link">&nbsp;</span></a><a class="b-vertical-arrow settings-row" href="#">&nbsp;</a></div></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>'
  204. + '<tr class="us-set-block" btype="diagr" cur-pos="8"><td>' + (lang === "ru" ? 'Диаграммы' : 'diargams') + '<div style="width: 30px; height: 12px; overflow:hidden; top: 4px; margin: auto; position: relative; float: right;"><a class="b-vertical-arrow settings-row b-vertical-arrow__open" href="#"><span class="b-fake-link">&nbsp;</span></a><a class="b-vertical-arrow settings-row" href="#">&nbsp;</a></div></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>'
  205. + '<tr class="us-set-block" btype="rat" cur-pos="9"><td>' + (lang === "ru" ? 'Рейтинги' : 'Ratings') + '<div style="width: 30px; height: 12px; overflow:hidden; top: 4px; margin: auto; position: relative; float: right;"><a class="b-vertical-arrow settings-row b-vertical-arrow__open" href="#"><span class="b-fake-link">&nbsp;</span></a><a class="b-vertical-arrow settings-row" href="#">&nbsp;</a></div></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>'
  206. + '<tr class="us-set-block" btype="veh" cur-pos="10"><td>' + (lang === "ru" ? 'Техника' : 'Vehicles') + '<div style="width: 30px; height: 12px; overflow:hidden; top: 4px; margin: auto; position: relative; float: right;"><a class="b-vertical-arrow settings-row b-vertical-arrow__open" href="#"><span class="b-fake-link">&nbsp;</span></a><a class="b-vertical-arrow settings-row" style="visibility:hidden;" href="#">&nbsp;</a></div></td><td><input type="checkbox"></td><td><input type="checkbox"></td></tr>'
  207. + '</tbody></table></div>'
  208. + '<div style="border: 1px solid; border-radius: 10px; -webkit-border-radius: 10px; padding: 5px; margin-top: 5px;">'
  209. + '<h5 style="text-align: center; margin: 0; color: #f25322;">'
  210. + (lang === "ru" ? 'Графики' : 'Graphs') + '</h5><br>'
  211. + '<label for="all" style="padding-left: 20px;">' + (lang === "ru" ? 'Все' : 'All') + '</label><input type="radio" name="gtype" id="all" value="all" checked/>'
  212. + '<label for="date" style="padding-left: 20px;">' + (lang === "ru" ? 'Дата' : 'Date') + '</label><input type="radio" name="gtype" id="date" value="date" />'
  213. + '<label for="bat" style="padding-left: 20px;">' + (lang === "ru" ? 'Бои' : 'Battles') + '</label><input type="radio" name="gtype" id="bat" value="bat" />'
  214. + '<label for="no" style="padding-left: 20px;">' + (lang === "ru" ? 'Не отображать' : 'Dont show') + '</label><input type="radio" name="gtype" id="no" value="no" />'
  215. + '</div>'
  216. + '<div style="border: 1px solid; border-radius: 10px; -webkit-border-radius: 10px; padding: 5px; margin-top: 5px;overflow-y: auto;width: 98%;"><h5 style="text-align: center; margin: 0; color: #f25322;">' + 'Названия ссылок' + '</h5><br><table>';
  217. for (var i = 0; i < uskeys.length; i++) {
  218. dtext += '<tr id="ustr' + uskeys[i] + '"><td><label for="us' + uskeys[i] + '" style="padding-left: 20px;"><a href="http://worldoftanks.ru/community/accounts/' + uskeys[i] + '/">Игрок ' + uskeys[i] + '</a></label></td><td><input style="margin-left: 45px;margin-bottom: 5px;width: 135%;" type="text" id="us' + uskeys[i] + '" uid="' + uskeys[i] + '" name="us' + uskeys[i] + '" class="us_st_name" value="Игрок ' + uskeys[i] + '" /></td></tr>';
  219. }
  220. dtext +=
  221. '</table></div>' +
  222. '<div style="border: 1px solid; border-radius: 10px; -webkit-border-radius: 10px; padding: 5px; margin-top: 5px;"><h5 style="text-align: center; margin: 0; color: #f25322;">' + (lang === "ru" ? 'Сравнение игроков' : 'Players compare') + '</h5><br><input type="checkbox" id="us-settings-compare">' + (lang === "ru" ? 'Сравнивать других игроков с "моими" данными' : 'Compare any players with "my" stat.') + '<br><br><div id="us-my-compare-block" style="display: none;">' + (lang === "ru" ? 'Адрес моей страницы' : 'Address of my page') + ': ' +
  223. '<input type="text" style="width: 100%;" id="us-settings-compare-page"><br><input type="checkbox" id="us-settings-current-page">' + (lang === "ru" ? 'Текущая страница' : 'Current page') + '</div></div>' +
  224. '</div><fieldset class="g-nopadding"><div class="b-popupbotton"><span class="b-button b-button__colored"><span class="b-button_right b-button-wrap"><input type="button" value="' + (lang === "ru" ? 'Сохранить' : 'Save') + '" tabindex="1003" id="us-settings-save">' +
  225. '</span></span><div class="b-cancel"><a href="#" class="us-close-settings" tabindex="1004">' + (lang === "ru" ? 'Отмена' : 'Cancel') + '</a></div></div></fieldset></div></div></div><div id="us-settings-overlay" class="ui-widget-overlay" style="display:none; width: 5000px; height: 20000px; min-height: 2000px; z-index: 1003;"></div>';
  226. fake_div = document.createElement("div");
  227. fake_div.innerHTML = dtext;
  228. document.getElementsByClassName("page-wrapper")[0].appendChild(fake_div);
  229. var avtemp = CalcAvgLev(tanksarr),
  230. AllAvgLev = avtemp[0], tnaSum = avtemp[1], expDmg = avtemp[2], expSpot = avtemp[3], expFrag = avtemp[4], expDef = avtemp[5], expWinRate = avtemp[6], expB = avtemp[7]
  231. wn8 = 0, own8 = 0, nwn8 = 0,
  232. WGRating = GetBattleStat(1),
  233. OldWGRating = WGRating,
  234. AllWins = GetBattleStat(4),
  235. AllDamag = GetBattleStat(7),
  236. AllFrags = GetBattleStat(9),
  237. AllSpotted = GetBattleStat(10),
  238. AllCaps = GetBattleStat(6),
  239. AllDefs = GetBattleStat(8),
  240. AllXp = GetBattleStat(11),
  241. AllBattles = GetBattleStat(5),
  242. AllGold = document.getElementsByClassName("currency-gold")[0],
  243. AllCredit = document.getElementsByClassName("currency-credit")[0],
  244. AllExp = document.getElementsByClassName("currency-experience")[0],
  245. playerNick = document.getElementById("js-profile-name").innerHTML,
  246. daypassed = (new Date() - new Date(document.getElementsByClassName("js-date-format")[0].getAttribute("data-timestamp") * 1000)) / 1000 / 60 / 60 / 24,
  247. timeDiv = document.getElementsByClassName("b-profile-name")[0],
  248. dayArray = [],
  249. comparedayArray = [],
  250. blockArray = [],
  251. statTooltip = '',
  252. clanDiv = document.getElementsByClassName("b-profile-clan")[0],
  253. oxeff = 0,
  254. oxwn = 0;
  255. var rDAMAGE = AllDamag / AllBattles * expB/ expDmg,
  256. rSPOT = AllSpotted / AllBattles * expB/ expSpot,
  257. rFRAG = AllFrags / AllBattles * expB/ expFrag,
  258. rDEF = AllDefs / AllBattles * expB/ expDef,
  259. rWIN = AllWins / AllBattles * expB / expWinRate,
  260. rWINc = Math.max(0, (rWIN - 0.71) / (1 - 0.71)),
  261. rDAMAGEc = Math.max(0, (rDAMAGE - 0.22) / (1 - 0.22)),
  262. rFRAGc = Math.max(0, Math.min(rDAMAGEc + 0.2, (rFRAG - 0.12) / (1 - 0.12))),
  263. rSPOTc = Math.max(0, Math.min(rDAMAGEc + 0.1, (rSPOT - 0.38) / (1 - 0.38))),
  264. rDEFc = Math.max(0, Math.min(rDAMAGEc + 0.1, (rDEF - 0.10) / (1 - 0.10)));
  265. wn8 = 980 * rDAMAGEc + 210 * rDAMAGEc * rFRAGc + 155 * rFRAGc * rSPOTc + 75 * rDEFc * rFRAGc + 145 * Math.min(1.8, rWINc);
  266. setup_script(toFl);
  267. setup_script(WriteStat);
  268. setup_script(setCookie);
  269. setup_script(getCookie);
  270. setup_script(SetLSData);
  271. setup_script(GetLSData);
  272. setup_script(GetBattleStat);
  273. setup_script(WriteCompareStat);
  274. setup_script(CalcEffColor);
  275. setup_script(FormatUsSetTable);
  276.  
  277. if (window.location.href.indexOf('#USCompareStat') !== -1)
  278. SaveCompareStatData();
  279.  
  280. var updateVer = GetLSData('UsUpdateVer1');
  281. if (!updateVer) {
  282. localStorage.removeItem('WN8Data');
  283. SetLSData('UsUpdateVer1', 1, '01-Jan-2031 00:00:00 GMT');
  284. window.location.reload();
  285. }
  286. var alltanks = GetLSData("AllTanksArr");
  287. if (alltanks) {
  288. xdr.xget("http://api." + document.location.host + "/wot/account/tanks/?application_id=" + api_key + "&account_id=" + UserId, fixStatData);
  289. } else {
  290. xdr.xget("http://api." + document.location.host + "/wot/encyclopedia/tanks/?application_id=" + api_key, saveTanksArr);
  291. }
  292.  
  293. document.getElementById("js-profile-name").setAttribute('style', "max-width: 100%;");
  294. var stats = document.getElementsByClassName("b-statistic_item");
  295. for (i = 0; i < stats.length; i++)
  296. stats[i].setAttribute('style', "max-width: 100%;");
  297. document.getElementsByClassName("b-userblock-wrpr")[0].style.margin = '0';
  298.  
  299. if (!clanDiv) {
  300. clanDiv = document.getElementsByClassName("b-profile-noclan")[0];
  301. } else {
  302. document.getElementsByClassName("b-statistic_item")[0].setAttribute('style', "max-width: 100%;");
  303. }
  304. if (!clanDiv)
  305. clanDiv = timeDiv;
  306. clanDiv.setAttribute('style', "width: 50%; max-width: 100%;");
  307.  
  308. timeDiv.setAttribute('style', "width: 30%; max-width: 100%;");
  309. fake_div = document.createElement("div");
  310. fake_div.innerHTML = "<p>" + (lang === "ru" ? "Версия <a href='http://forum.worldoftanks.ru/index.php?/topic/717208-'>скрипта</a> " : " <a href='http://forum.worldoftanks.ru/index.php?/topic/717208-'>Script</a> version ")
  311. + scriptVersion + " <br>"
  312. + "</p>"
  313. + "<p><a href='#' id='us-settings-a'>" + (lang === "ru" ? "Настройки скрипта" : "Script settings") + "</a></p>"
  314. + "<style>"
  315. + ".spoiler span.close,"
  316. + ".spoiler span.open{"
  317. + " padding-left:22px;"
  318. + " color: #F25322 !important;"
  319. + " border-bottom: 1px dashed #F25322;"
  320. + "}"
  321. + ".spoiler blockquote,"
  322. + ".spoiler{"
  323. + " padding:0.5em;"
  324. + " border-radius:15px;"
  325. + " -webkit-border-radius:15px;"
  326. + " -khtml-border-radius:15px;"
  327. + " -moz-border-radius:15px;"
  328. + " -o-border-radius:15px;"
  329. + " -ms-border-radius:15px;"
  330. + "}"
  331. + ".spoiler {"
  332. + " overflow-x:hidden;"
  333. + " overflow-y:hidden;"
  334. + " box-shadow: 0px 1px 8px #F2534A;"
  335. + " border:#f25322 solid 1px;"
  336. + " -webkit-box-shadow:0px 1px 8px #F2534A;"
  337. + " -khtml-box-shadow:0px 3px 8px #F2534A;"
  338. + " -moz-box-shadow:0px 1px 8px #F2534A;"
  339. + " -ms-box-shadow:0px 1px 8px #F2534A;"
  340. + "}"
  341. + ".spoiler blockquote {"
  342. + " margin-top:12px;"
  343. + " min-height: 23px;"
  344. + " border:#CDCDCD 2px dashed;"
  345. + "}"
  346. + " </style>"
  347. + '<div class="spoiler" style="border: #f25322 dashed 1px; margin-bottom: 10px;">'
  348. + ' <div class="box" style="text-align: center;">'
  349. + ' <a href="#" id="autor-pay" class="b-vertical-arrow">'
  350. + ' <span class="b-fake-link">' + (lang === "ru" ? 'Поддержать автора скрипта' : 'Please, give some money to support the author') + '</span>'
  351. + ' </a>'
  352. + ' <blockquote class="Untext" style="display:none">'
  353. + ' <span style="color: green;">WebMoney:</span>'
  354. + ' <br>WMR: R135164502303'
  355. + ' <br>WMZ: Z127526962810'
  356. + ' <br>WME: E419926987074<br><br>'
  357. + ' <span style="color: green;">Yandex:</span>'
  358. + ' <br>41001870448136<br>'
  359. + ' </blockquote>'
  360. + (lang === "ru" ? '<blockquote class="Untext" style="display:none">'
  361. + ' <span style="color: green;">Рассказать друзьям:</span><br><br>'
  362. + ' <a onclick="window.open(\'http://vkontakte.ru/share.php?url=http://userscripts.org/scripts/show/169225&title=Расширенная статистика на сайте http://worldoftanks.ru&description=Скрипт добавляет расширенную статистику(рейтинги, статистика по сохраненным данным и т.д.) на сайт worldoftanks&image=http://wiki.worldoftanks.ru/uploads/thumb/3/30/Wot_logo_metal.png/223px-Wot_logo_metal.png\', \'vkontakte\', \'width=626, height=436\'); return false;" rel="nofollow" href="http://vkontakte.ru/share.php?url=http://userscripts.org/scripts/show/169225">'
  363. + ' <img src="http://vk.com/images/vk32.png" width="32" height="32" title="Поделиться с друзьями ВКонтакте">'
  364. + ' </a>'
  365. + ' </blockquote>' : '')
  366. + "</div></div>";
  367. timeDiv.appendChild(fake_div);
  368.  
  369. // TODO Придумать новый способ проверки обновления
  370. //var sVersion = getCookie("usScriptVer");
  371. //if (!sVersion) xdr.xget("http://userscripts.org/scripts/show/169225", getNewScriptVersion); else if (sVersion !== scriptVersion)
  372. //{
  373. // var fake_div2 = document.createElement("div");
  374. // fake_div2.setAttribute('style', "color: red;font-size: 7pt;padding: 5px;border-radius: 15px;border: 2px solid yellow;");
  375. // fake_div2.innerHTML = "<strong>Вышла новая версия скрипта " + sVersion + ".<br>Пожалуйста, обновите скрипт.</strong>";
  376. // timeDiv.appendChild(fake_div2);
  377. //}
  378.  
  379. var server = document.location.host.match(/\.([^\.]+)$/)[1].toUpperCase();
  380. server = server === "COM" ? "NAm" : server;
  381. var fake_div = document.createElement("div");
  382. if (lang === "ru") {
  383. fake_div.innerHTML = "<p><a class='b-orange-arrow' href='http://worldofclans.ru/player/index.html?id=" + UserId + "'>История кланов</a></p>";
  384. } else {
  385. fake_div.innerHTML = "<p><a class='b-orange-arrow' href='http://td82.ru/wotka?nickname=" + playerNick + "&server=" + server + "'>"
  386. + ((lang === "ru") ? "История кланов" : "Clan history") + "</a></p>";
  387. }
  388. clanDiv.appendChild(fake_div);
  389.  
  390. var effres = CalcEff(0, AllAvgLev, AllBattles, AllWins, AllDamag, AllFrags, AllSpotted, AllCaps, AllDefs, AllXp);
  391.  
  392. var UsSettings = GetLSData("usSettings"),
  393. settings = new Object();
  394.  
  395. if (!UsSettings) {
  396. UsSettings = getCookie("usSettings");
  397. if (UsSettings) {
  398. SetLSData('usSettings', UsSettings, '01-Jan-2031 00:00:00 GMT');
  399. }
  400. }
  401. if (UsSettings) {
  402. var setArr = UsSettings.split("|"),
  403. blSetArr = setArr[0].split("/");
  404. for (var i = 0; i < blSetArr.length; i++) {
  405. var bsVals = blSetArr[i].split(';');
  406. if (toFl(bsVals[1]) === 1)
  407. document.querySelector('[btype="' + bsVals[0] + '"]').cells[1].getElementsByTagName('input')[0].checked = true;
  408. if (toFl(bsVals[2]) === 1)
  409. document.querySelector('[btype="' + bsVals[0] + '"]').cells[2].getElementsByTagName('input')[0].checked = true;
  410. if (toFl(bsVals[3]) === 0)
  411. document.querySelector('[btype="' + bsVals[0] + '"]').cells[0].getElementsByTagName('div')[0].getElementsByTagName('a')[0].setAttribute('style', 'visibility:hidden;');
  412. if (toFl(bsVals[3]) === 10)
  413. document.querySelector('[btype="' + bsVals[0] + '"]').cells[0].getElementsByTagName('div')[0].getElementsByTagName('a')[1].setAttribute('style', 'visibility:hidden;');
  414. if (bsVals[3])
  415. document.querySelector('[btype="' + bsVals[0] + '"]').setAttribute('cur-pos', bsVals[3]);
  416. settings[bsVals[0]] = [bsVals[1], bsVals[2], bsVals[3]];
  417. }
  418. FormatUsSetTable();
  419. bsVals = setArr[1].split(';');
  420. settings.compare = toFl(bsVals[0]);
  421. if (settings.compare === 1) {
  422. document.getElementById('us-settings-compare').checked = true;
  423. document.getElementById('us-my-compare-block').style.display = "block";
  424. }
  425. settings.compareAdr = bsVals[1];
  426. document.getElementById('us-settings-compare-page').value = settings.compareAdr;
  427. var suid = settings.compareAdr.match(/\/(\d+)/);
  428. settings.UserID = settings.compare && suid ? suid[1] : false;
  429. //if (settings.UserID && document.getElementById("ustr" + settings.UserID))
  430. // document.getElementById("ustr" + settings.UserID).style.display = "none";
  431. if (setArr.length > 2) {
  432. settings.gtype = setArr[2];
  433. } else {
  434. settings.gtype = "all";
  435. }
  436. if (setArr.length > 3) {
  437. var us_strs = setArr[3].split("/");
  438. for (i = 0; i < us_strs.length; i++) {
  439. var us_vals = us_strs[i].split(";");
  440. if (us_vals.length > 1 && document.getElementById('us' + us_vals[0])) {
  441. settings[us_vals[0]] = us_vals[1];
  442. document.getElementById('us' + us_vals[0]).value = us_vals[1];
  443. }
  444. }
  445. }
  446. document.getElementById(settings.gtype).click();
  447. }
  448.  
  449. daystat = GetStat();
  450.  
  451. if (daystat) {
  452. var dsArr = daystat.split("|"),
  453. strArray = dsArr[0].split("/"),
  454. str = strArray[0].split(";"),
  455. oldMedals = [],
  456. timeStat = new Date(str[0]),
  457. olddaypassed = (timeStat - new Date(document.getElementsByClassName("js-date-format")[0].getAttribute("data-timestamp") * 1000)) / 1000 / 60 / 60 / 24;
  458.  
  459. if (timeStat.toLocaleFormat)
  460. var oldTime = timeStat.toLocaleFormat("%d.%m.%Y %H:%M");
  461. else
  462. oldTime = timeStat.toLocaleString().substr(0, timeStat.toLocaleString().lastIndexOf(":"));
  463.  
  464. var statText = '<span style="font-weight: bold; color: white;">' + (lang === "ru" ? 'Статистика c ' + oldTime : 'Stat. from ' + oldTime) + '</span><br>';
  465.  
  466. if (dsArr.length > 3) {
  467. OldWGRating = toFl(dsArr[3]);
  468. }
  469.  
  470. if (dsArr.length > 1) {
  471. var MedArr = dsArr[1].split("/");
  472. for (var i = 0; i < MedArr.length; i++) {
  473. var MedStr = MedArr[i].split(";");
  474. oldMedals[MedStr[0]] = toFl(MedStr[1]);
  475. }
  476. }
  477.  
  478. if (str.length > 3) {
  479. var OldBattles = toFl(str[12]),
  480. NewBattles = AllBattles - OldBattles,
  481. OldWins = toFl(str[10]),
  482. NewWins = AllWins - OldWins,
  483. OldXp = toFl(str[24]),
  484. NewXp = AllXp - OldXp,
  485. OldDamag = toFl(str[16]),
  486. NewDamag = AllDamag - OldDamag,
  487. OldFrags = toFl(str[20]),
  488. NewFrags = AllFrags - OldFrags,
  489. OldSpotted = toFl(str[22]),
  490. NewSpotted = AllSpotted - OldSpotted,
  491. OldCaps = toFl(str[14]),
  492. NewCaps = AllCaps - OldCaps,
  493. OldDefs = toFl(str[18]),
  494. NewDefs = AllDefs - OldDefs,
  495. OldGold = toFl(str[1]),
  496. OldCredit = toFl(str[2]),
  497. OldExp = toFl(str[3]);
  498. }
  499. if (AllGold) {
  500. var NewGold = toFl(AllGold.innerHTML) - OldGold;
  501. if (NewGold) {
  502. AllGold.innerHTML = AllGold.innerHTML + " (" + (NewGold > 0 ? "+" + NewGold : NewGold) + ")";
  503. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Золото: ' : 'Gold: ') + '</div><span class="currency-gold" style="float:right">' + (NewGold > 0 ? "+" + NewGold : NewGold) + "</span><br>";
  504. }
  505. }
  506. if (AllCredit) {
  507. var NewCredit = toFl(AllCredit.innerHTML) - OldCredit;
  508. if (NewCredit) {
  509. AllCredit.innerHTML = AllCredit.innerHTML + " (" + (NewCredit > 0 ? "+" + NewCredit : NewCredit) + ")";
  510. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Кредиты: ' : 'Credits: ') + '</div><span class="currency-credit" style="float:right">' + (NewCredit > 0 ? "+" + NewCredit : NewCredit) + "</span><br>";
  511. }
  512. }
  513. if (AllExp) {
  514. var NewExp = toFl(AllExp.innerHTML) - OldExp;
  515. if (NewExp) {
  516. AllExp.innerHTML = AllExp.innerHTML + " (" + (NewExp > 0 ? "+" + NewExp : NewExp) + ")";
  517. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Свободный опыт: ' : 'Free experience: ') + '</div><span class="currency-experience" style="float:right">' + (NewExp > 0 ? "+" + NewExp : NewExp) + "</span><br>";
  518. }
  519. }
  520. for (var i = 1; i < strArray.length; i++) {
  521. str = strArray[i].split(";");
  522. var tName = str[0].toLowerCase();
  523. dayArray[tName] = new Object();
  524. dayArray[tName].b = toFl(str[1]);
  525. dayArray[tName].w = str.length > 3 ? str[3] : -1;
  526. }
  527. var cav = CalcOldAvgLev(dayArray, tanksarr),
  528. OldAvgLev = cav[0],
  529. NewAvgLev = cav[1],
  530. OldtnaSum = cav[2],
  531. expDmg = cav[3], expSpot = cav[4], expFrag = cav[5], expDef = cav[6], expWinRate = cav[7], expB = cav[8],
  532. neffs = CalcEff(1, NewAvgLev, NewBattles, NewWins, NewDamag, NewFrags, NewSpotted, NewCaps, NewDefs, NewXp),
  533. oeffs = CalcEff(0, OldAvgLev, OldBattles, OldWins, OldDamag, OldFrags, OldSpotted, OldCaps, OldDefs, OldXp);
  534. var rDAMAGE = OldDamag / expDmg,
  535. rSPOT = OldSpotted / expSpot,
  536. rFRAG = OldFrags / expFrag,
  537. rDEF = OldDefs / expDef,
  538. rWIN = OldWins / expWinRate,
  539. rWINc = Math.max(0, (rWIN - 0.71) / (1 - 0.71)),
  540. rDAMAGEc = Math.max(0, (rDAMAGE - 0.22) / (1 - 0.22)),
  541. rFRAGc = Math.max(0, Math.min(rDAMAGEc + 0.2, (rFRAG - 0.12) / (1 - 0.12))),
  542. rSPOTc = Math.max(0, Math.min(rDAMAGEc + 0.1, (rSPOT - 0.38) / (1 - 0.38))),
  543. rDEFc = Math.max(0, Math.min(rDAMAGEc + 0.1, (rDEF - 0.10) / (1 - 0.10)));
  544. own8 = 980 * rDAMAGEc + 210 * rDAMAGEc * rFRAGc + 155 * rFRAGc * rSPOTc + 75 * rDEFc * rFRAGc + 145 * Math.min(1.8, rWINc);
  545. var expDmg = (avtemp[2] - cav[3]),
  546. expSpot = (avtemp[3] - cav[4]),
  547. expFrag = (avtemp[4] - cav[5]),
  548. expDef = (avtemp[5] - cav[6]),
  549. expWinRate = (avtemp[6] - cav[7]);
  550. var rDAMAGE = NewDamag / OldBattles * expB / expDmg,
  551. rSPOT = NewSpotted / OldBattles * expB / expSpot,
  552. rFRAG = NewFrags / OldBattles * expB / expFrag,
  553. rDEF = NewDefs / OldBattles * expB / expDef,
  554. rWIN = NewWins / OldBattles * expB / expWinRate,
  555. rWINc = Math.max(0, (rWIN - 0.71) / (1 - 0.71)),
  556. rDAMAGEc = Math.max(0, (rDAMAGE - 0.22) / (1 - 0.22)),
  557. rFRAGc = Math.max(0, Math.min(rDAMAGEc + 0.2, (rFRAG - 0.12) / (1 - 0.12))),
  558. rSPOTc = Math.max(0, Math.min(rDAMAGEc + 0.1, (rSPOT - 0.38) / (1 - 0.38))),
  559. rDEFc = Math.max(0, Math.min(rDAMAGEc + 0.1, (rDEF - 0.10) / (1 - 0.10)));
  560. nwn8 = 980 * rDAMAGEc + 210 * rDAMAGEc * rFRAGc + 155 * rFRAGc * rSPOTc + 75 * rDEFc * rFRAGc + 145 * Math.min(1.8, rWINc);
  561. var oPR = (500 * (OldWins / OldBattles) / 0.4856) + (1000 * OldDamag / (OldtnaSum * 0.975));
  562. var clearedFromPenalties1 = 1500,
  563. expectedMinBattles1 = 500,
  564. expectedMinAvgTier1 = 6,
  565. clearedFromPenalties2 = 1900,
  566. expectedMinBattles2 = 2000,
  567. expectedMinAvgTier2 = 7;
  568. if (oPR > clearedFromPenalties1)
  569. oPR = oPR - (oPR - clearedFromPenalties1) * Math.pow(Math.max(0, 1 - (OldAvgLev / expectedMinAvgTier1), 1 - (OldBattles / expectedMinBattles1)), 0.5);
  570. if (oPR > clearedFromPenalties2)
  571. oPR = oPR - (oPR - clearedFromPenalties2) * Math.pow(Math.max(0, 1 - (OldAvgLev / expectedMinAvgTier2), 1 - (OldBattles / expectedMinBattles2)), 0.5);
  572.  
  573. var oXPR = GetXRating(oPR, "pr"),
  574. oxeff = GetXRating(effres[0], "effres"),
  575. oxwn = GetXRating(effres[2], "wn6"),
  576. xown8 = GetXRating(own8, "wn8");
  577. }
  578.  
  579. xdr.xget("http://api." + document.location.host + "/2.0/account/info/?application_id=" + api_key + "&account_id=" + UserId, batCompanyClan);
  580.  
  581. //<-Блок Новые бои
  582. if (NewBattles) {
  583. var NBtresulttable = document.getElementsByClassName("b-user-block")[0],
  584. NBmainDiv = document.createElement('div'),
  585. NBsDiv = document.createElement('div'),
  586. NBsDivH3 = document.createElement('h3'),
  587. NBMedalsA = document.createElement('div'),
  588. NBMedalsDiv = document.createElement("div"),
  589. NBMedalsDivUl = document.createElement("ul"),
  590. NBthDiv = document.createElement('div'),
  591. NBretbodytrtd1table = document.createElement('table'),
  592. NBretbodytrtd2table = document.createElement('table'),
  593. NBretbodytrtd3table = document.createElement('table'),
  594. NBretbodytrtd1tabletbody = document.createElement('tbody'),
  595. NBretbodytrtd2tabletbody = document.createElement('tbody'),
  596. NBretbodytrtd3tabletbody = document.createElement('tbody'),
  597. NBh31 = document.createElement('h3'),
  598. NBh32 = document.createElement('h3'),
  599. NBh33 = document.createElement('h3'),
  600. NBdiv1 = document.createElement('div'),
  601. NBdiv2 = document.createElement('div'),
  602. NBdiv3 = document.createElement('div'),
  603. spDiv1 = document.createElement('div'),
  604. spA1 = document.createElement('a'),
  605. spSp1 = document.createElement('span');
  606.  
  607. document.getElementsByClassName("b-userblock-wrpr")[0].insertBefore(NBmainDiv, NBtresulttable);
  608. NBmainDiv.className = "b-user-block b-user-block-new-battles";
  609. NBsDiv.className = "b-head-block";
  610. NBsDivH3.innerHTML = lang === "ru" ? "Новые бои" : "New battles";
  611. NBthDiv.setAttribute('class', "b-user-info clearfix");
  612.  
  613. NBh31.innerHTML = lang === "ru" ? "Новые" : "New";
  614. NBh32.innerHTML = lang === "ru" ? "Сохр. данные" : "Saved";
  615. NBh32.setAttribute('style', 'float: right;');
  616. NBh33.innerHTML = lang === "ru" ? "Тек. данные" : "Current";
  617. NBh33.setAttribute('style', 'float: right;');
  618.  
  619. NBretbodytrtd1table.setAttribute('class', 't-dotted');
  620. NBretbodytrtd1table.appendChild(NBretbodytrtd1tabletbody);
  621. NBretbodytrtd2table.setAttribute('class', 't-dotted');
  622. NBretbodytrtd2table.appendChild(NBretbodytrtd2tabletbody);
  623. NBretbodytrtd3table.setAttribute('class', 't-dotted');
  624. NBretbodytrtd3table.appendChild(NBretbodytrtd3tabletbody);
  625.  
  626. NBdiv1.setAttribute('style', 'float: left; width: 45%; margin-left: 25px;');
  627. NBdiv2.setAttribute('style', 'float: left; width: 24%;');
  628. NBdiv3.setAttribute('style', 'float: left; width: 24%;');
  629.  
  630. NBMedalsA.setAttribute('style', 'padding-left: 27px; padding-top: 10px;');
  631. NBMedalsDiv.setAttribute('style', 'padding-left: 20px; display: none;');
  632. NBMedalsA.innerHTML = '<a class="b-vertical-arrow us-show-medals" href="#"><span class="b-fake-link">' + (lang === "ru" ? "Медали" : "Medals") + '</span></a>';
  633.  
  634. NBdiv1.appendChild(NBh31);
  635. NBdiv1.appendChild(NBretbodytrtd1table);
  636. NBdiv2.appendChild(NBh32);
  637. NBdiv2.appendChild(NBretbodytrtd2table);
  638. NBdiv3.appendChild(NBh33);
  639. NBdiv3.appendChild(NBretbodytrtd3table);
  640. NBsDiv.appendChild(NBsDivH3);
  641. NBmainDiv.appendChild(NBsDiv);
  642. NBMedalsDiv.appendChild(NBMedalsDivUl);
  643. NBmainDiv.appendChild(NBMedalsA);
  644. NBmainDiv.appendChild(NBMedalsDiv);
  645. NBthDiv.appendChild(NBdiv1);
  646. NBthDiv.appendChild(NBdiv2);
  647. NBthDiv.appendChild(NBdiv3);
  648. NBmainDiv.appendChild(NBthDiv);
  649.  
  650. var hrIn = statTooltip.length === 0;
  651.  
  652. var medals = document.querySelector('[data-bind="visible: isAllAchievementsVisible()"]').getElementsByClassName("b-achivements_item");
  653. for (i = 0; i < medals.length; i++) {
  654. if ((" " + medals[i].className + " ").replace(/[\n\t]/g, " ").indexOf(" b-achivements_item__empty ") === -1) {
  655. var count = medals[i].getElementsByTagName('div')[0];
  656. if (count) {
  657. count = count.getElementsByTagName('span')[0];
  658. if (count) {
  659. count = count.getElementsByTagName('span')[0];
  660. if (count)
  661. count = toFl(count.innerHTML);
  662. else
  663. count = 1;
  664. } else {
  665. count = 1;
  666. }
  667. } else {
  668. count = 1;
  669. }
  670. var oldMCount = oldMedals[medals[i].id.split("-")[2]];
  671. if (!oldMCount)
  672. oldMCount = 0;
  673. if (count !== oldMCount) {
  674. var node = medals[i].cloneNode(true),
  675. node2 = document.getElementById("js-achivement-" + medals[i].id.split("-")[2] + "_tooltip").cloneNode(true);
  676. node.className = "js-tooltip";
  677. node.id = "nb-achivement-" + medals[i].id.split("-")[2];
  678. node2.id = "nb-achivement-" + medals[i].id.split("-")[2] + "_tooltip";
  679. node.setAttribute("style", "float: left; margin: 27px 10px 0 0; position: relative;");
  680. if (count !== 1)
  681. node.getElementsByTagName('div')[0].getElementsByTagName('span')[0].getElementsByTagName('span')[0].innerHTML = (count - oldMCount);
  682. NBMedalsDivUl.appendChild(node);
  683. NBMedalsDivUl.appendChild(node2);
  684. if (!hrIn && statTooltip.length !== 0) {
  685. statTooltip += '<hr>';
  686. hrIn = true;
  687. }
  688. statTooltip += "<div style='float:left'>" + node2.getElementsByTagName('p')[0].innerHTML + ':</div><span style="float:right">+' + (count - oldMCount) + "</span><br>";
  689. }
  690. }
  691. }
  692.  
  693. hrIn = statTooltip.length === 0;
  694.  
  695. insertNewTr(NBretbodytrtd1tabletbody, (lang === "ru") ? "Боев|Побед (%Побед)" : "Battles|Wins (%Wins):", (NewBattles) + "|" + (NewWins) + " (" + col(NewWins / NewBattles * 100, 2) + ")", "", "Nbw1");
  696. statText += "<br><div style='float:left;'>" + (lang === "ru" ? "Боев: " : "Battles: ") + NewBattles + "</div><div style='float:right;'>" + (lang === "ru" ? "Побед: " : "Wins: ") + NewWins + " (" + col(NewWins / NewBattles * 100, 2) + ")</div>";
  697. if ((AllWins / AllBattles * 100 - OldWins / OldBattles * 100).toFixed(2) * 1 !== 0) {
  698. if (!hrIn && statTooltip.length !== 0) {
  699. statTooltip += '<hr>';
  700. hrIn = true;
  701. }
  702. statTooltip += "<div style='float:left'>" + (lang === "ru" ? '% побед: ' : 'Win %: ') + "</div><div style='float:right'>" + (AllWins / AllBattles * 100 - OldWins / OldBattles * 100 > 0 ? "<font color='green'>+" + (AllWins / AllBattles * 100 - OldWins / OldBattles * 100).toFixed(2) : "<font color='red'>" + (AllWins / AllBattles * 100 - OldWins / OldBattles * 100).toFixed(2)) + "</font></div><br>";
  703. }
  704. var deltaWin = (NewWins / NewBattles * 100 - OldWins / OldBattles * 100).toFixed(2);
  705. insertNewTr(NBretbodytrtd2tabletbody, "", col(OldWins / OldBattles * 100, 2) + (deltaWin * 1 !== 0 ? (deltaWin > 0) ? "<font color='green'> (+" + deltaWin + "%)</font>" : "<font color='red'> (" + deltaWin + "%)</font>" : ""), "", "Nbw2");
  706. deltaWin = (AllWins / AllBattles * 100 - OldWins / OldBattles * 100).toFixed(2);
  707. insertNewTr(NBretbodytrtd3tabletbody, "", col(AllWins / AllBattles * 100, 2) + (deltaWin * 1 !== 0 ? (deltaWin > 0) ? "<font color='green'> (+" + deltaWin + "%)</font>" : "<font color='red'> (" + deltaWin + "%)</font>" : ""), "", "Nbw3");
  708.  
  709. insertNewTr(NBretbodytrtd1tabletbody, (lang === "ru") ? "Опыт за бой" : "Exp per battle", (NewXp / NewBattles).toFixed(2), "", "Nbe1");
  710. if ((AllXp / AllBattles - OldXp / OldBattles).toFixed(2) * 1 !== 0) {
  711. if (!hrIn && statTooltip.length !== 0) {
  712. statTooltip += '<hr>';
  713. hrIn = true;
  714. }
  715. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Опыт за бой: ' : 'Exp per battle: ') + "</div><div style='float:right'>" + (AllXp / AllBattles - OldXp / OldBattles > 0 ? "<font color='green'>+" + (AllXp / AllBattles - OldXp / OldBattles).toFixed(2) : "<font color='red'>" + (AllXp / AllBattles - OldXp / OldBattles).toFixed(2)) + "</font></div><br>";
  716. }
  717. var deltaExp = ((NewXp / NewBattles).toFixed(2) - (OldXp / OldBattles).toFixed(2)).toFixed(2);
  718. insertNewTr(NBretbodytrtd2tabletbody, "", (OldXp / OldBattles).toFixed(2) + (deltaExp * 1 !== 0 ? (deltaExp > 0) ? "<font color='green'> (+" + deltaExp + ")</font>" : "<font color='red'> (" + deltaExp + ")</font>" : ""), "", "Nbe2");
  719. deltaExp = ((AllXp / AllBattles).toFixed(2) - (OldXp / OldBattles).toFixed(2)).toFixed(2);
  720. insertNewTr(NBretbodytrtd3tabletbody, "", (AllXp / AllBattles).toFixed(2) + (deltaExp * 1 !== 0 ? (deltaExp > 0) ? "<font color='green'> (+" + deltaExp + ")</font>" : "<font color='red'> (" + deltaExp + ")</font>" : ""), "", "Nbe3");
  721.  
  722. insertNewTr(NBretbodytrtd1tabletbody, (lang === "ru") ? "Средний уровень танков" : "Average level of tanks", NewAvgLev.toFixed(2), "", "Nbav1");
  723. if ((AllAvgLev.toFixed(2) - OldAvgLev.toFixed(2)).toFixed(2) * 1 !== 0) {
  724. if (!hrIn && statTooltip.length !== 0) {
  725. statTooltip += '<hr>';
  726. hrIn = true;
  727. }
  728. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Средний уровень танков: ' : 'Average level of tanks: ') + "</div><div style='float:right'>" + (AllAvgLev.toFixed(2) - OldAvgLev.toFixed(2) > 0 ? "<font color='green'>+" + (AllAvgLev.toFixed(2) - OldAvgLev.toFixed(2)).toFixed(2) : "<font color='red'>" + (AllAvgLev.toFixed(2) - OldAvgLev.toFixed(2)).toFixed(2)) + "</font></div><br>";
  729. }
  730. var deltaAvg = (NewAvgLev.toFixed(2) - OldAvgLev.toFixed(2)).toFixed(2);
  731. insertNewTr(NBretbodytrtd2tabletbody, "", OldAvgLev.toFixed(2) + (deltaAvg * 1 !== 0 ? (deltaAvg > 0) ? "<font color='green'> (+" + deltaAvg + ")</font>" : "<font color='red'> (" + deltaAvg + ")</font>" : ""), "", "Nbav2");
  732. deltaAvg = (AllAvgLev.toFixed(2) - OldAvgLev.toFixed(2)).toFixed(2);
  733. insertNewTr(NBretbodytrtd3tabletbody, "", AllAvgLev.toFixed(2) + (deltaAvg * 1 !== 0 ? (deltaAvg > 0) ? "<font color='green'> (+" + deltaAvg + ")</font>" : "<font color='red'> (" + deltaAvg + ")</font>" : ""), "", "Nbav3");
  734.  
  735. insertNewTr(NBretbodytrtd1tabletbody, (lang === "ru") ? "Повреждений за бой" : "Damage per battle", (NewDamag / NewBattles).toFixed(2), EffTooltip("damage", NewDamag, neffs, NewBattles, NewAvgLev, lang), "Nbd1");
  736. if (((AllDamag / AllBattles).toFixed(2) - (OldDamag / OldBattles).toFixed(2)).toFixed(2) * 1 !== 0) {
  737. if (!hrIn && statTooltip.length !== 0) {
  738. statTooltip += '<hr>';
  739. hrIn = true;
  740. }
  741. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Повреждений за бой: ' : 'Damage per battle: ') + "</div><div style='float:right'>" + ((AllDamag / AllBattles).toFixed(2) - (OldDamag / OldBattles).toFixed(2) > 0 ? "<font color='green'>+" + ((AllDamag / AllBattles).toFixed(2) - (OldDamag / OldBattles).toFixed(2)).toFixed(2) : "<font color='red'>" + ((AllDamag / AllBattles).toFixed(2) - (OldDamag / OldBattles).toFixed(2)).toFixed(2)) + "</font></div><br>";
  742. }
  743. var deltaDmg = ((NewDamag / NewBattles).toFixed(2) - (OldDamag / OldBattles).toFixed(2)).toFixed(2);
  744. insertNewTr(NBretbodytrtd2tabletbody, "", (OldDamag / OldBattles).toFixed(2) + (deltaDmg * 1 !== 0 ? (deltaDmg > 0) ? "<font color='green'> (+" + deltaDmg + ")</font>" : "<font color='red'> (" + deltaDmg + ")</font>" : ""), EffTooltip("damage", OldDamag, oeffs, OldBattles, OldAvgLev, lang), "Nbd2");
  745. deltaDmg = ((AllDamag / AllBattles).toFixed(2) - (OldDamag / OldBattles).toFixed(2)).toFixed(2);
  746. insertNewTr(NBretbodytrtd3tabletbody, "", (AllDamag / AllBattles).toFixed(2) + (deltaDmg * 1 !== 0 ? (deltaDmg > 0) ? "<font color='green'> (+" + deltaDmg + ")</font>" : "<font color='red'> (" + deltaDmg + ")</font>" : ""), EffTooltip("damage", AllDamag, effres, AllBattles, AllAvgLev, lang), "Nbd3");
  747.  
  748.  
  749. insertNewTr(NBretbodytrtd1tabletbody, (lang === "ru") ? "Фрагов за бой" : "Frags per battle", (NewFrags / NewBattles).toFixed(2), EffTooltip("frags", NewFrags, neffs, NewBattles, NewAvgLev, lang), "Nbf1");
  750. if (((AllFrags / AllBattles).toFixed(2) - (OldFrags / OldBattles).toFixed(2)).toFixed(2) * 1 !== 0) {
  751. if (!hrIn && statTooltip.length !== 0) {
  752. statTooltip += '<hr>';
  753. hrIn = true;
  754. }
  755. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Фрагов за бой: ' : 'Frags per battle: ') + "</div><div style='float:right'>" + ((AllFrags / AllBattles).toFixed(2) - (OldFrags / OldBattles).toFixed(2) > 0 ? "<font color='green'>+" + ((AllFrags / AllBattles).toFixed(2) - (OldFrags / OldBattles).toFixed(2)).toFixed(2) : "<font color='red'>" + ((AllFrags / AllBattles).toFixed(2) - (OldFrags / OldBattles).toFixed(2)).toFixed(2)) + "</font></div><br>";
  756. }
  757. var deltaFr = ((NewFrags / NewBattles).toFixed(2) - (OldFrags / OldBattles).toFixed(2)).toFixed(2);
  758. insertNewTr(NBretbodytrtd2tabletbody, "", (OldFrags / OldBattles).toFixed(2) + (deltaFr * 1 !== 0 ? (deltaFr > 0) ? "<font color='green'> (+" + deltaFr + ")</font>" : "<font color='red'> (" + deltaFr + ")</font>" : ""), EffTooltip("frags", OldFrags, oeffs, OldBattles, OldAvgLev, lang), "Nbf2");
  759. deltaFr = ((AllFrags / AllBattles).toFixed(2) - (OldFrags / OldBattles).toFixed(2)).toFixed(2);
  760. insertNewTr(NBretbodytrtd3tabletbody, "", (AllFrags / AllBattles).toFixed(2) + (deltaFr * 1 !== 0 ? (deltaFr > 0) ? "<font color='green'> (+" + deltaFr + ")</font>" : "<font color='red'> (" + deltaFr + ")</font>" : ""), EffTooltip("frags", AllFrags, effres, AllBattles, AllAvgLev, lang), "Nbf3");
  761.  
  762.  
  763. insertNewTr(NBretbodytrtd1tabletbody, (lang === "ru") ? "Обнаружено за бой" : "Spotted per battle", (NewSpotted / NewBattles).toFixed(2), EffTooltip("spotted", NewSpotted, neffs, NewBattles, NewAvgLev, lang), "Nbs1");
  764. if (((AllSpotted / AllBattles).toFixed(2) - (OldSpotted / OldBattles).toFixed(2)).toFixed(2) * 1 !== 0) {
  765. if (!hrIn && statTooltip.length !== 0) {
  766. statTooltip += '<hr>';
  767. hrIn = true;
  768. }
  769. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Обнаружено за бой: ' : 'Spotted per battle: ') + "</div><div style='float:right'>" + ((AllSpotted / AllBattles).toFixed(2) - (OldSpotted / OldBattles).toFixed(2) > 0 ? "<font color='green'>+" + ((AllSpotted / AllBattles).toFixed(2) - (OldSpotted / OldBattles).toFixed(2)).toFixed(2) : "<font color='red'>" + ((AllSpotted / AllBattles).toFixed(2) - (OldSpotted / OldBattles).toFixed(2)).toFixed(2)) + "</font></div><br>";
  770. }
  771. var deltaSp = ((NewSpotted / NewBattles).toFixed(2) - (OldSpotted / OldBattles).toFixed(2)).toFixed(2);
  772. insertNewTr(NBretbodytrtd2tabletbody, "", (OldSpotted / OldBattles).toFixed(2) + (deltaSp * 1 !== 0 ? (deltaSp > 0) ? "<font color='green'> (+" + deltaSp + ")</font>" : "<font color='red'> (" + deltaSp + ")</font>" : ""), EffTooltip("spotted", OldSpotted, oeffs, OldBattles, OldAvgLev, lang), "Nbs2");
  773. deltaSp = ((AllSpotted / AllBattles).toFixed(2) - (OldSpotted / OldBattles).toFixed(2)).toFixed(2);
  774. insertNewTr(NBretbodytrtd3tabletbody, "", (AllSpotted / AllBattles).toFixed(2) + (deltaSp * 1 !== 0 ? (deltaSp > 0) ? "<font color='green'> (+" + deltaSp + ")</font>" : "<font color='red'> (" + deltaSp + ")</font>" : ""), EffTooltip("spotted", AllSpotted, effres, AllBattles, AllAvgLev, lang), "Nbs3");
  775.  
  776. insertNewTr(NBretbodytrtd1tabletbody, (lang === "ru") ? "Очков захвата за бой" : "Caps per battle", (NewCaps / NewBattles).toFixed(2), EffTooltip("caps", NewCaps, neffs, NewBattles, NewAvgLev, lang), "Nbc1");
  777. if (((AllCaps / AllBattles).toFixed(2) - (OldCaps / OldBattles).toFixed(2)).toFixed(2) * 1 !== 0) {
  778. if (!hrIn && statTooltip.length !== 0) {
  779. statTooltip += '<hr>';
  780. hrIn = true;
  781. }
  782. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Очков захвата за бой: ' : 'Caps per battle: ') + "</div><div style='float:right'>" + ((AllCaps / AllBattles).toFixed(2) - (OldCaps / OldBattles).toFixed(2) > 0 ? "<font color='green'>+" + ((AllCaps / AllBattles).toFixed(2) - (OldCaps / OldBattles).toFixed(2)).toFixed(2) : "<font color='red'>" + ((AllCaps / AllBattles).toFixed(2) - (OldCaps / OldBattles).toFixed(2)).toFixed(2)) + "</font></div><br>";
  783. }
  784. deltaCap = ((NewCaps / NewBattles).toFixed(2) - (OldCaps / OldBattles).toFixed(2)).toFixed(2);
  785. insertNewTr(NBretbodytrtd2tabletbody, "", (OldCaps / OldBattles).toFixed(2) + (deltaCap * 1 !== 0 ? (deltaCap > 0) ? "<font color='green'> (+" + deltaCap + ")</font>" : "<font color='red'> (" + deltaCap + ")</font>" : ""), EffTooltip("caps", OldCaps, oeffs, OldBattles, OldAvgLev, lang), "Nbc2");
  786. deltaCap = (AllCaps / AllBattles - OldCaps / OldBattles).toFixed(2);
  787. insertNewTr(NBretbodytrtd3tabletbody, "", (AllCaps / AllBattles).toFixed(2) + (deltaCap * 1 !== 0 ? (deltaCap > 0) ? "<font color='green'> (+" + deltaCap + ")</font>" : "<font color='red'> (" + deltaCap + ")</font>" : ""), EffTooltip("caps", AllCaps, effres, AllBattles, AllAvgLev, lang), "Nbc3");
  788.  
  789. insertNewTr(NBretbodytrtd1tabletbody, (lang === "ru") ? "Очков защиты за бой" : "Defs per battle", (NewDefs / NewBattles).toFixed(2), EffTooltip("defs", NewDefs, neffs, NewBattles, NewAvgLev, lang), "Nbde1");
  790. if (((AllDefs / AllBattles).toFixed(2) - (OldDefs / OldBattles).toFixed(2)).toFixed(2) * 1 !== 0) {
  791. if (!hrIn && statTooltip.length !== 0) {
  792. statTooltip += '<hr>';
  793. hrIn = true;
  794. }
  795. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Очков защиты за бой: ' : 'Defs per battle: ') + "</div><div style='float:right'>" + ((AllDefs / AllBattles).toFixed(2) - (OldDefs / OldBattles).toFixed(2) > 0 ? "<font color='green'>+" + ((AllDefs / AllBattles).toFixed(2) - (OldDefs / OldBattles).toFixed(2)).toFixed(2) : "<font color='red'>" + ((AllDefs / AllBattles).toFixed(2) - (OldDefs / OldBattles).toFixed(2)).toFixed(2)) + "</font></div><br>";
  796. }
  797. deltaDef = ((NewDefs / NewBattles).toFixed(2) - (OldDefs / OldBattles).toFixed(2)).toFixed(2);
  798. insertNewTr(NBretbodytrtd2tabletbody, "", (OldDefs / OldBattles).toFixed(2) + (deltaDef * 1 !== 0 ? (deltaDef > 0) ? "<font color='green'> (+" + deltaDef + ")</font>" : "<font color='red'> (" + deltaDef + ")</font>" : ""), EffTooltip("defs", OldDefs, oeffs, OldBattles, OldAvgLev, lang), "Nbde2");
  799. deltaDef = ((AllDefs / AllBattles).toFixed(2) - (OldDefs / OldBattles).toFixed(2)).toFixed(2);
  800. insertNewTr(NBretbodytrtd3tabletbody, "", (AllDefs / AllBattles).toFixed(2) + (deltaDef * 1 !== 0 ? (deltaDef > 0) ? "<font color='green'> (+" + deltaDef + ")</font>" : "<font color='red'> (" + deltaDef + ")</font>" : ""), EffTooltip("defs", AllDefs, effres, AllBattles, AllAvgLev, lang), "Nbde3");
  801.  
  802. insertNewTr(NBretbodytrtd1tabletbody, (lang === "ru") ? " Эффективность" : "Eff. rating", "<font color='" + CalcEffColor(Number(neffs[0]), "eff")[0] + "'>" + neffs[0] + "</font>", CalcEffColor(Number(neffs[0]), "eff")[1], "Nbef1");
  803. delta = neffs[0] - oeffs[0];
  804. insertNewTr(NBretbodytrtd2tabletbody, "", "<font color='" + CalcEffColor(Number(oeffs[0]), "eff")[0] + "'>" + oeffs[0] + (delta * 1 !== 0 ? (delta > 0) ? "<font color='green'> (+" + delta.toFixed(2) + ")</font>" : "<font color='red'> (" + delta.toFixed(2) + ")</font>" : "") + "</font>", CalcEffColor(Number(oeffs[0]), "eff")[1], "Nbef2");
  805. delta = effres[0] - oeffs[0];
  806. insertNewTr(NBretbodytrtd3tabletbody, "", "<font color='" + CalcEffColor(Number(effres[0]), "eff")[0] + "'>" + effres[0] + (delta * 1 !== 0 ? (delta > 0) ? "<font color='green'> (+" + delta.toFixed(2) + ")</font>" : "<font color='red'> (" + delta.toFixed(2) + ")</font>" : "") + "</font>", CalcEffColor(Number(effres[0]), "eff")[1], "Nbef3");
  807.  
  808. insertNewTr(NBretbodytrtd1tabletbody, (lang === "ru") ? " WN6 Рейтинг" : "WN6 Rating", "<font color='" + CalcEffColor(Number(neffs[2]), "wn6")[0] + "'>" + neffs[2] + "</font>", CalcEffColor(Number(neffs[2]), "wn6")[1], "Nbwn1");
  809. delta = neffs[2] - oeffs[2];
  810. insertNewTr(NBretbodytrtd2tabletbody, "", "<font color='" + CalcEffColor(Number(oeffs[2]), "wn6")[0] + "'>" + oeffs[2] + (delta * 1 !== 0 ? (delta > 0) ? "<font color='green'> (+" + delta.toFixed(2) + ")</font>" : "<font color='red'> (" + delta.toFixed(2) + ")</font>" : "") + "</font>", CalcEffColor(Number(oeffs[2]), "wn6")[1], "Nbwn2");
  811. delta = effres[2] - oeffs[2];
  812. insertNewTr(NBretbodytrtd3tabletbody, "", "<font color='" + CalcEffColor(Number(effres[2]), "wn6")[0] + "'>" + effres[2] + (delta * 1 !== 0 ? (delta > 0) ? "<font color='green'> (+" + delta.toFixed(2) + ")</font>" : "<font color='red'> (" + delta.toFixed(2) + ")</font>" : "") + "</font>", CalcEffColor(Number(effres[2]), "wn6")[1], "Nbwn3");
  813. insertNewTr(NBretbodytrtd1tabletbody, (lang === "ru") ? " WN8 Рейтинг" : "WN8 Rating", "<font color='" + CalcEffColor(Number(nwn8), "wn8")[0] + "'>" + nwn8.toFixed(2) + "</font>", CalcEffColor(Number(nwn8), "wn8")[1], "Nbwn81");
  814. delta = nwn8 - own8;
  815. insertNewTr(NBretbodytrtd2tabletbody, "", "<font color='" + CalcEffColor(Number(own8), "wn8")[0] + "'>" + own8.toFixed(2) + (delta * 1 !== 0 ? (delta > 0) ? "<font color='green'> (+" + delta.toFixed(2) + ")</font>" : "<font color='red'> (" + delta.toFixed(2) + ")</font>" : "") + "</font>", CalcEffColor(Number(own8), "wn8")[1], "Nbwn82");
  816. delta = wn8 - own8;
  817. insertNewTr(NBretbodytrtd3tabletbody, "", "<font color='" + CalcEffColor(Number(wn8), "wn8")[0] + "'>" + wn8.toFixed(2) + (delta * 1 !== 0 ? (delta > 0) ? "<font color='green'> (+" + delta.toFixed(2) + ")</font>" : "<font color='red'> (" + delta.toFixed(2) + ")</font>" : "") + "</font>", CalcEffColor(Number(wn8), "wn8")[1], "Nbwn83");
  818.  
  819. blBool = settings.newBat && (toFl(settings.newBat[1]) !== 0 || toFl(settings.newBat[0]) !== 0);
  820.  
  821. spSp1.className = "b-fake-link";
  822. spSp1.innerHTML = blBool ? (lang === "ru" ? 'Развернуть блок "Новые бои"' : 'Expand "New battles"') : (lang === "ru" ? 'Свернуть блок "Новые бои"' : 'Collapse "New battles"');
  823. spA1.appendChild(spSp1);
  824. spA1.className = "b-vertical-arrow sh-speedometr" + (blBool ? "" : " b-vertical-arrow__open");
  825. spA1.setAttribute('curSt', blBool ? 1 : 0);
  826. spA1.setAttribute('curStText', (lang === "ru" ? '"Новые бои"' : '"New battles"'));
  827. spA1.href = "#";
  828. spDiv1.setAttribute('style', 'text-align: right; margin-right: 15px;' + (blBool ? "padding-top: 10px; padding-bottom: 10px;" : ""));
  829. spDiv1.appendChild(spA1);
  830. }
  831. //->Блок Новые бои
  832.  
  833. //<-Блок сравнение игроков
  834. var comparestat = GetLSData("compareStat");
  835. if (comparestat && settings.compare === 1 && AllBattles && window.location.href.indexOf(settings.UserID) === -1) {
  836. var mArr = comparestat.split("|"),
  837. strArray = mArr[0].split("/"),
  838. str = strArray[0].split(";"),
  839. timeStat = new Date(str[0]),
  840. compareWGRating = 0,
  841. compareMedals = [];
  842. ;
  843. if (mArr.length > 3) compareWGRating = toFl(mArr[3]);
  844. if (timeStat) {
  845. if (timeStat.toLocaleFormat)
  846. var compareTime = timeStat.toLocaleFormat("%d.%m.%Y %H:%M");
  847. else
  848. compareTime = timeStat.toLocaleString().substr(0, timeStat.toLocaleString().lastIndexOf(":"));
  849.  
  850. if (mArr.length > 2) {
  851. var MedArr = mArr[2].split("/");
  852. for (var i = 0; i < MedArr.length; i++) {
  853. var MedStr = MedArr[i].split(";");
  854. compareMedals[MedStr[0]] = toFl(MedStr[1]);
  855. }
  856. }
  857.  
  858. if (str.length > 3) {
  859. var compareBattles = toFl(str[12]),
  860. compareWins = toFl(str[10]),
  861. compareXp = toFl(str[24]),
  862. compareDamag = toFl(str[16]),
  863. compareFrags = toFl(str[20]),
  864. compareSpotted = toFl(str[22]),
  865. compareCaps = toFl(str[14]),
  866. compareDefs = toFl(str[18]),
  867. compareAvgLev = parseFloat(mArr[1]);
  868. }
  869.  
  870. for (var i = 1; i < strArray.length; i++) {
  871. str = strArray[i].split(";");
  872. var tName = str[0].toLowerCase();
  873. comparedayArray[tName] = new Object();
  874. comparedayArray[tName].b = toFl(str[1]);
  875. comparedayArray[tName].w = toFl(str[2]);
  876. comparedayArray[tName].id = parseInt(str[3]);
  877. }
  878. var ccal = CalcCompareAvgLev(comparedayArray),
  879. cexpDmg = ccal[0],
  880. cexpSpot = ccal[1],
  881. cexpFrag = ccal[2],
  882. cexpDef = ccal[3],
  883. cexpWinRate = ccal[4],
  884. cexpB = ccal[5],
  885. rDAMAGE = compareDamag / compareBattles * cexpB / cexpDmg,
  886. rSPOT = compareSpotted / compareBattles * cexpB / cexpSpot,
  887. rFRAG = compareFrags / compareBattles * cexpB / cexpFrag,
  888. rDEF = compareDefs / compareBattles * cexpB / cexpDef,
  889. rWIN = compareWins / compareBattles * cexpB / cexpWinRate,
  890. rWINc = Math.max(0, (rWIN - 0.71) / (1 - 0.71)),
  891. rDAMAGEc = Math.max(0, (rDAMAGE - 0.22) / (1 - 0.22)),
  892. rFRAGc = Math.max(0, Math.min(rDAMAGEc + 0.2, (rFRAG - 0.12) / (1 - 0.12))),
  893. rSPOTc = Math.max(0, Math.min(rDAMAGEc + 0.1, (rSPOT - 0.38) / (1 - 0.38))),
  894. rDEFc = Math.max(0, Math.min(rDAMAGEc + 0.1, (rDEF - 0.10) / (1 - 0.10))),
  895. cwn8 = 980 * rDAMAGEc + 210 * rDAMAGEc * rFRAGc + 155 * rFRAGc * rSPOTc + 75 * rDEFc * rFRAGc + 145 * Math.min(1.8, rWINc);
  896. var Cmptresulttable = document.getElementsByClassName("b-user-block")[0],
  897. CmpmainDiv = document.createElement('div'),
  898. CmpsDiv = document.createElement('div'),
  899. CmpsDivH3 = document.createElement('h3'),
  900. CmpthDiv = document.createElement('div'),
  901. CmpMedalsA = document.createElement("div"),
  902. CmpMedalsDiv = document.createElement("div"),
  903. CmpMedalsDivUl = document.createElement("ul"),
  904. Cmpretbodytrtd1table = document.createElement('table'),
  905. Cmpretbodytrtd2table = document.createElement('table'),
  906. Cmpretbodytrtd3table = document.createElement('table'),
  907. Cmpretbodytrtd1tabletbody = document.createElement('tbody'),
  908. Cmpretbodytrtd2tabletbody = document.createElement('tbody'),
  909. Cmpretbodytrtd3tabletbody = document.createElement('tbody'),
  910. Cmph31 = document.createElement('h5'),
  911. Cmph32 = document.createElement('h5'),
  912. Cmph33 = document.createElement('h5'),
  913. Cmpdiv1 = document.createElement('div'),
  914. Cmpdiv2 = document.createElement('div'),
  915. Cmpdiv3 = document.createElement('div'),
  916. CmpspDiv1 = document.createElement('div'),
  917. CmpspA1 = document.createElement('a'),
  918. CmpspSp1 = document.createElement('span');
  919.  
  920. document.getElementsByClassName("b-userblock-wrpr")[0].insertBefore(CmpmainDiv, Cmptresulttable);
  921. CmpmainDiv.className = "b-user-block b-user-block-compare-stat";
  922. CmpsDiv.className = "b-head-block";
  923. CmpsDivH3.innerHTML = lang === "ru" ? "Сравнение игрока со мной" : "Compare player with me";
  924. CmpthDiv.setAttribute('class', "b-user-info clearfix");
  925.  
  926. Cmph31.innerHTML = lang === "ru" ? "Мои данные от <span style='color:green;'>" + compareTime + '</span>' : "My stat. from <span style='color:green;'>" + compareTime + '</span>';
  927. Cmph32.innerHTML = lang === "ru" ? "Данные игрока" : "Player stat.";
  928. Cmph32.setAttribute('style', 'float: right;');
  929. Cmph33.innerHTML = lang === "ru" ? "Дельта" : "Delta";
  930. Cmph33.setAttribute('style', 'float: right;');
  931.  
  932. Cmpretbodytrtd1table.setAttribute('class', 't-dotted');
  933. Cmpretbodytrtd1table.appendChild(Cmpretbodytrtd1tabletbody);
  934. Cmpretbodytrtd2table.setAttribute('class', 't-dotted');
  935. Cmpretbodytrtd2table.appendChild(Cmpretbodytrtd2tabletbody);
  936. Cmpretbodytrtd3table.setAttribute('class', 't-dotted');
  937. Cmpretbodytrtd3table.appendChild(Cmpretbodytrtd3tabletbody);
  938.  
  939. Cmpdiv1.setAttribute('style', 'float: left; width: 45%; margin-left: 25px;');
  940. Cmpdiv2.setAttribute('style', 'float: left; width: 24%;');
  941. Cmpdiv3.setAttribute('style', 'float: left; width: 24%;');
  942.  
  943. CmpMedalsA.setAttribute('style', 'padding-left: 27px; padding-top: 10px;');
  944. CmpMedalsDiv.setAttribute('style', 'padding-left: 20px; display: none;');
  945. CmpMedalsA.innerHTML = '<a class="b-vertical-arrow us-show-medals" href="#"><span class="b-fake-link">' + (lang === "ru" ? "Медали" : "Medals") + '</span></a>';
  946.  
  947. Cmpdiv1.appendChild(Cmph31);
  948. Cmpdiv1.appendChild(Cmpretbodytrtd1table);
  949. Cmpdiv2.appendChild(Cmph32);
  950. Cmpdiv2.appendChild(Cmpretbodytrtd2table);
  951. Cmpdiv3.appendChild(Cmph33);
  952. Cmpdiv3.appendChild(Cmpretbodytrtd3table);
  953. CmpsDiv.appendChild(CmpsDivH3);
  954. CmpmainDiv.appendChild(CmpsDiv);
  955. CmpMedalsDiv.appendChild(CmpMedalsDivUl);
  956. CmpmainDiv.appendChild(CmpMedalsA);
  957. CmpmainDiv.appendChild(CmpMedalsDiv);
  958. CmpthDiv.appendChild(Cmpdiv1);
  959. CmpthDiv.appendChild(Cmpdiv2);
  960. CmpthDiv.appendChild(Cmpdiv3);
  961. CmpmainDiv.appendChild(CmpthDiv);
  962.  
  963. medals = document.getElementsByClassName("js-all-achievements")[0].getElementsByClassName("b-achivements_item");
  964. for (i = 0; i < medals.length; i++) {
  965. if ((" " + medals[i].className + " ").replace(/[\n\t]/g, " ").indexOf(" b-achivements_item__empty ") === -1) {
  966. var count = medals[i].getElementsByTagName('div')[0];
  967. if (count) {
  968. count = count.getElementsByTagName('span')[0];
  969. if (count) {
  970. count = count.getElementsByTagName('span')[0];
  971. if (count)
  972. count = toFl(count.innerHTML);
  973. else
  974. count = 1;
  975. } else {
  976. count = 1;
  977. }
  978. } else {
  979. count = 1;
  980. }
  981. } else
  982. count = 0;
  983. var CmpMCount = compareMedals[medals[i].id.split("-")[2]];
  984. if (!CmpMCount)
  985. CmpMCount = 0;
  986. if (count !== CmpMCount) {
  987. var node = medals[i].cloneNode(true),
  988. node2 = document.getElementById("js-achivement-" + medals[i].id.split("-")[2] + "_tooltip").cloneNode(true);
  989. node.className = "js-tooltip";
  990. node.id = "cmp-achivement-" + medals[i].id.split("-")[2];
  991. node2.id = "cmp-achivement-" + medals[i].id.split("-")[2] + "_tooltip";
  992. node.setAttribute("style", "float: left; margin: 27px 10px 0 0; position: relative;");
  993. var mC = node.getElementsByTagName('div')[0];
  994. if (mC) {
  995. var McS = mC.getElementsByTagName('span')[0];
  996. } else {
  997. node.innerHTML += '<div class="b-achivements_wrpr"><span class="b-achivements_num"><span>' + (CmpMCount - count) + '</span></span></div>';
  998. }
  999. if (McS) {
  1000. var McS2 = McS.getElementsByTagName('span')[0];
  1001. } else {
  1002. mC.innerHTML += '<span class="b-achivements_num"><span>' + (CmpMCount - count) + '</span></span>';
  1003. }
  1004. if (McS2) {
  1005. McS2.innerHTML = CmpMCount - count;
  1006. } else {
  1007. McS.innerHTML += '<span>' + (CmpMCount - count) + '</span>';
  1008. }
  1009. ;
  1010. CmpMedalsDivUl.appendChild(node);
  1011. CmpMedalsDivUl.appendChild(node2);
  1012. }
  1013. }
  1014.  
  1015. var compareeffs = CalcEff(0, compareAvgLev, compareBattles, compareWins, compareDamag, compareFrags, compareSpotted, compareCaps, compareDefs, compareXp);
  1016.  
  1017. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? "Боев|Побед (%Побед)" : "Battles|Wins (%Wins):", (compareBattles) + "|" + (compareWins) + " (" + col(compareWins / compareBattles * 100, 2) + ")", "", "comparew1");
  1018. insertNewTr(Cmpretbodytrtd2tabletbody, "", (AllBattles) + "|" + (AllWins) + " (" + col(AllWins / AllBattles * 100, 2) + ")", "", "comparew2");
  1019. var deltaWin = ((compareWins / compareBattles * 100) - (AllWins / AllBattles * 100)).toFixed(2),
  1020. deltaBattles = compareBattles - AllBattles,
  1021. deltaWins = compareWins - AllWins,
  1022. dstr = '';
  1023. if (deltaBattles > 0) {
  1024. dstr += "<font color='green'>+" + deltaBattles + "</font>|";
  1025. } else {
  1026. dstr += "<font color='red'>" + deltaBattles + "</font>|";
  1027. }
  1028. if (deltaWins > 0) {
  1029. dstr += "<font color='green'>+" + deltaWins + "</font>(";
  1030. } else {
  1031. dstr += "<font color='red'>" + deltaWins + "</font> (";
  1032. }
  1033. if (deltaWin > 0) {
  1034. dstr += "<font color='green'>+" + deltaWin + "%</font>)";
  1035. } else {
  1036. dstr += "<font color='red'>" + deltaWin + "%</font>)";
  1037. }
  1038. insertNewTr(Cmpretbodytrtd3tabletbody, "", dstr, "", "comparew3");
  1039.  
  1040. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? "Средний уровень танков" : "Average level of tanks", compareAvgLev.toFixed(2), "", "compareav1");
  1041. insertNewTr(Cmpretbodytrtd2tabletbody, "", AllAvgLev.toFixed(2), "", "compareav2");
  1042. var deltaAvg = (compareAvgLev - AllAvgLev).toFixed(2);
  1043. insertNewTr(Cmpretbodytrtd3tabletbody, "", (deltaAvg > 0) ? "<font color='green'>+" + deltaAvg + "</font>" : "<font color='red'>" + deltaAvg + "</font>", "", "compareav3");
  1044.  
  1045. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? "Опыт за бой" : "Exp per battle", (compareXp / compareBattles).toFixed(2), "", "comparee1");
  1046. insertNewTr(Cmpretbodytrtd2tabletbody, "", (AllXp / AllBattles).toFixed(2), "", "comparee2");
  1047. var deltaExp = (compareXp / compareBattles - AllXp / AllBattles).toFixed(2);
  1048. insertNewTr(Cmpretbodytrtd3tabletbody, "", (deltaExp > 0) ? "<font color='green'>+" + deltaExp + "</font>" : "<font color='red'>" + deltaExp + "</font>", "", "comparee3");
  1049.  
  1050. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? "Повреждений за бой" : "Damage per battle", (compareDamag / compareBattles).toFixed(2), EffTooltip("damage", compareDamag, compareeffs, compareBattles, compareAvgLev, lang), "compared1");
  1051. insertNewTr(Cmpretbodytrtd2tabletbody, "", (AllDamag / AllBattles).toFixed(2), EffTooltip("damage", AllDamag, effres, AllBattles, AllAvgLev, lang), "compared2");
  1052. var deltaDmg = (compareDamag / compareBattles - AllDamag / AllBattles).toFixed(2);
  1053. insertNewTr(Cmpretbodytrtd3tabletbody, "", (deltaDmg > 0) ? "<font color='green'>+" + deltaDmg + "</font>" : "<font color='red'>" + deltaDmg + "</font>", "", "compared3");
  1054.  
  1055.  
  1056. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? "Фрагов за бой" : "Frags per battle", (compareFrags / compareBattles).toFixed(2), EffTooltip("frags", compareFrags, compareeffs, compareBattles, compareAvgLev, lang), "comparef1");
  1057. insertNewTr(Cmpretbodytrtd2tabletbody, "", (AllFrags / AllBattles).toFixed(2), EffTooltip("frags", AllFrags, effres, AllBattles, AllAvgLev, lang), "comparef2");
  1058. var deltaFr = (compareFrags / compareBattles - AllFrags / AllBattles).toFixed(2);
  1059. insertNewTr(Cmpretbodytrtd3tabletbody, "", (deltaFr > 0) ? "<font color='green'>+" + deltaFr + "</font>" : "<font color='red'>" + deltaFr + "</font>", "", "comparef3");
  1060.  
  1061.  
  1062. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? "Обнаружено за бой" : "Spotted per battle", (compareSpotted / compareBattles).toFixed(2), EffTooltip("spotted", compareSpotted, compareeffs, compareBattles, compareAvgLev, lang), "compares1");
  1063. insertNewTr(Cmpretbodytrtd2tabletbody, "", (AllSpotted / AllBattles).toFixed(2), EffTooltip("spotted", AllSpotted, effres, AllBattles, AllAvgLev, lang), "compares2");
  1064. var deltaSp = (compareSpotted / compareBattles - AllSpotted / AllBattles).toFixed(2);
  1065. insertNewTr(Cmpretbodytrtd3tabletbody, "", (deltaSp > 0) ? "<font color='green'>+" + deltaSp + "</font>" : "<font color='red'>" + deltaSp + "</font>", "", "compares3");
  1066.  
  1067. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? "Очков захвата за бой" : "Caps per battle", (compareCaps / compareBattles).toFixed(2), EffTooltip("caps", compareCaps, compareeffs, compareBattles, compareAvgLev, lang), "comparec1");
  1068. insertNewTr(Cmpretbodytrtd2tabletbody, "", (AllCaps / AllBattles).toFixed(2), EffTooltip("caps", AllCaps, effres, AllBattles, AllAvgLev, lang), "comparec2");
  1069. var deltaCap = (compareCaps / compareBattles - AllCaps / AllBattles).toFixed(2);
  1070. insertNewTr(Cmpretbodytrtd3tabletbody, "", (deltaCap > 0) ? "<font color='green'>+" + deltaCap + "</font>" : "<font color='red'>" + deltaCap + "</font>", "", "comparec3");
  1071.  
  1072. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? "Очков защиты за бой" : "Defs per battle", (compareDefs / compareBattles).toFixed(2), EffTooltip("defs", compareDefs, compareeffs, compareBattles, compareAvgLev, lang), "comparede1");
  1073. insertNewTr(Cmpretbodytrtd2tabletbody, "", (AllDefs / AllBattles).toFixed(2), EffTooltip("defs", AllDefs, effres, AllBattles, AllAvgLev, lang), "comparede2");
  1074. var deltaDef = (compareDefs / compareBattles - AllDefs / AllBattles).toFixed(2);
  1075. insertNewTr(Cmpretbodytrtd3tabletbody, "", (deltaDef > 0) ? "<font color='green'>+" + deltaDef + "</font>" : "<font color='red'>" + deltaDef + "</font>", "", "comparede3");
  1076.  
  1077. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? " Эффективность" : "Eff. rating", "<font color='" + CalcEffColor(Number(compareeffs[0]), "eff")[0] + "'>" + compareeffs[0] + "</font>", CalcEffColor(Number(compareeffs[0]), "eff")[1], "compareef1");
  1078. insertNewTr(Cmpretbodytrtd2tabletbody, "", "<font color='" + CalcEffColor(Number(effres[0]), "eff")[0] + "'>" + effres[0] + "</font>", CalcEffColor(Number(effres[0]), "eff")[1], "compareef2");
  1079. var delta = compareeffs[0] - effres[0];
  1080. insertNewTr(Cmpretbodytrtd3tabletbody, "", (delta > 0) ? "<font color='green'>+" + delta.toFixed(2) + "</font>" : "<font color='red'>" + delta.toFixed(2) + "</font>", "", "compareef3");
  1081.  
  1082. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? " WN6 Рейтинг" : "WN6 Rating", "<font color='" + CalcEffColor(Number(compareeffs[2]), "wn6")[0] + "'>" + compareeffs[2] + "</font>", CalcEffColor(Number(compareeffs[2]), "wn6")[1], "comparewn1");
  1083. insertNewTr(Cmpretbodytrtd2tabletbody, "", "<font color='" + CalcEffColor(Number(effres[2]), "wn6")[0] + "'>" + effres[2] + "</font>", CalcEffColor(Number(effres[2]), "wn6")[1], "comparewn2");
  1084. var delta = compareeffs[2] - effres[2];
  1085. insertNewTr(Cmpretbodytrtd3tabletbody, "", (delta > 0) ? "<font color='green'>+" + delta.toFixed(2) + "</font>" : "<font color='red'>" + delta.toFixed(2) + "</font>", "", "comparewn3");
  1086.  
  1087. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? " WN8 Рейтинг" : "WN8 Rating", "<font color='" + CalcEffColor(Number(cwn8), "wn8")[0] + "'>" + cwn8.toFixed(2) + "</font>", CalcEffColor(Number(cwn8), "wn8")[1], "comparewn81");
  1088. insertNewTr(Cmpretbodytrtd2tabletbody, "", "<font color='" + CalcEffColor(Number(wn8), "wn8")[0] + "'>" + wn8.toFixed(2) + "</font>", CalcEffColor(Number(wn8), "wn8")[1], "comparewn82");
  1089. var delta = cwn8 - wn8;
  1090. insertNewTr(Cmpretbodytrtd3tabletbody, "", (delta > 0) ? "<font color='green'>+" + delta.toFixed(2) + "</font>" : "<font color='red'>" + delta.toFixed(2) + "</font>", "", "comparewn83");
  1091.  
  1092. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? 'Эффективность БС' : 'Eff. rating of BS', compareeffs[3], "");
  1093. insertNewTr(Cmpretbodytrtd2tabletbody, "", effres[3], "");
  1094. var delta = compareeffs[3] - effres[3];
  1095. insertNewTr(Cmpretbodytrtd3tabletbody, "", (delta > 0) ? "<font color='green'>+" + delta.toFixed(2) + "</font>" : "<font color='red'>" + delta.toFixed(2) + "</font>", "");
  1096.  
  1097. insertNewTr(Cmpretbodytrtd1tabletbody, (lang === "ru") ? 'Личный рейтинг' : 'Personal Rating', compareWGRating, "");
  1098. insertNewTr(Cmpretbodytrtd2tabletbody, "", WGRating, "");
  1099. var delta = compareWGRating - WGRating;
  1100. insertNewTr(Cmpretbodytrtd3tabletbody, "", (delta > 0) ? "<font color='green'>+" + delta.toFixed(2) + "</font>" : "<font color='red'>" + delta.toFixed(2) + "</font>", "");
  1101.  
  1102. var blBool = settings.plComp && (toFl(settings.plComp[1]) !== 0 || toFl(settings.plComp[0]) !== 0);
  1103.  
  1104. CmpspSp1.className = "b-fake-link";
  1105. CmpspSp1.innerHTML = blBool ? (lang === "ru" ? 'Развернуть блок "Сравнение игроков"' : 'Expand "Players compare"') : (lang === "ru" ? 'Свернуть блок "Сравнение игроков"' : 'Collapse "Players compare"');
  1106. CmpspA1.appendChild(CmpspSp1);
  1107. CmpspA1.className = "b-vertical-arrow sh-speedometr" + (blBool ? "" : " b-vertical-arrow__open");
  1108. CmpspA1.setAttribute('curSt', blBool ? 1 : 0);
  1109. CmpspA1.setAttribute('curStText', (lang === "ru" ? '"Сравнение игроков"' : '"Players compare"'));
  1110. CmpspA1.href = "#";
  1111. CmpspDiv1.setAttribute('style', 'text-align: right; margin-right: 15px;' + (blBool ? "padding-top: 10px; padding-bottom: 10px;" : ""));
  1112. CmpspDiv1.appendChild(CmpspA1);
  1113. }
  1114. }
  1115. //->Блок сравнение игроков
  1116.  
  1117.  
  1118. //<-Блок рейтинга эффективности
  1119. var tresulttable = document.getElementsByClassName("b-user-block")[0],
  1120. mainDiv = document.createElement('div'),
  1121. sDiv = document.createElement('div'),
  1122. sDivH3 = document.createElement('h3'),
  1123. sDiva = document.createElement('a'),
  1124. thDiv = document.createElement('div'),
  1125. lDiv = document.createElement('div'),
  1126. lhr = document.createElement('hr'),
  1127. rhr = document.createElement('hr'),
  1128. companyTable = document.createElement('table'),
  1129. companyH4 = document.createElement('h4'),
  1130. clanTable = document.createElement('table'),
  1131. clanH4 = document.createElement('h4'),
  1132. clanTabletbody = document.createElement('tbody'),
  1133. companyTabletbody = document.createElement('tbody'),
  1134. rDiv = document.createElement('div'),
  1135. NB7div = document.createElement('div'),
  1136. NB7div2 = document.createElement('div'),
  1137. NB7Tdiv = document.createElement('div'),
  1138. NB7Tdiv2 = document.createElement('div'),
  1139. retbodytrtd1table = document.createElement('table'),
  1140. retbodytrtd2table = document.createElement('table'),
  1141. retbodytrtd1tabletbody = document.createElement('tbody'),
  1142. retbodytrtd2tabletbody = document.createElement('tbody'),
  1143. spDiv = document.createElement('div'),
  1144. spA = document.createElement('a'),
  1145. spSp = document.createElement('span');
  1146.  
  1147. if (NBmainDiv)
  1148. tresulttable = document.getElementsByClassName("b-user-block")[1];
  1149.  
  1150. document.getElementsByClassName("b-userblock-wrpr")[0].insertBefore(mainDiv, tresulttable);
  1151.  
  1152. clanTable.setAttribute('style', 'display: none;');
  1153. companyTable.setAttribute('style', 'display: none;');
  1154.  
  1155. mainDiv.className = "b-user-block b-user-block-eff-ratings";
  1156. sDiv.className = "b-head-block";
  1157. sDivH3.innerHTML = lang === "ru" ? "Эффективность" : "Efficiency";
  1158. sDiva.innerHTML = 'Смотреть видеообзоры рейтингов';
  1159. sDiva.setAttribute('href', 'http://www.youtube.com/playlist?list=PLBy529l9aTSiq1ORoe0R2FS43y4oax5jg');
  1160. sDiva.setAttribute('target', '__blank');
  1161. sDiva.setAttribute('style', 'float: right; font-size: 11pt; padding-top: 10px; padding-right: 10px;');
  1162. sDiv.appendChild(sDiva);
  1163. companyH4.innerHTML = '<a class="b-vertical-arrow us-show-medals" href="#"><span class="b-fake-link">' + (lang === "ru" ? "Ротные бои" : "Company battles") + '</span></a>';
  1164. companyTabletbody.setAttribute('id', 'company-battles');
  1165. companyTable.setAttribute('class', 't-dotted');
  1166. clanTabletbody.setAttribute('id', 'clan-battles');
  1167. clanTable.setAttribute('class', 't-dotted');
  1168. clanH4.innerHTML = '<a class="b-vertical-arrow us-show-medals" href="#"><span class="b-fake-link">' + (lang === "ru" ? "Глобальная карта" : "Clan battles") + '</span></a>';
  1169. thDiv.setAttribute('class', "b-user-info clearfix");
  1170. lDiv.className = "b-user-block_left-column";
  1171. lDiv.setAttribute('style', 'margin-left:25px;');
  1172. rDiv.className = "b-user-block_right-column";
  1173. rDiv.setAttribute('style', 'margin-right:25px;');
  1174. NB7div.setAttribute('style', 'padding-left: 27px; padding-top: 5px; padding-bottom: 5px;');
  1175. NB7Tdiv.setAttribute('style', 'padding-left: 27px; padding-top: 5px; padding-bottom: 5px;');
  1176. NB7div2.setAttribute('style', 'padding-left: 5px; padding-right: 5px; display: none; padding-bottom: 5px;');
  1177. NB7Tdiv2.setAttribute('style', 'padding-left: 5px; padding-right: 5px; display: none; padding-bottom: 5px;');
  1178. NB7div2.innerHTML =
  1179. '<h3 style="text-align: center;">' + (lang === "ru" ? "Тип графика" : "Graph type") + '</h3>'
  1180. + '<span id="hoverdata"></span><div style="text-align: center;"><label for="gall" style="padding-left: 50px;">' + (lang === "ru" ? 'Все' : 'All') + '</label><input type="radio" name="ggtype" id="gall" value="all" checked/>'
  1181. + '<label for="gdate" style="padding-left: 50px;">' + (lang === "ru" ? 'Дата' : 'Date') + '</label><input type="radio" name="ggtype" id="gdate" value="date" />'
  1182. + '<label for="gbat" style="padding-left: 50px;">' + (lang === "ru" ? 'Бои' : 'Battles') + '</label><input type="radio" name="ggtype" id="gbat" value="bat" /></div>'
  1183. + '<hr><h4 style="text-align: center;">' + (lang === "ru" ? "% побед" : "Win %") + '</h4><div id="percStr" style="width:600px;height:100px;" gtype="date"></div><br><div id="percStrB" style="width:600px;height:100px;" gtype="bat"></div><br>'
  1184. + '<h4 style="text-align: center;">' + (lang === "ru" ? "Опыт за бой" : "Exp per battle") + '</h4><div id="exp7" style="width:600px;height:100px;" gtype="date"></div><br><div id="xpStrB" style="width:600px;height:100px;" gtype="bat"></div><br>'
  1185. + '<h4 style="text-align: center;">' + (lang === "ru" ? "Повреждений за бой" : "Damage per battle") + '</h4><div id="damagStr" style="width:600px;height:100px;" gtype="date"></div><br><div id="damagStrB" style="width:600px;height:100px;" gtype="bat"></div><br>'
  1186. + '<h4 style="text-align: center;">' + (lang === "ru" ? "Фрагов за бой" : "Frags per battle") + '</h4><div id="FragsStr" style="width:600px;height:100px;" gtype="date"></div><br><div id="FragsStrB" style="width:600px;height:100px;" gtype="bat"></div><br>'
  1187. + '<h4 style="text-align: center;">' + (lang === "ru" ? "Обнаружено за бой" : "Spotted per battle") + '</h4><div id="SpottedStr" style="width:600px;height:100px;" gtype="date"></div><br><div id="SpottedStrB" style="width:600px;height:100px;" gtype="bat"></div><br>'
  1188. + '<h4 style="text-align: center;">' + (lang === "ru" ? "Очков захвата за бой" : "Caps per battle") + '</h4><div id="CapsStr" style="width:600px;height:100px;" gtype="date"></div><br><div id="CapsStrB" style="width:600px;height:100px;" gtype="bat"></div><br>'
  1189. + '<h4 style="text-align: center;">' + (lang === "ru" ? "Очков защиты за бой" : "Defs per battle") + '</h4><div id="DefsStr" style="width:600px;height:100px;" gtype="date"></div><br><div id="DefsStrB" style="width:600px;height:100px;" gtype="bat"></div><br>'
  1190. + '<h4 style="text-align: center;">' + (lang === "ru" ? "Эффективность" : "Eff. rating") + '</h4><div id="EffStr" style="width:600px;height:100px;" gtype="date"></div><br><div id="EffStrB" style="width:600px;height:100px;" gtype="bat"></div><br>'
  1191. + '<h4 style="text-align: center;">' + (lang === "ru" ? "WN6 Рейтинг" : "WN6 Rating") + '</h4><div id="WN6Str" style="width:600px;height:100px;" gtype="date"></div><br><div id="WN6StrB" style="width:600px;height:100px;" gtype="bat"></div><br><hr>';
  1192. NB7div.innerHTML = '<a class="b-vertical-arrow us-show-medals" href="#"><span class="b-fake-link">' + (lang === "ru" ? "Последние 7 сохранений (графики)" : "Last 7 savepoints (graphs)") + '</span></a>';
  1193. NB7Tdiv.innerHTML = '<a class="b-vertical-arrow us-show-medals" href="#"><span class="b-fake-link">' + (lang === "ru" ? "Последние 7 сохранений танки (графики)" : "Last 7 savepoints tanks (graphs)") + '</span></a>';
  1194.  
  1195. retbodytrtd1table.setAttribute('class', 't-dotted');
  1196. retbodytrtd1table.appendChild(retbodytrtd1tabletbody);
  1197.  
  1198. retbodytrtd2table.setAttribute('class', 't-dotted');
  1199. retbodytrtd2table.appendChild(retbodytrtd2tabletbody);
  1200.  
  1201. companyTable.appendChild(companyTabletbody);
  1202. clanTable.appendChild(clanTabletbody);
  1203.  
  1204. lDiv.appendChild(companyH4);
  1205. lDiv.appendChild(companyTable);
  1206. lDiv.appendChild(lhr);
  1207. rDiv.appendChild(clanH4);
  1208. rDiv.appendChild(clanTable);
  1209. rDiv.appendChild(rhr);
  1210.  
  1211. lDiv.appendChild(retbodytrtd1table);
  1212. rDiv.appendChild(retbodytrtd2table);
  1213. sDiv.appendChild(sDivH3);
  1214. mainDiv.appendChild(sDiv);
  1215. if (daystat && settings.gtype !== "no") {
  1216. mainDiv.appendChild(NB7div);
  1217. mainDiv.appendChild(NB7div2);
  1218. }
  1219. thDiv.appendChild(rDiv);
  1220. thDiv.appendChild(lDiv);
  1221. mainDiv.appendChild(thDiv);
  1222. if (daystat && settings.gtype !== "no") {
  1223. mainDiv.appendChild(NB7Tdiv);
  1224. mainDiv.appendChild(NB7Tdiv2);
  1225. }
  1226.  
  1227. blBool = settings.efRat && (toFl(settings.efRat[1]) !== 0 || toFl(settings.efRat[0]) !== 0);
  1228.  
  1229. spSp.className = "b-fake-link";
  1230. spSp.innerHTML = blBool ? (lang === "ru" ? 'Развернуть блок "Рейтинги эффективности"' : 'Expand "Eff. ratings"') : (lang === "ru" ? 'Свернуть блок "Рейтинги эффективности"' : 'Collapse "Eff. ratings"');
  1231. spA.appendChild(spSp);
  1232. spA.className = "b-vertical-arrow sh-speedometr" + (blBool ? "" : " b-vertical-arrow__open");
  1233. spA.setAttribute('curSt', blBool ? 1 : 0);
  1234. spA.setAttribute('curStText', (lang === "ru" ? '"Рейтинги эффективности"' : '"Eff. ratings"'));
  1235. spA.href = "#";
  1236. spDiv.appendChild(spA);
  1237. spDiv.setAttribute('style', 'text-align: right; margin-right: 15px;' + (blBool ? "padding-top: 10px; padding-bottom: 10px;" : ""));
  1238. mainDiv.parentNode.insertBefore(spDiv, mainDiv);
  1239. if (blBool)
  1240. spDiv.nextElementSibling.setAttribute('style', 'display:none;');
  1241. if (settings.efRat && toFl(settings.efRat[1]) === 1)
  1242. spDiv.setAttribute('style', 'display:none;');
  1243.  
  1244. if (CmpmainDiv && settings.compare && window.location.href.indexOf(settings.UserID) === -1) {
  1245. blBool = settings.plComp && (toFl(settings.plComp[1]) !== 0 || toFl(settings.plComp[0]) !== 0);
  1246. CmpmainDiv.parentNode.insertBefore(CmpspDiv1, CmpmainDiv);
  1247. if (settings.plComp && toFl(settings.plComp[1]) === 1)
  1248. CmpspDiv1.setAttribute('style', 'display:none;');
  1249. if (blBool)
  1250. CmpspDiv1.nextElementSibling.setAttribute('style', 'display:none;');
  1251. }
  1252.  
  1253. if (NBmainDiv) {
  1254. blBool = settings.newBat && (toFl(settings.newBat[1]) !== 0 || toFl(settings.newBat[0]) !== 0);
  1255. NBmainDiv.parentNode.insertBefore(spDiv1, NBmainDiv);
  1256. if (settings.newBat && toFl(settings.newBat[1]) === 1)
  1257. spDiv1.setAttribute('style', 'display:none;');
  1258. if (blBool)
  1259. spDiv1.nextElementSibling.setAttribute('style', 'display:none;');
  1260. }
  1261.  
  1262. // Эффективность
  1263. var xeff = GetXRating(effres[0], "effres");
  1264. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? " <a href='http://wot-news.com/index.php/stat/calc/ru/ru/" + playerNick + "' target='_blank'>Эффективность</a>" : "<a href='http://wot-news.com/index.php' target='_blank'>Eff. rating</a>", "<font color='"
  1265. + CalcEffColor(Number(effres[0]), "eff")[0] + "'>" + effres[0] + "</font>" + (NewBattles && (effres[0] - oeffs[0]).toFixed(2) * 1 !== 0 ? (effres[0] - oeffs[0] > 0 ? "<font color='green'> (+" + (effres[0] - oeffs[0]).toFixed(2) : "<font color='red'> (" + (effres[0] - oeffs[0]).toFixed(2)) + ")</font>" : ""), CalcEffColor(Number(effres[0]), "eff")[1], "eff-rating");
  1266. hrIn = statTooltip.length === 0;
  1267. if (NewBattles && (effres[0] - oeffs[0]).toFixed(2) * 1 !== 0) {
  1268. if (!hrIn && statTooltip.length !== 0) {
  1269. statTooltip += '<hr>';
  1270. hrIn = true;
  1271. }
  1272. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Эффективность: ' : 'Eff. rating: ') + "</div><div style='float:right'>" + (effres[0] - oeffs[0] > 0 ? "<font color='green'>+" + (effres[0] - oeffs[0]).toFixed(2) : "<font color='red'>" + (effres[0] - oeffs[0]).toFixed(2)) + "</font></div><br>";
  1273. }
  1274. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? "<a href='http://wot-news.com/index.php/stat/calc/ru/ru/" + playerNick + "' target='_blank'>Эффективность xvm</a>" : "<a href='http://wot-news.com/index.php' target='_blank'>Eff. rating xwm</a>", "<font color='" + CalcEffColor(Number(effres[0]), "eff")[0] + "'>" + xeff + "</font>" + (NewBattles && oxeff !== 0 && (xeff - oxeff).toFixed(2) * 1 !== 0 ? (xeff - oxeff > 0 ? "<font color='green'> (+" + (xeff - oxeff).toFixed(2) : "<font color='red'> (" + (xeff - oxeff).toFixed(2)) + ")</font>" : ""), "", "xeff-rating");
  1275.  
  1276. if (NewBattles && oxeff !== 0 && (xeff - oxeff).toFixed(2) * 1 !== 0) {
  1277. if (!hrIn && statTooltip.length !== 0) {
  1278. statTooltip += '<hr>';
  1279. hrIn = true;
  1280. }
  1281. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'Эффективность xvm: ' : 'Eff. rating xwm: ') + "</div><div style='float:right'>" + (xeff - oxeff > 0 ? "<font color='green'>+" + (xeff - oxeff).toFixed(2) : "<font color='red'>" + (xeff - oxeff).toFixed(2)) + "</font></div><br>";
  1282. }
  1283. // WN6
  1284. var xwn = GetXRating(effres[2], "wn6")
  1285. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? " <a href='http://wot-news.com/index.php/stat/calc/ru/ru/" + playerNick + "' target='_blank'>WN6 Рейтинг</a>" : "<a href='http://wot-news.com/index.php' target='_blank'>WN6 Rating</a>", "<font color='"
  1286. + CalcEffColor(Number(effres[2]), "wn6")[0] + "'>" + effres[2] + "</font>" + (NewBattles && (effres[2] - oeffs[2]).toFixed(2) * 1 !== 0 ? (effres[2] - oeffs[2] > 0 ? "<font color='green'> (+" + (effres[2] - oeffs[2]).toFixed(2) : "<font color='red'> (" + (effres[2] - oeffs[2]).toFixed(2)) + ")</font>" : ""), CalcEffColor(Number(effres[2]), "wn6")[1], "wn6-rating");
  1287. if (NewBattles && (effres[2] - oeffs[2]).toFixed(2) * 1 !== 0) {
  1288. if (!hrIn && statTooltip.length !== 0) {
  1289. statTooltip += '<hr>';
  1290. hrIn = true;
  1291. }
  1292. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'WN6 Рейтинг: ' : 'WN6 Rating: ') + "</div><div style='float:right'>" + (effres[2] - oeffs[2] > 0 ? "<font color='green'>+" + (effres[2] - oeffs[2]).toFixed(2) : "<font color='red'>" + (effres[2] - oeffs[2]).toFixed(2)) + "</font></div><br>";
  1293. }
  1294.  
  1295. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? "<a href='http://wot-news.com/index.php/stat/calc/ru/ru/" + playerNick + "' target='_blank'>WN6 Рейтинг xvm</a>" : "<a href='http://wot-news.com/index.php' target='_blank'>WN6 Rating xwm</a>", "<font color='" + CalcEffColor(Number(effres[2]), "wn6")[0] + "'>" + xwn + "</font>" + (NewBattles && oxwn !== 0 && (xwn - oxwn).toFixed(2) * 1 !== 0 ? (xwn - oxwn > 0 ? "<font color='green'> (+" + (xwn - oxwn).toFixed(2) : "<font color='red'> (" + (xwn - oxwn).toFixed(2)) + ")</font>" : ""), "", "xwn-rating");
  1296. if (NewBattles && oxwn !== 0 && (xwn - oxwn).toFixed(2) * 1 !== 0) {
  1297. if (!hrIn && statTooltip.length !== 0) {
  1298. statTooltip += '<hr>';
  1299. hrIn = true;
  1300. }
  1301. statTooltip += "<div style='float:left'>" + (lang === "ru" ? 'WN6 Рейтинг xvm: ' : 'WN6 Rating xwm: ') + "</div><div style='float:right'>" + (xwn - oxwn > 0 ? "<font color='green'>+" + (xwn - oxwn).toFixed(2) : "<font color='red'>" + (xwn - oxwn).toFixed(2)) + "</font></div><br>";
  1302. }
  1303.  
  1304. // WN8
  1305. var xwn8 = GetXRating(wn8, "wn8");
  1306. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? "<a href='http://www.noobmeter.com/player/ru/" + playerNick + "/" + UserId + "/' target='_blank'>WN8 Рейтинг</a>" : "<a href='http://www.noobmeter.com/player/ru/" + playerNick + "/" + UserId + "/' target='_blank'>WN8 Rating</a>", "<font color='"
  1307. + CalcEffColor(Number(wn8), "wn8")[0] + "'>" + wn8.toFixed(2) + "</font>" + (NewBattles && (wn8 - own8).toFixed(2) * 1 !== 0 ? (wn8 - own8 > 0 ? "<font color='green'> (+" + (wn8 - own8).toFixed(2) : "<font color='red'> (" + (wn8 - own8).toFixed(2)) + ")</font>" : ""), CalcEffColor(Number(wn8), "wn8")[1], "wn8-rating");
  1308.  
  1309. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? "<a href='http://www.noobmeter.com/player/ru/" + playerNick + "/" + UserId + "/' target='_blank'>WN8 Рейтинг xwm</a>" : "<a href='http://www.noobmeter.com/player/ru/" + playerNick + "/" + UserId + "/' target='_blank'>WN8 Rating xwm</a>", "<font color='"
  1310. + CalcEffColor(Number(wn8), "wn8")[0] + "'>" + xwn8 + "</font>" + (NewBattles && (xwn8 - xown8) * 1 !== 0 ? (xwn8 - xown8 > 0 ? "<font color='green'> (+" + (xwn8 - xown8).toFixed(2) : "<font color='red'> (" + (xwn8 - xown8).toFixed(2)) + ")</font>" : ""), "", "xwn8-rating");
  1311.  
  1312. // Личный рейтинг
  1313. var wgr = GetXRating(WGRating, "wgr"),
  1314. owgr = GetXRating(OldWGRating, "wgr");
  1315. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? " <a href='http://forum.worldoftanks.ru/index.php?/topic/995453-/page__pid__24377030#entry24377030' target='_blank'>Личный рейтинг</a>" : "<a href='http://forum.worldoftanks.ru/index.php?/topic/995453-/page__pid__24377030#entry24377030' target='_blank'>Personal Rating</a>",
  1316. "<font color='" + CalcEffColor(WGRating, "WGRating")[0] + "'>" + WGRating + "</font>" + (((WGRating - OldWGRating).toFixed(0) != 0.0) ? ( "<font color='" + ((WGRating - OldWGRating > 0) ? "green'> (+" + (WGRating - OldWGRating).toFixed(0) : "red'> (" + (WGRating - OldWGRating).toFixed(0)) + ")</font>") : ""), CalcEffColor(WGRating, "WGRating")[1], "us-WGRating");
  1317. insertNewTr(retbodytrtd2tabletbody, "<a href='http://www.noobmeter.com/player/ru/" + playerNick + "/" + UserId + "/' target='_blank'>Личный рейтинг xvm</a>",
  1318. "<font color='" + CalcEffColor(WGRating, "WGRating")[0] + "'>" + wgr + "</font>" + ((owgr && (wgr - owgr).toFixed(2) != 0.0) ? ( "<font color='" + ((wgr - owgr > 0) ? "green'> (+" + (wgr - owgr).toFixed(2) : "red'> (" + (wgr - owgr).toFixed(2)) + ")</font>") : ""), "", "wgrating-xvm");
  1319. //Рейтинг нагиба
  1320. var PR = (500 * (AllWins / AllBattles) / 0.4856) + (1000 * AllDamag / (tnaSum * 0.975));
  1321. var clearedFromPenalties1 = 1500,
  1322. expectedMinBattles1 = 500,
  1323. expectedMinAvgTier1 = 6,
  1324. clearedFromPenalties2 = 1900,
  1325. expectedMinBattles2 = 2000,
  1326. expectedMinAvgTier2 = 7;
  1327. if (PR > clearedFromPenalties1)
  1328. PR = PR - (PR - clearedFromPenalties1) * Math.pow(Math.max(0, 1 - (AllAvgLev / expectedMinAvgTier1), 1 - (AllBattles / expectedMinBattles1)), 0.5);
  1329. if (PR > clearedFromPenalties2)
  1330. PR = PR - (PR - clearedFromPenalties2) * Math.pow(Math.max(0, 1 - (AllAvgLev / expectedMinAvgTier2), 1 - (AllBattles / expectedMinBattles2)), 0.5);
  1331.  
  1332. var XPR = GetXRating(PR, "pr");
  1333. insertNewTr(retbodytrtd1tabletbody, "<a href='http://www.noobmeter.com/player/ru/" + playerNick + "/" + UserId + "/' target='_blank'>Рейтинг нагиба</a>",
  1334. "<font color='" + CalcEffColor(PR, "pr")[0] + "'>" + PR.toFixed(2) + "</font>" + ((oPR && (PR - oPR).toFixed(2) != 0.0) ? ( "<font color='" + ((PR - oPR > 0) ? "green'> (+" + (PR - oPR).toFixed(2) : "red'> (" + (PR - oPR).toFixed(2)) + ")</font>") : ""), CalcEffColor(PR, "pr")[1], "noobmeter-rating");
  1335. insertNewTr(retbodytrtd2tabletbody, "<a href='http://www.noobmeter.com/player/ru/" + playerNick + "/" + UserId + "/' target='_blank'>Рейтинг нагиба xvm</a>",
  1336. "<font color='" + CalcEffColor(PR, "pr")[0] + "'>" + XPR + "</font>" + ((oXPR && (XPR - oXPR).toFixed(2) != 0.0) ? ( "<font color='" + ((XPR - oXPR > 0) ? "green'> (+" + (XPR - oXPR).toFixed(2) : "red'> (" + (XPR - oXPR).toFixed(2)) + ")</font>") : ""), "", "noobmeter-rating-xvm");
  1337. // Эффективность БС
  1338. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? "<a href='http://armor.kiev.ua/wot/gamerstat/" + playerNick + "' target='_blank'>Эффективность БС</a>" : "<a href='http://armor.kiev.ua/wot/' target='_blank'>Eff. rating of BS</a>", "x", "x", "bs-rating");
  1339. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? "<a href='http://armor.kiev.ua/wot/gamerstat/" + playerNick + "' target='_blank'>Эффективность БС xvm</a>" : "<a href='http://armor.kiev.ua/wot/' target='_blank'>Eff. rating of BS xvm</a>", "x", "x", "bs-rating-xvm");
  1340.  
  1341. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? " <a href='http://wot-noobs.ru/nubomer/?nick=" + playerNick + "' target='_blank'>Нубо-Рейтинг</a>" : "<a href='http://wot-noobs.ru/nubomer/?nick=" + playerNick + "' target='_blank'>Wot-noobs rating</a>", "", "x", "us-NoobStat");
  1342. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? " <a href='http://wot-noobs.ru/nubomer/?nick=" + playerNick + "' target='_blank'>Нубо-Рейтинг xvm</a>" : "<a href='http://wot-noobs.ru/nubomer/?nick=" + playerNick + "' target='_blank'>Wot-noobs rating xvm</a>", "", "x", "us-NoobStat-xvm");
  1343.  
  1344. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? " Боев" : "Battles", (AllBattles).toFixed(0) + (NewBattles && ((AllBattles).toFixed(0) - (OldBattles).toFixed(0)).toFixed(0) * 1 !== 0.0 ? (((AllBattles).toFixed(0) - (OldBattles).toFixed(0)).toFixed(0) > 0 ? "<font color='green'> (+" + ((AllBattles).toFixed(0) - (OldBattles).toFixed(0)).toFixed(0) : "<font color='red'> (" + ((AllBattles).toFixed(0) - (OldBattles).toFixed(0)).toFixed(0)) + ")</font>" : ""), "", "us-battles");
  1345. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? "Опыт за бой" : "Exp per battle", (AllXp / AllBattles).toFixed(2) + (NewBattles && ((AllXp / AllBattles).toFixed(2) - (OldXp / OldBattles).toFixed(2)).toFixed(2) * 1 !== 0 ? (((AllXp / AllBattles).toFixed(2) - (OldXp / OldBattles).toFixed(2)).toFixed(2) > 0 ? "<font color='green'> (+" + ((AllXp / AllBattles).toFixed(2) - (OldXp / OldBattles).toFixed(2)).toFixed(2) : "<font color='red'> (" + ((AllXp / AllBattles).toFixed(2) - (OldXp / OldBattles).toFixed(2)).toFixed(2)) + ")<font>" : ""), AllXp + " <font color='red'>/</font> <font color='green'>" + AllBattles + "</font>", "us-xp");
  1346. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? "Повреждений за бой" : "Damage per battle", (AllDamag / AllBattles).toFixed(2) + (NewBattles && ((AllDamag / AllBattles).toFixed(2) - (OldDamag / OldBattles).toFixed(2)).toFixed(2) * 1 !== 0.0 ? (((AllDamag / AllBattles).toFixed(2) - (OldDamag / OldBattles).toFixed(2)).toFixed(2) > 0 ? "<font color='green'> (+" + ((AllDamag / AllBattles).toFixed(2) - (OldDamag / OldBattles).toFixed(2)).toFixed(2) : "<font color='red'> (" + ((AllDamag / AllBattles).toFixed(2) - (OldDamag / OldBattles).toFixed(2)).toFixed(2)) + ")<font>" : ""), EffTooltip("damage", AllDamag, effres, AllBattles, AllAvgLev, lang), "us-damag");
  1347. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? "Фрагов за бой" : "Frags per battle", (AllFrags / AllBattles).toFixed(2) + (NewBattles && ((AllFrags / AllBattles).toFixed(2) - (OldFrags / OldBattles).toFixed(2)).toFixed(2) * 1 !== 0.0 ? (((AllFrags / AllBattles).toFixed(2) - (OldFrags / OldBattles).toFixed(2)).toFixed(2) > 0 ? "<font color='green'> (+" + ((AllFrags / AllBattles).toFixed(2) - (OldFrags / OldBattles).toFixed(2)).toFixed(2) : "<font color='red'> (" + ((AllFrags / AllBattles).toFixed(2) - (OldFrags / OldBattles).toFixed(2)).toFixed(2)) + ")<font>" : ""), EffTooltip("frags", AllFrags, effres, AllBattles, AllAvgLev, lang), "us-frags");
  1348. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? "Обнаружено за бой" : "Spotted per battle", (AllSpotted / AllBattles).toFixed(2) + (NewBattles && ((AllSpotted / AllBattles).toFixed(2) - (OldSpotted / OldBattles).toFixed(2)).toFixed(2) * 1 !== 0.0 ? (((AllSpotted / AllBattles).toFixed(2) - (OldSpotted / OldBattles).toFixed(2)).toFixed(2) > 0 ? "<font color='green'> (+" + ((AllSpotted / AllBattles).toFixed(2) - (OldSpotted / OldBattles).toFixed(2)).toFixed(2) : "<font color='red'> (" + ((AllSpotted / AllBattles).toFixed(2) - (OldSpotted / OldBattles).toFixed(2)).toFixed(2)) + ")<font>" : ""), EffTooltip("spotted", AllSpotted, effres, AllBattles, AllAvgLev, lang), "us-spotted");
  1349. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? "Очков захвата за бой" : "Caps per battle", (AllCaps / AllBattles).toFixed(2) + (NewBattles && ((AllCaps / AllBattles).toFixed(2) - (OldCaps / OldBattles).toFixed(2)).toFixed(2) * 1 !== 0.0 ? (((AllCaps / AllBattles).toFixed(2) - (OldCaps / OldBattles).toFixed(2)).toFixed(2) > 0 ? "<font color='green'> (+" + ((AllCaps / AllBattles).toFixed(2) - (OldCaps / OldBattles).toFixed(2)).toFixed(2) : "<font color='red'> (" + ((AllCaps / AllBattles).toFixed(2) - (OldCaps / OldBattles).toFixed(2)).toFixed(2)) + ")<font>" : ""), EffTooltip("caps", AllCaps, effres, AllBattles, AllAvgLev, lang), "us-caps");
  1350. insertNewTr(retbodytrtd2tabletbody, (lang === "ru") ? "Очков защиты за бой" : "Defs per battle", (AllDefs / AllBattles).toFixed(2) + (NewBattles && ((AllDefs / AllBattles).toFixed(2) - (OldDefs / OldBattles).toFixed(2)).toFixed(2) * 1 !== 0.0 ? (((AllDefs / AllBattles).toFixed(2) - (OldDefs / OldBattles).toFixed(2)).toFixed(2) > 0 ? "<font color='green'> (+" + ((AllDefs / AllBattles).toFixed(2) - (OldDefs / OldBattles).toFixed(2)).toFixed(2) : "<font color='red'> (" + ((AllDefs / AllBattles).toFixed(2) - (OldDefs / OldBattles).toFixed(2)).toFixed(2)) + ")<font>" : ""), EffTooltip("defs", AllDefs, effres, AllBattles, AllAvgLev, lang), "us-defs");
  1351.  
  1352. if (daypassed !== 0)
  1353. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? " Боев в день" : "Battles per day", (AllBattles / daypassed).toFixed(2) + (NewBattles && ((AllBattles / daypassed).toFixed(2) - (OldBattles / olddaypassed).toFixed(2)).toFixed(2) * 1 !== 0.0 ? (((AllBattles / daypassed).toFixed(2) - (OldBattles / olddaypassed).toFixed(2)).toFixed(2) > 0 ? "<font color='green'> (+" + ((AllBattles / daypassed).toFixed(2) - (OldBattles / olddaypassed).toFixed(2)).toFixed(2) : "<font color='red'> (" + ((AllBattles / daypassed).toFixed(2) - (OldBattles / olddaypassed).toFixed(2)).toFixed(2)) + ")</font>" : ""), ((lang === "ru") ? "дней" : "days") + ": " + daypassed.toFixed(), "us-daypassed");
  1354. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? "Средний уровень танков" : "Average level of tanks", AllAvgLev.toFixed(2) + (NewBattles && (AllAvgLev.toFixed(2) - OldAvgLev.toFixed(2)).toFixed(2) * 1 !== 0.0 ? ((AllAvgLev.toFixed(2) - OldAvgLev.toFixed(2)).toFixed(2) > 0 ? "<font color='green'> (+" + (AllAvgLev.toFixed(2) - OldAvgLev.toFixed(2)).toFixed(2) : "<font color='red'> (" + (AllAvgLev.toFixed(2) - OldAvgLev.toFixed(2)).toFixed(2)) + ")<font>" : ""), "", "");
  1355. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? "% побед" : "Win %", col(AllWins / AllBattles * 100, 2) + (NewBattles && ((AllWins / AllBattles * 100).toFixed(2) - (OldWins / OldBattles * 100).toFixed(2)).toFixed(2) * 1 !== 0.0 ? (((AllWins / AllBattles * 100).toFixed(2) - (OldWins / OldBattles * 100).toFixed(2)).toFixed(2) > 0 ? "<font color='green'> (+" + ((AllWins / AllBattles * 100).toFixed(2) - (OldWins / OldBattles * 100).toFixed(2)).toFixed(2) : "<font color='red'> (" + ((AllWins / AllBattles * 100).toFixed(2) - (OldWins / OldBattles * 100).toFixed(2)).toFixed(2)) + ")</font>" : ""), FoundProc(AllWins, AllBattles), "us-winperc");
  1356. var AllDefeat = toFl(document.getElementsByClassName("b-result")[0].getElementsByClassName("t-dotted")[0].rows[2].cells[1].innerHTML.split("(")[0]);
  1357. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? "% поражений" : "Defeat %", col(AllDefeat / AllBattles * 100, 2, true), FoundProc(AllDefeat, AllBattles), "us-defeat");
  1358. var AllSurvived = toFl(document.getElementsByClassName("b-result")[0].getElementsByClassName("t-dotted")[0].rows[3].cells[1].innerHTML.split("(")[0]);
  1359. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? "% выживания" : "Survived %", (AllSurvived / AllBattles * 100).toFixed(2) + "%", FoundProc(AllSurvived, AllBattles), "us-surv");
  1360. var AllHR = toFl(document.getElementsByClassName("b-result")[1].getElementsByClassName("t-dotted")[0].rows[2].cells[1].innerHTML);
  1361. insertNewTr(retbodytrtd1tabletbody, (lang === "ru") ? "% попадания" : "Hit Ratio", col(AllHR), "x", "hit-ratio");
  1362.  
  1363. if (daystat && settings.gtype !== "no") {
  1364. var plotScript = document.createElement("script"),
  1365. xpStr = '[{ color: 0, data: [',
  1366. xpStrB = '[{ color: 0, data: [',
  1367. percStrB = '[{ color: 1, data: [',
  1368. percStr = '[{ color: 1, data: [',
  1369. damagStr = '[{ color: 2, data: [',
  1370. FragsStr = '[{ color: 3, data: [',
  1371. SpottedStr = '[{ color: 4, data: [',
  1372. CapsStr = '[{ color: 5, data: [',
  1373. DefsStr = '[{ color: 6, data: [',
  1374. EffStr = '[{ color: 7, data: [',
  1375. WN6Str = '[{ color: 8, data: [',
  1376. damagStrB = '[{ color: 2, data: [',
  1377. FragsStrB = '[{ color: 3, data: [',
  1378. SpottedStrB = '[{ color: 4, data: [',
  1379. CapsStrB = '[{ color: 5, data: [',
  1380. DefsStrB = '[{ color: 6, data: [',
  1381. EffStrB = '[{ color: 7, data: [',
  1382. WN6StrB = '[{ color: 8, data: [',
  1383. firstSt = true;
  1384. plotScript.type = "text/javascript";
  1385.  
  1386. var grTanks = [], grtindex = [];
  1387.  
  1388. for (var k = 0; k < 7; k++) {
  1389. var statData = GetLSData("daystat_" + UserId + "_" + k);
  1390. if (statData) {
  1391. var dsArr = statData.split("|"),
  1392. strArray = dsArr[0].split("/"),
  1393. str = strArray[0].split(";"),
  1394. timeStat = (new Date(str[0])).getTime(),
  1395. gOldBattles = toFl(str[12]),
  1396. gOldWins = toFl(str[10]),
  1397. gOldXp = toFl(str[24]),
  1398. gOldDamag = toFl(str[16]),
  1399. gOldFrags = toFl(str[20]),
  1400. gOldSpotted = toFl(str[22]),
  1401. gOldCaps = toFl(str[14]),
  1402. gOldDefs = toFl(str[18]);
  1403. if (firstSt) {
  1404. firstSt = false;
  1405. } else if (timeStat) {
  1406. xpStr += ', ';
  1407. xpStrB += ', ';
  1408. percStr += ', ';
  1409. percStrB += ', ';
  1410. damagStr += ', ';
  1411. FragsStr += ', ';
  1412. SpottedStr += ', ';
  1413. CapsStr += ', ';
  1414. DefsStr += ', ';
  1415. EffStr += ', ';
  1416. WN6Str += ', ';
  1417. damagStrB += ', ';
  1418. FragsStrB += ', ';
  1419. SpottedStrB += ', ';
  1420. CapsStrB += ', ';
  1421. DefsStrB += ', ';
  1422. EffStrB += ', ';
  1423. WN6StrB += ', ';
  1424. }
  1425. if (timeStat) {
  1426. xpStr += '[' + timeStat + ', ' + (gOldXp / gOldBattles).toFixed(2) + ']';
  1427. xpStrB += '[' + gOldBattles + ', ' + (gOldXp / gOldBattles).toFixed(2) + ']';
  1428. percStr += '[' + timeStat + ', ' + (gOldWins / gOldBattles * 100).toFixed(2) + ']';
  1429. percStrB += '[' + gOldBattles + ', ' + (gOldWins / gOldBattles * 100).toFixed(2) + ']';
  1430. damagStr += '[' + timeStat + ', ' + (gOldDamag / gOldBattles).toFixed(2) + ']';
  1431. FragsStr += '[' + timeStat + ', ' + (gOldFrags / gOldBattles).toFixed(2) + ']';
  1432. SpottedStr += '[' + timeStat + ', ' + (gOldSpotted / gOldBattles).toFixed(2) + ']';
  1433. CapsStr += '[' + timeStat + ', ' + (gOldCaps / gOldBattles).toFixed(2) + ']';
  1434. DefsStr += '[' + timeStat + ', ' + (gOldDefs / gOldBattles).toFixed(2) + ']';
  1435. damagStrB += '[' + gOldBattles + ', ' + (gOldDamag / gOldBattles).toFixed(2) + ']';
  1436. FragsStrB += '[' + gOldBattles + ', ' + (gOldFrags / gOldBattles).toFixed(2) + ']';
  1437. SpottedStrB += '[' + gOldBattles + ', ' + (gOldSpotted / gOldBattles).toFixed(2) + ']';
  1438. CapsStrB += '[' + gOldBattles + ', ' + (gOldCaps / gOldBattles).toFixed(2) + ']';
  1439. DefsStrB += '[' + gOldBattles + ', ' + (gOldDefs / gOldBattles).toFixed(2) + ']';
  1440. var odayArray = [];
  1441.  
  1442. for (var p = 1; p < strArray.length; p++) {
  1443. str = strArray[p].split(";");
  1444. var tName = str[0].toLowerCase();
  1445. odayArray[tName] = new Object();
  1446. odayArray[tName].b = toFl(str[1]);
  1447. odayArray[tName].w = str.length > 3 ? toFl(str[3]) : -1;
  1448. if (tanksarr[tName] && tanksarr[tName].bcount !== odayArray[tName].b) {
  1449. if (!grTanks[tName]) {
  1450. grTanks[tName] = [];
  1451. grtindex[tName] = [];
  1452. }
  1453. if (grtindex[tName].indexOf(odayArray[tName].b) === -1) {
  1454. grTanks[tName].push({'bcount': odayArray[tName].b, 'wcount': odayArray[tName].w});
  1455. grtindex[tName].push(odayArray[tName].b);
  1456. }
  1457. }
  1458. }
  1459. var cav = CalcgOldAvgLev(odayArray),
  1460. gAvgLev = cav[0],
  1461. ogeff = CalcEff(0, gAvgLev, gOldBattles, gOldWins, gOldDamag, gOldFrags, gOldSpotted, gOldCaps, gOldDefs, gOldXp);
  1462. EffStr += '[' + timeStat + ', ' + ogeff[0] + ']';
  1463. WN6Str += '[' + timeStat + ', ' + ogeff[2] + ']';
  1464. EffStrB += '[' + gOldBattles + ', ' + ogeff[0] + ']';
  1465. WN6StrB += '[' + gOldBattles + ', ' + ogeff[2] + ']';
  1466. }
  1467. }
  1468. ;
  1469. }
  1470. plotScript.textContent = ' var plot_conf = { series: {lines: {show: true, lineWidth: 2 }, points: {show: true}}, grid: {hoverable: true}, xaxis: { mode: "time", timeformat: "%d.%m.%y"}}; '
  1471. + ' var plot_confB = { series: {lines: {show: true, lineWidth: 2 }, points: {show: true}}, grid: {hoverable: true}}; ' + ' function showTooltip(x, y, contents) {$("<div id=\'tooltip\'>" + contents + "</div>").css({position: "absolute",display: "none",top: y + 5,left: x + 5,border: "1px solid #fdd",padding: "2px","background-color": "white"}).appendTo("body").fadeIn(200);}var previousPoint = null;';
  1472.  
  1473. for (var gtank in grTanks) {
  1474. if (grTanks[gtank].length > 1) {
  1475. NB7Tdiv2.innerHTML += '<div style="margin-top: 15px;' + (tanksarr[gtank]['prem'] ? ' color: #ffc363 !important;"' : '"') + '><img src="' + tanksarr[gtank]['img'] + '"> ' + tanksarr[gtank]['name'] + ' <strong>' + tanksarr[gtank]['ttype'] + tanksarr[gtank]['tlev'] + '</strong></div><br><div style="width:600px;height:100px;" id="tgr' + gtank + '">';
  1476. plotScript.textContent += 'var tgrdata' + gtank.split('-').join('_') + ' = [{ color: 0, data: [';
  1477. var fst = true;
  1478. for (var grc in grTanks[gtank]) {
  1479. if (fst) {
  1480. fst = false;
  1481. } else {
  1482. plotScript.textContent += ', ';
  1483. }
  1484. plotScript.textContent += '[' + grTanks[gtank][grc]['bcount'] + ', ' + (grTanks[gtank][grc]['wcount'] / grTanks[gtank][grc]['bcount'] * 100).toFixed(2) + ']';
  1485. }
  1486. plotScript.textContent += ']}]; ' + ' $.plot($("#tgr' + gtank + '"), tgrdata' + gtank.split('-').join('_') + ', plot_confB); ';
  1487. plotScript.textContent += ' $("#tgr' + gtank + '").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = item.datapoint[0].toFixed(0),y = item.datapoint[1].toFixed(2);showTooltip(item.pageX, item.pageY, "Боев: " + x + "; " + y + "% побед.");}} else {$("#tooltip").remove();previousPoint = null; }});'
  1488. }
  1489. }
  1490. xpStr += ']}]';
  1491. xpStrB += ']}]';
  1492. percStr += ']}]';
  1493. percStrB += ']}]';
  1494. damagStr += ']}]';
  1495. FragsStr += ']}]';
  1496. SpottedStr += ']}]';
  1497. CapsStr += ']}]';
  1498. DefsStr += ']}]';
  1499. EffStr += ']}]';
  1500. WN6Str += ']}]';
  1501. damagStrB += ']}]';
  1502. FragsStrB += ']}]';
  1503. SpottedStrB += ']}]';
  1504. CapsStrB += ']}]';
  1505. DefsStrB += ']}]';
  1506. EffStrB += ']}]';
  1507. WN6StrB += ']}]';
  1508. plotScript.textContent +=
  1509. " var xp_data = " + xpStr + ","
  1510. + " xpStrB_data = " + xpStrB + ","
  1511. + " damagStr_data = " + damagStr + ","
  1512. + " FragsStr_data = " + FragsStr + ","
  1513. + " SpottedStr_data = " + SpottedStr + ","
  1514. + " CapsStr_data = " + CapsStr + ","
  1515. + " DefsStr_data = " + DefsStr + ","
  1516. + " EffStr_data = " + EffStr + ","
  1517. + " WN6Str_data = " + WN6Str + ","
  1518. + " damagStrB_data = " + damagStrB + ","
  1519. + " FragsStrB_data = " + FragsStrB + ","
  1520. + " SpottedStrB_data = " + SpottedStrB + ","
  1521. + " CapsStrB_data = " + CapsStrB + ","
  1522. + " DefsStrB_data = " + DefsStrB + ","
  1523. + " EffStrB_data = " + EffStrB + ","
  1524. + " WN6StrB_data = " + WN6StrB + ","
  1525. + " percStr_data = " + percStr + ";"
  1526. + " percStrB_data = " + percStrB + ";"
  1527. + ' $.plot($("#percStr"), percStr_data, plot_conf);'
  1528. + ' $("#percStr").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = new Date(item.datapoint[0]),y = item.datapoint[1].toFixed(2); if (x.toLocaleFormat) x = x.toLocaleFormat("%d.%m.%Y %H:%M"); else x = x.toLocaleString().substr(0, x.toLocaleString().lastIndexOf(":")); showTooltip(item.pageX, item.pageY, y + "% побед на " + x);}} else {$("#tooltip").remove();previousPoint = null; }});'
  1529. + ' $.plot($("#percStrB"), percStrB_data, plot_confB);'
  1530. + ' $("#percStrB").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = item.datapoint[0].toFixed(0),y = item.datapoint[1].toFixed(2);showTooltip(item.pageX, item.pageY, "Боев: " + x + "; " + y + "% побед.");}} else {$("#tooltip").remove();previousPoint = null; }});'
  1531. + ' $.plot($("#exp7"), xp_data, plot_conf);'
  1532. + ' $("#exp7").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = new Date(item.datapoint[0]),y = item.datapoint[1].toFixed(2); if (x.toLocaleFormat) x = x.toLocaleFormat("%d.%m.%Y %H:%M"); else x = x.toLocaleString().substr(0, x.toLocaleString().lastIndexOf(":")); showTooltip(item.pageX, item.pageY, y + " опыта за бой на " + x);}} else {$("#tooltip").remove();previousPoint = null; }});'
  1533. + ' $.plot($("#xpStrB"), xpStrB_data, plot_confB);'
  1534. + ' $("#xpStrB").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = item.datapoint[0].toFixed(0),y = item.datapoint[1].toFixed(2);showTooltip(item.pageX, item.pageY, "Боев: " + x + "; " + y + " опыта за бой.");}} else {$("#tooltip").remove();previousPoint = null; }});'
  1535. + ' $.plot($("#damagStr"), damagStr_data, plot_conf);'
  1536. + ' $("#damagStr").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = new Date(item.datapoint[0]),y = item.datapoint[1].toFixed(2); if (x.toLocaleFormat) x = x.toLocaleFormat("%d.%m.%Y %H:%M"); else x = x.toLocaleString().substr(0, x.toLocaleString().lastIndexOf(":")); showTooltip(item.pageX, item.pageY, y + " повреждений за бой на " + x);}} else {$("#tooltip").remove();previousPoint = null; }});'
  1537. + ' $.plot($("#damagStrB"), damagStrB_data, plot_confB);'
  1538. + ' $("#damagStrB").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = item.datapoint[0].toFixed(0),y = item.datapoint[1].toFixed(2);showTooltip(item.pageX, item.pageY, "Боев: " + x + "; " + y + " повреждений за бой.");}} else {$("#tooltip").remove();previousPoint = null; }});'
  1539. + ' $.plot($("#FragsStr"), FragsStr_data, plot_conf);'
  1540. + ' $("#FragsStr").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = new Date(item.datapoint[0]),y = item.datapoint[1].toFixed(2); if (x.toLocaleFormat) x = x.toLocaleFormat("%d.%m.%Y %H:%M"); else x = x.toLocaleString().substr(0, x.toLocaleString().lastIndexOf(":")); showTooltip(item.pageX, item.pageY, y + " фрагов за бой на " + x);}} else {$("#tooltip").remove();previousPoint = null; }});'
  1541. + ' $.plot($("#FragsStrB"), FragsStrB_data, plot_confB);'
  1542. + ' $("#FragsStrB").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = item.datapoint[0].toFixed(0),y = item.datapoint[1].toFixed(2);showTooltip(item.pageX, item.pageY, "Боев: " + x + "; " + y + " фрагов за бой.");}} else {$("#tooltip").remove();previousPoint = null; }});'
  1543. + ' $.plot($("#SpottedStr"), SpottedStr_data, plot_conf);'
  1544. + ' $("#SpottedStr").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = new Date(item.datapoint[0]),y = item.datapoint[1].toFixed(2); if (x.toLocaleFormat) x = x.toLocaleFormat("%d.%m.%Y %H:%M"); else x = x.toLocaleString().substr(0, x.toLocaleString().lastIndexOf(":")); showTooltip(item.pageX, item.pageY, y + " обнаружено за бой на " + x);}} else {$("#tooltip").remove();previousPoint = null; }});'
  1545. + ' $.plot($("#SpottedStrB"), SpottedStrB_data, plot_confB);'
  1546. + ' $("#SpottedStrB").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = item.datapoint[0].toFixed(0),y = item.datapoint[1].toFixed(2);showTooltip(item.pageX, item.pageY, "Боев: " + x + "; " + y + " обнаружено за бой.");}} else {$("#tooltip").remove();previousPoint = null; }});'
  1547. + ' $.plot($("#CapsStr"), CapsStr_data, plot_conf);'
  1548. + ' $("#CapsStr").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = new Date(item.datapoint[0]),y = item.datapoint[1].toFixed(2); if (x.toLocaleFormat) x = x.toLocaleFormat("%d.%m.%Y %H:%M"); else x = x.toLocaleString().substr(0, x.toLocaleString().lastIndexOf(":")); showTooltip(item.pageX, item.pageY, y + " очков захвата за бой на " + x);}} else {$("#tooltip").remove();previousPoint = null; }});'
  1549. + ' $.plot($("#CapsStrB"), CapsStrB_data, plot_confB);'
  1550. + ' $("#CapsStrB").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = item.datapoint[0].toFixed(0),y = item.datapoint[1].toFixed(2);showTooltip(item.pageX, item.pageY, "Боев: " + x + "; " + y + " очков захвата за бой.");}} else {$("#tooltip").remove();previousPoint = null; }});'
  1551. + ' $.plot($("#DefsStr"), DefsStr_data, plot_conf);'
  1552. + ' $("#DefsStr").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = new Date(item.datapoint[0]),y = item.datapoint[1].toFixed(2); if (x.toLocaleFormat) x = x.toLocaleFormat("%d.%m.%Y %H:%M"); else x = x.toLocaleString().substr(0, x.toLocaleString().lastIndexOf(":")); showTooltip(item.pageX, item.pageY, y + " очков защиты за бой на " + x);}} else {$("#tooltip").remove();previousPoint = null; }});'
  1553. + ' $.plot($("#DefsStrB"), DefsStrB_data, plot_confB);'
  1554. + ' $("#DefsStrB").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = item.datapoint[0].toFixed(0),y = item.datapoint[1].toFixed(2);showTooltip(item.pageX, item.pageY, "Боев: " + x + "; " + y + " очков защиты за бой.");}} else {$("#tooltip").remove();previousPoint = null; }});'
  1555. + ' $.plot($("#EffStr"), EffStr_data, plot_conf);'
  1556. + ' $("#EffStr").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = new Date(item.datapoint[0]),y = item.datapoint[1].toFixed(2); if (x.toLocaleFormat) x = x.toLocaleFormat("%d.%m.%Y %H:%M"); else x = x.toLocaleString().substr(0, x.toLocaleString().lastIndexOf(":")); showTooltip(item.pageX, item.pageY, "Эффективность на " + x + ": " + y);}} else {$("#tooltip").remove();previousPoint = null; }});'
  1557. + ' $.plot($("#EffStrB"), EffStrB_data, plot_confB);'
  1558. + ' $("#EffStrB").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = item.datapoint[0].toFixed(0),y = item.datapoint[1].toFixed(2);showTooltip(item.pageX, item.pageY, "Боев: " + x + "; Эффективность: " + y);}} else {$("#tooltip").remove();previousPoint = null; }});'
  1559. + ' $.plot($("#WN6Str"), WN6Str_data, plot_conf);'
  1560. + ' $("#WN6Str").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = new Date(item.datapoint[0]),y = item.datapoint[1].toFixed(2); if (x.toLocaleFormat) x = x.toLocaleFormat("%d.%m.%Y %H:%M"); else x = x.toLocaleString().substr(0, x.toLocaleString().lastIndexOf(":")); showTooltip(item.pageX, item.pageY, "Эффективность WN6 на " + x + ": " + y);}} else {$("#tooltip").remove();previousPoint = null; }});'
  1561. + ' $.plot($("#WN6StrB"), WN6StrB_data, plot_confB);'
  1562. + ' $("#WN6StrB").bind("plothover", function (event, pos, item) {if (item) {if (previousPoint != item.dataIndex) {previousPoint = item.dataIndex;$("#tooltip").remove();var x = item.datapoint[0].toFixed(0),y = item.datapoint[1].toFixed(2);showTooltip(item.pageX, item.pageY, "Боев: " + x + "; Эффективность WN6: " + y);}} else {$("#tooltip").remove();previousPoint = null; }});';
  1563. document.body.appendChild(plotScript);
  1564. }
  1565. //->Блок рейтинга эффективности
  1566.  
  1567. var mtext = "<li><a id='WriteStat' style='cursor: pointer;'>" + ((lang === "ru") ? "Сохранить статистику" : "Save statistic") + "</a></li>";
  1568. if (uskeys.length > 0) {
  1569. mtext += "<br>";
  1570. for (var i = 0; i < uskeys.length; i++)
  1571. //if (settings.UserID !== uskeys[i])
  1572. mtext += '<li><a href="http://worldoftanks.ru/community/accounts/' + uskeys[i] + '">' + (settings[uskeys[i]] ? (uskeys[i] === UserId ? "<span style='color:green;'>" + settings[uskeys[i]] + "</span>" : settings[uskeys[i]]) : 'Игрок ' + uskeys[i]) + '</a></li>';
  1573. }
  1574. mtext += "<br>";
  1575. if (uskeys.indexOf(UserId) !== -1)
  1576. mtext += '<li><a class="us-remove-stat" href="#" uid="' + UserId + '">Удалить статистику</a></li>';
  1577.  
  1578. var fake_div = document.createElement("div");
  1579. fake_div.innerHTML = mtext;
  1580. document.getElementsByClassName("b-context-menu-list__bottomindent")[0].appendChild(fake_div);
  1581. create_expanders(blockArray, lang, settings, NewBattles);
  1582. var statDiv = document.createElement("div"),
  1583. statDiv2 = document.createElement('div'),
  1584. statDiv3 = document.createElement('div');
  1585. statDiv2.innerHTML = statText;
  1586. statDiv2.setAttribute('style', 'text-align: center;');
  1587. statDiv.appendChild(statDiv2);
  1588. if (statTooltip.length > 0)
  1589. statDiv.setAttribute("id", "js-stat-div");
  1590. statDiv.className = (statTooltip.length > 0 ? "js-tooltip " : "") + "spoiler";
  1591. statDiv3.innerHTML = statTooltip;
  1592. statDiv3.setAttribute("id", "js-stat-div_tooltip");
  1593. statDiv3.className = "b-tooltip-main";
  1594. statDiv.setAttribute("style", "position: fixed; bottom: 1%; right: 1%; background-color: black; z-index: 1000;");
  1595. statDiv.style.border = "#f25322 dashed 1px";
  1596. if (statTooltip.length > 0)
  1597. statDiv.appendChild(statDiv3);
  1598.  
  1599. if (daystat)
  1600. document.body.appendChild(statDiv);
  1601.  
  1602. xdr.xget("http://wot-noobs.ru/nubomer/?nick=" + playerNick, outWotNoobStat);
  1603. //document.getElementsByClassName("t-profile__vehicle")[0].style.width = '140%';
  1604. xdr.xget("http://api." + document.location.host + "/wot/tanks/stats/?application_id=" + api_key + "&fields=tank_id%2C%20all.battles%2C%20all.wins%2C%20all.damage_dealt%2C%20all.dropped_capture_points%2C%20all.frags%2C%20all.spotted&account_id=" + UserId, putTankStats);
  1605.  
  1606. function saveTanksArr(response) {
  1607. var now = new Date(),
  1608. time = now.getTime();
  1609. time += 3600 * 24 * 1000;
  1610. now.setTime(time);
  1611. SetLSData("AllTanksArr", response, now.toGMTString());
  1612. var UserId = window.location.href.match(/\/(\d+)/)[1];
  1613. xdr.xget("http://api." + document.location.host + "/wot/account/tanks/?application_id=" + api_key + "&account_id=" + UserId, fixStatData);
  1614. }
  1615.  
  1616. function EffTooltip(ttype, tval, effsArr, allB, tAvgL, lang) {
  1617. var retStr = tval + " <font color='red'>/</font> <font color='green'>" + allB + "</font><br>",
  1618. tPval;
  1619. if (ttype === "damage") {
  1620. tPval = tval / allB * (10 / (tAvgL + 2)) * (0.23 + 2 * tAvgL / 100);
  1621. retStr += "<font color='" + CalcEffColor(effsArr[0], 'eff')[0] + "'>" + (tPval / effsArr[0] * 100).toFixed(2) + "%" + (lang === "ru" ? " от эффективности" : " of eff. rating") + " (" + tPval.toFixed(2) + ")</font><br>";
  1622. tPval = tval / allB * 530 / (184 * Math.pow(Math.E, 0.24 * tAvgL) + 130) + (6 - Math.min(tAvgL, 6)) * -60;
  1623. retStr += "<font color='" + CalcEffColor(effsArr[2], 'wn6')[0] + "'>" + (tPval / effsArr[2] * 100).toFixed(2) + "%" + (lang === "ru" ? " от рейтинга WN6" : " of WN6 rating") + " (" + tPval.toFixed(2) + ")</font>";
  1624. } else if (ttype === "frags") {
  1625. tPval = tval / allB * 250;
  1626. retStr += "<font color='" + CalcEffColor(effsArr[0], 'eff')[0] + "'>" + (tPval / effsArr[0] * 100).toFixed(2) + "%" + (lang === "ru" ? " от эффективности" : " of eff. rating") + " (" + tPval.toFixed(2) + ")</font><br>";
  1627. tPval = (1240 - 1040 / Math.pow(Math.min(tAvgL, 6), 0.164)) * tval / allB + (6 - Math.min(tAvgL, 6)) * -60;
  1628. retStr += "<font color='" + CalcEffColor(effsArr[2], 'wn6')[0] + "'>" + (tPval / effsArr[2] * 100).toFixed(2) + "%" + (lang === "ru" ? " от рейтинга WN6" : " of WN6 rating") + " (" + tPval.toFixed(2) + ")</font>";
  1629. } else if (ttype === "spotted") {
  1630. tPval = tval / allB * 150;
  1631. retStr += "<font color='" + CalcEffColor(effsArr[0], 'eff')[0] + "'>" + (tPval / effsArr[0] * 100).toFixed(2) + "%" + (lang === "ru" ? " от эффективности" : " of eff. rating") + " (" + tPval.toFixed(2) + ")</font><br>";
  1632. tPval = tval / allB * 125 + (6 - Math.min(tAvgL, 6)) * -60;
  1633. retStr += "<font color='" + CalcEffColor(effsArr[2], 'wn6')[0] + "'>" + (tPval / effsArr[2] * 100).toFixed(2) + "%" + (lang === "ru" ? " от рейтинга WN6" : " of WN6 rating") + " (" + tPval.toFixed(2) + ")</font>";
  1634. } else if (ttype === "caps") {
  1635. tPval = Math.log((tval / allB) + 1) / Math.log(1.732) * 150;
  1636. retStr += "<font color='" + CalcEffColor(effsArr[0], 'eff')[0] + "'>" + (tPval / effsArr[0] * 100).toFixed(2) + "%" + (lang === "ru" ? " от эффективности" : " of eff. rating") + " (" + tPval.toFixed(2) + ")</font><br>";
  1637. tPval = 0;
  1638. retStr += "<font color='" + CalcEffColor(effsArr[2], 'wn6')[0] + "'>" + (tPval / effsArr[2] * 100).toFixed(2) + "%" + (lang === "ru" ? " от рейтинга WN6" : " of WN6 rating") + " (" + tPval.toFixed(2) + ")</font>";
  1639. } else if (ttype === "defs") {
  1640. tPval = tval / allB * 150;
  1641. retStr += "<font color='" + CalcEffColor(effsArr[0], 'eff')[0] + "'>" + (tPval / effsArr[0] * 100).toFixed(2) + "%" + (lang === "ru" ? " от эффективности" : " of eff. rating") + " (" + tPval.toFixed(2) + ")</font><br>";
  1642. tPval = Math.min(tval / allB, 2.2) * 100 + (6 - Math.min(tAvgL, 6)) * -60;
  1643. retStr += "<font color='" + CalcEffColor(effsArr[2], 'wn6')[0] + "'>" + (tPval / effsArr[2] * 100).toFixed(2) + "%" + (lang === "ru" ? " от рейтинга WN6" : " of WN6 rating") + " (" + tPval.toFixed(2) + ")</font>";
  1644. }
  1645. return retStr;
  1646. }
  1647.  
  1648. function getNewScriptVersion(response) {
  1649. var regexp = /<b>Version:<\/b>[^0-9\.]+([0-9\.]+)[^0-9\.]+<\/p>/gi,
  1650. res = regexp.exec(response);
  1651. if (res.length > 0) {
  1652. if (res[1] !== scriptVersion)
  1653. popup(lang === "ru" ? "Вышла новая версия скрипта " + res[1] + ".<br>Пожалуйста, обновите скрипт." : "New script version " + res[1] + " enable.<br>Please upgrade script.", false, false);
  1654. var now = new Date();
  1655. var time = now.getTime();
  1656. time += 3600 * 6 * 1000;
  1657. now.setTime(time);
  1658. document.cookie = 'usScriptVer=' + res[1] + '; expires=' + now.toGMTString() + '; domain=.' + window.location.host.toString() + '; path=/ru/community/;';
  1659. }
  1660. }
  1661.  
  1662. function create_expanders(bA, lang, settings, NewBattles) {
  1663. //Добавляем фиктивные блоки для перемещения разделов
  1664. var spContent = document.getElementsByClassName("l-content")[0],
  1665. spDivFake = document.createElement('div');
  1666. spDivFake.setAttribute('style', 'display:none;');
  1667. spDivFake.setAttribute('div-cur-pos', 0);
  1668. spContent.appendChild(spDivFake);
  1669. spDivFake = document.createElement('div');
  1670. spDivFake.setAttribute('style', 'display:none;');
  1671. spDivFake.setAttribute('div-cur-pos', 1);
  1672.  
  1673. spContent.appendChild(spDivFake);
  1674. spDivFake = document.createElement('div');
  1675. spDivFake.setAttribute('style', 'display:none;');
  1676. spDivFake.setAttribute('div-cur-pos', 2);
  1677.  
  1678. spContent.appendChild(spDivFake);
  1679. spDivFake = document.createElement('div');
  1680. spDivFake.setAttribute('style', 'display:none;');
  1681. spDivFake.setAttribute('div-cur-pos', 3);
  1682.  
  1683. spContent.appendChild(spDivFake);
  1684. spDivFake = document.createElement('div');
  1685. spDivFake.setAttribute('style', 'display:none;');
  1686. spDivFake.setAttribute('div-cur-pos', 4);
  1687.  
  1688. spContent.appendChild(spDivFake);
  1689. spDivFake = document.createElement('div');
  1690. spDivFake.setAttribute('style', 'display:none;');
  1691. spDivFake.setAttribute('div-cur-pos', 5);
  1692.  
  1693. spContent.appendChild(spDivFake);
  1694. spDivFake = document.createElement('div');
  1695. spDivFake.setAttribute('style', 'display:none;');
  1696. spDivFake.setAttribute('div-cur-pos', 6);
  1697.  
  1698. spContent.appendChild(spDivFake);
  1699. spDivFake = document.createElement('div');
  1700. spDivFake.setAttribute('style', 'display:none;');
  1701. spDivFake.setAttribute('div-cur-pos', 7);
  1702.  
  1703. spContent.appendChild(spDivFake);
  1704. spDivFake = document.createElement('div');
  1705. spDivFake.setAttribute('style', 'display:none;');
  1706. spDivFake.setAttribute('div-cur-pos', 8);
  1707.  
  1708. spContent.appendChild(spDivFake);
  1709. spDivFake = document.createElement('div');
  1710. spDivFake.setAttribute('style', 'display:none;');
  1711. spDivFake.setAttribute('div-cur-pos', 9);
  1712.  
  1713. spContent.appendChild(spDivFake);
  1714. spDivFake = document.createElement('div');
  1715. spDivFake.setAttribute('style', 'display:none;');
  1716. spDivFake.setAttribute('div-cur-pos', 10);
  1717.  
  1718. spContent.appendChild(spDivFake);
  1719. //Перемещаем блок новых боев
  1720. var spMet = document.getElementsByClassName("b-user-block-new-battles")[0];
  1721. if (spMet && settings.newBat && settings.newBat[2]) {
  1722. spDivFake = document.querySelector('[div-cur-pos="' + settings.newBat[2] + '"]');
  1723. var spNewBlock = document.createElement('div');
  1724. spNewBlock.className="b-userblock-wrpr";
  1725. spNewBlock.setAttribute('style', 'margin: 0px;');
  1726. spContent.insertBefore(spNewBlock, spDivFake);
  1727. spNewBlock.appendChild(spMet.previousElementSibling);
  1728. spNewBlock.appendChild(spMet);
  1729. }
  1730. //Перемещаем блок рейтингов эффективности
  1731. var spMet = document.getElementsByClassName("b-user-block-eff-ratings")[0];
  1732. if (spMet && settings.efRat && settings.efRat[2]) {
  1733. spDivFake = document.querySelector('[div-cur-pos="' + settings.efRat[2] + '"]');
  1734. var spNewBlock = document.createElement('div');
  1735. spNewBlock.className="b-userblock-wrpr";
  1736. spNewBlock.setAttribute('style', 'margin: 0px;');
  1737. spContent.insertBefore(spNewBlock, spDivFake);
  1738. spNewBlock.appendChild(spMet.previousElementSibling);
  1739. spNewBlock.appendChild(spMet);
  1740. }
  1741. //Перемещаем блок сравнения статистики
  1742. var spMet = document.getElementsByClassName("b-user-block-compare-stat")[0];
  1743. if (spMet && settings.plComp && settings.plComp[2]) {
  1744. spDivFake = document.querySelector('[div-cur-pos="' + settings.plComp[2] + '"]');
  1745. var spNewBlock = document.createElement('div');
  1746. spNewBlock.className="b-userblock-wrpr";
  1747. spNewBlock.setAttribute('style', 'margin: 0px;');
  1748. spContent.insertBefore(spNewBlock, spDivFake);
  1749. spNewBlock.appendChild(spMet.previousElementSibling);
  1750. spNewBlock.appendChild(spMet);
  1751. }
  1752. //Добавляем раздел для сворачивания блока спидометров
  1753. var spMet = document.getElementsByClassName("b-user-block__sparks")[0],
  1754. spDiv = document.createElement('div'),
  1755. spA = document.createElement('a'),
  1756. spSp = document.createElement('span');
  1757. var blBool = settings.speed && (toFl(settings.speed[1]) !== 0 || toFl(settings.speed[0]) !== 0);
  1758. spSp.className = "b-fake-link";
  1759. spSp.innerHTML = blBool ? (lang === "ru" ? 'Развернуть блок спидометров' : 'Expand speedometers') : (lang === "ru" ? 'Свернуть блок спидометров' : 'Collapse speedometers');
  1760. spA.appendChild(spSp);
  1761. spA.className = "b-vertical-arrow sh-speedometr" + (blBool ? "" : " b-vertical-arrow__open");
  1762. spA.setAttribute('curSt', blBool ? 1 : 0);
  1763. spA.setAttribute('curStText', (lang === "ru" ? 'спидометров' : 'speedometers'));
  1764. spA.href = "#";
  1765. spDiv.appendChild(spA);
  1766. spDiv.setAttribute('style', 'text-align: right; margin-right: 15px;' + (blBool ? "padding-top: 10px; padding-bottom: 10px;" : ""));
  1767. if (settings.speed && settings.speed[2]) {
  1768. spDivFake = document.querySelector('[div-cur-pos="' + settings.speed[2] + '"]');
  1769. var spNewBlock = document.createElement('div');
  1770. spNewBlock.className="b-userblock-wrpr";
  1771. spNewBlock.setAttribute('style', 'margin: 0px;');
  1772. spContent.insertBefore(spNewBlock, spDivFake);
  1773. spNewBlock.appendChild(spDiv);
  1774. spNewBlock.appendChild(spMet);
  1775. } else
  1776. spMet.parentNode.insertBefore(spDiv, spMet);
  1777. if (settings.speed && toFl(settings.speed[1]) !== 0)
  1778. spDiv.setAttribute('style', 'display:none;');
  1779. if (blBool)
  1780. spDiv.nextElementSibling.setAttribute('style', 'display:none;');
  1781.  
  1782. //Добавляем раздел для сворачивания блока личных данных (показывается только себе)
  1783. var pLink = document.getElementsByClassName("b-personal-link")[0];
  1784.  
  1785. if (pLink) {
  1786. var plDiv = pLink.parentNode.parentNode,
  1787. spDiv1 = document.createElement('div'),
  1788. spA1 = document.createElement('a'),
  1789. spSp1 = document.createElement('span');
  1790. blBool = settings.pers && (toFl(settings.pers[1]) !== 0 || toFl(settings.pers[0]) !== 0);
  1791. spSp1.className = "b-fake-link";
  1792. spSp1.innerHTML = blBool ? (lang === "ru" ? 'Развернуть блок "Личные данные"' : 'Expand "Personal"') : (lang === "ru" ? 'Свернуть блок "Личные данные"' : 'Collapse "Personal"');
  1793. spA1.appendChild(spSp1);
  1794. spA1.className = "b-vertical-arrow sh-speedometr" + (blBool ? "" : " b-vertical-arrow__open");
  1795. spA1.setAttribute('curSt', blBool ? 1 : 0);
  1796. spA1.setAttribute('curStText', (lang === "ru" ? '"Личные данные"' : '"Personal"'));
  1797. spA1.href = "#";
  1798. spDiv1.appendChild(spA1);
  1799. spDiv1.setAttribute('style', 'text-align: right; margin-right: 15px;' + (blBool ? "padding-top: 10px; padding-bottom: 10px;" : ""));
  1800. if (settings.pers && settings.pers[2]) {
  1801. spDivFake = document.querySelector('[div-cur-pos="' + settings.pers[2] + '"]');
  1802. spNewBlock = document.createElement('div');
  1803. spNewBlock.className="b-userblock-wrpr";
  1804. spNewBlock.setAttribute('style', 'margin: 0px;');
  1805. spContent.insertBefore(spNewBlock, spDivFake);
  1806. spNewBlock.appendChild(spDiv1);
  1807. spNewBlock.appendChild(plDiv);
  1808. } else
  1809. plDiv.parentNode.insertBefore(spDiv1, plDiv);
  1810. if (settings.pers && toFl(settings.pers[1]) !== 0)
  1811. spDiv1.setAttribute('style', 'display:none;');
  1812. if (blBool)
  1813. spDiv1.nextElementSibling.setAttribute('style', 'display:none;');
  1814. }
  1815.  
  1816. //Добавляем раздел для сворачивания блока диаграмм
  1817. var spMet2 = document.getElementsByClassName("b-diagrams-sector")[0],
  1818. spDiv2 = document.createElement('div'),
  1819. spA2 = document.createElement('a'),
  1820. spSp2 = document.createElement('span');
  1821. blBool = settings.diagr && (toFl(settings.diagr[1]) !== 0 || toFl(settings.diagr[0]) !== 0);
  1822. spSp2.className = "b-fake-link";
  1823. spSp2.innerHTML = blBool ? (lang === "ru" ? 'Развернуть блок диаграм' : 'Expand diargams') : (lang === "ru" ? 'Свернуть блок диаграм' : 'Collapse diargams');
  1824. spA2.appendChild(spSp2);
  1825. spA2.className = "b-vertical-arrow sh-speedometr" + (blBool ? "" : " b-vertical-arrow__open");
  1826. spA2.setAttribute('curSt', blBool ? 1 : 0);
  1827. spA2.setAttribute('curStText', (lang === "ru" ? 'диаграм' : 'diargams'));
  1828. spA2.href = "#";
  1829. spDiv2.appendChild(spA2);
  1830. spDiv2.setAttribute('style', 'text-align: right; margin-right: 15px;' + (blBool ? "padding-top: 10px; padding-bottom: 10px;" : ""));
  1831. if (settings.diagr && settings.diagr[2]) {
  1832. spDivFake = document.querySelector('[div-cur-pos="' + settings.diagr[2] + '"]');
  1833. var spMet2prev = spMet2.nextElementSibling;
  1834. spContent.insertBefore(spDiv2, spDivFake);
  1835. spContent.insertBefore(spMet2, spDivFake);
  1836. spContent.insertBefore(spMet2prev, spDivFake);
  1837. } else
  1838. spMet2.parentNode.insertBefore(spDiv2, spMet2);
  1839. if (settings.diagr && toFl(settings.diagr[1]) !== 0)
  1840. spDiv2.setAttribute('style', 'display:none;');
  1841. if (blBool) {
  1842. spDiv2.nextElementSibling.setAttribute('style', 'display:none;');
  1843. spDiv2.nextElementSibling.nextElementSibling.setAttribute('style', 'display:none;');
  1844. }
  1845. //Добавляем раздел для сворачивания блока "Общее"
  1846. var spMet3 = document.getElementsByClassName("b-result-classes")[0].parentNode,
  1847. spDiv3 = document.createElement('div'),
  1848. spA3 = document.createElement('a'),
  1849. spSp3 = document.createElement('span');
  1850. blBool = settings.common && (toFl(settings.common[1]) !== 0 || toFl(settings.common[0]) !== 0);
  1851. spSp3.className = "b-fake-link";
  1852. spSp3.innerHTML = blBool ? (lang === "ru" ? 'Развернуть блок "Общее"' : 'Expand "Common"') : (lang === "ru" ? 'Свернуть блок "Общее"' : 'Collapse "Common"');
  1853. spA3.appendChild(spSp3);
  1854. spA3.className = "b-vertical-arrow sh-speedometr" + (blBool ? "" : " b-vertical-arrow__open");
  1855. spA3.setAttribute('curSt', blBool ? 1 : 0);
  1856. spA3.setAttribute('curStText', (lang === "ru" ? '"Общее"' : '"Common"'));
  1857. spA3.href = "#";
  1858. spDiv3.appendChild(spA3);
  1859. spDiv3.setAttribute('style', 'text-align: right; margin-right: 15px;' + (blBool ? "padding-top: 10px; padding-bottom: 10px;" : ""));
  1860. if (settings.common && settings.common[2]) {
  1861. spDivFake = document.querySelector('[div-cur-pos="' + settings.common[2] + '"]');
  1862. var spMet3prev = spMet3.nextElementSibling;
  1863. spContent.insertBefore(spDiv3, spDivFake);
  1864. spContent.insertBefore(spMet3, spDivFake);
  1865. spContent.insertBefore(spMet3prev, spDivFake);
  1866. } else
  1867. spMet3.parentNode.insertBefore(spDiv3, spMet3);
  1868. if (settings.common && toFl(settings.common[1]) !== 0)
  1869. spDiv3.setAttribute('style', 'display:none;');
  1870. if (blBool) {
  1871. spDiv3.nextElementSibling.setAttribute('style', 'display:none;');
  1872. spDiv3.nextElementSibling.nextElementSibling.setAttribute('style', 'display:none;');
  1873. }
  1874.  
  1875. //Добавляем раздел для сворачивания блока рейтингов
  1876. var spMet5 = document.getElementById("js-knockout-ratings"),
  1877. spDiv5 = document.createElement('div'),
  1878. spA5 = document.createElement('a'),
  1879. spSp5 = document.createElement('span');
  1880. blBool = settings.rat && (toFl(settings.rat[1]) !== 0 || toFl(settings.rat[0]) !== 0);
  1881. spSp5.className = "b-fake-link";
  1882. spSp5.innerHTML = blBool ? (lang === "ru" ? 'Развернуть блок "Рейтинги"' : 'Expand "Ratings"') : (lang === "ru" ? 'Свернуть блок "Рейтинги"' : 'Collapse "Ratings"');
  1883. spA5.appendChild(spSp5);
  1884. spA5.className = "b-vertical-arrow sh-speedometr" + (blBool ? "" : " b-vertical-arrow__open");
  1885. spA5.setAttribute('curSt', blBool ? 1 : 0);
  1886. spA5.setAttribute('curStText', (lang === "ru" ? '"Рейтинги"' : '"Ratings"'));
  1887. spA5.href = "#";
  1888. spDiv5.appendChild(spA5);
  1889. spDiv5.setAttribute('style', 'text-align: right; margin-right: 15px;' + (blBool ? "padding-top: 10px; padding-bottom: 10px;" : ""));
  1890. if (settings.rat && settings.rat[2]) {
  1891. spDivFake = document.querySelector('[div-cur-pos="' + settings.rat[2] + '"]');
  1892. var spMet5prev = spMet5.nextElementSibling;
  1893. spContent.insertBefore(spDiv5, spDivFake);
  1894. spContent.insertBefore(spMet5, spDivFake);
  1895. spContent.insertBefore(spMet5prev, spDivFake);
  1896. } else
  1897. spMet5.parentNode.insertBefore(spDiv5, spMet5);
  1898. if (settings.rat && toFl(settings.rat[1]) !== 0)
  1899. spDiv5.setAttribute('style', 'display:none;');
  1900. if (blBool) {
  1901. spDiv5.nextElementSibling.setAttribute('style', 'display:none;');
  1902. spDiv5.nextElementSibling.nextElementSibling.setAttribute('style', 'display:none;');
  1903. }
  1904.  
  1905. //Добавляем раздел для сворачивания блока техники
  1906. var spMet5 = document.getElementById("js-vehicle-details-template"),
  1907. spDiv5 = document.createElement('div'),
  1908. spA5 = document.createElement('a'),
  1909. spSp5 = document.createElement('span');
  1910. blBool = settings.veh && (toFl(settings.veh[1]) !== 0 || toFl(settings.veh[0]) !== 0);
  1911. spSp5.className = "b-fake-link";
  1912. spSp5.innerHTML = blBool ? (lang === "ru" ? 'Развернуть блок "Техника"' : 'Expand "Vehicles"') : (lang === "ru" ? 'Свернуть блок "Техника"' : 'Collapse "Vehicles"');
  1913. spA5.appendChild(spSp5);
  1914. spA5.className = "b-vertical-arrow sh-speedometr" + (blBool ? "" : " b-vertical-arrow__open");
  1915. spA5.setAttribute('curSt', blBool ? 1 : 0);
  1916. spA5.setAttribute('curStText', (lang === "ru" ? '"Техника"' : '"Vehicles"'));
  1917. spA5.href = "#";
  1918. spDiv5.appendChild(spA5);
  1919. spDiv5.setAttribute('style', 'text-align: right; margin-right: 15px;' + (blBool ? "padding-top: 10px; padding-bottom: 10px;" : ""));
  1920. if (settings.veh && settings.veh[2]) {
  1921. spDivFake = document.querySelector('[div-cur-pos="' + settings.veh[2] + '"]');
  1922. var spMet5prev = spMet5.nextElementSibling;
  1923. spContent.insertBefore(spDiv5, spDivFake);
  1924. spContent.insertBefore(spMet5.previousElementSibling, spDivFake);
  1925. spContent.insertBefore(spMet5, spDivFake);
  1926. spContent.insertBefore(spMet5prev, spDivFake);
  1927. } else
  1928. spMet5.parentNode.insertBefore(spDiv5, spMet5.previousElementSibling);
  1929. if (settings.veh && toFl(settings.veh[1]) !== 0)
  1930. spDiv5.setAttribute('style', 'display:none;');
  1931. var utanks = document.createElement('div');
  1932. utanks.innerHTML = "<a href='#' id='show-tanks-rating' style='padding-left:5px;'>Показать рейтинги танков</a>\
  1933. <div class='b-user-info clearfix'>\
  1934. <div class='b-user-block_left-column' id='bestTanksPR'></div>\
  1935. <div class='b-user-block_right-column' id='loseTanksPR'></div>\
  1936. <div class='b-user-block_left-column' id='bestTanksWN8'></div>\
  1937. <div class='b-user-block_right-column' id='loseTanksWN8'></div>\
  1938. </div>";
  1939. spMet5.parentNode.insertBefore(utanks, spMet5.nextElementSibling);
  1940. if (NewBattles) {
  1941. var onb = document.createElement('div');
  1942. onb.setAttribute('style', 'padding-top: 10px; padding-bottom: 10px; float:none;');
  1943. onb.innerHTML = "<input type='checkbox' name='new' id='js-nb-ch'> " + ((lang === "ru") ? "только новые бои" : "only new battles");
  1944. var sttab = document.getElementsByClassName("t-profile__vehicle")[0];
  1945. sttab.parentNode.insertBefore(onb, sttab);
  1946. }
  1947. if (blBool) {
  1948. spDiv5.nextElementSibling.setAttribute('style', 'display:none;');
  1949. spDiv5.nextElementSibling.nextElementSibling.nextElementSibling.setAttribute('style', 'display:none;');
  1950. spDiv5.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.setAttribute('style', 'display:none;');
  1951. if (NewBattles)
  1952. spDiv5.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.setAttribute('style', 'display:none;');
  1953. }
  1954.  
  1955. //Добавляем раздел для сворачивания блока достижений
  1956. var spMet6 = document.getElementsByClassName("js-all-achievements")[0],
  1957. spDiv6 = document.createElement('div'),
  1958. spA6 = document.createElement('a'),
  1959. spSp6 = document.createElement('span');
  1960. blBool = settings.achiev && (toFl(settings.achiev[1]) !== 0 || toFl(settings.achiev[0]) !== 0);
  1961. spSp6.className = "b-fake-link";
  1962. spSp6.innerHTML = blBool ? (lang === "ru" ? 'Развернуть блок "Достижения"' : 'Expand "Achievements"') : (lang === "ru" ? 'Свернуть блок "Достижения"' : 'Collapse "Achievements"');
  1963. spA6.appendChild(spSp6);
  1964. spA6.className = "b-vertical-arrow sh-speedometr" + (blBool ? "" : " b-vertical-arrow__open");
  1965. spA6.setAttribute('curSt', blBool ? 1 : 0);
  1966. spA6.setAttribute('curStText', (lang === "ru" ? '"Достижения"' : '"Achievements"'));
  1967. spA6.href = "#";
  1968. spDiv6.appendChild(spA6);
  1969. spDiv6.setAttribute('style', 'text-align: right; margin-right: 15px;' + (blBool ? "padding-top: 10px; padding-bottom: 10px;" : ""));
  1970. if (settings.achiev && settings.achiev[2]) {
  1971. spDivFake = document.querySelector('[div-cur-pos="' + settings.achiev[2] + '"]');
  1972. var spMet6prev = spMet6.nextElementSibling;
  1973. spContent.insertBefore(spDiv6, spDivFake);
  1974. spContent.insertBefore(spMet6, spDivFake);
  1975. spContent.insertBefore(spMet6prev, spDivFake);
  1976. } else
  1977. spMet6.parentNode.insertBefore(spDiv6, spMet6);
  1978. if (settings.achiev && toFl(settings.achiev[1]) !== 0)
  1979. spDiv6.setAttribute('style', 'display:none;');
  1980. if (blBool) {
  1981. spDiv6.nextElementSibling.setAttribute('style', 'display:none;');
  1982. spDiv6.nextElementSibling.nextElementSibling.setAttribute('style', 'display:none;');
  1983. }
  1984.  
  1985. //Добавляем раздел для сворачивания блока аллеи славы (показывается не у всех)
  1986. var spMet7 = document.getElementById("js-knockout-fame-points"),
  1987. spDiv7 = document.createElement('div'),
  1988. spA7 = document.createElement('a'),
  1989. spSp7 = document.createElement('span'),
  1990. curStVer = 1;
  1991. if (typeof(spMet7) == 'undefined' || spMet7 == null) {
  1992. spMet7 = document.getElementsByClassName("b-fame-message")[0];
  1993. if (typeof(spMet7) != 'undefined' && spMet7 != null)
  1994. spMet7 = spMet7.parentNode;
  1995. curStVer = 2;
  1996. }
  1997. if (typeof(spMet7) != 'undefined' && spMet7 != null) {
  1998. blBool = settings.fame && (toFl(settings.fame[1]) !== 0 || toFl(settings.fame[0]) !== 0);
  1999. spSp7.className = "b-fake-link";
  2000. spSp7.innerHTML = blBool ? (lang === "ru" ? 'Развернуть блок "Аллея славы"' : 'Expand "Hall of Fame"') : (lang === "ru" ? 'Свернуть блок "Аллея славы"' : 'Collapse "Hall of fame"');
  2001. spA7.appendChild(spSp7);
  2002. spA7.className = "b-vertical-arrow sh-speedometr" + (blBool ? "" : " b-vertical-arrow__open");
  2003. spA7.setAttribute('curSt', blBool ? 1 : 0);
  2004. spA7.setAttribute('curStText', (lang === "ru" ? '"Аллея славы"' : '"Hall of fame"'));
  2005. spA7.setAttribute('curStVer', curStVer);
  2006. spA7.href = "#";
  2007. spDiv7.appendChild(spA7);
  2008. spDiv7.setAttribute('style', 'text-align: right; margin-right: 15px;' + (blBool ? "padding-top: 10px; padding-bottom: 10px;" : ""));
  2009. if (settings.fame && settings.fame[2] && curStVer === 1) {
  2010. spDivFake = document.querySelector('[div-cur-pos="' + settings.fame[2] + '"]');
  2011. var spMet7prev = spMet7.nextElementSibling.nextElementSibling.nextElementSibling;
  2012. spContent.insertBefore(spDiv7, spDivFake);
  2013. spContent.insertBefore(spMet7.previousElementSibling, spDivFake);
  2014. spContent.insertBefore(spMet7, spDivFake);
  2015. spContent.insertBefore(spMet7prev, spDivFake);
  2016. } else if (settings.fame && settings.fame[2] && curStVer === 2) {
  2017. spDivFake = document.querySelector('[div-cur-pos="' + settings.fame[2] + '"]');
  2018. var spMet7prev = spMet7.nextElementSibling;
  2019. spContent.insertBefore(spDiv7, spDivFake);
  2020. spContent.insertBefore(spMet7, spDivFake);
  2021. spContent.insertBefore(spMet7prev, spDivFake);
  2022. } else if (curStVer === 1) {
  2023. spMet7.parentNode.insertBefore(spDiv7, spMet7.previousElementSibling);
  2024. } else if (curStVer === 2) {
  2025. spMet7.parentNode.insertBefore(spDiv7, spMet7);
  2026. }
  2027. if (settings.fame && toFl(settings.fame[1]) !== 0)
  2028. spDiv7.setAttribute('style', 'display:none;');
  2029. if (blBool) {
  2030. spDiv7.nextElementSibling.setAttribute('style', 'display:none;');
  2031. if (curStVer === 1) {
  2032. spDiv7.nextElementSibling.nextElementSibling.setAttribute('style', 'display:none;');
  2033. spDiv7.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.setAttribute('style', 'display:none;');
  2034. }
  2035. if (curStVer === 2)
  2036. spDiv7.nextElementSibling.nextElementSibling.setAttribute('style', 'display:none;');
  2037. }
  2038. }
  2039. if (settings.compare/* && window.location.href.indexOf(settings.UserID) === -1*/) {
  2040. var fake_div = document.createElement("div");
  2041. fake_div.innerHTML = "<li><a onclick='WriteCompareStat();' style='cursor: pointer;'>" + ((lang === "ru") ? 'Обновить "мои" данные' : 'Refresh "my" stat.') + "</a></li>";
  2042. document.getElementsByClassName("b-context-menu-list__bottomindent")[0].appendChild(fake_div);
  2043. }
  2044.  
  2045. var script = document.createElement("script");
  2046. script.type = "text/javascript";
  2047. script.textContent = "function popup(message, autoHide, autoReload) {\
  2048. var maskHeight = $(document).height();\
  2049. var maskWidth = $(window).width();\
  2050. var dialogTop = (maskHeight / 3) - ($('#dialog-box').height());\
  2051. var dialogLeft = (maskWidth / 2) - ($('#dialog-box').width() / 2);\
  2052. $('#dialog-overlay').css({\
  2053. height: maskHeight,\
  2054. width: maskWidth\
  2055. }).show();\
  2056. $('#dialog-box').show();\
  2057. $('#dialog-message').html(message);\
  2058. if (autoHide)\
  2059. setTimeout(function() {\
  2060. $('#dialog-overlay, #dialog-box').hide();\
  2061. }, 2000);\
  2062. if (autoReload)\
  2063. setTimeout(function() {\
  2064. window.location.reload();\
  2065. }, 2000);\
  2066. }\
  2067. jQuery(document).ready(function() {\
  2068. function bestUserTanks() {\
  2069. var tanksArr = [],\
  2070. tanksArrwn8 = [],\
  2071. c;\
  2072. $('.t-profile_tankstype__item').each(function() {\
  2073. var tName = $(this).children()[0].getElementsByClassName('b-name-vehicle')[0].innerHTML,\
  2074. prRat = $(this).attr('PR');\
  2075. wn8 = $(this).attr('WN8');\
  2076. tanksArr.push({\
  2077. 'name': tName,\
  2078. 'pr': prRat\
  2079. });\
  2080. tanksArrwn8.push({\
  2081. 'name': tName,\
  2082. 'wn8': wn8\
  2083. });\
  2084. });\
  2085. for (var i = 0; i < tanksArr.length; i++)\
  2086. for (var j = i; j < tanksArr.length; j++)\
  2087. if (parseFloat(tanksArr[i].pr) < parseFloat(tanksArr[j].pr)) {\
  2088. c = tanksArr[i];\
  2089. tanksArr[i] = tanksArr[j];\
  2090. tanksArr[j] = c;\
  2091. }\
  2092. for (var i = 0; i < tanksArrwn8.length; i++)\
  2093. for (var j = i; j < tanksArrwn8.length; j++)\
  2094. if (parseFloat(tanksArrwn8[i].wn8) < parseFloat(tanksArrwn8[j].wn8)) {\
  2095. c = tanksArrwn8[i];\
  2096. tanksArrwn8[i] = tanksArrwn8[j];\
  2097. tanksArrwn8[j] = c;\
  2098. }\
  2099. var bText = '<h3>Лучшие танки игрока (PR)</h3><ul>',\
  2100. lText = '<h3>Худшие танки игрока (PR)</h3><ul>';\
  2101. for (var i = 0; i < 5; i++) {\
  2102. bText += '<li style=\"color: #' + CalcEffColor(parseFloat(tanksArr[i].pr), 'pr')[0] + ';\">' + (i + 1) + '. ' + tanksArr[i].name + ' - ' + tanksArr[i].pr + '</li>';\
  2103. lText += '<li style=\"color: #' + CalcEffColor(parseFloat(tanksArr[tanksArr.length - 1 - i].pr), 'pr')[0] + ';\">' + (tanksArr.length - 1 - i) + '. ' + tanksArr[tanksArr.length - 1 - i].name + ' - ' + tanksArr[tanksArr.length - 1 - i].pr + '</li>';\
  2104. }\
  2105. bText += '</ul><br>';\
  2106. lText += '</ul><br>';\
  2107. $('#bestTanksPR').html(bText);\
  2108. $('#loseTanksPR').html(lText);\
  2109. var bText = '<h3>Лучшие танки игрока (WN8)</h3><ul>',\
  2110. lText = '<h3>Худшие танки игрока (WN8)</h3><ul>';\
  2111. for (var i = 0; i < 5; i++) {\
  2112. bText += '<li style=\"color: #' + CalcEffColor(parseFloat(tanksArrwn8[i].wn8), 'wn8')[0] + ';\">' + (i + 1) + '. ' + tanksArrwn8[i].name + ' - ' + parseFloat(tanksArrwn8[i].wn8).toFixed(2) + '</li>';\
  2113. lText += '<li style=\"color: #' + CalcEffColor(parseFloat(tanksArrwn8[tanksArrwn8.length - 1 - i].wn8), 'wn8')[0] + ';\">' + (tanksArrwn8.length - 1 - i) + '. ' + tanksArrwn8[tanksArrwn8.length - 1 - i].name + ' - ' + parseFloat(tanksArrwn8[tanksArrwn8.length - 1 - i].wn8).toFixed(2) + '</li>';\
  2114. }\
  2115. bText += '</ul><br>';\
  2116. lText += '</ul><br>';\
  2117. $('#bestTanksWN8').html(bText);\
  2118. $('#loseTanksWN8').html(lText);\
  2119. }\
  2120. $('.t-profile_tankstype__item').click(function() {\
  2121. var me = this;\
  2122. function tankPRRating() {\
  2123. if(!!$(me).attr('PR')) {\
  2124. if ($($(me).next().children()[0]).find('.us-pr-trating').length === 0) {\
  2125. $($(me).next().children()[0]).prepend('<div style=\"float:left;width:33%; text-align: center;\"><h3 class=\"us-pr-trating\"></h3></div>')\
  2126. }\
  2127. $($(me).next().children()[0]).find('.us-pr-trating').attr('style', 'text-align: center; color: #' + CalcEffColor($(me).attr('PR'), 'pr')[0] + ';'); \
  2128. $($(me).next().children()[0]).find('.us-pr-trating').html('Рейтинг нагиба: ' + parseInt($(me).attr('PR'))); \
  2129. $($(me).next().children()[0]).find('.us-pr-trating').attr('pr', $(me).attr('PR'));\
  2130. }\
  2131. }\
  2132. function tankWN8Rating() {\
  2133. if(!!$(me).attr('WN8')) {\
  2134. if ($($(me).next().children()[0]).find('.us-wn8-trating').length === 0) {\
  2135. $($(me).next().children()[0]).prepend('<div style=\"float:left;width:33%; text-align: center;\"><h3 class=\"us-wn8-trating\"></h3></div>')\
  2136. }\
  2137. $($(me).next().children()[0]).find('.us-wn8-trating').attr('style', 'text-align: center; color: #' + CalcEffColor($(me).attr('WN8'), 'wn8')[0] + ';'); \
  2138. $($(me).next().children()[0]).find('.us-wn8-trating').html('WN8 Рейтинг: ' + parseInt($(me).attr('WN8'))); \
  2139. $($(me).next().children()[0]).find('.us-wn8-trating').attr('wn8', $(me).attr('WN8'));\
  2140. }\
  2141. }\
  2142. setTimeout(tankPRRating, 1000);\
  2143. setTimeout(tankWN8Rating, 1000);\
  2144. });\
  2145. $('#show-tanks-rating').click(function(event) {\
  2146. event.preventDefault();\
  2147. bestUserTanks();\
  2148. });\
  2149. $('a.btn-ok, #dialog-overlay, #dialog-box').click(function() {\
  2150. $('#dialog-overlay, #dialog-box').hide();\
  2151. return false;\
  2152. });\
  2153. $(window).resize(function() {\
  2154. if (!$('#dialog-box').is(':hidden')) popup();\
  2155. });\
  2156. $('.sh-speedometr').click(function(event) {\
  2157. event.preventDefault();\
  2158. if ($(this).attr('curStText') === '\"Достижения\"' || $(this).attr('curStText') === '\"Achievements\"') {\
  2159. var achDiv = $('.js-all-achievements');\
  2160. if (parseInt($(this).attr('curSt')) === 0) {\
  2161. achDiv.slideUp('slow');\
  2162. $(this).attr('curSt', 1);\
  2163. $(this).removeClass('b-vertical-arrow__open');\
  2164. $(this).children()[0].innerHTML = (document.title.indexOf('Профиль игрока') > -1 ? 'Развернуть блок ' : 'Expand ') + $(this).attr('curStText');\
  2165. $(this).parent().css('padding-top', '10px');\
  2166. $(this).parent().css('padding-bottom', '10px');\
  2167. $(this).parent().prev().hide();\
  2168. $(this).parent().next().next().hide();\
  2169. } else {\
  2170. achDiv.slideDown('slow');\
  2171. $(this).attr('curSt', 0);\
  2172. $(this).addClass('b-vertical-arrow__open');\
  2173. $(this).children()[0].innerHTML = (document.title.indexOf('Профиль игрока') > -1 ? 'Свернуть блок ' : 'Collapse ') + $(this).attr('curStText');\
  2174. $(this).parent().css('padding-top', '0');\
  2175. $(this).parent().css('padding-bottom', '0');\
  2176. $(this).parent().prev().show();\
  2177. $(this).parent().next().next().show();\
  2178. }\
  2179. } else {\
  2180. if (parseInt($(this).attr('curSt')) === 0) {\
  2181. if ($(this).attr('curStText') === '\"Общее\"' || $(this).attr('curStText') === 'диаграм' || $(this).attr('curStText') === '\"Common\"' || $(this).attr('curStText') === 'diargams')\
  2182. $(this).parent().next().next().hide();\
  2183. $(this).parent().css('padding-top', '10px');\
  2184. $(this).parent().css('padding-bottom', '10px');\
  2185. if ($(this).attr('curStText') === '\"Рейтинги\"' || $(this).attr('curStText') === '\"Ratings\"') {\
  2186. $(this).parent().next().next().hide();\
  2187. }\
  2188. if ($(this).attr('curStText') === '\"Техника\"') {\
  2189. $(this).parent().next().next().next().hide();\
  2190. $(this).parent().next().next().next().next().hide();\
  2191. $(this).parent().next().next().next().next().next().slideUp('slow');\
  2192. }\
  2193. if ($(this).attr('curStText') === '\"Vehicles\"') {\
  2194. $(this).parent().prev().hide();\
  2195. $(this).parent().prev().prev().hide();\
  2196. }\
  2197. if ($(this).attr('curStText') === '\"Аллея славы\"' && $(this).attr('curStVer') === '1') {\
  2198. $(this).parent().next().next().slideUp('slow');\
  2199. $(this).parent().next().next().next().hide();\
  2200. $(this).parent().next().next().next().next().hide();\
  2201. }\
  2202. if ($(this).attr('curStText') === '\"Аллея славы\"' && $(this).attr('curStVer') === '2') {\
  2203. $(this).parent().next().next().slideUp('slow');\
  2204. }\
  2205. $(this).parent().next().slideUp('slow');\
  2206. $(this).attr('curSt', 1);\
  2207. $(this).removeClass('b-vertical-arrow__open');\
  2208. $(this).children()[0].innerHTML = (document.title.indexOf('Профиль игрока') > -1 ? 'Развернуть блок ' : 'Expand ') + $(this).attr('curStText');\
  2209. } else {\
  2210. if ($(this).attr('curStText') === '\"Общее\"' || $(this).attr('curStText') === 'диаграм' || $(this).attr('curStText') === '\"Common\"' || $(this).attr('curStText') === 'diargams')\
  2211. $(this).parent().next().next().show();\
  2212. $(this).parent().css('padding-top', '0');\
  2213. $(this).parent().css('padding-bottom', '0');\
  2214. if ($(this).attr('curStText') === '\"Рейтинги\"' || $(this).attr('curStText') === '\"Ratings\"') {\
  2215. $(this).parent().next().next().show();\
  2216. }\
  2217. if ($(this).attr('curStText') === '\"Техника\"') {\
  2218. $(this).parent().next().next().next().show();\
  2219. $(this).parent().next().next().next().next().show();\
  2220. $(this).parent().next().next().next().next().next().slideDown('slow');\
  2221. }\
  2222. if ($(this).attr('curStText') === '\"Vehicles\"') {\
  2223. $(this).parent().prev().show();\
  2224. $(this).parent().prev().prev().show();\
  2225. }\
  2226. if ($(this).attr('curStText') === '\"Аллея славы\"' && $(this).attr('curStVer') === '1') {\
  2227. $(this).parent().next().next().slideDown('slow');\
  2228. $(this).parent().next().next().next().show();\
  2229. $(this).parent().next().next().next().next().show();\
  2230. }\
  2231. if ($(this).attr('curStText') === '\"Аллея славы\"' && $(this).attr('curStVer') === '2') {\
  2232. $(this).parent().next().next().slideDown('slow');\
  2233. }\
  2234. $(this).parent().next().slideDown('slow');\
  2235. $(this).attr('curSt', 0);\
  2236. $(this).addClass('b-vertical-arrow__open');\
  2237. $(this).children()[0].innerHTML = (document.title.indexOf('Профиль игрока') > -1 ? 'Свернуть блок ' : 'Collapse ') + $(this).attr('curStText');\
  2238. }\
  2239. }\
  2240. });\
  2241. $('#autor-pay').click(function(event) {\
  2242. event.preventDefault();\
  2243. if ($(this).hasClass('b-vertical-arrow__open')) {\
  2244. $(this).removeClass('b-vertical-arrow__open');\
  2245. $('.Untext').slideUp();\
  2246. } else {\
  2247. $(this).addClass('b-vertical-arrow__open');\
  2248. $('.Untext').slideDown();\
  2249. }\
  2250. });\
  2251. $('.settings-row').click(function(event) {\
  2252. event.preventDefault();\
  2253. if ($(this).hasClass('b-vertical-arrow__open')) {\
  2254. $(this).parent().parent().parent().attr('cur-pos', parseInt($(this).parent().parent().parent().attr('cur-pos')) - 1);\
  2255. $(this).parent().parent().parent().prev().attr('cur-pos', parseInt($(this).parent().parent().parent().attr('cur-pos')) + 1);\
  2256. } else {\
  2257. $(this).parent().parent().parent().attr('cur-pos', parseInt($(this).parent().parent().parent().attr('cur-pos')) + 1);\
  2258. $(this).parent().parent().parent().next().attr('cur-pos', parseInt($(this).parent().parent().parent().attr('cur-pos')) - 1);\
  2259. }\
  2260. FormatUsSetTable();\
  2261. });\
  2262. $('#js-nb-ch').change(function() {\
  2263. if ($(this).is(':checked')) {\
  2264. $('.js-tank-head-row').hide();\
  2265. $('.js-tank-row').hide();\
  2266. $('.js-nb-tank-row').show();\
  2267. } else {\
  2268. $('.js-tank-head-row').show();\
  2269. $('.js-tank-row').show()\
  2270. }\
  2271. });\
  2272. $('.us-close-settings').click(function(event) {\
  2273. event.preventDefault();\
  2274. $('#us-settings-overlay').hide();\
  2275. $('#us-settings-block').hide();\
  2276. });\
  2277. $('#us-settings-a').click(function(event) {\
  2278. event.preventDefault();\
  2279. $('#us-settings-overlay').show();\
  2280. $('#us-settings-block').show();\
  2281. });\
  2282. $('#us-settings-current-page').change(function(event) {\
  2283. event.preventDefault();\
  2284. if ($(this).is(':checked')) {\
  2285. $('#us-settings-compare-page').val(window.location.href)\
  2286. } else {\
  2287. $('#us-settings-compare-page').val('');\
  2288. }\
  2289. });\
  2290. $('#us-settings-compare').change(function(event) {\
  2291. if ($(this).is(':checked')) {\
  2292. $('#us-my-compare-block').show()\
  2293. } else {\
  2294. $('#us-my-compare-block').hide()\
  2295. }\
  2296. });\
  2297. $('#us-settings-save').click(function(event) {\
  2298. event.preventDefault();\
  2299. var uBls = $('.us-set-block'),\
  2300. saveC = '';\
  2301. for (var i = 0; i < uBls.length; i++) {\
  2302. saveC += uBls[i].getAttribute('btype') + ';' + (uBls[i].cells[1].getElementsByTagName('input')[0].checked ? '1' : '0') + ';' + (uBls[i].cells[2].getElementsByTagName('input')[0].checked ? '1' : '0') + ';' + i + '/';\
  2303. }\
  2304. var padr = $('#us-settings-compare-page').val(),\
  2305. cmpD = $('#us-settings-compare')[0].checked;\
  2306. if (!padr) padr = 'x';\
  2307. if (cmpD && padr.length === 0) return false;\
  2308. saveC += '|';\
  2309. saveC += (cmpD ? '1' : '0') + ';' + padr;\
  2310. var gtype = $('input[name=gtype]:checked').val();\
  2311. saveC += '|';\
  2312. saveC += gtype;\
  2313. saveC += '|';\
  2314. $('.us_st_name').each(function() {\
  2315. saveC += $(this).attr('uid') + ';' + $(this).val() + '/';\
  2316. });\
  2317. SetLSData('usSettings', saveC, '01-Jan-2031 00:00:00 GMT');\
  2318. $('#us-settings-overlay').hide();\
  2319. $('#us-settings-block').hide();\
  2320. window.location.reload();\
  2321. });\
  2322. $('.us-show-medals').click(function(event) {\
  2323. event.preventDefault();\
  2324. if ($(this).hasClass('b-vertical-arrow__open')) {\
  2325. $(this).removeClass('b-vertical-arrow__open');\
  2326. $(this).parent().next().slideUp('slow');\
  2327. } else {\
  2328. $(this).addClass('b-vertical-arrow__open');\
  2329. $(this).parent().next().slideDown('slow');\
  2330. }\
  2331. });\
  2332. $('#WriteStat').click(function(event) {\
  2333. event.preventDefault();\
  2334. WriteStat();\
  2335. });\
  2336. $('input[name=ggtype]').change(function(event) {\
  2337. var gtype = $('input[name=ggtype]:checked').val();\
  2338. $('div[gtype=bat]').show();\
  2339. $('div[gtype=date]').show();\
  2340. if (gtype === 'bat') $('div[gtype=date]').hide();\
  2341. if (gtype === 'date') $('div[gtype=bat]').hide();\
  2342. });\
  2343. $('.us-remove-stat').click(function(event) {\
  2344. event.preventDefault();\
  2345. if (confirm('Вы действительно хотите удалить сохраненную статистику данного игрока?')) {\
  2346. var uid = $(this).attr('uid');\
  2347. for (var i = 0; i < 8; i++) {\
  2348. localStorage.removeItem('daystat_' + uid + '_' + i)\
  2349. }\
  2350. window.location.reload();\
  2351. }\
  2352. });\
  2353. $('#g" + settings.gtype + "').click(); " + "$('div[gtype=bat]').show(); $('div[gtype=date]').show(); var ggtype = '" + settings.gtype + "'; if (ggtype === 'bat') $('div[gtype=date]').hide(); if (ggtype === 'date') $('div[gtype=bat]').hide();\
  2354. });";
  2355. document.body.appendChild(script);
  2356. }
  2357.  
  2358. function setup_script(script_name) {
  2359. var script = document.createElement("script");
  2360. script.type = "text/javascript";
  2361. script.textContent = script_name.toString();
  2362. document.body.appendChild(script);
  2363. }
  2364.  
  2365. function CalcAvgLev(tanksarr) {
  2366. var avgL = 0,
  2367. totalB = 0,
  2368. tnaSum = 0,
  2369. expDmg = 0,
  2370. expSpot = 0,
  2371. expFrag = 0,
  2372. expDef = 0,
  2373. expWinRate = 0,
  2374. tanks = document.getElementsByClassName("t-profile_tankstype__item"),
  2375. tbcount,
  2376. tlev,
  2377. imgName,
  2378. tank_Id,
  2379. tankLevs = {
  2380. "I": 1,
  2381. "II": 2,
  2382. "III": 3,
  2383. "IV": 4,
  2384. "V": 5,
  2385. "VI": 6,
  2386. "VII": 7,
  2387. "VIII": 8,
  2388. "IX": 9,
  2389. "X": 10
  2390. };
  2391. var nominalDamage = GetLSData("nominalDamage"),
  2392. wn8Data = GetLSData("WN8Data"),
  2393. nominalDamageArr = [], wn8DataArr = [], tankid, nArr;
  2394. if (nominalDamage) {
  2395. nominalDamage = eval(nominalDamage);
  2396. for (i = 0; i < nominalDamage.length; i++) {
  2397. if (nominalDamage[i].nominalDamage)
  2398. nominalDamageArr[(nominalDamage[i].id).toLowerCase()] = [
  2399. nominalDamage[i].nominalDamage * 1
  2400. ];
  2401. }
  2402. } else {
  2403. xdr.xget("http://www.noobmeter.com/tankListJson/elfx_133054", savenominalDamage);
  2404. }
  2405. if (wn8Data) {
  2406. eval("var allwn8Data =" + wn8Data);
  2407. for (var key = 0; key < allwn8Data.data.length; key++) {
  2408. t = allwn8Data.data[key];
  2409. wn8DataArr[parseInt(t.IDNum)] = [t.expDamage / 1, t.expSpot / 1, t.expFrag / 1, t.expDef / 1, (t.expWinRate / 100).toFixed(4)];
  2410. }
  2411. } else {
  2412. xdr.xget("http://www.wnefficiency.net/exp/expected_tank_values_latest.json", saveWN8Data);
  2413. }
  2414. for (var i = 0; i < tanks.length; i++) {
  2415. imgName = (tanks[i].cells[0].getElementsByTagName('img')[0].src.match(/\/[^-]+-([^\/]*)\.png/)[1]).toLowerCase();
  2416. tank_Id = parseInt(tanks[i].nextElementSibling.getAttribute('data-vehicle-cd'));
  2417. if (tanksarr.indexOf(imgName) === -1)
  2418. tanksarr[imgName] = {};
  2419. tbcount = toFl(tanks[i].cells[1].innerHTML);
  2420. if (nominalDamageArr[imgName]) {
  2421. if (nominalDamageArr[imgName][0]) tnaSum += tbcount * nominalDamageArr[imgName][0];
  2422. }
  2423. if (wn8DataArr[tank_Id]) {
  2424. expDmg += tbcount * wn8DataArr[tank_Id][0];
  2425. expSpot += tbcount * wn8DataArr[tank_Id][1];
  2426. expFrag += tbcount * wn8DataArr[tank_Id][2];
  2427. expDef += tbcount * wn8DataArr[tank_Id][3];
  2428. expWinRate += tbcount * wn8DataArr[tank_Id][4];
  2429. }
  2430. tlev = tankLevs[tanks[i].cells[0].getElementsByTagName('div')[0].getElementsByTagName('span')[0].innerHTML];
  2431. tanksarr[imgName]['tId'] = tank_Id;
  2432. tanksarr[imgName]['tlev'] = tlev;
  2433. tanksarr[imgName]['img'] = tanks[i].cells[0].getElementsByTagName('img')[0].src;
  2434. tanksarr[imgName]['name'] = tanks[i].cells[0].getElementsByClassName('b-name-vehicle')[0].innerHTML;
  2435. var tcl = tanks[i].parentNode.previousElementSibling.getElementsByTagName('span')[0].getAttribute('class');
  2436.  
  2437. tanksarr[imgName]['bcount'] = tbcount;
  2438.  
  2439. if (tcl.indexOf('lighttank') !== -1) {
  2440. tanksarr[imgName]['ttype'] = 'ЛТ';
  2441. }
  2442.  
  2443. if (tcl.indexOf('mediumtank') !== -1) {
  2444. tanksarr[imgName]['ttype'] = 'СТ';
  2445. }
  2446.  
  2447. if (tcl.indexOf('heavytank') !== -1) {
  2448. tanksarr[imgName]['ttype'] = 'ТТ';
  2449. }
  2450.  
  2451. if (tcl.indexOf('at-spg') !== -1) {
  2452. tanksarr[imgName]['ttype'] = 'ПТ';
  2453. }
  2454.  
  2455. if (tcl.indexOf('_spg') !== -1) {
  2456. tanksarr[imgName]['ttype'] = 'САУ';
  2457. }
  2458.  
  2459. totalB += tbcount;
  2460. avgL += tlev * tbcount;
  2461. }
  2462. return [avgL / totalB, tnaSum, expDmg, expSpot, expFrag, expDef, expWinRate, totalB];
  2463. }
  2464. function CalcCompareAvgLev(comparedayArray) {
  2465. var tnaSum = 0,
  2466. expDmg = 0,
  2467. expSpot = 0,
  2468. expFrag = 0,
  2469. expDef = 0,
  2470. expWinRate = 0,
  2471. wn8Data = GetLSData("WN8Data"),
  2472. wn8DataArr = [],
  2473. totalB = 0;
  2474. if (wn8Data) {
  2475. eval("var allwn8Data =" + wn8Data);
  2476. for (var key = 0; key < allwn8Data.data.length; key++) {
  2477. t = allwn8Data.data[key];
  2478. wn8DataArr[parseInt(t.IDNum)] = [t.expDamage / 1, t.expSpot / 1, t.expFrag / 1, t.expDef / 1, (t.expWinRate / 100).toFixed(4)];
  2479. }
  2480. } else {
  2481. xdr.xget("http://www.wnefficiency.net/exp/expected_tank_values_latest.json", saveWN8Data);
  2482. }
  2483. for (var i = 0; i < Object.keys(comparedayArray).length; i++) {
  2484. var tank = Object.keys(comparedayArray)[i],
  2485. tankid = comparedayArray[tank].id,
  2486. tank_battles = comparedayArray[tank].b;
  2487. totalB += tank_battles;
  2488. if (wn8DataArr[tankid]) {
  2489. expDmg += tank_battles * wn8DataArr[tankid][0];
  2490. expSpot += tank_battles * wn8DataArr[tankid][1];
  2491. expFrag += tank_battles * wn8DataArr[tankid][2];
  2492. expDef += tank_battles * wn8DataArr[tankid][3];
  2493. expWinRate += tank_battles * wn8DataArr[tankid][4];
  2494. }
  2495.  
  2496. }
  2497.  
  2498. return [expDmg, expSpot, expFrag, expDef, expWinRate, totalB];
  2499. }
  2500.  
  2501. function CalcgOldAvgLev(ds) {
  2502. var avgL = 0,
  2503. totalB = 0,
  2504. tanks = document.getElementsByClassName("t-profile_tankstype__item"),
  2505. tbcount,
  2506. twcount,
  2507. tlev,
  2508. imgName,
  2509. tankLevs = {
  2510. "I": 1,
  2511. "II": 2,
  2512. "III": 3,
  2513. "IV": 4,
  2514. "V": 5,
  2515. "VI": 6,
  2516. "VII": 7,
  2517. "VIII": 8,
  2518. "IX": 9,
  2519. "X": 10
  2520. };
  2521. for (i = 0; i < tanks.length; i++) {
  2522. imgName = tanks[i].cells[0].getElementsByTagName('img')[0].src.match(/\/[^-]+-([^\/]*)\.png/)[1];
  2523. if (ds[imgName]) {
  2524. tbcount = toFl(ds[imgName].b);
  2525. twcount = toFl(ds[imgName].w);
  2526. } else {
  2527. tbcount = 0;
  2528. twcount = 0;
  2529. }
  2530. tlev = tankLevs[tanks[i].cells[0].getElementsByTagName('div')[0].getElementsByTagName('span')[0].innerHTML];
  2531. totalB += tbcount;
  2532. avgL += tlev * tbcount;
  2533.  
  2534. }
  2535. return [avgL / totalB];
  2536. }
  2537.  
  2538. function FoundProc(Wins, Battles) {
  2539. nextD3 = Math.ceil(Wins / Battles * 100 + 0.5) - 0.5;
  2540. nextD1 = nextD3 - 1;
  2541. nextD2 = nextD3 - 0.5;
  2542. need_b1 = Math.floor(Battles - Wins * 100 / nextD1);
  2543. if (100 * Wins / Battles > nextD2)
  2544. need_b2 = Math.floor(Battles - Wins * 100 / nextD2);
  2545. else
  2546. need_b2 = Math.ceil((nextD2 * Battles - Wins * 100) / (100 - nextD2));
  2547. need_b3 = Math.ceil((nextD3 * Battles - Wins * 100) / (100 - nextD3));
  2548. return Wins + "<font color='red'>/</font> <font color='green'>" + Battles + "</font><br>" + nextD1 + "% (" + need_b1 + ")<br>" + nextD2 + "% (" + need_b2 + ")<br>" + nextD3 + "% (" + need_b3 + ")";
  2549. }
  2550.  
  2551. function outWotNoobStatTitle(nr) {
  2552. if (0 <= nr && nr < 40)
  2553. return "оДНОклеточное\nподающая надежды бОльшая половина сервера";
  2554. if (40 <= nr && nr < 45)
  2555. return "донышко\nподающая надежды бОльшая половина сервера";
  2556. if (45 <= nr && nr < 50)
  2557. return "ИЛита\nподающая надежды бОльшая половина сервера";
  2558. if (50 <= nr && nr < 55)
  2559. return "НЛДнище\nподающая надежды бОльшая половина сервера";
  2560. if (55 <= nr && nr < 60)
  2561. return "неМОЩный\nподающая надежды бОльшая половина сервера";
  2562.  
  2563. if (60 <= nr && nr < 65)
  2564. return "Мистер Крабс\n~46,26%";
  2565. if (65 <= nr && nr < 70)
  2566. return "обуза\n~40,34%";
  2567. if (70 <= nr && nr < 75)
  2568. return "РАКетмэн\n~34,91%";
  2569. if (75 <= nr && nr < 80)
  2570. return "оЛОЛошка\n~29,94%";
  2571.  
  2572. if (80 <= nr && nr < 85)
  2573. return "агроЛЕНЬ\n~25,41%";
  2574. if (85 <= nr && nr < 90)
  2575. return "драчун-забияка\n~21,37%";
  2576. if (90 <= nr && nr < 95)
  2577. return "го в треньку!\n~17,76%";
  2578. if (95 <= nr && nr < 100)
  2579. return "небезнадежный\n~14,56%";
  2580. if (100 <= nr && nr < 110)
  2581. return "всё ровно\n~11,80%";
  2582.  
  2583. if (110 <= nr && nr < 120)
  2584. return "закаленный\n~7,44%";
  2585. if (120 <= nr && nr < 130)
  2586. return "раСЧЕТливый\n~4,40%";
  2587. if (130 <= nr && nr < 140)
  2588. return "пользАдел\n~2,43%";
  2589. if (140 <= nr && nr < 150)
  2590. return "PRO.думанный\~1,26%";
  2591. if (150 <= nr && nr < 160)
  2592. return "вездесуЮщий\n~0,61%";
  2593. if (160 <= nr && nr < 170)
  2594. return "УМелец\n~0,29%";
  2595. if (170 <= nr && nr < 180)
  2596. return "УМникум\n~0,13%";
  2597. if (180 <= nr && nr < 190)
  2598. return "нинзя-мастер\n~0,06%";
  2599.  
  2600. if (190 <= nr && nr < 200)
  2601. return "Джоkер\n~0,0287%";
  2602. if (200 <= nr && nr < 210)
  2603. return "игра пройдена\n~0,0141%";
  2604. if (210 <= nr && nr < 220)
  2605. return "маньяк\n~0,0077%";
  2606. if (220 <= nr && nr < 250)
  2607. return "директор зоопарка\n~0,0039%";
  2608. if (250 <= nr)
  2609. return "убийца ВБРа\n~0,0007%";
  2610. }
  2611.  
  2612. function outWotNoobStat(response) {
  2613. var regexp = /<div class="kpd">(\d*\.*\d*)+<\/div>/gi,
  2614. res = regexp.exec(response);
  2615. if (res && res.length > 0) {
  2616. var nr = Number(res[1]),
  2617. xnr = GetXRating(nr, "nr");
  2618. document.getElementById("js-us-NoobStat").innerHTML = "<font color='" + CalcEffColor(nr, "nr") + "'>" + nr + "</font>";
  2619. document.getElementById("js-us-NoobStat-xvm").innerHTML = "<font color='" + CalcEffColor(nr, "nr") + "'>" + xnr + "</font>";
  2620. document.getElementById("js-us-NoobStat_tooltip").innerHTML = outWotNoobStatTitle(Number(res[1]));
  2621. }
  2622. }
  2623. }//////////////////////////main
  2624.  
  2625. function CalcEff(New, AvgLev, battles, wins, damag, frags, spotted, caps, defs, summaryxp) {
  2626. var effs = [];
  2627. effs[0] = (damag / battles * (10 / (AvgLev + 2)) * (0.23 + 2 * AvgLev / 100) +
  2628. frags / battles * 250 +
  2629. spotted / battles * 150 +
  2630. Math.log((caps / battles) + 1) / Math.log(1.732) * 150 +
  2631. defs / battles * 150).toFixed(2); //eff
  2632. effs[1] = (damag / battles * (10 / AvgLev) * (0.15 + 2 * AvgLev / 100) +
  2633. frags / battles * (0.35 - 2 * AvgLev / 100) * 1000 +
  2634. spotted / battles * 200 +
  2635. caps / battles * 150 +
  2636. defs / battles * 150).toFixed(2); //old eff
  2637. effs[2] = ((1240 - 1040 / Math.pow(Math.min(AvgLev, 6), 0.164)) * frags / battles +
  2638. damag / battles * 530 / (184 * Math.pow(Math.E, 0.24 * AvgLev) + 130) +
  2639. spotted / battles * 125 +
  2640. Math.min(defs / battles, 2.2) * 100 +
  2641. ((185 / (0.17 + Math.pow(Math.E, (wins / battles * 100 - 35) * -0.134))) - 500) * 0.45 +
  2642. (6 - Math.min(AvgLev, 6)) * -60).toFixed(2);
  2643. if (New === 0)
  2644. effs[3] = (Math.log(battles) / 10 * (summaryxp / battles * 1 +
  2645. damag / battles * (wins / battles * 2.0 + frags / battles * 0.9 + spotted / battles * 0.5 + caps / battles * 0.5 + defs / battles * 0.5))).toFixed(2);
  2646. return effs;
  2647. }
  2648.  
  2649. function insertNewTr(NewTrParent, text, val, title, tid) {
  2650. var trNew = document.createElement('tr');
  2651. var tdNewName = document.createElement('td'),
  2652. div1 = document.createElement('div'),
  2653. div2 = document.createElement('div');
  2654. tdNewName.className = "td-minor";
  2655. tdNewName.innerHTML = text;
  2656. var tdNew = document.createElement('td');
  2657. div1.innerHTML = val;
  2658. tdNew.className = "t-dotted_value";
  2659. tdNew.appendChild(div1);
  2660. if (title && title.length) {
  2661. div1.setAttribute("id", "js-" + tid);
  2662. div1.className = "js-tooltip";
  2663. div2.innerHTML = title;
  2664. div2.setAttribute("id", "js-" + tid + "_tooltip");
  2665. div2.className = "b-tooltip-main";
  2666. tdNew.appendChild(div2);
  2667. }
  2668. NewTrParent.parentNode.appendChild(trNew);
  2669. trNew.appendChild(tdNewName);
  2670. trNew.appendChild(tdNew);
  2671. return trNew;
  2672. }
  2673.  
  2674. function fixStatData(response) {
  2675. var lang,
  2676. UserId = window.location.href.match(/\/(\d+)/)[1];
  2677. if (document.title.indexOf("Профиль игрока") > -1)
  2678. lang = "ru";
  2679. eval("var resp =" + response);
  2680. var alltanks = GetLSData("AllTanksArr");
  2681. if (alltanks) {
  2682. eval("var alltdata =" + alltanks);
  2683. var alltanksArr = [], tankid;
  2684. for (var t in alltdata.data) {
  2685. tankid = alltdata.data[t].tank_id;
  2686. alltanksArr[tankid] = [];
  2687. alltanksArr[tankid]["name"] = alltdata.data[t].name_i18n;
  2688. alltanksArr[tankid]["is_premium"] = alltdata.data[t].is_premium;
  2689. }
  2690. var ttStat = [], tStat = [];
  2691. for (var i = 0; i < resp.data[UserId].length; i++) {
  2692. tankid = resp.data[UserId][i].tank_id;
  2693. if (tankid in alltanksArr) {
  2694. var tName = alltanksArr[tankid]["name"];
  2695. ttStat[tankid] = {"win": resp.data[UserId][i].statistics.wins, "battles": resp.data[UserId][i].statistics.battles, "is_premium": alltanksArr[tankid]["is_premium"]};
  2696. }
  2697. }
  2698. var tanks = document.getElementsByClassName("t-profile_tankstype__item");
  2699. for (i = 0; i < tanks.length; i++) {
  2700. var t = tanks[i].cells,
  2701. imgName = t[0].getElementsByTagName('img')[0].src.match(/\/[^-]+-([^\/]*)\.png/)[1],
  2702. tankId = parseInt(tanks[i].nextElementSibling.getAttribute('data-vehicle-cd')),
  2703. tName = t[0].getElementsByClassName('b-name-vehicle')[0].innerHTML;
  2704. tanks[i].className += " js-tooltip";
  2705. tanks[i].id = "us-t-" + imgName;
  2706. var div = document.createElement('div');
  2707. tStat[imgName] = ttStat[tankId];
  2708. if (tStat[imgName]) {
  2709. if (tStat[imgName].is_premium) tanks[i].cells[0].getElementsByClassName('b-name-vehicle')[0].setAttribute('style', 'color: #ffc363 !important;');
  2710. div.innerHTML = "<div style='float:left;'>" + (lang === "ru" ? "Боев|Побед (%Побед)" : "Battles|Wins (%Wins)") + "</div><div style='float:right; padding-left:10px;'>" + tStat[imgName].battles + "|" + tStat[imgName].win + " (" + col(tStat[imgName].win / tStat[imgName].battles * 100, 2) + ")</div>";
  2711. }
  2712. div.setAttribute("id", "us-t-" + imgName + "_tooltip");
  2713. div.className = "b-tooltip-main";
  2714. tanks[i].appendChild(div);
  2715. if (tStat[imgName])
  2716. t[2].innerHTML = col(tStat[imgName].win / tStat[imgName].battles * 100, 2);
  2717. if (tStat[imgName])
  2718. t[2].setAttribute("wcount", tStat[imgName].win);
  2719. }
  2720. var daystat = GetStat();
  2721. if (daystat) {
  2722. var dayArray = [],
  2723. dsArr = daystat.split("|"),
  2724. strArray = dsArr[0].split("/");
  2725. for (var i = 1; i < strArray.length; i++) {
  2726. str = strArray[i].split(";");
  2727. var tName = str[0].toLowerCase();
  2728. dayArray[tName] = new Object();
  2729. dayArray[tName].b = toFl(str[1]);
  2730. dayArray[tName].w = str.length > 3 ? str[3] : -1;
  2731. }
  2732. PaintOldAvgLev(dayArray);
  2733. }
  2734. //OutUnoffStat();
  2735. } else {
  2736. xdr.xget("http://api." + document.location.host + "/wot/encyclopedia/tanks/?application_id=" + api_key, saveTanksArr);
  2737. }
  2738. }
  2739.  
  2740. function batCompanyClan(response) {
  2741. eval("var resp =" + response);
  2742. var UserId = window.location.href.match(/\/(\d+)/)[1],
  2743. companyTable = document.getElementById('company-battles'),
  2744. clanTable = document.getElementById('clan-battles'),
  2745. daystat = GetStat(),
  2746. oldeffres = false;
  2747. if (daystat) {
  2748. var dsArr = daystat.split("|");
  2749. if (dsArr[2]) {
  2750. eval('ostr =' + dsArr[2]);
  2751. var oldeffres = CalcEff(0, 6,
  2752. ostr.all.battles - ostr.company.battles - ostr.clan.battles,
  2753. ostr.all.wins - ostr.company.wins - ostr.clan.wins,
  2754. ostr.all.damage_dealt - ostr.company.damage_dealt - ostr.clan.damage_dealt,
  2755. ostr.all.frags - ostr.company.frags - ostr.clan.frags,
  2756. ostr.all.spotted - ostr.company.spotted - ostr.clan.spotted,
  2757. ostr.all.capture_points - ostr.company.capture_points - ostr.clan.capture_points,
  2758. ostr.all.dropped_capture_points - ostr.company.dropped_capture_points - ostr.clan.dropped_capture_points,
  2759. ostr.all.xp - ostr.company.xp - ostr.clan.xp);
  2760. var ohr = (ostr.all.hits / ostr.all.shots * 100).toFixed(2),
  2761. osurvb = (ostr.all.survived_battles / ostr.all.battles * 100).toFixed(2);
  2762. }
  2763. }
  2764.  
  2765. insertNewTr(companyTable, "Боев", resp.data[UserId].statistics.company.battles +
  2766. (oldeffres ? "<font color='green'>" + ((resp.data[UserId].statistics.company.battles - ostr.company.battles > 0) ? " (+" + (resp.data[UserId].statistics.company.battles - ostr.company.battles) + ")" : "") + "</font>" : "") +
  2767. " (" + (resp.data[UserId].statistics.company.battles / resp.data[UserId].statistics.all.battles * 100).toFixed(2) + "%)",
  2768. resp.data[UserId].statistics.company.battles + " <font color='red'>/</font> <font color='green'>" + resp.data[UserId].statistics.all.battles + "</font>", "cpbat");
  2769. insertNewTr(companyTable, "Побед", resp.data[UserId].statistics.company.wins +
  2770. (oldeffres ? "<font color='green'>" + ((resp.data[UserId].statistics.company.wins - ostr.company.wins > 0) ? " (+" + (resp.data[UserId].statistics.company.wins - ostr.company.wins) + ")" : "") + "</font>" : "") +
  2771. " (" + (resp.data[UserId].statistics.company.wins / resp.data[UserId].statistics.all.wins * 100).toFixed(2) + "%)", resp.data[UserId].statistics.company.wins + " <font color='red'>/</font> <font color='green'>" + resp.data[UserId].statistics.all.wins + "</font>", "cpwin");
  2772. insertNewTr(companyTable, "Повреждений за бой", resp.data[UserId].statistics.company.battles > 0 ? (resp.data[UserId].statistics.company.damage_dealt / resp.data[UserId].statistics.company.battles).toFixed(2) : '-', "");
  2773. insertNewTr(companyTable, "Фрагов за бой", resp.data[UserId].statistics.company.battles > 0 ? (resp.data[UserId].statistics.company.frags / resp.data[UserId].statistics.company.battles).toFixed(2) : '-', "");
  2774. insertNewTr(companyTable, "Обнаружено за бой", resp.data[UserId].statistics.company.battles > 0 ? (resp.data[UserId].statistics.company.spotted / resp.data[UserId].statistics.company.battles).toFixed(2) : '-', "");
  2775. insertNewTr(companyTable, "Очков захвата за бой", resp.data[UserId].statistics.company.battles > 0 ? (resp.data[UserId].statistics.company.capture_points / resp.data[UserId].statistics.company.battles).toFixed(2) : '-', "");
  2776. insertNewTr(companyTable, "Очков защиты за бой", resp.data[UserId].statistics.company.battles > 0 ? (resp.data[UserId].statistics.company.dropped_capture_points / resp.data[UserId].statistics.company.battles).toFixed(2) : '-', "");
  2777. insertNewTr(companyTable, "Опыт за бой", resp.data[UserId].statistics.company.battles > 0 ? (resp.data[UserId].statistics.company.xp / resp.data[UserId].statistics.company.battles).toFixed(2) : '-', "");
  2778. insertNewTr(companyTable, "% побед", resp.data[UserId].statistics.company.battles > 0 ? col((resp.data[UserId].statistics.company.wins / resp.data[UserId].statistics.company.battles * 100).toFixed(2)) : '-', "");
  2779. insertNewTr(companyTable, "% выживания", resp.data[UserId].statistics.company.battles > 0 ? col((resp.data[UserId].statistics.company.survived_battles / resp.data[UserId].statistics.company.battles * 100).toFixed(2)) : '-', "");
  2780. insertNewTr(companyTable, "% попадания", resp.data[UserId].statistics.company.battles > 0 ? col((resp.data[UserId].statistics.company.hits / resp.data[UserId].statistics.company.shots * 100).toFixed(2)) : '-', "");
  2781.  
  2782. insertNewTr(clanTable, "Боев", resp.data[UserId].statistics.clan.battles +
  2783. (oldeffres ? "<font color='green'>" + ((resp.data[UserId].statistics.clan.battles - ostr.clan.battles > 0) ? " (+" + (resp.data[UserId].statistics.clan.battles - ostr.clan.battles) + ")" : "") + "</font>" : "") +
  2784. " (" + (resp.data[UserId].statistics.clan.battles / resp.data[UserId].statistics.all.battles * 100).toFixed(2) + "%)", resp.data[UserId].statistics.clan.battles + " <font color='red'>/</font> <font color='green'>" + resp.data[UserId].statistics.all.battles + "</font>", "clbat");
  2785. insertNewTr(clanTable, "Побед", resp.data[UserId].statistics.clan.wins +
  2786. (oldeffres ? "<font color='green'>" + ((resp.data[UserId].statistics.clan.wins - ostr.clan.wins > 0) ? " (+" + (resp.data[UserId].statistics.clan.wins - ostr.clan.wins) + ")" : "") + "</font>" : "") +
  2787. " (" + (resp.data[UserId].statistics.clan.wins / resp.data[UserId].statistics.all.wins * 100).toFixed(2) + "%)", resp.data[UserId].statistics.clan.wins + " <font color='red'>/</font> <font color='green'>" + resp.data[UserId].statistics.all.wins + "</font>", "clwin");
  2788. insertNewTr(clanTable, "Повреждений за бой", resp.data[UserId].statistics.clan.battles > 0 ? (resp.data[UserId].statistics.clan.damage_dealt / resp.data[UserId].statistics.clan.battles).toFixed(2) : '-', "");
  2789. insertNewTr(clanTable, "Фрагов за бой", resp.data[UserId].statistics.clan.battles > 0 ? (resp.data[UserId].statistics.clan.frags / resp.data[UserId].statistics.clan.battles).toFixed(2) : '-', "");
  2790. insertNewTr(clanTable, "Обнаружено за бой", resp.data[UserId].statistics.clan.battles > 0 ? (resp.data[UserId].statistics.clan.spotted / resp.data[UserId].statistics.clan.battles).toFixed(2) : '-', "");
  2791. insertNewTr(clanTable, "Очков захвата за бой", resp.data[UserId].statistics.clan.battles > 0 ? (resp.data[UserId].statistics.clan.capture_points / resp.data[UserId].statistics.clan.battles).toFixed(2) : '-', "");
  2792. insertNewTr(clanTable, "Очков защиты за бой", resp.data[UserId].statistics.clan.battles > 0 ? (resp.data[UserId].statistics.clan.dropped_capture_points / resp.data[UserId].statistics.clan.battles).toFixed(2) : '-', "");
  2793. insertNewTr(clanTable, "Опыт за бой", resp.data[UserId].statistics.clan.battles > 0 ? (resp.data[UserId].statistics.clan.xp / resp.data[UserId].statistics.clan.battles).toFixed(2) : '-', "");
  2794. insertNewTr(clanTable, "% побед", resp.data[UserId].statistics.clan.battles > 0 ? col((resp.data[UserId].statistics.clan.wins / resp.data[UserId].statistics.clan.battles * 100).toFixed(2)) : '-', "");
  2795. insertNewTr(clanTable, "% выживания", resp.data[UserId].statistics.clan.battles > 0 ? col((resp.data[UserId].statistics.clan.survived_battles / resp.data[UserId].statistics.clan.battles * 100).toFixed(2)) : '-', "");
  2796. insertNewTr(clanTable, "% попадания", resp.data[UserId].statistics.clan.battles > 0 ? col((resp.data[UserId].statistics.clan.hits / resp.data[UserId].statistics.clan.shots * 100).toFixed(2)) : '-', "");
  2797.  
  2798. var effres = CalcEff(0, 6,
  2799. resp.data[UserId].statistics.all.battles - resp.data[UserId].statistics.company.battles - resp.data[UserId].statistics.clan.battles,
  2800. resp.data[UserId].statistics.all.wins - resp.data[UserId].statistics.company.wins - resp.data[UserId].statistics.clan.wins,
  2801. resp.data[UserId].statistics.all.damage_dealt - resp.data[UserId].statistics.company.damage_dealt - resp.data[UserId].statistics.clan.damage_dealt,
  2802. resp.data[UserId].statistics.all.frags - resp.data[UserId].statistics.company.frags - resp.data[UserId].statistics.clan.frags,
  2803. resp.data[UserId].statistics.all.spotted - resp.data[UserId].statistics.company.spotted - resp.data[UserId].statistics.clan.spotted,
  2804. resp.data[UserId].statistics.all.capture_points - resp.data[UserId].statistics.company.capture_points - resp.data[UserId].statistics.clan.capture_points,
  2805. resp.data[UserId].statistics.all.dropped_capture_points - resp.data[UserId].statistics.company.dropped_capture_points - resp.data[UserId].statistics.clan.dropped_capture_points,
  2806. resp.data[UserId].statistics.all.xp - resp.data[UserId].statistics.company.xp - resp.data[UserId].statistics.clan.xp);
  2807. var bsr = document.getElementById("js-bs-rating"),
  2808. xbsr = document.getElementById("js-bs-rating-xvm"),
  2809. hitrat = document.getElementById("js-hit-ratio"),
  2810. hitratt = document.getElementById("js-hit-ratio_tooltip"),
  2811. surv = document.getElementById("js-us-surv"),
  2812. survb = (resp.data[UserId].statistics.all.survived_battles / resp.data[UserId].statistics.all.battles * 100).toFixed(2);
  2813. bsr.innerHTML = "<font color='" + CalcEffColor(effres[3], "bs")[0] + "'>" + effres[3] + "</font>" + ((oldeffres && (effres[3] - oldeffres[3]).toFixed(2) != 0.0) ? "<font color='" + ((effres[3] - oldeffres[3]) > 0 ? "green'> (+" : "red'> (") + (effres[3] - oldeffres[3]).toFixed(2) + ")</font>" : "");
  2814. var xbs = GetXRating(effres[3], "bs");
  2815. if (oldeffres) var oxbs = GetXRating(oldeffres[3], "bs");
  2816. xbsr.innerHTML = "<font color='" + CalcEffColor(effres[3], "bs")[0] + "'>" + xbs + "</font>" + ((oldeffres && (xbs - oxbs).toFixed(2) != 0.0 ) ? "<font color='" + ((xbs - oxbs) > 0 ? "green'> (+" : "red'> (") + (xbs - oxbs).toFixed(2) + ")</font>" : "");
  2817. var hr = (resp.data[UserId].statistics.all.hits / resp.data[UserId].statistics.all.shots * 100).toFixed(2);
  2818. hitrat.innerHTML = col(hr) + ((oldeffres && (hr - ohr).toFixed(2) != 0.0) ? "<font color='" + ((hr - ohr) > 0 ? "green'> (+" : "red'> (") + (hr - ohr).toFixed(2) + ")</font>" : "");
  2819. hitratt.innerHTML = resp.data[UserId].statistics.all.hits + " <font color='red'>/</font> <font color='green'>" + resp.data[UserId].statistics.all.shots + "</font>";
  2820. if (oldeffres && (survb - osurvb).toFixed(2) != 0.0) surv.innerHTML += "<font color='" + ((survb - osurvb > 0) ? "green'> (+" : "red'> (") + (survb - osurvb).toFixed(2) + ")</font>";
  2821. GetStatData(effres);
  2822. }
  2823.  
  2824. function savenominalDamage(response) {
  2825. var now = new Date(),
  2826. time = now.getTime();
  2827. time += 3600 * 24 * 1000;
  2828. now.setTime(time);
  2829. SetLSData("nominalDamage", response, now.toGMTString());
  2830. window.location.reload();
  2831. }
  2832.  
  2833. function saveWN8Data(response) {
  2834. var now = new Date(),
  2835. time = now.getTime();
  2836. time += 3600 * 24 * 1000;
  2837. now.setTime(time);
  2838. SetLSData("WN8Data", response, now.toGMTString());
  2839. window.location.reload();
  2840. }
  2841.  
  2842. function GetBattleStat(col) {
  2843. switch (col) {
  2844. case 1:
  2845. return toFl(document.getElementsByClassName("t-personal-data_value__pr")[0].innerHTML);
  2846. break;
  2847. case 4:
  2848. return toFl(document.getElementsByClassName("b-result")[0].getElementsByClassName("t-dotted_value")[1].innerHTML.split("(")[0]);
  2849. break;
  2850. case 7:
  2851. return toFl(document.getElementsByClassName("b-result")[1].getElementsByClassName("t-dotted_value")[3].innerHTML);
  2852. break;
  2853. case 9:
  2854. return toFl(document.getElementsByClassName("b-result")[1].getElementsByClassName("t-dotted_value")[0].innerHTML);
  2855. break;
  2856. case 10:
  2857. return toFl(document.getElementsByClassName("b-result")[1].getElementsByClassName("t-dotted_value")[1].innerHTML);
  2858. break;
  2859. case 6:
  2860. return toFl(document.getElementsByClassName("b-result")[1].getElementsByClassName("t-dotted_value")[5].innerHTML);
  2861. break;
  2862. case 8:
  2863. return toFl(document.getElementsByClassName("b-result")[1].getElementsByClassName("t-dotted_value")[6].innerHTML);
  2864. break;
  2865. case 11:
  2866. return toFl(document.getElementsByClassName("b-result")[0].getElementsByClassName("t-dotted_value")[4].innerHTML);
  2867. break;
  2868. case 5:
  2869. return toFl(document.getElementsByClassName("b-result")[0].getElementsByClassName("t-dotted_value")[0].innerHTML);
  2870. break;
  2871. default:
  2872. return 0;
  2873. break;
  2874. break;
  2875. }
  2876. }
  2877.  
  2878. function toFl(s) {
  2879. var a = "" + s;
  2880. a = a.indexOf(">") > 0 ? a.substr(0, a.indexOf(">")) : a;
  2881. return (parseFloat(a.replace(/[\D\.]/g, "")));
  2882. }
  2883.  
  2884. function getCookie(name) {
  2885. var start = document.cookie.indexOf(name + '=');
  2886. var len = start + name.length + 1;
  2887. if ((!start) && (name !== document.cookie.substring(0, name.length))) {
  2888. return null;
  2889. }
  2890. if (start === -1)
  2891. return undefined;
  2892. var end = document.cookie.indexOf(';', len);
  2893. if (end === -1)
  2894. end = document.cookie.length;
  2895.  
  2896. var resval = document.cookie.substring(len, end);
  2897.  
  2898. name = name + "__2";
  2899. start = document.cookie.indexOf(name + '=');
  2900. len = start + name.length + 1;
  2901. if ((!start) && (name !== document.cookie.substring(0, name.length))) {
  2902. return unescape(resval);
  2903. }
  2904. if (start === -1)
  2905. return unescape(resval);
  2906. end = document.cookie.indexOf(';', len);
  2907. if (end === -1)
  2908. end = document.cookie.length;
  2909.  
  2910. resval += document.cookie.substring(len, end);
  2911.  
  2912. return unescape(resval);
  2913. }
  2914.  
  2915. function setCookie(name, value, endstr) {
  2916. var savestr = escape(value),
  2917. savestr2 = false;
  2918. if (savestr.length > 3900) {
  2919. savestr2 = savestr.slice(3900);
  2920. savestr = savestr.slice(0, 3900);
  2921. }
  2922. if (!endstr)
  2923. endstr = "; expires=Mon, 01-Jan-2031 00:00:00 GMT";
  2924. document.cookie = name + "=" + savestr + endstr;
  2925. if (savestr2) {
  2926. document.cookie = name + "__2" + "=" + savestr2 + endstr;
  2927. }
  2928. }
  2929.  
  2930. function GetStat() {
  2931. var UserId = window.location.href.match(/\/(\d+)/)[1],
  2932. day = 0;
  2933. // Перенос старого формата данных
  2934. if (GetLSData("daystat_" + UserId)) {
  2935. var daystat = GetLSData("daystat_" + UserId);
  2936. SetLSData("daystat_" + UserId + "_" + 0, daystat, '01-Jan-2031 00:00:00 GMT');
  2937. localStorage.removeItem("daystat_" + UserId);
  2938. }
  2939. for (var i = 1; i < 7; i++) {
  2940. if (GetLSData("daystat_" + UserId + "_" + i))
  2941. day += 1;
  2942. }
  2943. return GetLSData("daystat_" + UserId + "_" + day);
  2944. }
  2945.  
  2946. function WriteStat() {
  2947. var day = 0,
  2948. UserId = window.location.href.match(/\/(\d+)/)[1],
  2949. WGRating = GetBattleStat(1),
  2950. api_key,
  2951. saveStat = false;
  2952. for (i = 0; i < 7; i++) {
  2953. if (!GetLSData("daystat_" + UserId + "_" + i)) {
  2954. day = i;
  2955. break;
  2956. }
  2957. day = 7;
  2958. }
  2959. if (document.location.host.indexOf(".ru") !== -1) {
  2960. api_key = "895d3dafdd87af03e1e515befcd83882";
  2961. } else if (document.location.host.indexOf(".eu") !== -1) {
  2962. api_key = "d0a293dc77667c9328783d489c8cef73";
  2963. } else if (document.location.host.indexOf(".com") !== -1) {
  2964. api_key = "16924c431c705523aae25b6f638c54dd";
  2965. }
  2966. if (day !== 0) {
  2967. var daystat = GetLSData("daystat_" + UserId + "_" + (day - 1)),
  2968. dsArr = daystat.split("|"),
  2969. strArray = dsArr[0].split("/"),
  2970. str = strArray[0].split(";"),
  2971. OldBattles = toFl(str[12]);
  2972. if (parseInt(OldBattles) !== parseInt(GetBattleStat(5))) {
  2973. saveStat = true;
  2974. }
  2975. } else {
  2976. saveStat = true;
  2977. }
  2978. if (saveStat) {
  2979. $.get("http://api." + document.location.host + "/2.0/account/info/?application_id=" + api_key + "&account_id=" + UserId, function (response) {
  2980. var UserId = window.location.href.match(/\/(\d+)/)[1];
  2981. var timeStamp = new Date();
  2982. var cookie = "" + timeStamp + ";",
  2983. AllGold = document.getElementsByClassName("currency-gold")[0],
  2984. AllCredit = document.getElementsByClassName("currency-credit")[0],
  2985. AllExp = document.getElementsByClassName("currency-experience")[0],
  2986. tstsr = JSON.stringify(response.data[UserId].statistics);
  2987.  
  2988. if (AllGold) {
  2989. cookie += "" + toFl(AllGold.innerHTML.split("(")[0]) + ";";
  2990. } else
  2991. cookie += "NaN;";
  2992. if (AllCredit) {
  2993. cookie += "" + toFl(AllCredit.innerHTML.split("(")[0]) + ";";
  2994. } else
  2995. cookie += "NaN;";
  2996. if (AllExp) {
  2997. cookie += "" + toFl(AllExp.innerHTML.split("(")[0]) + ";";
  2998. } else
  2999. cookie += "NaN;";
  3000.  
  3001. for (var i = 1; i < 12; i++) {
  3002. cookie += GetBattleStat(i) + ";";
  3003. cookie += "0;";
  3004. }
  3005.  
  3006. var tanks = document.getElementsByClassName("t-profile_tankstype__item");
  3007. for (var i = 0; i < tanks.length; i++) {
  3008. var t = tanks[i].cells,
  3009. imgName = t[0].getElementsByTagName('img')[0].src.match(/\/[^-]+-([^\/]*)\.png/)[1];
  3010. cookie += "/" + imgName + ";" + toFl(t[1].innerHTML.split("(")[0]) + ";" + toFl(t[2].innerHTML.split("(")[0]) + ";" + t[2].getAttribute("wcount");
  3011. }
  3012.  
  3013. cookie += "|";
  3014.  
  3015. var medals = document.getElementsByClassName("js-all-achievements")[0].getElementsByClassName("b-achivements_item");
  3016. for (i = 0; i < medals.length; i++) {
  3017. if ((" " + medals[i].className + " ").replace(/[\n\t]/g, " ").indexOf(" b-achivements_item__empty ") === -1) {
  3018. var count = medals[i].getElementsByTagName('div')[0];
  3019. if (count) {
  3020. count = count.getElementsByTagName('span')[0];
  3021. if (count) {
  3022. count = count.getElementsByTagName('span')[0];
  3023. if (count)
  3024. count = toFl(count.innerHTML);
  3025. else
  3026. count = 1;
  3027. } else {
  3028. count = 1;
  3029. }
  3030. } else {
  3031. count = 1;
  3032. }
  3033. cookie += "/" + medals[i].id.split("-")[2] + ";" + count;
  3034. }
  3035. }
  3036. cookie += "|" + tstsr;
  3037. cookie += "|" + WGRating;
  3038. var day = 0;
  3039. for (i = 0; i < 7; i++) {
  3040. if (!GetLSData("daystat_" + UserId + "_" + i)) {
  3041. day = i;
  3042. break;
  3043. }
  3044. day = 7;
  3045. }
  3046. if (day === 0) {
  3047. SetLSData("daystat_" + UserId + "_0", cookie, '01-Jan-2031 00:00:00 GMT');
  3048. if (document.title.indexOf("Профиль игрока") > -1) {
  3049. popup("Статистика сохранена", true, false);
  3050. } else {
  3051. popup("Stat. saved", true, false);
  3052. }
  3053. } else {
  3054. var daystat = GetLSData("daystat_" + UserId + "_" + (day - 1)),
  3055. dsArr = daystat.split("|"),
  3056. strArray = dsArr[0].split("/"),
  3057. str = strArray[0].split(";"),
  3058. OldBattles = toFl(str[12]);
  3059. if (parseInt(OldBattles) === parseInt(GetBattleStat(5))) {
  3060. if (document.title.indexOf("Профиль игрока") > -1) {
  3061. popup("Нет новых боев", true, false);
  3062. } else {
  3063. popup("No new battles", true, false);
  3064. }
  3065. } else {
  3066. if (day === 7) {
  3067. for (i = 1; i < 7; i++) {
  3068. daystat = GetLSData("daystat_" + UserId + "_" + (i));
  3069. SetLSData("daystat_" + UserId + "_" + (i - 1), daystat, '01-Jan-2031 00:00:00 GMT');
  3070. }
  3071. day = 6;
  3072. }
  3073. SetLSData("daystat_" + UserId + "_" + day, cookie, '01-Jan-2031 00:00:00 GMT');
  3074. if (document.title.indexOf("Профиль игрока") > -1) {
  3075. popup("Статистика сохранена", true, false);
  3076. } else {
  3077. popup("Stat. saved", true, false);
  3078. }
  3079. }
  3080. }
  3081. });
  3082. } else {
  3083. if (document.title.indexOf("Профиль игрока") > -1) {
  3084. popup("Нет новых боев", true, false);
  3085. } else {
  3086. popup("No new battles", true, false);
  3087. }
  3088. }
  3089. }
  3090.  
  3091. function col(v1, digit, inv) {
  3092. if (isNaN(v1))
  3093. return "x";
  3094. var color = "90ffff";
  3095. if (inv) {
  3096. var v = 100 - v1;
  3097. } else {
  3098. v = v1;
  3099. }
  3100. if (digit)
  3101. v1 = v1.toFixed(digit);
  3102. if (v < 101)
  3103. color = "D042F3";
  3104. if (v < 64.9)
  3105. color = "02C9B3";
  3106. if (v < 56.9)
  3107. color = "60FF00";
  3108. if (v < 51.9)
  3109. color = "F8F400";
  3110. if (v < 48.9)
  3111. color = "FE7903";
  3112. if (v < 46.9)
  3113. color = "FE0E00";
  3114.  
  3115. return "<font color='" + color + "'>" + v1 + "%</font>";
  3116. }
  3117.  
  3118. function col2(v) {
  3119. if (isNaN(v))
  3120. v = 0;
  3121. var color = "D042F3";
  3122. if (v < 15)
  3123. color = "02C9B3";
  3124. if (v < 10)
  3125. color = "60FF00";
  3126. if (v < 5)
  3127. color = "F8F400";
  3128. if (v < 0)
  3129. color = "FE7903";
  3130. if (v < -5)
  3131. color = "FE0E00"; //красный
  3132. v = v.toFixed(2);
  3133. if (v >= 0)
  3134. v = "+" + v;
  3135. return "<font color='" + color + "'>" + v + "</font>";
  3136. }
  3137.  
  3138. function SaveCompareStatData() {
  3139. var timeStamp = new Date();
  3140. var cookie = "" + timeStamp + ";",
  3141. AllGold = document.getElementsByClassName("currency-gold")[0],
  3142. AllCredit = document.getElementsByClassName("currency-credit")[0],
  3143. AllExp = document.getElementsByClassName("currency-experience")[0],
  3144. WGRating = GetBattleStat(1);
  3145.  
  3146. if (AllGold) {
  3147. cookie += "" + toFl(AllGold.innerHTML.split("(")[0]) + ";";
  3148. } else
  3149. cookie += "NaN;";
  3150. if (AllCredit) {
  3151. cookie += "" + toFl(AllCredit.innerHTML.split("(")[0]) + ";";
  3152. } else
  3153. cookie += "NaN;";
  3154. if (AllExp) {
  3155. cookie += "" + toFl(AllExp.innerHTML.split("(")[0]) + ";";
  3156. } else
  3157. cookie += "NaN;";
  3158.  
  3159. for (var i = 1; i < 12; i++) {
  3160. cookie += GetBattleStat(i) + ";";
  3161. cookie += "0;";
  3162. }
  3163.  
  3164. var tanks = document.getElementsByClassName("t-profile_tankstype__item"),
  3165. tlev, totalB = 0, avgL = 0, tbcount, tankLevs = {
  3166. "I": 1,
  3167. "II": 2,
  3168. "III": 3,
  3169. "IV": 4,
  3170. "V": 5,
  3171. "VI": 6,
  3172. "VII": 7,
  3173. "VIII": 8,
  3174. "IX": 9,
  3175. "X": 10
  3176. };
  3177.  
  3178. for (var i = 0; i < tanks.length; i++) {
  3179. var t = tanks[i].cells,
  3180. imgName = t[0].getElementsByTagName('img')[0].src.match(/\/[^-]+-([^\/]*)\.png/)[1];
  3181. tank_Id = parseInt(tanks[i].nextElementSibling.getAttribute('data-vehicle-cd'));
  3182. tbcount = toFl(tanks[i].cells[1].innerHTML);
  3183. tlev = tankLevs[tanks[i].cells[0].getElementsByTagName('div')[0].getElementsByTagName('span')[0].innerHTML];
  3184. totalB += tbcount;
  3185. avgL += tlev * tbcount;
  3186. cookie += "/" + imgName + ";" + toFl(t[1].innerHTML.split("(")[0]) + ";" + toFl(t[2].innerHTML.split("(")[0]) + ";" + tank_Id;
  3187. }
  3188.  
  3189. cookie += "|" + (avgL / totalB).toFixed(4);
  3190. cookie += "|";
  3191.  
  3192. var medals = document.getElementsByClassName("js-all-achievements")[0].getElementsByClassName("b-achivements_item");
  3193. for (i = 0; i < medals.length; i++) {
  3194. if ((" " + medals[i].className + " ").replace(/[\n\t]/g, " ").indexOf(" b-achivements_item__empty ") === -1) {
  3195. var count = medals[i].getElementsByTagName('div')[0];
  3196. if (count) {
  3197. count = count.getElementsByTagName('span')[0];
  3198. if (count) {
  3199. count = count.getElementsByTagName('span')[0];
  3200. if (count)
  3201. count = toFl(count.innerHTML);
  3202. else
  3203. count = 1;
  3204. } else {
  3205. count = 1;
  3206. }
  3207. } else {
  3208. count = 1;
  3209. }
  3210. cookie += "/" + medals[i].id.split("-")[2] + ";" + count;
  3211. }
  3212. }
  3213. cookie += "|" + WGRating;
  3214. SetLSData("compareStat", cookie, '01-Jan-2031 00:00:00 GMT');
  3215. window.close();
  3216. }
  3217.  
  3218. function WriteCompareStat() {
  3219. var set = GetLSData("usSettings").split('|')[1].split(';');
  3220. if (toFl(set[0]) === 1/* && set[1].match(/\/(\d+)/)[1] !== window.location.href.match(/\/(\d+)/)[1]*/) {
  3221. window.open(set[1] + '#USCompareStat', 'usCompare', 'width=100, height=100');
  3222. return false;
  3223. }
  3224. }
  3225.  
  3226. function GetLSData(name) {
  3227. var stVal = localStorage.getItem(name);
  3228. if (stVal && new Date(stVal.split("||")[0]) <= new Date()) {
  3229. localStorage.removeItem(name);
  3230. stVal = null;
  3231. }
  3232. if (stVal) {
  3233. return stVal.split("||")[1];
  3234. } else
  3235. return null;
  3236. }
  3237.  
  3238. function SetLSData(name, value, expire) {
  3239. var stval = expire + "||" + value;
  3240. localStorage.setItem(name, stval);
  3241. }
  3242.  
  3243. function outStatData2(response) {
  3244. eval("var resp =" + response);
  3245. var sStat = resp.veh_stat,
  3246. arstr = '';
  3247. for (var sc in sStat) {
  3248. arstr += "/" + sStat[sc]["link"].match(/\/[^-]+-([^\/]*)\.png/)[1].toLowerCase() + ";" + (sStat[sc]["win"] / sStat[sc]["total"] * 100).toFixed(2);
  3249. }
  3250. var now = new Date(),
  3251. time = now.getTime();
  3252. time += 3600 * 24 * 1000;
  3253. now.setTime(time);
  3254. SetLSData("UsUnOfStat", arstr, now.toGMTString());
  3255. OutUnoffStat();
  3256. }
  3257.  
  3258. function CalcOldAvgLev(ds, tankarr) {
  3259. var avgL = 0,
  3260. totalB = 0,
  3261. NavgL = 0,
  3262. NtotalB = 0,
  3263. tnaSum = 0,
  3264. expDmg = 0,
  3265. expSpot = 0,
  3266. expFrag = 0,
  3267. expDef = 0,
  3268. expWinRate = 0,
  3269. tankLevs = {
  3270. "I": 1,
  3271. "II": 2,
  3272. "III": 3,
  3273. "IV": 4,
  3274. "V": 5,
  3275. "VI": 6,
  3276. "VII": 7,
  3277. "VIII": 8,
  3278. "IX": 9,
  3279. "X": 10
  3280. };
  3281. var nominalDamage = GetLSData("nominalDamage"),
  3282. wn8Data = GetLSData("WN8Data"),
  3283. nominalDamageArr = [], wn8DataArr = [], tankid, tank_Id, nArr;
  3284. if (nominalDamage) {
  3285. nominalDamage = eval(nominalDamage);
  3286. for (i = 0; i < nominalDamage.length; i++) {
  3287. if (nominalDamage[i].nominalDamage)
  3288. nominalDamageArr[(nominalDamage[i].id).toLowerCase()] = [
  3289. nominalDamage[i].nominalDamage * 1
  3290. ];
  3291. }
  3292. } else {
  3293. xdr.xget("http://www.noobmeter.com/tankListJson/elfx_133054", savenominalDamage);
  3294. }
  3295. if (wn8Data) {
  3296. eval("var allwn8Data =" + wn8Data);
  3297. for (var key = 0; key < allwn8Data.data.length; key++) {
  3298. t = allwn8Data.data[key];
  3299. wn8DataArr[parseInt(t.IDNum)] = [t.expDamage / 1, t.expSpot / 1, t.expFrag / 1, t.expDef / 1, t.expWinRate / 100];
  3300. }
  3301. } else {
  3302. xdr.xget("http://www.wnefficiency.net/exp/expected_tank_values_latest.json", saveWN8Data);
  3303. }
  3304.  
  3305. for (var tank in ds) {
  3306. if (tankarr[tank]) {
  3307. totalB += ds[tank].b;
  3308. if (nominalDamageArr[tank]) {
  3309. if (nominalDamageArr[tank][0]) tnaSum += ds[tank].b * nominalDamageArr[tank][0];
  3310. }
  3311. tank_Id = tankarr[tank]["tId"];
  3312. if (wn8DataArr[tank_Id]) {
  3313. expDmg += ds[tank].b * wn8DataArr[tank_Id][0];
  3314. expSpot += ds[tank].b * wn8DataArr[tank_Id][1];
  3315. expFrag += ds[tank].b * wn8DataArr[tank_Id][2];
  3316. expDef += ds[tank].b * wn8DataArr[tank_Id][3];
  3317. expWinRate += ds[tank].b * wn8DataArr[tank_Id][4];
  3318. }
  3319. avgL += tankarr[tank].tlev * ds[tank].b;
  3320. if (ds[tank].b !== tankarr[tank].bcount) {
  3321. NtotalB += (tankarr[tank].bcount - ds[tank].b);
  3322. NavgL += tankarr[tank].tlev * (tankarr[tank].bcount - ds[tank].b);
  3323. }
  3324. }
  3325. }
  3326. return [avgL / totalB, NavgL / NtotalB, tnaSum, expDmg, expSpot, expFrag, expDef, expWinRate, totalB];
  3327. }
  3328.  
  3329. function PaintOldAvgLev(ds) {
  3330. var avgL = 0,
  3331. totalB = 0,
  3332. NavgL = 0,
  3333. NtotalB = 0,
  3334. tanks = document.getElementsByClassName("t-profile_tankstype__item"),
  3335. tbcount,
  3336. twcount,
  3337. tlev,
  3338. imgName,
  3339. tHd,
  3340. newBat,
  3341. tankLevs = {
  3342. "I": 1,
  3343. "II": 2,
  3344. "III": 3,
  3345. "IV": 4,
  3346. "V": 5,
  3347. "VI": 6,
  3348. "VII": 7,
  3349. "VIII": 8,
  3350. "IX": 9,
  3351. "X": 10
  3352. };
  3353.  
  3354. var theads = document.getElementsByClassName("t-profile__vehicle")[0].getElementsByTagName('tbody');
  3355. for (var i = 0; i < theads.length; i++) {
  3356. if (theads[i].style.display !== 'none')
  3357. theads[i].setAttribute('class', 'js-tank-head-row');
  3358. }
  3359.  
  3360. for (i = 0; i < tanks.length; i++) {
  3361. if (tanks[i].parentNode.previousElementSibling.style.display !== 'none')
  3362. tanks[i].setAttribute('class', tanks[i].getAttribute('class') + ' js-tank-row');
  3363. imgName = tanks[i].cells[0].getElementsByTagName('img')[0].src.match(/\/[^-]+-([^\/]*)\.png/)[1];
  3364. if (ds[imgName]) {
  3365. tbcount = toFl(ds[imgName].b);
  3366. twcount = ds[imgName].w;
  3367. } else {
  3368. tbcount = 0;
  3369. twcount = 0;
  3370. }
  3371. tlev = tankLevs[tanks[i].cells[0].getElementsByTagName('div')[0].getElementsByTagName('span')[0].innerHTML];
  3372. totalB += tbcount;
  3373. avgL += tlev * tbcount;
  3374. if (toFl(tanks[i].cells[1].innerHTML) !== tbcount) {
  3375. NtotalB += toFl(tanks[i].cells[1].innerHTML.split("(")[0]) - tbcount;
  3376. tHd = tanks[i].parentNode.previousElementSibling;
  3377. newBat = toFl(tHd.getAttribute('newbat'));
  3378. if (newBat) {
  3379. newBat += toFl(tanks[i].cells[1].innerHTML.split("(")[0]) - tbcount;
  3380. } else {
  3381. newBat = toFl(tanks[i].cells[1].innerHTML.split("(")[0]) - tbcount;
  3382. }
  3383. tHd.setAttribute("style", "background-color: Darkslategray;");
  3384. tHd.setAttribute("newBat", newBat);
  3385. tHd.rows[0].cells[1].innerHTML = tHd.rows[0].cells[1].innerHTML.split("(")[0] + " (+" + newBat + ")";
  3386. tanks[i].setAttribute("style", "background-color: Darkslategray;");
  3387. tanks[i].setAttribute('class', tanks[i].getAttribute('class') + ' js-nb-tank-row');
  3388. if (!tHd.getAttribute('class') || tHd.getAttribute('class').indexOf('js-nb-tank-row') === -1)
  3389. tHd.setAttribute('class', (tHd.getAttribute('class') ? tHd.getAttribute('class') + ' js-nb-tank-row' : 'js-nb-tank-row'));
  3390. tanks[i].cells[1].innerHTML = tanks[i].cells[1].innerHTML + " (" + (toFl(tanks[i].cells[1].innerHTML.split("(")[0]) - tbcount) + "|" + (tanks[i].cells[2].getAttribute('wcount') - twcount) + ")";
  3391. if (twcount !== -1 && tbcount !== 0) {
  3392. var windelta = ((tanks[i].cells[2].getAttribute('wcount') / toFl(tanks[i].cells[1].innerHTML.split("(")[0]) * 100).toFixed(2) - (twcount / tbcount * 100).toFixed(2)).toFixed(2);
  3393. tanks[i].cells[2].innerHTML = tanks[i].cells[2].innerHTML + " (" + (windelta > 0 ? "<font color='green'>+" + windelta + "</font>" : "<font color='red'>" + windelta + "</font>") + ")";
  3394. }
  3395. NavgL += tlev * (toFl(tanks[i].cells[1].innerHTML.split("(")[0]) - tbcount);
  3396. }
  3397.  
  3398. }
  3399. }
  3400.  
  3401. function outStatData(response) {
  3402. eval("var resp =" + response);
  3403. var sStat = resp.classRatings,
  3404. arstr = '';
  3405. for (var i = 0; i < rangA.length; i++) {
  3406. arstr += sStat[rangA[i]] + ';';
  3407. }
  3408. var now = new Date(),
  3409. time = now.getTime();
  3410. time += 3600 * 24 * 1000;
  3411. now.setTime(time);
  3412. SetLSData("UsBsRangs", arstr, now.toGMTString());
  3413. GetStatData();
  3414. }
  3415.  
  3416. function OutUnoffStat() {
  3417. var stData = GetLSData("UsUnOfStat");
  3418. if (stData) {
  3419. var vTh = document.getElementsByClassName("t-profile__vehicle")[0].getElementsByTagName('th')[4],
  3420. nTh = document.createElement('th');
  3421. document.getElementsByClassName("t-profile__vehicle")[0].getElementsByTagName('th')[0].width = "288";
  3422. nTh.innerHTML = '<span class="t-vehicle-head t-vehicle-head__fix"><span>' + (lang === "ru" ? "ср % побед по серверу" : "avg win %") + "</span></span>";
  3423. nTh.className = "t-profile_center";
  3424. vTh.parentNode.insertBefore(nTh, vTh);
  3425. var tTypes = document.getElementsByClassName("js-tank-head-row");
  3426. for (var i = 0; i < tTypes.length; i++) {
  3427. var nrth = tTypes[i].rows[0].getElementsByClassName('t-profile_center');
  3428. if (nrth.length) {
  3429. nrth[0].width = "288";
  3430. var fTh = document.createElement('td');
  3431. fTh.innerHTML = '-';
  3432. fTh.className = "t-profile_center";
  3433. tTypes[i].rows[0].cells[4].parentNode.insertBefore(fTh, tTypes[i].rows[0].cells[4]);
  3434. }
  3435. }
  3436. var UnOffStat = stData.split("/");
  3437. if (UnOffStat) {
  3438. var unOffStatArr = [];
  3439. for (i = 0; i < UnOffStat.length; i++) {
  3440. var uoss = UnOffStat[i].split(";");
  3441. unOffStatArr[uoss[0]] = uoss[1];
  3442. }
  3443. var tanks = document.getElementsByClassName("t-profile_tankstype__item");
  3444. for (i = 0; i < tanks.length; i++) {
  3445. var t = tanks[i].cells,
  3446. imgName = t[0].getElementsByTagName('img')[0].src.match(/\/[^-]+-([^\/]*)\.png/)[1].toLowerCase();
  3447. var sTd = document.createElement('td');
  3448. sTd.className = "t-profile_right";
  3449. var med = unOffStatArr[imgName];
  3450. if (med && t[2].getElementsByTagName('font')[0]) {
  3451. sTd.innerHTML = col(med) + " (" + col2(parseFloat(t[2].getElementsByTagName('font')[0].innerHTML) - med) + ")";
  3452. } else {
  3453. sTd.innerHTML = "x";
  3454. }
  3455. t[4].parentNode.insertBefore(sTd, t[4]);
  3456. var rItem = t[4].parentNode.getElementsByClassName("t-profile_ico-dropdown")[0];
  3457. t[4].parentNode.removeChild(rItem);
  3458. }
  3459. }
  3460. } else {
  3461. xdr.xget("http://wot-crabe.ru/api/server_stats.json", outStatData2);
  3462. }
  3463. }
  3464.  
  3465. function GetStatData() {
  3466. var stData = GetLSData("UsBsRangs"),
  3467. lang,
  3468. bsrat = document.getElementById("js-bs-rating").innerHTML.split("(")[0].split("<")[0];
  3469. if (document.title.indexOf("Профиль игрока") > -1)
  3470. lang = "ru";
  3471. if (stData) {
  3472. var bsRangs = stData.split(";");
  3473. if (bsRangs) {
  3474. var rcr = 0,
  3475. rcrv = 0;
  3476. for (var i = bsRangs.length - 1; i > -1; i--) {
  3477. if (Number(bsrat) > Number(bsRangs[i])) {
  3478. rcr = i;
  3479. if (i > 0) {
  3480. rcrv = (Number(bsRangs[i - 1]) - Number(bsrat)).toFixed(2) + (lang === "ru" ? " баллов до следующего ранга" : " balls to next level");
  3481. } else {
  3482. rcrv = (lang === "ru" ? 'Максимальный уровень. Круче только вареные яйца.' : 'Max. level');
  3483. }
  3484. }
  3485. }
  3486. document.getElementById("js-bs-rating_tooltip").innerHTML = (lang === "ru" ? rangD[rcr] : rangDE[rcr]) + "<br>" + rcrv;
  3487. }
  3488. } else {
  3489. xdr.xget("http://armor.kiev.ua/wot/api.php", outStatData);
  3490. }
  3491. }
  3492.  
  3493. function FormatUsSetTable() {
  3494. var rowsSorted = [[]];
  3495. var tBody = document.getElementById("us-set-table").getElementsByTagName('tbody')[0];
  3496. for (i = 0; i < tBody.childNodes.length; i++) {
  3497. rowsSorted[tBody.childNodes[i].getAttribute('cur-pos')] = [];
  3498. rowsSorted[tBody.childNodes[i].getAttribute('cur-pos')][0] = tBody.childNodes[i].getAttribute('btype');
  3499. rowsSorted[tBody.childNodes[i].getAttribute('cur-pos')][1] = tBody.childNodes[i].cells[0].innerText;
  3500. rowsSorted[tBody.childNodes[i].getAttribute('cur-pos')][2] = tBody.childNodes[i].cells[1].getElementsByTagName('input')[0].checked;
  3501. rowsSorted[tBody.childNodes[i].getAttribute('cur-pos')][3] = tBody.childNodes[i].cells[2].getElementsByTagName('input')[0].checked;
  3502. }
  3503.  
  3504. for (i = 0; i < tBody.childNodes.length; i++) {
  3505. tBody.childNodes[i].setAttribute('btype', rowsSorted[i][0]);
  3506. tBody.childNodes[i].setAttribute('cur-pos', i);
  3507. tBody.childNodes[i].cells[0].childNodes[0].nodeValue = rowsSorted[i][1].replace(/\u00a0/g, "");
  3508. tBody.childNodes[i].cells[1].getElementsByTagName('input')[0].checked = rowsSorted[i][2];
  3509. tBody.childNodes[i].cells[2].getElementsByTagName('input')[0].checked = rowsSorted[i][3];
  3510. if (i === 0) {
  3511. tBody.childNodes[i].cells[0].getElementsByTagName('div')[0].getElementsByTagName('a')[0].setAttribute('style', 'visibility:hidden;');
  3512. tBody.childNodes[i].cells[0].getElementsByTagName('div')[0].getElementsByTagName('a')[1].setAttribute('style', '');
  3513. } else if (i === 10) {
  3514. tBody.childNodes[i].cells[0].getElementsByTagName('div')[0].getElementsByTagName('a')[0].setAttribute('style', '');
  3515. tBody.childNodes[i].cells[0].getElementsByTagName('div')[0].getElementsByTagName('a')[1].setAttribute('style', 'visibility:hidden;');
  3516. } else {
  3517. tBody.childNodes[i].cells[0].getElementsByTagName('div')[0].getElementsByTagName('a')[0].setAttribute('style', '');
  3518. tBody.childNodes[i].cells[0].getElementsByTagName('div')[0].getElementsByTagName('a')[1].setAttribute('style', '');
  3519. }
  3520. }
  3521. rowsSorted = [[]];
  3522. }
  3523.  
  3524. function GetXRating (value, ratingtype) {
  3525. // Волшебные формулы взяты из исходного кода XVM (https://bitbucket.org/XVM/xvm/src/default/src/xpm/xvm_main/xvm_scale.py?at=default)
  3526. // по рекомендации на форуме koreanrandom (http://www.koreanrandom.com/forum/topic/2625-xvm-%D1%88%D0%BA%D0%B0%D0%BB%D0%B0-scale/)
  3527. var result;
  3528. switch (ratingtype) {
  3529. case "effres":
  3530. if (value > 2250) {
  3531. result = 100;
  3532. } else {
  3533. result = Math.max(0, Math.min(100,
  3534. value * (value * (value * (value * (value *
  3535. (value * 0.000000000000000013172 - 0.000000000000092286)
  3536. + 0.00000000023692)
  3537. - 0.00000027377)
  3538. + 0.00012983)
  3539. + 0.05935)
  3540. - 31.684, 100), 0).toFixed(2);
  3541. }
  3542. break;
  3543. case "wn6":
  3544. if (value > 2350) {
  3545. result = 100;
  3546. } else {
  3547. result = Math.max(0, Math.min(100,
  3548. value * (value * (value * (value * (value * (value *
  3549. 0.000000000000000001225
  3550. - 0.000000000000007167)
  3551. + 0.000000000005501)
  3552. + 0.00000002368)
  3553. - 0.00003668)
  3554. + 0.05965)
  3555. - 5.297, 100), 0).toFixed(2);
  3556. }
  3557. break;
  3558. case "wn8":
  3559. if (value > 3650) {
  3560. result = 100;
  3561. } else {
  3562. result = Math.max(0, Math.min(100,
  3563. value * (value * (value * (value * (value * (-value *
  3564. 0.00000000000000000007656
  3565. + 0.0000000000000014848)
  3566. - 0.0000000000099633)
  3567. + 0.00000002858)
  3568. - 0.00003836)
  3569. + 0.0575)
  3570. - 0.99, 100), 0).toFixed(2);
  3571. }
  3572. break;
  3573. case "wgr":
  3574. if (value > 11100) {
  3575. result = 100;
  3576. } else {
  3577. result = Math.max(0, Math.min(100,
  3578. value * (value * (value * (value * (value * (-value *
  3579. 0.0000000000000000000013018
  3580. + 0.00000000000000004812)
  3581. - 0.00000000000071831)
  3582. + 0.0000000055583)
  3583. - 0.000023362)
  3584. + 0.059054)
  3585. - 47.85, 100), 0).toFixed(2);
  3586. }
  3587. break;
  3588. case "pr":
  3589.  
  3590. if (value >= 2175) {
  3591. result = 100;
  3592. } else if (value >= 1500 && value < 2175) {
  3593. result = Math.max(value * (value * (value *
  3594. (0.00000000074489 * value - 0.0000051431)
  3595. + 0.01313866)
  3596. - 14.65) + 6057.52
  3597. , value*(value*(0.000000081703*value - 0.000699026) + 1.88722) - 1538.59).toFixed(2);
  3598.  
  3599. } else {
  3600. result = Math.max(value*(0.00001717*value + 0.03825) - 38.45, 0).toFixed(2);
  3601. }
  3602. break;
  3603.  
  3604. case "bs":
  3605.  
  3606. if (value > 13200) {
  3607. result = 100;
  3608. } else {
  3609. result = Math.max(Math.min(value * (value * (value * (value * (value *
  3610. (-0.00000000000000000000024883*value + 0.0000000000000000117935)
  3611. - 0.00000000000021706)
  3612. + 0.00000000193685)
  3613. - 0.0000089711)
  3614. + 0.02948)
  3615. - 0.78, 100), 0).toFixed(2);
  3616. }
  3617. break;
  3618.  
  3619. case "nr":
  3620. if (value > 240) {
  3621. result = 100;
  3622. } else {
  3623. result = Math.max(Math.min(value*(value*(value*(value*(value*
  3624. (0.0000000000060542*value - 0.0000000047258)
  3625. + 0.00000132876)
  3626. - 0.00016789)
  3627. + 0.009921)
  3628. + 0.2677)
  3629. - 17.3, 100), 0).toFixed(2);
  3630. }
  3631. break;
  3632.  
  3633. default:
  3634. result = 0;
  3635. }
  3636. return result;
  3637.  
  3638. }
  3639.  
  3640. function CalcEffColor(effval, type) {
  3641. //Цифры границ взяты с на форума koreanrandom (http://www.koreanrandom.com/forum/topic/2625-xvm-%D1%88%D0%BA%D0%B0%D0%BB%D0%B0-scale/)
  3642. var lang;
  3643. if (document.title.indexOf("Профиль игрока") > -1)
  3644. lang = "ru";
  3645. var color, lboundary, uboundary;
  3646. switch (type) {
  3647.  
  3648. case "xvm":
  3649. if (effval < 16.5) color = 'FE0E00', lboundary = 0, uboundary = 16.5;
  3650. else if (effval < 33.5) color = 'FE7903', lboundary = 16.5, uboundary = 33.5;
  3651. else if (effval < 52.5) color = 'F8F400', lboundary = 33.5, uboundary = 52.5;
  3652. else if (effval < 75.5) color = '60FF00', lboundary = 52.5, uboundary = 75.5;
  3653. else if (effval < 92.5) color = '02C9B3', lboundary = 75.5, uboundary = 92.5;
  3654. else if (effval < 99999) color = 'D042F3', lboundary = 92.5, uboundary = 99999;
  3655. else color = 'white' , lboundary = '', uboundary = '';
  3656. break;
  3657. case "winrate":
  3658. if (effval < 47) color = 'FE0E00', lboundary = 0, uboundary = 47;
  3659. else if (effval < 49) color = 'FE7903', lboundary = 47, uboundary = 49;
  3660. else if (effval < 53) color = 'F8F400', lboundary = 49, uboundary = 53;
  3661. else if (effval < 58) color = '60FF00', lboundary = 53, uboundary = 58;
  3662. else if (effval < 65) color = '02C9B3', lboundary = 58, uboundary = 65;
  3663. else if (effval < 99999) color = 'D042F3', lboundary = 65, uboundary = 99999;
  3664. else color = 'white' , lboundary = '', uboundary = '';
  3665. break;
  3666. case "eff":
  3667. if (effval < 615) color = 'FE0E00', lboundary = 0, uboundary = 615;
  3668. else if (effval < 870) color = 'FE7903', lboundary = 615, uboundary = 870;
  3669. else if (effval < 1175) color = 'F8F400', lboundary = 870, uboundary = 1175;
  3670. else if (effval < 1525) color = '60FF00', lboundary = 1175, uboundary = 1525;
  3671. else if (effval < 1850) color = '02C9B3', lboundary = 1525, uboundary = 1850;
  3672. else if (effval < 99999) color = 'D042F3', lboundary = 1850, uboundary = 99999;
  3673. else color = 'white' , lboundary = '', uboundary = '';
  3674. break;
  3675. case "wn6":
  3676. if (effval < 460) color = 'FE0E00', lboundary = 0, uboundary = 460;
  3677. else if (effval < 850) color = 'FE7903', lboundary = 460, uboundary = 850;
  3678. else if (effval < 1215) color = 'F8F400', lboundary = 850, uboundary = 1215;
  3679. else if (effval < 1620) color = '60FF00', lboundary = 1215, uboundary = 1620;
  3680. else if (effval < 1960) color = '02C9B3', lboundary = 1620, uboundary = 1960;
  3681. else if (effval < 99999) color = 'D042F3', lboundary = 1960, uboundary = 99999;
  3682. else color = 'white' , lboundary = '', uboundary = '';
  3683. break;
  3684. case "wn8":
  3685. if (effval < 380) color = 'FE0E00', lboundary = 0, uboundary = 380;
  3686. else if (effval < 860) color = 'FE7903', lboundary = 380, uboundary = 860;
  3687. else if (effval < 1420) color = 'F8F400', lboundary = 860, uboundary = 1420;
  3688. else if (effval < 2105) color = '60FF00', lboundary = 1420, uboundary = 2105;
  3689. else if (effval < 2770) color = '02C9B3', lboundary = 2105, uboundary = 2770;
  3690. else if (effval < 99999) color = 'D042F3', lboundary = 2770, uboundary = 99999;
  3691. else color = 'white' , lboundary = '', uboundary = '';
  3692. break;
  3693. case "WGRating":
  3694. if (effval < 2495) color = 'FE0E00', lboundary = 0, uboundary = 2495;
  3695. else if (effval < 4345) color = 'FE7903', lboundary = 2495, uboundary = 4345;
  3696. else if (effval < 6425) color = 'F8F400', lboundary = 4345, uboundary = 6425;
  3697. else if (effval < 8625) color = '60FF00', lboundary = 6425, uboundary = 8625;
  3698. else if (effval < 10040) color = '02C9B3', lboundary = 8625, uboundary = 10040;
  3699. else if (effval < 99999) color = 'D042F3', lboundary = 10040,uboundary = 99999;
  3700. else color = 'white' , lboundary = '', uboundary = '';
  3701. break;
  3702. case "bs":
  3703. if (effval < 720) color = 'FE0E00', lboundary = 0, uboundary = 720;
  3704. else if (effval < 1920) color = 'FE7903', lboundary = 720, uboundary = 1920;
  3705. else if (effval < 3905) color = 'F8F400', lboundary = 1920, uboundary = 3905;
  3706. else if (effval < 6700) color = '60FF00', lboundary = 3905, uboundary = 6700;
  3707. else if (effval < 9600) color = '02C9B3', lboundary = 6700, uboundary = 9600;
  3708. else if (effval < 99999) color = 'D042F3', lboundary = 9600, uboundary = 99999;
  3709. else color = 'white' , lboundary = '', uboundary = '';
  3710. break;
  3711. case "nr":
  3712. if (effval < 69) color = 'FE0E00', lboundary = 0, uboundary = 69;
  3713. else if (effval < 102) color = 'FE7903', lboundary = 69, uboundary = 102;
  3714. else if (effval < 135) color = 'F8F400', lboundary = 102, uboundary = 135;
  3715. else if (effval < 172) color = '60FF00', lboundary = 135, uboundary = 172;
  3716. else if (effval < 203) color = '02C9B3', lboundary = 172, uboundary = 203;
  3717. else if (effval < 99999) color = 'D042F3', lboundary = 203, uboundary = 99999;
  3718. else color = 'white' , lboundary = '', uboundary = '';
  3719. break;
  3720. case "pr":
  3721. if (effval < 1000) color = 'FE0E00', lboundary = 0, uboundary = 1000;
  3722. else if (effval < 1215) color = 'FE7903', lboundary = 1000, uboundary = 1215;
  3723. else if (effval < 1445) color = 'F8F400', lboundary = 1215, uboundary = 1445;
  3724. else if (effval < 1685) color = '60FF00', lboundary = 1445, uboundary = 1685;
  3725. else if (effval < 1990) color = '02C9B3', lboundary = 1685, uboundary = 1990;
  3726. else if (effval < 99999) color = 'D042F3', lboundary = 1990, uboundary = 99999;
  3727. else color = 'white' , lboundary = '', uboundary = '';
  3728. break;
  3729. default: color = 'white', lboundary = '', uboundary = '';
  3730. }
  3731. return [color, (uboundary === 99999 ? (lang === "ru" ? 'Максимальный уровень. Круче только вареные яйца.'
  3732. : 'Max. level')
  3733. : (uboundary - effval).toFixed(2) + (lang === "ru" ? ' баллов до следующего ранга'
  3734. : ' points to next level')) + '<br/>' +
  3735. (effval - lboundary).toFixed(2) + (lang === "ru" ? ' баллов выше предыдущего ранга'
  3736. : ' points past previous level')];
  3737. }
  3738.  
  3739. function putTankStats(response) {
  3740. var UserId = window.location.href.match(/\/(\d+)/)[1],
  3741. tanks = document.getElementsByClassName("t-profile_tankstype__item"),
  3742. tank_stats = [],
  3743. nominalDamage = GetLSData("nominalDamage"),
  3744. nominalDamageArr = [],
  3745. wn8Data = GetLSData("WN8Data"),
  3746. wn8DataArr = [],
  3747. lvl = 0,
  3748. tPR = 0,
  3749. tWN8 = 0,
  3750. tnaSum = 0;
  3751. eval("var resp =" + response);
  3752. if (resp) {
  3753. for (var key = 0; key < resp.data[UserId].length; key++) {
  3754. var tank = resp.data[UserId][key];
  3755. tank_stats[tank.tank_id] = [];
  3756. tank_stats[tank.tank_id]['battles'] = tank.all.battles;
  3757. tank_stats[tank.tank_id]['damage_dealt'] = tank.all.damage_dealt;
  3758. tank_stats[tank.tank_id]['dropped_capture_points'] = tank.all.dropped_capture_points;
  3759. tank_stats[tank.tank_id]['frags'] = tank.all.frags;
  3760. tank_stats[tank.tank_id]['spotted'] = tank.all.spotted;
  3761. tank_stats[tank.tank_id]['wins'] = tank.all.wins;
  3762.  
  3763. }
  3764. }
  3765. if (nominalDamage) {
  3766. nominalDamage = eval(nominalDamage);
  3767. for (i = 0; i < nominalDamage.length; i++) {
  3768. if (nominalDamage[i].nominalDamage) {
  3769. nominalDamageArr[(nominalDamage[i].id).toLowerCase()] = [];
  3770. nominalDamageArr[(nominalDamage[i].id).toLowerCase()].nominalDamage = nominalDamage[i].nominalDamage * 1;
  3771. nominalDamageArr[(nominalDamage[i].id).toLowerCase()].level = nominalDamage[i].level * 1;
  3772. }
  3773. }
  3774. } else {
  3775. xdr.xget("http://www.noobmeter.com/tankListJson/elfx_133054", savenominalDamage);
  3776. }
  3777. if (wn8Data) {
  3778. eval("var allwn8Data =" + wn8Data);
  3779. for (var key = 0; key < allwn8Data.data.length; key++) {
  3780. t = allwn8Data.data[key];
  3781. wn8DataArr[parseInt(t.IDNum)] = [];
  3782. wn8DataArr[parseInt(t.IDNum)].expDamage = t.expDamage / 1;
  3783. wn8DataArr[parseInt(t.IDNum)].expSpot = t.expSpot / 1;
  3784. wn8DataArr[parseInt(t.IDNum)].expFrag = t.expFrag / 1;
  3785. wn8DataArr[parseInt(t.IDNum)].expDef = t.expDef / 1;
  3786. wn8DataArr[parseInt(t.IDNum)].expWinRate = (t.expWinRate / 100).toFixed(4);
  3787. }
  3788. } else {
  3789. xdr.xget("http://www.wnefficiency.net/exp/expected_tank_values_latest.json", saveWN8Data);
  3790. }
  3791. for (var i = 0; i < tanks.length; i++) {
  3792. var imgName = (tanks[i].cells[0].getElementsByTagName('img')[0].src.match(/\/[^-]+-([^\/]*)\.png/)[1]).toLowerCase(),
  3793. tank_id = parseInt(tanks[i].nextElementSibling.getAttribute('data-vehicle-cd'));
  3794. if (nominalDamageArr[imgName]) {
  3795. lvl = nominalDamageArr[imgName].level;
  3796. tnaSum = tank_stats[tank_id]['battles'] * nominalDamageArr[imgName].nominalDamage;
  3797. }
  3798.  
  3799. if (tnaSum > 0) {
  3800. tPR = (500 * (tank_stats[tank_id]['wins'] / tank_stats[tank_id]['battles']) / 0.4856) + (1000 * tank_stats[tank_id]['damage_dealt'] / (tnaSum * 0.975));
  3801. var clearedFromPenalties1 = 1500,
  3802. expectedMinBattles1 = 500,
  3803. expectedMinAvgTier1 = 6,
  3804. clearedFromPenalties2 = 1900,
  3805. expectedMinBattles2 = 2000,
  3806. expectedMinAvgTier2 = 7;
  3807. if (tPR > clearedFromPenalties1)
  3808. tPR = tPR - (tPR - clearedFromPenalties1) * Math.pow(Math.max(0, 1 - (lvl / expectedMinAvgTier1), 1 - (tank_stats[tank_id]['battles'] / expectedMinBattles1)), 0.5);
  3809. if (tPR > clearedFromPenalties2)
  3810. tPR = tPR - (tPR - clearedFromPenalties2) * Math.pow(Math.max(0, 1 - (lvl / expectedMinAvgTier2), 1 - (tank_stats[tank_id]['battles'] / expectedMinBattles2)), 0.5);
  3811. tPR = tPR.toFixed(2);
  3812. }
  3813.  
  3814. tanks[i].setAttribute('PR', tPR);
  3815. if (wn8DataArr[tank_id]) {
  3816. var expDmg = tank_stats[tank_id]['battles'] * wn8DataArr[tank_id].expDamage,
  3817. expSpot = tank_stats[tank_id]['battles'] * wn8DataArr[tank_id].expSpot,
  3818. expFrag = tank_stats[tank_id]['battles'] * wn8DataArr[tank_id].expFrag,
  3819. expDef = tank_stats[tank_id]['battles'] * wn8DataArr[tank_id].expDef,
  3820. expWinRate = tank_stats[tank_id]['battles'] * wn8DataArr[tank_id].expWinRate,
  3821. rDAMAGE = tank_stats[tank_id]['damage_dealt'] / expDmg,
  3822. rSPOT = tank_stats[tank_id]['spotted'] / expSpot,
  3823. rFRAG = tank_stats[tank_id]['frags'] / expFrag,
  3824. rDEF = tank_stats[tank_id]['dropped_capture_points'] / expDef,
  3825. rWIN = tank_stats[tank_id]['wins'] / expWinRate,
  3826. rWINc = Math.max(0, (rWIN - 0.71) / (1 - 0.71)),
  3827. rDAMAGEc = Math.max(0, (rDAMAGE - 0.22) / (1 - 0.22)),
  3828. rFRAGc = Math.max(0, Math.min(rDAMAGEc + 0.2, (rFRAG - 0.12) / (1 - 0.12))),
  3829. rSPOTc = Math.max(0, Math.min(rDAMAGEc + 0.1, (rSPOT - 0.38) / (1 - 0.38))),
  3830. rDEFc = Math.max(0, Math.min(rDAMAGEc + 0.1, (rDEF - 0.10) / (1 - 0.10))),
  3831. tWN8 = 980 * rDAMAGEc + 210 * rDAMAGEc * rFRAGc + 155 * rFRAGc * rSPOTc + 75 * rDEFc * rFRAGc + 145 * Math.min(1.8, rWINc);
  3832. }
  3833. tanks[i].setAttribute('WN8', tWN8);
  3834. }
  3835. }