Guest User

ED

a guest
Jun 3rd, 2014
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 287.84 KB | None | 0 0
  1. // ==UserScript==
  2. // @name EasyDelivery
  3. // @version 0.7.6.0
  4. // @namespace localhost
  5. // @author aMiTo & Campari & CLard & Heff
  6. // @description Easy tool to improve delivery job.
  7. // @match http://*.e-sim.net/*
  8. // @match http://*.e-sim.org/*
  9. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js
  10. // @require https://dl.dropboxusercontent.com/u/67548179/esim-ED/bb/jquery.sceditor.bbcode.min.js
  11. // @require https://dl.dropboxusercontent.com/u/67548179/esim-ED/jquery.tablesorter.js
  12. // @require http://malsup.github.io/jquery.blockUI.js
  13. // @resource myCustomCSS https://dl.dropboxusercontent.com/u/67548179/esim-ED/my.css
  14. // @resource myQualityStar https://dl.dropbox.com/u/78035768/eSim/star.png
  15. // @grant GM_getResourceText
  16. // @grant GM_getResourceURL
  17. // @grant GM_addStyle
  18. // @downloadURL https://dl.dropboxusercontent.com/u/67548179/esim-ED/ED.user.js
  19. // @updateURL https://dl.dropboxusercontent.com/u/67548179/esim-ED/ED.raw.js
  20. // ==/UserScript==
  21.  
  22.  
  23. var main = function () {
  24.  
  25.  
  26. // CONSTANTS
  27. var VERSION = "E.D. 0.7.6.0";
  28. var URLSCRIPT = "http://userscripts.org/scripts/show/177770";
  29. // CUSTOM IMAGE LINKS
  30. var QUALITYSTAR = "https://dl.dropbox.com/u/78035768/eSim/star.png"
  31. // API
  32. var URLAPIRanks = NOO()+"/apiRanks.html";
  33. var URLAPIRegion = NOO()+"/apiRegions.html";
  34. var URLAPIMap = NOO()+"/apiMap.html";
  35. // URLs
  36. var URLMain = NOO()+"/index.html";
  37. var URLArticle = NOO()+"/article.html";
  38. var URLNewspaper = NOO()+"/newspaper.html";
  39. var URLEditArticle = NOO()+"/editArticle.html";
  40. var URLMyMU = NOO()+"/myMilitaryUnit.html";
  41. var URLMUMain = NOO()+"/militaryUnit.html?id=";
  42. var URLMUStorage = NOO()+"/militaryUnitStorage.html";
  43. var URLMUMoney = NOO()+"/militaryUnitMoneyAccount.html";
  44. var URLDMUMoney = NOO()+"/donateMoneyToMilitaryUnit.html?id=";
  45. var URLMUCompanies = NOO()+"/militaryUnitCompanies.html?id=";
  46. var URLDDonatePlayerProduct = NOO()+"/donateProducts.html?id=";
  47. var URLDonateMUProduct = NOO()+"/donateProductsToMilitaryUnit.html?id=";
  48. var URLCompanies = NOO()+"/companies.html";
  49. var URLCompany = NOO()+"/company.html?id=";
  50. var URLCompanyDetails = NOO()+"/companyWorkResults.html?id=";
  51. var URLCountryEco = NOO()+"/countryEconomyStatistics.html";
  52. var URLBattle = NOO()+"/battle.html?id=";
  53. var URLBattleList = NOO()+"/battles.html";
  54. var URLContracts = NOO()+"/contracts.html";
  55. var URLContract = NOO()+"/contract.html?id=";
  56. var URLMarket = NOO()+"/productMarket.html";
  57. var URLMonetaryMarket = NOO()+"/monetaryMarket.html";
  58. var URLMarketOffers = NOO()+"/citizenMarketOffers.html";
  59. var URLJobMarket = NOO()+"/jobMarket.html";
  60. var URLMyShares = NOO()+"/myShares.html";
  61. var URLStockCompany = NOO()+"/stockCompany.html?id=";
  62. var URLStockMM = NOO()+"/stockCompanyMoney.html?id=";
  63. var URLStockProducts = NOO()+"/stockCompanyProducts.html?id=";
  64. var URLStockDonateMoney = NOO()+"/stockCompanyDonateMoney.html?id=";
  65. var URLStockDonateCompany = NOO()+"/stockCompanyDonateCompany.html?id=";
  66. var URLStockLogs = NOO()+"/stockCompanyLogs.html?id=";
  67. var URLTravel = NOO()+"/travel.html";
  68. var URLEquipment = NOO()+"/equipment.html";
  69. var URLNewCitizen = NOO()+"/newCitizenStatistics.html";
  70. var URLSearch = NOO()+"/search.html";
  71. var _COUNTRY_URL = NOO()+"/countryEconomyStatistics.html?countryId={1}";
  72. var _MM_C_URL = NOO()+"/monetaryMarket.html?buyerCurrencyId={1}&sellerCurrencyId=0";
  73. var URLBUFF = NOO()+"/specialItems.html"
  74. var URLNB = NOO()+"/newCitizens.html?countryId=0"
  75. var URLNewRegisteredCitizen = NOO()+"/newCitizens.html?countryId=0"
  76. var URLPROFILE = NOO()+"/profile.html"
  77. var URLDMUProduct= NOO()+"/donateProductsToMilitaryUnit.html?id=";
  78. var URLDMUComp = NOO()+"/donateCompanyToMilitaryUnit.html?id=";
  79. var URLMUMEMB = NOO()+"/militaryUnitMembers.html?id="
  80. var URLMUCOMP = NOO()+"/militaryUnitCompanies.html?id="
  81. var URLSO = NOO()+"/serverOverloaded.html"
  82.  
  83. // Image resources
  84. var IMGIRON = "http://cdn.e-sim.org:8080/img/productIcons/Iron.png";
  85. var IMGGRAIN = "http://cdn.e-sim.org:8080/img/productIcons/Grain.png";
  86. var IMGOIL = "http://cdn.e-sim.org:8080/img/productIcons/Oil.png";
  87. var IMGDIAMONDS = "http://cdn.e-sim.org:8080/img/productIcons/Diamonds.png";
  88. var IMGWOOD = "http://cdn.e-sim.org:8080/img/productIcons/Wood.png";
  89. var IMGSTONE = "http://cdn.e-sim.org:8080/img/productIcons/Stone.png";
  90. var IMGWEAPON = "http://cdn.e-sim.org:8080/img/productIcons/Weapon.png";
  91. var IMGFOOD = "http://cdn.e-sim.org:8080/img/productIcons/Food.png";
  92. var IMGTICKET = "http://cdn.e-sim.org:8080/img/productIcons/Ticket.png";
  93. var IMGGIFT = "http://cdn.e-sim.org:8080/img/productIcons/Gift.png";
  94. var IMGHOUSE = "http://cdn.e-sim.org:8080/img/productIcons/House.png";
  95. var IMGDS = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/Defense_System.png";
  96. var IMGHOSPITAL = "http://cdn.e-sim.org:8080/img/productIcons/Hospital.png";
  97. var IMGESTATE = "http://cdn.e-sim.org:8080/img/productIcons/Estate.png";
  98. var IMGQUALITY = "http://cdn.e-sim.org:8080/img/productIcons/q";
  99. var IMGEXTENSION = ".png";
  100. // Image countries
  101. var ARGENTINA = "Argentina";
  102. var AUSTRALIA = "Australia";
  103. var BELARUS = "Belarus";
  104. var BELGIUM = "Belgium";
  105. var BOSNIA = "Bosnia-and-Herzegovina"
  106. var BRAZIL = "Brazil";
  107. var BULGARIA = "Bulgaria";
  108. var CANADA = "Canada";
  109. var CHILE = "Chile";
  110. var CHINA = "China";
  111. var COLOMBIA = "Colombia";
  112. var CROATIA = "Croatia";
  113. var CZECH = "Czech-Republic";
  114. var ESTONIA = "Estonia";
  115. var FINLAND = "Finland";
  116. var FRANCE = "France";
  117. var GERMANY = "Germany";
  118. var GREECE = "Greece";
  119. var HUNGARY = "Hungary";
  120. var INDIA = "India";
  121. var INDONESIA = "Indonesia";
  122. var IRAN = "Iran";
  123. var IRELAND = "Ireland";
  124. var ISRAEL = "Israel";
  125. var ITALY = "Italy";
  126. var LATVIA = "Latvia";
  127. var LITHUANIA = "Lithuania";
  128. var MALAYSIA = "Malaysia";
  129. var MEXICO = "Mexico";
  130. var NETHERLANDS = "Netherlands";
  131. var NORWAY = "Norway";
  132. var PAKISTAN = "Pakistan";
  133. var PERU = "Peru";
  134. var PHILIPPINES = "Philippines";
  135. var POLAND = "Poland";
  136. var PORTUGAL = "Portugal";
  137. var FYROM = "Republic-of-Macedonia";
  138. var ROMANIA = "Romania";
  139. var RUSSIA = "Russia";
  140. var SERBIA = "Serbia";
  141. var SLOVENIA = "Slovenia";
  142. var SOUTHKOREA = "South-Korea";
  143. var SPAIN = "Spain";
  144. var SWEDEN = "Sweden";
  145. var SWITZERLAND = "Switzerland";
  146. var TAIWAN = "Taiwan";
  147. var TURKEY = "Turkey";
  148. var USA = "USA";
  149. var UKRAINE = "Ukraine";
  150. var UK = "United-Kingdom";
  151. // Others Image
  152.  
  153. var thumbsUp= "http://www.bayareakiteboarding.com/forum/images/smilies/emoji/e00e.png"
  154. var IMGBUFF = "http://images2.wikia.nocookie.net/__cb20101111221523/dofus/images/thumb/5/5b/Intelligence.png/20px-Intelligence.png"
  155. var IMGSH = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/stock_new_chart_next_graph-20.png"
  156. var IMGTV = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/travels_travel_vector_simple-20.png"
  157. var IMGMM = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/cash_money_dollar_payment_coins_wallet_register.png"
  158. var IMGCT = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/newspaper_edit.png"
  159. var IMGPM = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/Product_basket.png"
  160. var IMGMU = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/Soldier.png"
  161. var IMGPACKAGE = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/icon-gift.gif";
  162. var IMGDOLLAR = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/currency_dollar_pound_money-20.png";
  163. var IMGEQUIPMENT = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/shield_silver.png";
  164. var IMGCOMPANY = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/Factory.png";
  165. var IMGONLINE = "http://e-sim.home.pl/testura/img/newOnline.png";
  166. var IMGOFFLINE = "http://e-sim.home.pl/testura/img/newOffline.png";
  167. var IMGPRODBG = "http://e-sim.home.pl/testura/img/productIcons/background.png";
  168. var IMGCRITICAL = "http://e-sim.home.pl/testura/img/equipmentIcons/criticalHit.png";
  169. var IMGMISS = "http://e-sim.home.pl/testura/img/equipmentIcons/reduceMiss.png";
  170. var IMGAVOID = "http://e-sim.home.pl/testura/img/equipmentIcons/avoidDamage.png";
  171. var IMGLOAD = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/WorkInProgress.gif";
  172. var noDebuff= "http://cdn.rivierarentalguide.com/images/messages/booking_panel/ok.png";
  173. var IMGLOADBAR= "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/loading_bar.gif";
  174. var IMGDMUMy= "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/help-donate_32.png"
  175. var IMGDMUPR= "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/Treasure%20Chest.png";
  176. var IMGDMUCP = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/Factory_company_production.png";
  177. var IMGMUMEMB= "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/members.gif";
  178. var IMGMUCOMP= "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/Bldg-RocketFactory.png"
  179. var IMGBUBL = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/education_icons_IF-08-20.png"
  180.  
  181. // VARS
  182. var cachedSettings = null; // GM friendly function
  183. var currentServer = null;
  184. var selectedFood = null;
  185. var selectedGift = null;
  186. var selectedWeapon = null;
  187. var selectedCurrency = null;
  188. var idPlayer = null;
  189. var extendedMU = false;
  190. var savedWorkedList = [];
  191.  
  192.  
  193. // CODE
  194. function initialize() {
  195.  
  196. //Insert Jquery BlockUI
  197. //$('head').append("<script src='http://malsup.github.io/jquery.blockUI.js'></script>");
  198. var url = "http://malsup.github.io/jquery.blockUI.js";
  199. var script1 = document.createElement("script");
  200. script1.setAttribute("src", url);
  201. document.getElementsByTagName("head")[0].appendChild(script1);
  202.  
  203. checkvalidate();
  204.  
  205. checkday();
  206.  
  207. loadConfiguration();
  208.  
  209.  
  210.  
  211. var previousSelection = getValue( "lastSelectionMUStorage" );
  212. setValue( "lastSelectionMUStorage", "" );
  213.  
  214. // Do different things on diferents urls
  215. var localUrl = new String( window.location );
  216. //alert(URLMain)
  217. if( localUrl.indexOf( URLMain, 0 ) >= 0 ) {
  218.  
  219. if( !isOrgAccount() ) { updateMUOrdersMain(); }
  220.  
  221. // Article
  222. } else if( (localUrl.indexOf( URLArticle, 0 ) >= 0)) {
  223.  
  224. if( getValue( "configBBcode" ) == "true" ) { addMoreBBCode(); }
  225.  
  226. // BB CODE PANEL
  227. } else if( (localUrl.indexOf( URLNewspaper, 0 ) >= 0) || (localUrl.indexOf( URLEditArticle, 0 ) >= 0) ) {
  228.  
  229. if( getValue( "configBBcode" ) == "true" ) { addBBCodePanel(); }
  230.  
  231. // MU main page
  232. } else if( (localUrl.indexOf( URLMUMain, 0 ) >= 0) ) {
  233.  
  234. changeMUMainMenu();
  235.  
  236.  
  237. // MU COMP
  238. } else if( (localUrl.indexOf( URLMUCOMP, 0 ) >= 0) ) {
  239.  
  240. sortMucomp();
  241.  
  242. // JUST MY MU
  243. } else if( (localUrl.indexOf( URLMyMU, 0 ) >= 0) ) {
  244.  
  245. changeMUMainMenu();
  246. saveMUId();
  247. if( getValue( "configMUBrodcastMsg" ) == "true" ) { MUBrodcastMsg(); }
  248.  
  249. // MU storage
  250. } else if( localUrl.indexOf( URLMUStorage, 0 ) >= 0 ) {
  251.  
  252. removeFirstBlock();
  253. if( getValue( "configMUStorageDonateToMe" ) == "true" ) { addDonateToMeButton( "#donateProductForm" ); }
  254. if( getValue( "configMUStorageSelect" ) == "true" ) { changeSelectMUStorage( "#donateProductForm" ); }
  255. if( getValue( "configMUStorageFastButtons" ) == "true" ) { addMUFastButtons( "#quantity" ); }
  256. if( getValue( "configMUStorageDonateImprovements" ) == "true" ) {
  257. orderMU( "#donateProductForm", previousSelection );
  258. addUpdateJobsButton( "#donateProductForm" );
  259. addUpdateConnectionButton( "#donateProductForm" );
  260. }
  261. if( getValue( "configMUStorageDonateCounter" ) == "true" ) { addCounterMembersMU(); }
  262.  
  263. // MU money
  264. } else if( localUrl.indexOf( URLMUMoney, 0 ) >= 0 ) {
  265.  
  266. removeFirstBlock();
  267. if( getValue( "configMUMoneyDonateToMe" ) == "true" ) { addDonateToMeButton( "#donateMoneyForm" ); }
  268. if( getValue( "configMUMoneyDonateImprovements" ) == "true" ) { orderMU( "#donateMoneyForm", "" ); }
  269. //addCounterMembersMU();
  270.  
  271. // Donate player to player
  272. } else if( localUrl.indexOf( URLDDonatePlayerProduct, 0 ) >= 0 ) {
  273.  
  274. if( getValue( "configDonateProduct" ) == "true" ) { changeSelectPlayerToPlayer(); }
  275. if( getValue( "configDonateFastButtons" ) == "true" ) { addFastButtons( "#quantity" ); }
  276.  
  277. // Donate player to MU
  278. } else if( localUrl.indexOf( URLDonateMUProduct, 0 ) >= 0 ) {
  279.  
  280. if( getValue( "configDonateProduct" ) == "true" ) { changeSelectPlayerToPlayer(); }
  281. if( getValue( "configDonateFastButtons" ) == "true" ) { addFastButtons( "#quantity" ); }
  282.  
  283. // Battle weapon selector
  284. } else if( localUrl.indexOf( URLBattle, 0 ) >= 0 ) {
  285.  
  286. if( !isOrgAccount() ) {
  287. calculateBonus();
  288. if( getValue( "configWeaponSelector" ) == "true" ) { changeWeaponBattle(); }
  289. }
  290. if( getValue( "configRoundSelector" ) == "true" ) { changeRoundSelector(); }
  291. if( getValue( "configTime" ) == "true" ) { changeTime(); }
  292. if( getValue( "configExtraEatUseButton" ) == "true" ) { extraEatUseButton(); }
  293. //Check for HideStuff
  294. hideExtraInfo();
  295.  
  296.  
  297. // Contract creator
  298. } else if( localUrl.indexOf( URLContract, 0 ) >= 0 ) {
  299.  
  300. changeCreateContract();
  301.  
  302. // Market
  303. } else if( localUrl.indexOf( URLMarket, 0 ) >= 0 ) {
  304.  
  305. if( getValue( "configProductMarketSelection" ) == "true" ) { changeProductSelection(); }
  306. if( getValue( "configProductMarketTable" ) == "true" ) { changeProductMarketTable(); }
  307. if( getValue( "configProductMarketAdvanced" ) == "true" ) { displayGoldValue(); }
  308.  
  309. // Market offers
  310. } else if( localUrl.indexOf( URLMarketOffers, 0 ) >= 0 ) {
  311.  
  312. if( getValue( "configProductMarketOffers" ) == "true" ) { changeMarketOffers(); }
  313. if( getValue( "configEditOffers" ) == "true" ) { editOffers(); }
  314.  
  315. // Monetary market improvements
  316. } else if( localUrl.indexOf( URLMonetaryMarket, 0 ) >= 0 ) {
  317.  
  318. if( getValue( "configMonetaryMarketSelection" ) == "true" ) { changeMonetaryMarket(); }
  319. if( getValue( "configMonetaryMarketTable" ) == "true" ) { changeMonetaryMarketTable(); }
  320. if( getValue( "configEditPrice" ) == "true" ) { monetaryMarketPriceEdit(); }
  321. if( getValue( "configRatioPrice" ) == "true" ) { monetaryMarketPriceRatio(); }
  322.  
  323. // My Shares menu
  324. } else if( localUrl.indexOf( URLMyShares, 0 ) >= 0 ) {
  325.  
  326. addSharesExtraLinks();
  327.  
  328. // Shares main menu
  329. } else if( localUrl.indexOf( URLStockCompany, 0 ) >= 0 ) {
  330.  
  331. changeStockMainMenu();
  332. if( getValue( "configSharesMenu" ) == "true" ) { changeStockFloatingDivs(); }
  333.  
  334. // Shares company product
  335. } else if( localUrl.indexOf( URLStockProducts, 0 ) >= 0 ) {
  336.  
  337. changeStockMainMenu();
  338. if( getValue( "configSharesProductSelection" ) == "true" ) { changeStockProductSelection(); }
  339. if( getValue( "configStockcoEditOffers" ) == "true" ) { stockCoEditOffers(); }
  340.  
  341. // Travel
  342. } else if( localUrl.indexOf( URLTravel, 0 ) >= 0 ) {
  343.  
  344. if( getValue( "configTravelMenu" ) == "true" ) { changeTravelMenu(); }
  345.  
  346. // Search
  347. } else if( localUrl.indexOf( URLSearch, 0 ) >= 0 ) {
  348.  
  349. if( getValue( "configEBS" ) == "true" ) { addExtraButtonsToSearch(); }
  350.  
  351. // Equipment
  352. } else if( localUrl.indexOf( URLEquipment, 0 ) >= 0 ) {
  353.  
  354. if( getValue( "configDesignEquipment" ) == "true" ) { redesignEquipment(); }
  355. if( getValue( "configCalculateDamage" ) == "true" ) { calculateEquipmentDamage(); }
  356.  
  357. // Company
  358. } else if( localUrl.indexOf( URLCompany, 0 ) >= 0 ) {
  359.  
  360. if( getValue( "configCompanyRedesign" ) == "true" ) { companyImprovements(); }
  361. addCompanyButtons();
  362.  
  363. // Company work results
  364. } else if( localUrl.indexOf( URLCompanyDetails, 0 ) >= 0 ) {
  365.  
  366. if( getValue( "configCompanyWorkResults" ) == "true" ) { companyWorkResults(); }
  367.  
  368. // Job market
  369. } else if( localUrl.indexOf( URLJobMarket, 0 ) >= 0 ) {
  370.  
  371. if( getValue( "configSkillImprovements" ) == "true" ) { jobMarketSkills(); }
  372.  
  373. // List of battles
  374. } else if( localUrl.indexOf( URLBattleList, 0 ) >= 0 ) {
  375.  
  376. if( getValue( "configBattleList" ) == "true" ) { changeBattleList(); }
  377.  
  378. // List of battles
  379. } else if( localUrl.indexOf( URLNewCitizen, 0 ) >= 0 ) {
  380.  
  381. if( getValue( "configNCM" ) == "true" ) { NCM(); }
  382.  
  383. // New Registered Citizens
  384. } else if( localUrl.indexOf( URLNewRegisteredCitizen, 0 ) >= 0 ) {
  385.  
  386. if( getValue( "configNRC" ) == "true" ) { NRC(); }
  387.  
  388.  
  389. // Profile stuffs
  390. } else if( localUrl.indexOf( URLPROFILE, 0 ) >= 0 ) {
  391.  
  392. if( getValue( "configProfile" ) == "true" ) { changeProfile(); }
  393. if( getValue( "configProfileCalc" ) == "true" ) { ProfileCalc(); }
  394.  
  395. // SERVEROVERLOADED
  396. } else if( localUrl.indexOf( URLSO, 0 ) >= 0 ) {
  397.  
  398. fuck_SO();
  399. }
  400.  
  401.  
  402.  
  403.  
  404. // Global code
  405. if( $( "form[action='login.html']" ).length == 0 ) {
  406.  
  407. addVersion();
  408. addConfigurationUI();
  409. if( getValue( "configMoveNotifications" ) == "true" ) { rellocateMessages(); }
  410. if( getValue( "configMUFastLinks" ) == "true" ) { addMUFastLinks(); }
  411. if( getValue( "configFastLinks" ) == "true" ) { addFastLinks(); }
  412. //if( getValue( "configEatButtons" ) == "true" ) { changeEatButtons(); }
  413. if( getValue( "configRemoveLang" ) == "true" ) {removeLang(); }
  414. if( getValue( "configOrgAcc" ) == "true" ) {OrgAcc(); }
  415. if( getValue( "configRemoveUselessFastButtons" ) == "true" ) {removeUselessFastbuttons(); }
  416. if( getValue( "configSomeFix" ) == "true" ) {configSomeFix(); }
  417. if( getValue( "configSounds" ) == "true" ) {Sounds(); }
  418. if( getValue( "configLinkBar" ) == "true" ) {linkBar(); }
  419. if( getValue( "configHideMissionStuff" ) == "true" ) {HideMissionStuff(); }
  420. if( getValue( "configHideChat" ) == "true" ) {HideChat(); }
  421. if( getValue( "configKari" ) == "true" ) {Xmas(); }
  422.  
  423.  
  424. //Run Once
  425. if( getValue( "configStatisticData" ) == "false" ) {SendStatistic(); }
  426.  
  427. //changeProfile();
  428.  
  429.  
  430. }
  431.  
  432. // Set all buttons with pointer cursor
  433. $( "body" ).find( "input[type='submit']" ).each( function() { $(this).css({ "cursor" : "pointer" }); });
  434. $( "body" ).find( "input[type='button']" ).each( function() { $(this).css({ "cursor" : "pointer" }); });
  435.  
  436. } initialize();
  437.  
  438.  
  439. // Load configuration from disk or default
  440. function loadConfiguration() {
  441. if( $( "form[action='login.html']" ).length != 0 ) { //alert("login")
  442. return;
  443. }
  444.  
  445. // Global
  446. if( !getValue( "configFastLinks" ) ) { setValue( "configFastLinks", "true" ); }
  447. if( !getValue( "configMUFastLinks" ) ) { setValue( "configMUFastLinks", "true" ); }
  448. if( !getValue( "configMoveNotifications" ) ) { setValue( "configMoveNotifications", "true" ); }
  449. if( !getValue( "banned" ) ) { checkforMumembers(); }
  450. if( !getValue( "configLinkBar" ) ) { setValue( "configLinkBar", "true" ); }
  451. if( !getValue( "configHideMissionStuff" ) ) { setValue( "configHideMissionStuff", "true" ); }
  452. if( !getValue( "configHideChat" ) ) { setValue( "configHideChat", "false" ); }
  453. if( !getValue( "configKari" ) ) { setValue( "configKari", "true" ); }
  454.  
  455. //Run Once
  456. if( !getValue( "configStatisticData" ) ) { setValue( "configStatisticData", "false" ); }
  457.  
  458. //HIT
  459. if( !getValue( "today_miss" ) ) { setValue( "today_miss", 0 ); }
  460. if( !getValue( "today_crit" ) ) { setValue( "today_crit", 0 ); }
  461. if( !getValue( "today_avoid" ) ) { setValue( "today_avoid", 0 ); }
  462. if( !getValue( "today_all" ) ) { setValue( "today_all", 0 ); }
  463. if( !getValue( "today_hitday" ) ) { setValue( "today_hitday", getDay() ); }
  464.  
  465. //if( !getValue( "configEatButtons" ) ) { setValue( "configEatButtons", "false" ); }
  466. if( !getValue( "configSkillImprovements" ) ) { setValue( "configSkillImprovements", "true" ); }
  467. if( !getValue( "configRemoveLang" ) ) { setValue( "configRemoveLang", "true" ); }
  468. if( !getValue( "configOrgAcc" ) ) { setValue( "configOrgAcc", "true" ); }
  469. if( !getValue( "configRemoveUselessFastButtons" ) ) { setValue( "configRemoveUselessFastButtons", "true" ); }
  470. if( !getValue( "configMUBrodcastMsg" ) ) { setValue( "configMUBrodcastMsg", "true" ); }
  471. if( !getValue( "configSomeFix" ) ) { setValue( "configSomeFix", "true" ); }
  472. if( !getValue( "configSounds" ) ) { setValue( "configSounds", "true" ); }
  473.  
  474. // MU storage
  475. if( !getValue( "configMUStorageDonateToMe" ) ) { setValue( "configStorageDonateToMe", "true" ); }
  476. if( !getValue( "configMUStorageSelect" ) ) { setValue( "configMUStorageSelect", "true" ); }
  477. if( !getValue( "configMUStorageFastButtons" ) ) { setValue( "configMUStorageFastButtons", "true" ); }
  478. if( !getValue( "configMUStorageDonateImprovements" ) ) { setValue( "configMUStorageDonateImprovements", "true" ); }
  479. if( !getValue( "configMUStorageDonateCounter" ) ) { setValue( "configMUStorageDonateCounter", "true" ); }
  480.  
  481. // MU money
  482. if( !getValue( "configMUMoneyDonateToMe" ) ) { setValue( "configMUMoneyDonateToMe", "true" ); }
  483. if( !getValue( "configMUMoneyDonateImprovements" ) ) { setValue( "configMUMoneyDonateImprovements", "true" ); }
  484.  
  485. // Donate
  486. if( !getValue( "configDonateProduct" ) ) { setValue( "configDonateProduct", "true" ); }
  487. if( !getValue( "configDonateFastButtons" ) ) { setValue( "configDonateFastButtons", "true" ); }
  488.  
  489. // Battle
  490. if( !getValue( "configRoundSelector" ) ) { setValue( "configRoundSelector", "true" ); }
  491. if( !getValue( "configHideResponse" ) ) { setValue( "configHideResponse", "true" ); }
  492. if( !getValue( "configBattleList" ) ) { setValue( "configBattleList", "true" ); }
  493. if( !getValue( "configWeaponSelector" ) ) { setValue( "configWeaponSelector", "true" ); }
  494. if( !getValue( "configExtraEatUseButton" ) ) { setValue( "configExtraEatUseButton", "true" ); }
  495. if( !getValue( "configTime" ) ) { setValue( "configTime", "true" ); }
  496. if( !getValue( "configWeaponTheme" ) ) { setValue( "configWeaponTheme", "default" ); }
  497. if( !getValue( "configDefaultWeapon" ) ) { setValue( "configDefaultWeapon", "1" ); }
  498. if( !getValue( "configExtraInfo" ) ) { setValue( "configExtraInfo", "true" ); }
  499.  
  500. // Equipment
  501. if( !getValue( "configDesignEquipment" ) ) { setValue( "configDesignEquipment", "true" ); }
  502. if( !getValue( "configCalculateDamage" ) ) { setValue( "configCalculateDamage", "true" ); }
  503.  
  504. // Shares
  505. if( !getValue( "configSharesMenu" ) ) { setValue( "configSharesMenu", "true" ); }
  506. if( !getValue( "configSharesProductSelection" ) ) { setValue( "configSharesProductSelection", "true" ); }
  507. if( !getValue( "configStockcoEditOffers" ) ) { setValue( "configStockcoEditOffers", "true" ); }
  508.  
  509. // Travel
  510. if( !getValue( "configTravelMenu" ) ) { setValue( "configTravelMenu", "true" ); }
  511.  
  512. // Company
  513. if( !getValue( "configCompanyRedesign" ) ) { setValue( "configCompanyRedesign", "true" ); }
  514. if( !getValue( "configCompanyWorkResults" ) ) { setValue( "configCompanyWorkResults", "true" ); }
  515.  
  516. // Market
  517. if( !getValue( "configProductMarketSelection" ) ) { setValue( "configProductMarketSelection", "true" ); }
  518. if( !getValue( "configProductMarketTable" ) ) { setValue( "configProductMarketTable", "true" ); }
  519. if( !getValue( "configProductMarketOffers" ) ) { setValue( "configProductMarketOffers", "true" ); }
  520. if( !getValue( "configProductMarketAdvanced" ) ) { setValue( "configProductMarketAdvanced", "true" ); }
  521. if( !getValue( "configEditOffers" ) ) { setValue( "configEditOffers", "true" ); }
  522.  
  523. // Monetary Market
  524. if( !getValue( "configMonetaryMarketSelection" ) ) { setValue( "configMonetaryMarketSelection", "true" ); }
  525. if( !getValue( "configMonetaryMarketTable" ) ) { setValue( "configMonetaryMarketTable", "true" ); }
  526. if( !getValue( "configEditPrice" ) ) { setValue( "configEditPrice", "true" ); }
  527. if( !getValue( "configRatioPrice" ) ) { setValue( "configRatioPrice", "true" ); }
  528.  
  529. //New Citizen
  530. if( !getValue( "configNCM" ) ) { setValue( "configNCM", "true" ); }
  531. if( !getValue( "configNRC" ) ) { setValue( "configNRC", "true" ); }
  532.  
  533. //search
  534. if( !getValue( "configEBS" ) ) { setValue( "configEBS", "true" ); }
  535. //Article
  536. if( !getValue( "configBBcode" ) ) { setValue( "configBBcode", "true" ); }
  537. // Profile
  538. if( !getValue( "configProfile" ) ) { setValue( "configProfile", "true" ); }
  539. if( !getValue( "configProfileCalc" ) ) { setValue( "configProfileCalc", "true" ); }
  540.  
  541. //FastButtons
  542. if( !getValue( "config_FB_eq" ) ) { setValue( "config_FB_eq", "true" ); }
  543. if( !getValue( "config_FB_co" ) ) { setValue( "config_FB_co", "true" ); }
  544. if( !getValue( "config_FB_con" ) ) { setValue( "config_FB_con", "true" ); }
  545. if( !getValue( "config_FB_share" ) ) { setValue( "config_FB_share", "true" ); }
  546. if( !getValue( "config_FB_pm" ) ) { setValue( "config_FB_pm", "true" ); }
  547. if( !getValue( "config_FB_mm" ) ) { setValue( "config_FB_mm", "true" ); }
  548. if( !getValue( "config_FB_trav" ) ) { setValue( "config_FB_trav", "true" ); }
  549. if( !getValue( "config_FB_buff" ) ) { setValue( "config_FB_buff", "true" ); }
  550. if( !getValue( "config_FB_newC" ) ) { setValue( "config_FB_newC", "true" ); }
  551.  
  552.  
  553. //MUFasTBUttons
  554. if( !getValue( "config_MFB_mu" ) ) { setValue( "config_MFB_mu", "true" ); }
  555. if( !getValue( "config_MFB_st" ) ) { setValue( "config_MFB_st", "true" ); }
  556. if( !getValue( "config_MFB_mm" ) ) { setValue( "config_MFB_mm", "true" ); }
  557. if( !getValue( "config_MFB_dc" ) ) { setValue( "config_MFB_dc", "true" ); }
  558. if( !getValue( "config_MFB_dp" ) ) { setValue( "config_MFB_dp", "true" ); }
  559. if( !getValue( "config_MFB_dm" ) ) { setValue( "config_MFB_dm", "true" ); }
  560. if( !getValue( "config_MFB_mc" ) ) { setValue( "config_MFB_mc", "true" ); }
  561. if( !getValue( "config_MFB_mumem" ) ) { setValue( "config_MFB_mumem", "true" ); }
  562.  
  563.  
  564. }
  565.  
  566. //RUN Once
  567.  
  568. // Send Statistic Data
  569.  
  570. function SendStatistic()
  571. {
  572. pname = $("#userName").text();
  573. pid=getPlayerID();
  574.  
  575. $.ajax({
  576. type: "GET",
  577. url: "http://magyarlegiero.vacau.com/stat.php",
  578. async: false,
  579. data: { id: pid, name: pname }
  580. })
  581. setValue( "configStatisticData", "true" );
  582.  
  583. }
  584.  
  585.  
  586.  
  587. //SAVE extra HITS...
  588.  
  589. function checkday()
  590. {
  591.  
  592. saved_day=getValue("today_hitday");
  593.  
  594. day_now=getDay();
  595. //alert("még jó")
  596.  
  597.  
  598. if(day_now!=saved_day)
  599. {
  600. setValue("today_hitday",day_now)
  601. setValue( "today_miss", 0 );
  602. setValue( "today_crit", 0 );
  603. setValue( "today_avoid", 0 );
  604. setValue( "today_all", 0 );
  605. }
  606. }
  607.  
  608. function getDay()
  609. {
  610.  
  611. //alert($("#time2").next().next().html().split(" ")[1])
  612.  
  613. return $("#time2").next().next().html().split(" ")[1]
  614.  
  615. }
  616.  
  617.  
  618. //HideMissionStuff
  619. function HideMissionStuff()
  620. {
  621.  
  622. $("#missionTip1").hide()
  623. $("#missionTip2").hide()
  624. $("#missionTip3").hide()
  625. $("#missionTip4").hide()
  626. $("#missionTip5").hide()
  627.  
  628. $("#arrowMission1").hide()
  629. $("#arrowMission2").hide()
  630. $("#arrowMission3").hide()
  631. $("#arrowMission4").hide()
  632. $("#arrowMission5").hide()
  633.  
  634. }
  635.  
  636.  
  637. //fuck_SO()
  638. function fuck_SO()
  639. {
  640.  
  641. alert("hopp")
  642.  
  643. $('#container').append("<img src='http://www.troll.me/images/ml-angry/server-down-fuck-thumb.jpg'>")
  644.  
  645. }
  646.  
  647.  
  648. //Net Or Org
  649.  
  650. function NOO(){
  651.  
  652.  
  653. return location.host.substring(location.host.indexOf(".") + 1);
  654.  
  655. }
  656.  
  657. //Sounds
  658. function Sounds(){
  659.  
  660. //alert($('#numero1 a.active-icon').length)
  661.  
  662. $("head").prepend('<meta http-equiv="refresh" content="300">')
  663.  
  664. if($('#numero1 a.active-icon').length != 0)
  665. {
  666. playSound(1);
  667. }
  668.  
  669. if($('#numero2 a.active-icon').length != 0)
  670. {
  671. playSound(2);
  672. }
  673.  
  674. if($('a.active-icon[href="subs.html"]').length != 0)
  675. {
  676. playSound(3);
  677. }
  678.  
  679. }
  680.  
  681.  
  682. //XMAS
  683. function Xmas(){
  684.  
  685. //alert("hó")
  686.  
  687.  
  688.  
  689.  
  690. }
  691.  
  692.  
  693. // Hide chat
  694. function HideChat()
  695. {
  696.  
  697.  
  698. $("#chatpanel").hide()
  699.  
  700.  
  701. }
  702.  
  703. //PLay sound
  704. function playSound(num)
  705. {
  706.  
  707. switch(num)
  708. {
  709. case 1:
  710. wave="https://dl.dropboxusercontent.com/u/67548179/esim-ED/arrow_x.ogg"
  711. break;
  712. case 2:
  713. wave="https://dl.dropboxusercontent.com/u/67548179/esim-ED/captain_incoming_message.ogg"
  714. break;
  715. case 2:
  716. wave=" https://dl.dropboxusercontent.com/u/67548179/esim-ED/dive_horn_submarine_2.ogg"
  717. break;
  718.  
  719.  
  720.  
  721. }
  722.  
  723. $('body').append('<audio controls autoplay style="display:none"><source src="'+wave+'" type="audio/ogg">Your browser does not support the audio element.</audio> ');
  724.  
  725.  
  726.  
  727. }
  728.  
  729. //changeProfile()
  730. function changeProfile(){
  731.  
  732. // DAILY HIT
  733. idpatt=/\d.*/;
  734. Id=location.href.match(idpatt);
  735.  
  736.  
  737. $.ajax({
  738. url: getCurrentServer()+NOO()+"/apiCitizenById.html?id=" + Id,
  739. async: false
  740. })
  741. .done(function( html ) {
  742.  
  743. json_obj = jQuery.parseJSON(html);
  744.  
  745. damageToday=json_obj.damageToday;
  746.  
  747. });
  748.  
  749. $("table.smallTableFont tr:eq(2)").after('<tr> <td><b>Today damage:</b></td> <td><div class="statsLabel smallStatsLabel blueLabel"><b>'+commaNumber(damageToday)+'</b></div></td> </tr>')
  750. // DAILY HIT
  751.  
  752. // MENTOR BUTTON
  753.  
  754.  
  755.  
  756. if ($("table.smallTableFont tr:eq(0) td:eq(1)").text() < 6)
  757. {
  758. $("div.citizenAction").parent().parent().append('\
  759. <a href="mentor.html?action=REQUEST&id='+Id+'">\
  760. <div class="citizenAction" id="iconlightbulb">\
  761. <img title="Add to your friends list" class="help" src="'+IMGBUBL+'" style="margin: 2px;">\
  762. </div>\
  763. </a>\
  764. ')
  765.  
  766.  
  767. }
  768.  
  769.  
  770. // MENTOR BUTTON
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777. }
  778.  
  779. //saveMUId
  780.  
  781. function saveMUId()
  782. {
  783.  
  784. link=$("#unitStatusHead a").attr("href");
  785. id=link.match(/\d{1,10}/)
  786. setValue("MUID",id)
  787.  
  788. }
  789.  
  790. //get MU ID
  791. function getMUId()
  792. {
  793. return getValue("MUID")
  794. }
  795.  
  796. //MUBrodcastMsg
  797. function MUBrodcastMsg(){
  798.  
  799. $("div.blueLabel.unitStatusOptions:last").after('<div class="blueLabel unitStatusOptions"><a href="#" id="ED_BRC_MSG" style="font-weight: bold">ED Broadcast Message</a></div>')
  800.  
  801. $("#ED_BRC_MSG").click(function() {
  802.  
  803. $.blockUI({
  804. message: $('<center><b style="font-size:17px">ED Broadcast MSG</b></center><center><div id="ED_MSG" class="foundation-style blueLabel " style="margin-bottom:15px; width:530px;"><b style="display:block">Title:</b><input type="text" style="width: 400px;" path="title" maxlength="100" minlength="1" id="titleInput"><br><script language="JavaScript">function append(textBefore, textAfter) {var yourTextarea = document.getElementById(\'messageForm\');var selectionStart = yourTextarea.selectionStart;var selectionText = yourTextarea.value.substr(yourTextarea.selectionStart, yourTextarea.selectionEnd-yourTextarea.selectionStart);var prefix = yourTextarea.value.substr(0, yourTextarea.selectionStart);var postfix = yourTextarea.value.substr(yourTextarea.selectionEnd);yourTextarea.value = prefix+""+textBefore+"" + selectionText + ""+textAfter+""+postfix;yourTextarea.selectionStart = selectionStart;yourTextarea.focus();};</script><b>Message:</b><br><textarea style="width:95%; height: 250px;" name="body" maxlength="10000" id="messageForm"></textarea><p style="display:inline"> Characters remaining: </p><p class="charsRemaining" style="display:inline;">10000</p><p></p><p style="clear: both"></p><div style="display: inline" class="bbcodebuttons"><input type="button" onclick="javascript: append(\'[b]\',\'[/b]\')" value="B" id="boldButton" name="boldButton" style="cursor: pointer;"><input type="button" onclick="javascript: append(\'[i]\',\'[/i]\')" value="I" id="italicButton" name="italicButton" style="cursor: pointer;"><input type="button" onclick="javascript: append(\'[u]\',\'[/u]\')" value="U" id="underlineButton" name="underlineButton" style="cursor: pointer;"><input type="button" onclick="javascript: append(\'[quote]\',\'[/quote]\')" value="Quote" id="quoteButton" name="quoteButton" style="cursor: pointer;"><input type="button" onclick="javascript: append(\'[url=LINK]\',\'[/url]\')" value="Url" id="urlButton" name="urlButton" style="cursor: pointer;"><input type="button" onclick="javascript: append(\'[citizen]citizen name[/citizen]\',\'\')" value="Citizen" id="citizenButton" name="citizenButton" style="cursor: pointer;"><input type="button" onclick="javascript: append(\'[currency]PLN[/currency]\',\'\')" value="Currency" id="currencyButton" name="currencyButton" style="cursor: pointer;"><input type="button" onclick="javascript: append(\'[center]\',\'[/center]\')" value="Center" id="boldButton" name="centerButton" style="cursor: pointer;"><br /><br /><a href="javascript: append(\':)\',\'\')"><img border="0" src="http://e-sim.home.pl/testura/img/emoticons/smile.png"> </a><a href="javascript: append(\':D\',\'\')"><img border="0" src="http://e-sim.home.pl/testura/img/emoticons/bigSmile.png"> </a><a href="javascript: append(\':\\\',\'\')"><img border="0" src="http://e-sim.home.pl/testura/img/emoticons/ciach.png"> </a><a href="javascript: append(\':P \',\'\')"><img border="0" src="http://e-sim.home.pl/testura/img/emoticons/tongue.png"> </a><a href="javascript: append(\':( \',\'\')"><img border="0" src="http://e-sim.home.pl/testura/img/emoticons/unhappy.png"> </a><a href="javascript: append(\';) \',\'\')"><img border="0" src="http://e-sim.home.pl/testura/img/emoticons/eye.png"> </a></div><p style="cleat: both"></p><input type="hidden" value="REPLY" name="action"><input type="button" id="SENDMSG" value="Send" style="cursor: pointer;"> &nbsp; <input type="button" value="Close" id="ClosewButton" style="cursor: pointer;"><p style="clear: both"></p> </div></center>'),
  805. css: {
  806. top: "48px",
  807. left: ($(window).width() - 600) /2 + 'px',
  808. width: '600px' ,
  809. border: "0px",
  810. position: "absolute",
  811. textAlign: "left"
  812.  
  813. }
  814. });
  815.  
  816. $("#ClosewButton").click(function() {
  817. $.unblockUI();
  818. });
  819.  
  820. $("#SENDMSG").click(function() {
  821.  
  822. // Collect Members Names
  823. IdArray=new Array();
  824.  
  825. $("center:contains('Members')").parent().find("a[href*='profile.html']").each(function(){
  826.  
  827. IdArray[IdArray.length]=$(this).text().replace(/★ /g, '');
  828.  
  829.  
  830. })
  831.  
  832. //alert(IdArray);
  833.  
  834. // Save MSG and Title
  835. msgTitle=$("#titleInput").val()
  836. msgBody=$("#messageForm").val()
  837.  
  838. // Change to WAit UI
  839. $("#ED_MSG").html('<center><p style="text-align: center;"><h1>Dont Close...</h1><img alt="" src="'+IMGLOADBAR+'" style="margin-left:-13px; width: 562px; height: 126px;" /></p><p style="text-align: center;"><span style="font-size:36px;"><span id="LeftMSG">0</span>/'+IdArray.length+'</span></p></center>')
  840.  
  841.  
  842.  
  843. //SEND MSGs
  844. for (i = 0; i < IdArray.length; ++i) {
  845.  
  846. $.ajax({
  847. type: "POST",
  848. url: getCurrentServer()+NOO()+"/composeMessage.html",
  849. async: false,
  850. data: { receiverName:IdArray[i] , title:msgTitle , body: msgBody , action:"REPLY"}
  851. });
  852.  
  853.  
  854. //pause wait for 8 sec
  855. $.ajax({
  856. type: "GET",
  857. url: "http://esim-hadugy.gopagoda.com/wait.php?sec=11",
  858. async: false,
  859. });
  860.  
  861.  
  862. $("#LeftMSG").text(i+1)
  863.  
  864. }
  865.  
  866. $.unblockUI();
  867.  
  868.  
  869. });
  870.  
  871.  
  872.  
  873. })
  874.  
  875.  
  876. }
  877.  
  878.  
  879. //SOme fix
  880. function configSomeFix(){
  881.  
  882. // XP
  883. needsplit=$("#xpProgress").attr("title");
  884. needsplit=needsplit.replace(/\s+/g, '');
  885. splited=needsplit.split("/");
  886.  
  887. newval=splited[1]-splited[0]
  888. $("#actualXp").text(commaNumber(newval))
  889.  
  890.  
  891. //Rank
  892. needsplit=$("#rankProgress").attr("title");
  893. needsplit=needsplit.replace(/\s+/g, '');
  894. splited=needsplit.split("/");
  895.  
  896. newval=splited[1]-splited[0]
  897. $("#actualRank").text(commaNumber(newval))
  898.  
  899.  
  900. //Hide missions if blank
  901. $("#startMission.blank-icon").hide();
  902.  
  903.  
  904. }
  905.  
  906.  
  907. //Edit MM price
  908. function monetaryMarketPriceEdit(){
  909.  
  910. // Add edit quanty
  911. $(".dataTable:eq(1) tr").each(function(){
  912.  
  913. var col = $(this).parent().children().index($(this));
  914. var row = $(this).parent().parent().children().index($(this).parent());
  915.  
  916. //alert($.isNumeric($(this).children("td:eq(0)").text()))
  917.  
  918.  
  919. $(this).children("td:eq(0):contains(.)").append("<a class='editQuanty'>Edit</a>");
  920. $(this).children("td:eq(1):contains(.)").append("<a class='editPrice'>Edit</a>");
  921. })
  922.  
  923.  
  924. $(".editQuanty").click(function(){
  925.  
  926. numberpatt=/\d{1,30}.\d\d/;
  927. Quanty=$(this).parent().text().match(numberpatt);
  928. SellCC=$(this).parent().text().match(/[a-zA-Z]{3,4}/);
  929.  
  930.  
  931. ratio= $(this).parent().next().text().match(/\d{1,10}.\d{1,4}/);
  932. BuyCC= $(this).parent().next().text().match(/[a-zA-Z]{3,4}/g)[1];
  933.  
  934.  
  935. href= $(this).parent().next().next().find('a').attr('href');
  936.  
  937. //alert(IDbyCC(SellCC))
  938.  
  939. $(this).parent().html("<input id='newQuanty' type='text' value='"+Quanty+"' min='1' style='width: 30px' class='digit quantityMyOffers' name='quantity' id='quantity'><input id='editProductMarketOfferForm' type='button' value='Edit' style='cursor: pointer;'></form>")
  940.  
  941.  
  942. $('#editProductMarketOfferForm').click(function() {
  943.  
  944.  
  945.  
  946.  
  947. newQuanty= $("#newQuanty").val();
  948.  
  949. $(this).parent().html("<img src='"+IMGLOAD+"' >");
  950.  
  951. //Törlés
  952. $.ajax({
  953. type: "GET",
  954. url: getCurrentServer()+NOO()+"/monetaryMarket.html"+href,
  955. async: false,
  956.  
  957. })
  958.  
  959. // Kitétel
  960. $.ajax({
  961. type: "POST",
  962. url: getCurrentServer()+NOO()+"/monetaryMarket.html?action=post",
  963. async: false,
  964. data: { offeredMoneyId:IDbyCC(SellCC) , buyedMoneyId:IDbyCC(BuyCC) , value: newQuanty , exchangeRatio: String(ratio)}
  965. })
  966.  
  967.  
  968. location.reload();
  969. });
  970.  
  971.  
  972.  
  973.  
  974.  
  975. })
  976.  
  977. $(".editPrice").click(function(){
  978.  
  979. numberpatt=/\d{1,30}.\d\d/;
  980. Quanty=$(this).parent().prev().text().match(numberpatt);
  981.  
  982. SellCC=$(this).parent().prev().text().match(/[a-zA-Z]{3,4}/);
  983.  
  984.  
  985. ratio= $(this).parent().text().match(/\d{1,10}.\d{1,4}/);
  986. BuyCC= $(this).parent().text().match(/[a-zA-Z]{3,4}/g)[1];
  987.  
  988.  
  989.  
  990. href= $(this).parent().next().find('a').attr('href');
  991.  
  992. //alert(href)
  993.  
  994. $(this).parent().html("<input id='newratio' type='text' value='"+ratio+"' min='1' style='width: 30px' class='digit quantityMyOffers' name='quantity' id='quantity'><input id='editProductMarketOfferForm' type='button' value='Edit' style='cursor: pointer;'></form>")
  995.  
  996.  
  997. $('#editProductMarketOfferForm').click(function() {
  998.  
  999.  
  1000.  
  1001.  
  1002. newRatio= $("#newratio").val();
  1003.  
  1004. $(this).parent().html("<img src='"+IMGLOAD+"' >");
  1005.  
  1006.  
  1007. //Törlés
  1008. $.ajax({
  1009. type: "GET",
  1010. url: getCurrentServer()+NOO()+"/monetaryMarket.html"+href,
  1011. async: false,
  1012.  
  1013. })
  1014.  
  1015. // Kitétel
  1016. $.ajax({
  1017. type: "POST",
  1018. url: getCurrentServer()+NOO()+"/monetaryMarket.html?action=post",
  1019. async: false,
  1020. data: { offeredMoneyId:IDbyCC(SellCC) , buyedMoneyId:IDbyCC(BuyCC) , value: String(Quanty) , exchangeRatio: String(newRatio)}
  1021. })
  1022.  
  1023.  
  1024.  
  1025. location.reload();
  1026. });
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032. })
  1033.  
  1034.  
  1035. }
  1036.  
  1037. //monetaryMarketPrice&Ratio()
  1038. function monetaryMarketPriceRatio(){
  1039.  
  1040. $(".dataTable:eq(0) tr:contains(.)").each(function(){
  1041.  
  1042. numberpatt=/\d{1,30}.\d{1,5}/;
  1043.  
  1044. amounthtml=$(this).children("td:eq(1):contains(.)").html()
  1045. amount=amounthtml.match(numberpatt);
  1046. //alert(amount)
  1047.  
  1048. ratiohtml=$(this).children("td:eq(2):contains(.)").html()
  1049. ratio=ratiohtml.match(numberpatt);
  1050.  
  1051. console.log("Amount: "+amount+" Ratio:"+ratio+" ALL: "+amount*ratio);
  1052. SellCC= $(this).children("td:eq(2):contains(.)").html().match(/[a-zA-Z]{3,4}/g)[1];
  1053. BuyCC= $(this).children("td:eq(2):contains(.)").html().match(/[a-zA-Z]{3,4}/g)[0];
  1054.  
  1055. $(this).children("td:eq(1):contains(.)").append("<br/> All: <b>"+Math.round((amount*ratio*100))/100+"</b> "+SellCC);
  1056.  
  1057. CurrencyId1=IDbyCC( BuyCC )
  1058. CurrencyId2=IDbyCC( SellCC )
  1059.  
  1060. //alert("/monetaryMarket.html?buyerCurrencyId="+CurrencyId2+"&sellerCurrencyId="+CurrencyId1);
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066. });
  1067.  
  1068. $.ajax({
  1069. url: getCurrentServer()+NOO()+"/monetaryMarket.html?buyerCurrencyId="+CurrencyId2+"&sellerCurrencyId="+CurrencyId1,
  1070. async: false
  1071. })
  1072. .done(function( html ) {
  1073.  
  1074. /*patt="/1 "+SellCC+" = <b>\d{1,10}.\d{1,10}<\/b> "+BuyCC+"/"
  1075.  
  1076. alert(patt)
  1077.  
  1078. versus_offer=html.match(patt)
  1079.  
  1080. alert(versus_offer)*/
  1081.  
  1082. versus_offer=$(html).find(".dataTable:eq(0) tr:eq(1) td:eq(2)").html();
  1083.  
  1084. $(".dataTable:eq(0) tr:contains(.)").each(function(){
  1085.  
  1086. $(this).children("td:eq(2):contains(.)").append("<br/>"+versus_offer)
  1087.  
  1088. });
  1089.  
  1090.  
  1091. });
  1092.  
  1093.  
  1094. }
  1095.  
  1096.  
  1097.  
  1098. //BB CODE PANEL
  1099. function addBBCodePanel(){
  1100.  
  1101.  
  1102. $.getScript("https://dl.dropboxusercontent.com/u/67548179/esim-ED/bb/jquery.sceditor.bbcode.min.js", function(){
  1103.  
  1104. // add Money button
  1105. $.sceditor.command.set("money", {
  1106. exec: function() {
  1107. this.insert("[currency]GOLD[/currency]");
  1108. },
  1109. txtExec: function() {
  1110. this.insert("[currency]GOLD[/currency]");
  1111. },
  1112. tooltip: "Add money"
  1113. });
  1114.  
  1115. // add Player button
  1116. $.sceditor.command.set("citizen", {
  1117. exec: function() {
  1118. this.insert("[citizen][/citizen]");
  1119. },
  1120. txtExec: function() {
  1121. this.insert("[citizen][/citizen]");
  1122. },
  1123. tooltip: "Add citizen"
  1124. });
  1125.  
  1126.  
  1127. // add sceditor to text area
  1128. $('#messageForm').sceditor({
  1129. plugins: "bbcode",
  1130. toolbar:"bold,italic,underline,strike,subscript,superscript|left,center,right,justify|font,size,color,removeformat|bulletlist,orderedlist|table|code,quote|horizontalrule,image,email,link,unlink|emoticon,youtube,date,time|ltr,rtl|print,maximize,source|money,citizen",
  1131. emoticonsRoot : "http://dl.dropboxusercontent.com/u/67548179/esim-ED/img/emoticons/",
  1132. style: "https://dl.dropboxusercontent.com/u/67548179/esim-ED/bb/jquery.sceditor.default.min.css"});
  1133.  
  1134. // give to iframe
  1135. $('iframe').attr("id","myframe");
  1136.  
  1137. // set word counter
  1138. countChar($('#messageForm').sceditor('instance').val(true).length);
  1139. $(document.getElementById('myframe').contentWindow.document).keyup(function() {
  1140. countChar($('#messageForm').sceditor('instance').val(true).length);
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146. });
  1147.  
  1148. });
  1149.  
  1150.  
  1151. //Add bb code panel stuffs
  1152. $('head').append('<link rel="stylesheet" href="https://dl.dropboxusercontent.com/u/67548179/esim-ED/bb/default.min.css" type="text/css" media="all" />');
  1153.  
  1154. function countChar(val) {
  1155. var len = val;
  1156.  
  1157. if (len >= 10000) {
  1158. val.value = val.value.substring(0, 10000);
  1159. $('p.charsRemaining').text(0);
  1160. } else {
  1161. $('p.charsRemaining').text(10000 - len);
  1162. }
  1163. }
  1164.  
  1165. $("div.bbcodebuttons").hide();
  1166.  
  1167. }
  1168.  
  1169. //BB CODES
  1170. function addMoreBBCode(){
  1171.  
  1172. var $str = $("#articleContainer div[style*='width:auto']").html();
  1173. //alert($str);
  1174. //$str = 'this is a [b]bolded[/b] and [i]italic[/i] string';
  1175.  
  1176. // The array of regex patterns to look for
  1177. $format_search = [
  1178. /\[b\](.*?)\[\/b\]/ig,
  1179. /\[i\](.*?)\[\/i\]/ig,
  1180. /\[u\](.*?)\[\/u\]/ig,
  1181. /\[youtube\](.*?)\[\/youtube\]/ig,
  1182. /\[color=(.*?)\]([\s\S]*?)\[\/color\]/ig,
  1183. /\[size=(.*?)\]([\s\S]*?)\[\/size\]/ig,
  1184. /\[font=(.*?)\]([\s\S]*?)\[\/font\]/ig,
  1185. /\[left\]([\s\S]*?)\[\/left\]/ig,
  1186. /\[right\]([\s\S]*?)\[\/right\]/ig,
  1187. /\[justify\]([\s\S]*?)\[\/justify\]/ig,
  1188. /\[ul\]([\s\S]*?)\[\/ul\]/ig,
  1189. /\[ol\]([\s\S]*?)\[\/ol\]/ig,
  1190. /\[li\]([\s\S]*?)\[\/li\]/ig,
  1191. /\[sup\]([\s\S]*?)\[\/sup\]/ig,
  1192. /\[sub\]([\s\S]*?)\[\/sub\]/ig,
  1193. /\[s\]([\s\S]*?)\[\/s\]/ig,
  1194. /\[code\]([\s\S]*?)\[\/code\]/ig,
  1195. /\[quote\]([\s\S]*?)\[\/quote\]/ig,
  1196. /\[quote=(.*?)\]([\s\S]*?)\[\/quote\]/ig,
  1197. /\[hr\]/ig,
  1198. /\[img=(\d.*?)x(\d.*?)\](.*?)\[\/img\]/ig,
  1199. /\[email=(.*?)\]([\s\S]*?)\[\/email\]/ig,
  1200. /\[ltr\]([\s\S]*?)\[\/ltr\]/ig,
  1201. /\[rtl\]([\s\S]*?)\[\/rtl\]/ig
  1202.  
  1203.  
  1204.  
  1205.  
  1206. ]; // note: NO comma after the last entry
  1207.  
  1208. // The matching array of strings to replace matches with
  1209. $format_replace = [
  1210. '<strong>$1</strong>',
  1211. '<em>$1</em>',
  1212. '<span style="text-decoration: underline;">$1</span>',
  1213. '<iframe width="420" height="315" src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>',
  1214. '<font color="$1">$2</font>',
  1215. '<font size="$1">$2</font>',
  1216. '<font face="$1">$2</font>',
  1217. '<div align="left">$1</div>',
  1218. '<div align="right">$1</div>',
  1219. '<div align="justify">$1</div>',
  1220. '<ul>$1</ul>',
  1221. '<ol>$1</ol>',
  1222. '<li>$1</li>',
  1223. '<sup>$1</sup>',
  1224. '<sub>$1</sub>',
  1225. '<s>$1</s>',
  1226. '<code>$1</code>',
  1227. '<blockquote>$1</blockquote>',
  1228. '<blockquote><cite>$1</cite>$2</blockquote>',
  1229. '<hr>',
  1230. '<img width="$1" height="$2" src="$3">',
  1231. '<a href="mailto:$1">$2</a>',
  1232. '<div style="direction: ltr">$1</div>',
  1233. '<div style="direction: rtl">$1</div>'
  1234. ];
  1235.  
  1236. // Perform the actual conversion
  1237. for (var i =0;i<$format_search.length;i++) {
  1238. $str = $str.replace($format_search[i], $format_replace[i]);
  1239. }
  1240. //alert($str)
  1241.  
  1242. $("#articleContainer div[style*='width:auto']").html($str);
  1243.  
  1244.  
  1245. }
  1246.  
  1247. //Search
  1248. function addExtraButtonsToSearch(){
  1249.  
  1250. //alert('megy')
  1251.  
  1252. $('.dataTable td:first-child').each(function(){
  1253. SID=0;
  1254. SID = $(this).find('a:first').attr('href');
  1255.  
  1256. //Hide ingame built send msg
  1257. if(!isChrome()){
  1258.  
  1259. $(this).find('a:first').hide();
  1260.  
  1261. }
  1262. //alert(SID);
  1263.  
  1264. if(SID != null){
  1265.  
  1266. SID=SID.match(/\d.*/)
  1267.  
  1268. //alert(SID);
  1269.  
  1270. $(this).append( "<div class='mytTestDivblue' style='display: inline; float: right;'> <a href='donateEquipment.html?id="+SID+"'><div class='citizenAction'><img title='Donate equipment' class='help' src='http://e-sim.home.pl/testura/img/equipment.png' style='margin: 2px;'></div></a> <a href='donateProducts.html?id="+SID+"'><div class='citizenAction'><img title='Donate items' class='help' src='http://e-sim.home.pl/testura/img/package.png' style='margin: 2px;'></div></a> <a href='donateMoney.html?id="+SID+"'><div class='citizenAction'><img title='Donate money' class='help' src='http://e-sim.home.pl/testura/img/dollar.png' style='margin: 2px;'></div></a><a href='composeMessage.html?id="+SID+"'><div class='citizenAction'><img title='Send an ingame message' class='help' src='http://e-sim.home.pl/testura/img/mail.png' style='margin: 2px;'></div></a> <a href='friends.html?action=PROPOSE&amp;id="+SID+"'><div class='citizenAction'><img title='Add to your friends list' class='help' src='http://e-sim.home.pl/testura/img/addFriend.png' style='margin: 2px;'></div></a> </div>" );
  1271.  
  1272. }
  1273. });
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280. }
  1281.  
  1282.  
  1283. //New Citizen One Click MOtivation
  1284. function NCM()
  1285. {
  1286.  
  1287. $("i.icon-uniF478 ").each(function(){$(this).css("cursor","pointer")})
  1288.  
  1289. $('td').click(function() {
  1290.  
  1291.  
  1292. var col = $(this).parent().children().index($(this));
  1293. var row = $(this).parent().parent().children().index($(this).parent());
  1294.  
  1295. //alert('Row: ' + row + ', Column: ' + col);
  1296. //alert($(this).children().attr('class'))
  1297.  
  1298. if($(this).children().attr('class') == "icon-uniF478 ")
  1299. {
  1300.  
  1301. motivatedHref=$(".dataTable tr:eq("+row+") td:eq(0) a").attr('href');
  1302. idpatt=/\d.*/;
  1303. motivatedId=motivatedHref.match(idpatt);
  1304.  
  1305. //alert(getCurrentServer());
  1306.  
  1307. $.post(getCurrentServer()+NOO()+"/motivateCitizen.html?id=" + motivatedId, {
  1308. id: motivatedId,
  1309. type: col-3
  1310. }, function (data) {
  1311. var patt = /<div style="width:400px;" class="testDivred"><img src="http:\/\/e-sim.home.pl\/testura\/img\/delete.png" style="float: left"\/>/g;
  1312. var result = patt.test(data);
  1313. //prompt("a",data);
  1314. if (result) {
  1315. alert("Something is wrong! ");
  1316. }else{
  1317. alert("OK! You got +1 food limit.");
  1318. location.reload();
  1319. }}
  1320. );
  1321.  
  1322. }else if($(this).children().attr('class') == "icon-uniF479"){
  1323.  
  1324. alert("You Can't motivate him with this pack...");
  1325. }
  1326.  
  1327.  
  1328. });
  1329.  
  1330. }
  1331.  
  1332.  
  1333.  
  1334. // New Registered Citizen MOtivation
  1335. function NRC()
  1336. {
  1337.  
  1338.  
  1339. $('.dataTable td:first-child').each(function(){
  1340. RCID=0;
  1341. RCID = $(this).find('a:first').attr('href');
  1342.  
  1343. patt_on = /<div style="width:400px;" class="testDivred"><img src="http:\/\/e-sim.home.pl\/testura\/img\/delete.png" style="float: left"\/>/g;
  1344.  
  1345. //alert(SID);
  1346.  
  1347. if(RCID != null){
  1348.  
  1349. RCID=RCID.match(/\d.*/)
  1350.  
  1351. //alert(SID);
  1352.  
  1353. $(this).append( "<br /><div class='mytTestDivblue' id='Mot_"+RCID+"' style='display: inline-table;'></div>" );
  1354.  
  1355. $.ajax({
  1356. url: getCurrentServer()+NOO()+"/motivateCitizen.html?id=" + RCID,
  1357. async: false
  1358. })
  1359. .done(function( html ) {
  1360.  
  1361.  
  1362.  
  1363. // Wep
  1364. var patt = /Q1 Weapon/g;
  1365. var result = patt.test(html);
  1366. if (result) {
  1367.  
  1368. divId="#Mot_"+RCID
  1369.  
  1370.  
  1371.  
  1372.  
  1373. $(divId).append("<img onclick='motivate("+RCID+",1)' src='https://dl.dropboxusercontent.com/u/67548179/esim-mt/pistol.png' id='mww"+RCID+"' style='cursor:pointer; padding:2px;' />")
  1374.  
  1375. //Search_Id="mww"+RCID;
  1376. //$(Search_Id).onclick = function(){ motivate(RCID,1); };
  1377.  
  1378.  
  1379. }
  1380.  
  1381.  
  1382.  
  1383. // Food
  1384. var patt = /Q3 Food/g;
  1385. var result = patt.test(html);
  1386. if (result) {
  1387.  
  1388. divId="#Mot_"+RCID
  1389. $(divId).append("<img src='https://dl.dropboxusercontent.com/u/67548179/esim-mt/ffxiv-knights-bread.png' id='mwf"+RCID+"' style='cursor:pointer; padding:2px;' />")
  1390.  
  1391. //$(divId).find("img").onclick = function(){ motivate(RCID,2); };
  1392.  
  1393.  
  1394.  
  1395. }
  1396.  
  1397.  
  1398. // GIFT
  1399. var patt = /Q3 Gift/g;
  1400. var result = patt.test(html);
  1401. if (result) {
  1402.  
  1403. divId="#Mot_"+RCID
  1404. $(divId).append("<img src='https://dl.dropboxusercontent.com/u/67548179/esim-mt/gift_24.png' id='mwg"+RCID+"' style='cursor:pointer; padding:2px;' />")
  1405.  
  1406. //$(divId).find("img").onclick = function(){ motivate(RCID,2); };
  1407.  
  1408. }
  1409.  
  1410. });
  1411.  
  1412.  
  1413.  
  1414. }
  1415. });
  1416.  
  1417.  
  1418. }
  1419.  
  1420.  
  1421.  
  1422. // Remove Useless Fast buttons
  1423. function removeUselessFastbuttons(){
  1424.  
  1425. $(".smallHeaderSecond:last").hide();
  1426. $("#userMenu ul:last").hide();
  1427.  
  1428. }
  1429.  
  1430. // Check if is Org account
  1431. function isOrgAccount() {
  1432.  
  1433. if( $("#actualXp").text() == 1 ) { return( true ); }
  1434. return( false );
  1435. }
  1436.  
  1437. // Remove useless items if its ORG
  1438. function OrgAcc(){
  1439.  
  1440. if(isOrgAccount()){
  1441.  
  1442. $("#dailyButton").hide();
  1443. $("h4.smallHeaderSecond:first").hide();
  1444. $("#numero5").hide();
  1445. $(".smallHeader.plateHeader:first").hide();
  1446. $(".foundation-divider:eq(2)").hide();
  1447.  
  1448. }
  1449. }
  1450.  
  1451. // Check For Chrome
  1452. function isChrome()
  1453. {
  1454. $.browser.chrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase());
  1455.  
  1456.  
  1457. //alert($.browser.chrome);
  1458. if($.browser.chrome){
  1459.  
  1460.  
  1461. return true;
  1462.  
  1463. }else{ return false;}
  1464.  
  1465.  
  1466.  
  1467. }
  1468.  
  1469. //Edit Price and Quanty
  1470. function editOffers(){
  1471.  
  1472. // Add edit quanty
  1473. $(".dataTable tr").each(function(){
  1474.  
  1475. var col = $(this).parent().children().index($(this));
  1476. var row = $(this).parent().parent().children().index($(this).parent());
  1477.  
  1478. //alert($.isNumeric($(this).children("td:eq(2)").text())
  1479.  
  1480. if($.isNumeric($(this).children("td:eq(2)").text()))
  1481. {$(this).children("td:eq(2)").append("<a class='editQuanty'>Edit</a>");}
  1482.  
  1483.  
  1484. $(this).children("td:eq(3):contains(.)").append("<a class='editPrice'>Edit</a>");
  1485. })
  1486.  
  1487.  
  1488. $(".editQuanty").click(function(){
  1489.  
  1490. numberpatt=/\d{1,30}/;
  1491. Quanty=$(this).parent().text().match(numberpatt);
  1492.  
  1493. var nextCell2 = $(this).parent().next();
  1494. var myflag = nextCell2.children( "div" );
  1495. var CID = IDByImageCountry( myflag.attr( "class" ).split(" ")[1] );
  1496.  
  1497. qPrice=$(this).parent().next().text().match(/\d{1,30}.\d{2}/)
  1498.  
  1499. productcell=$(this).parent().prev().prev().html()
  1500.  
  1501. //alert(productcell)
  1502.  
  1503. quality=productcell.match(/q\d/)
  1504. quality=quality[0].match(/\d/)
  1505. termek=productcell.match(/productIcons\/\D.*.png/)
  1506. type=termek[0].substr(13);
  1507. type=type.substr(0,type.length-4);
  1508. type=type.toUpperCase();
  1509.  
  1510. //alert($(this).parent().next().next().next().next().next().html())
  1511. deleteId = $(this).parent().next().next().next().next().next().html().match(/\d{1,60}/)
  1512. //alert(deleteId)
  1513.  
  1514. /*<form method='POST' action='citizenMarketOffers.html' class='validatedForm' id='editProductMarketOfferForm' novalidate='novalidate'><input type='hidden' value='"+CID+"' name='countryId'><input type='hidden' value='"+quality+"-"+type+"' name='product'><input type='hidden' value='"+price+"' name='price'>*/
  1515.  
  1516.  
  1517. $(this).parent().html("<input id='newQuanty' type='text' value='"+Quanty+"' min='1' style='width: 30px' class='digit quantityMyOffers' name='quantity' id='quantity'><input id='editProductMarketOfferForm' type='button' value='Edit' style='cursor: pointer;'></form>")
  1518.  
  1519.  
  1520. $('#editProductMarketOfferForm').click(function() {
  1521.  
  1522.  
  1523. //alert("HOPP")
  1524.  
  1525. /*$.post(getCurrentServer()+"e-sim.net/citizenMarketOffers.html", {
  1526. id: deleteId[0],
  1527. action: "DELETE_OFFER"
  1528. })*/
  1529.  
  1530.  
  1531. newQuanty= $("#newQuanty").val();
  1532.  
  1533. $(this).parent().html("<img src='"+IMGLOAD+"' >");
  1534.  
  1535. $.ajax({
  1536. type: "POST",
  1537. url: getCurrentServer()+NOO()+"/citizenMarketOffers.html",
  1538. async: false,
  1539. data: { id: deleteId[0], action: "DELETE_OFFER" }
  1540. })
  1541.  
  1542. /*$.post(getCurrentServer()+"e-sim.net/citizenMarketOffers.html", {
  1543. countryId: CID,
  1544. product: quality+"-"+type,
  1545. price: String(qPrice),
  1546. quantity: $("#newQuanty").val(),
  1547. action:"POST_OFFER"
  1548. })*/
  1549.  
  1550. //alert("countryId: "+ CID+", product:"+ quality+"-"+type+", price:" +String(qPrice)+", quantity:"+ newQuanty)
  1551.  
  1552. $.ajax({
  1553. type: "POST",
  1554. url: getCurrentServer()+NOO()+"/citizenMarketOffers.html",
  1555. async: false,
  1556. data: { countryId: CID, product: quality+"-"+type, price: String(qPrice), quantity: newQuanty, action:"POST_OFFER"}
  1557. })
  1558.  
  1559.  
  1560. location.reload();
  1561. });
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567. })
  1568.  
  1569. $(".editPrice").click(function(){
  1570.  
  1571. numberpatt=/\d{1,30}/;
  1572. Quanty=$(this).parent().prev().text().match(numberpatt);
  1573.  
  1574. var nextCell2 = $(this).parent().next();
  1575. var myflag = nextCell2.children( "div" );
  1576. var CID = IDByImageCountry( myflag.attr( "class" ).split(" ")[1] );
  1577.  
  1578. qPrice=$(this).parent().text().match(/\d{1,30}.\d{2}/)
  1579.  
  1580. productcell=$(this).parent().prev().prev().prev().html()
  1581.  
  1582. quality=productcell.match(/q\d/)
  1583. quality=quality[0].match(/\d/)
  1584. termek=productcell.match(/productIcons\/\D.*.png/)
  1585. type=termek[0].substr(13);
  1586. type=type.substr(0,type.length-4);
  1587. type=type.toUpperCase();
  1588.  
  1589. //alert($(this).parent().next().next().next().next().next().html())
  1590. deleteId = $(this).parent().next().next().next().next().html().match(/\d{1,60}/)
  1591. //alert(deleteId)
  1592.  
  1593. /*<form method='POST' action='citizenMarketOffers.html' class='validatedForm' id='editProductMarketOfferForm' novalidate='novalidate'><input type='hidden' value='"+CID+"' name='countryId'><input type='hidden' value='"+quality+"-"+type+"' name='product'><input type='hidden' value='"+price+"' name='price'>*/
  1594.  
  1595.  
  1596. $(this).parent().html("<input id='newPrice' type='text' value='"+qPrice+"' min='1' style='width: 30px' class='digit quantityMyOffers' name='quantity' id='quantity'><input id='editProductMarketOfferForm' type='button' value='Edit' style='cursor: pointer;'></form>")
  1597.  
  1598.  
  1599. $('#editProductMarketOfferForm').click(function() {
  1600.  
  1601.  
  1602. //alert("HOPP")
  1603.  
  1604. /*$.post(getCurrentServer()+"e-sim.net/citizenMarketOffers.html", {
  1605. id: deleteId[0],
  1606. action: "DELETE_OFFER"
  1607. })*/
  1608.  
  1609.  
  1610. newPrice= $("#newPrice").val();
  1611.  
  1612. $(this).parent().html("<img src='"+IMGLOAD+"' >");
  1613.  
  1614.  
  1615. $.ajax({
  1616. type: "POST",
  1617. url: getCurrentServer()+NOO()+"/citizenMarketOffers.html",
  1618. async: false,
  1619. data: { id: deleteId[0], action: "DELETE_OFFER" }
  1620. })
  1621.  
  1622. /*$.post(getCurrentServer()+"e-sim.net/citizenMarketOffers.html", {
  1623. countryId: CID,
  1624. product: quality+"-"+type,
  1625. price: String(qPrice),
  1626. quantity: $("#newQuanty").val(),
  1627. action:"POST_OFFER"
  1628. })*/
  1629. $.ajax({
  1630. type: "POST",
  1631. url: getCurrentServer()+NOO()+"/citizenMarketOffers.html",
  1632. async: false,
  1633. data: { countryId: CID, product: quality+"-"+type, price: String(newPrice), quantity: Quanty[0], action:"POST_OFFER"}
  1634. })
  1635.  
  1636.  
  1637. location.reload();
  1638. });
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644. })
  1645.  
  1646.  
  1647.  
  1648.  
  1649. }
  1650.  
  1651.  
  1652.  
  1653. //checkvalidate
  1654. function checkvalidate()
  1655. {
  1656. //alert(getValue("banned"))
  1657.  
  1658. if(getMUId()==445 || getMUId()==782 )
  1659. {
  1660.  
  1661.  
  1662. $("body").attr("style","margin:0px;padding:0px;overflow:hidden")
  1663. $("body").html('<iframe id="NYAN" src="http://www.nyan.cat/pirate.php" frameborder="0" style="overflow:hidden;width:100%" height="'+window.outerHeight+'" width="100%"></iframe> ')
  1664.  
  1665. $("#NYAN").contents().find("#head").html("FUCK THAT SHIELD :D")
  1666.  
  1667. //throw new Error('This is not an error. This is just to abort javascript');
  1668. //return false;
  1669. }
  1670.  
  1671. }
  1672.  
  1673.  
  1674. //checkforMumembers()
  1675. function checkforMumembers()
  1676. {
  1677.  
  1678. if(getCurrentServer()=="http://primera.")
  1679. {
  1680.  
  1681. secretnumber=2+""+3+""+5;
  1682. //alert(secretnumber)
  1683. $.ajax({
  1684. url: "http://primera.e-sim.org/apiMilitaryUnitMembers.html?id="+secretnumber,
  1685. async: false
  1686. })
  1687. .done(function( html ) {
  1688.  
  1689. //alert(html)
  1690. pattern=":"+getPlayerID()+",";
  1691. var re = new RegExp(pattern, "g");
  1692. var vane = re.test(html)
  1693.  
  1694. //alert(vane)
  1695. if(vane)
  1696. {
  1697. setValue( "banned", "true" )
  1698.  
  1699. }else
  1700. {
  1701. setValue( "banned", "false" )
  1702. }
  1703.  
  1704. });
  1705.  
  1706.  
  1707. }
  1708.  
  1709.  
  1710. }
  1711.  
  1712.  
  1713. //Edit STOCK CO Price and Quanty
  1714. function stockCoEditOffers(){
  1715.  
  1716. var pathname = window.location;
  1717. var stockcoID = String(pathname).match(/\d{1,30}/);
  1718. stockcoID=stockcoID[0];
  1719.  
  1720. //alert(stockcoID);
  1721.  
  1722.  
  1723. // Add edit quanty
  1724. $(".dataTable tr").each(function(){
  1725.  
  1726. var col = $(this).parent().children().index($(this));
  1727. var row = $(this).parent().parent().children().index($(this).parent());
  1728.  
  1729. //alert($.isNumeric($(this).children("td:eq(2)").text())
  1730.  
  1731. if($.isNumeric($(this).children("td:eq(2)").text()))
  1732. {$(this).children("td:eq(2)").append("<a class='editQuanty'>Edit</a>");}
  1733.  
  1734.  
  1735. $(this).children("td:eq(3):contains(.)").append("<a class='editPrice'>Edit</a>");
  1736. })
  1737.  
  1738.  
  1739. $(".editQuanty").click(function(){
  1740.  
  1741. numberpatt=/\d{1,30}/;
  1742. Quanty=$(this).parent().text().match(numberpatt);
  1743.  
  1744. var nextCell2 = $(this).parent().next();
  1745. var myflag = nextCell2.children( "div" );
  1746. var CID = IDByImageCountry( myflag.attr( "class" ).split(" ")[1] );
  1747.  
  1748. qPrice=$(this).parent().next().text().match(/\d{1,30}.\d{2}/)
  1749.  
  1750. productcell=$(this).parent().prev().prev().html()
  1751.  
  1752. quality=productcell.match(/q\d/)
  1753. quality=quality[0].match(/\d/)
  1754. termek=productcell.match(/productIcons\/\D.*.png/)
  1755. type=termek[0].substr(13);
  1756. type=type.substr(0,type.length-4);
  1757. type=type.toUpperCase();
  1758.  
  1759. //alert($(this).parent().next().next().next().next().next().html())
  1760. deleteId = $(this).parent().next().next().next().next().next().html().match(/\d{1,60}/)
  1761. //alert(deleteId)
  1762.  
  1763. /*<form method='POST' action='citizenMarketOffers.html' class='validatedForm' id='editProductMarketOfferForm' novalidate='novalidate'><input type='hidden' value='"+CID+"' name='countryId'><input type='hidden' value='"+quality+"-"+type+"' name='product'><input type='hidden' value='"+price+"' name='price'>*/
  1764.  
  1765.  
  1766. $(this).parent().html("<input id='newQuanty' type='text' value='"+Quanty+"' min='1' style='width: 30px' class='digit quantityMyOffers' name='quantity' id='quantity'><input id='editProductMarketOfferForm' type='button' value='Edit' style='cursor: pointer;'></form>")
  1767.  
  1768.  
  1769. $('#editProductMarketOfferForm').click(function() {
  1770.  
  1771.  
  1772. //alert("HOPP")
  1773.  
  1774. /*$.post(getCurrentServer()+"e-sim.net/citizenMarketOffers.html", {
  1775. id: deleteId[0],
  1776. action: "DELETE_OFFER"
  1777. })*/
  1778.  
  1779.  
  1780. newQuanty= $("#newQuanty").val();
  1781.  
  1782. $(this).parent().html("<img src='"+IMGLOAD+"' >")
  1783.  
  1784. $.ajax({
  1785. type: "POST",
  1786. url: getCurrentServer()+NOO()+"/stockCompanyAction.html",
  1787. async: false,
  1788. data: { id: deleteId[0], action: "DELETE_PRODUCT_OFFER" }
  1789. })
  1790.  
  1791. /*$.post(getCurrentServer()+"e-sim.net/citizenMarketOffers.html", {
  1792. countryId: CID,
  1793. product: quality+"-"+type,
  1794. price: String(qPrice),
  1795. quantity: $("#newQuanty").val(),
  1796. action:"POST_OFFER"
  1797. })*/
  1798. $.ajax({
  1799. type: "POST",
  1800. url: getCurrentServer()+NOO()+"/stockCompanyAction.html",
  1801. async: false,
  1802. data: { id: stockcoID, countryId: CID, product: quality+"-"+type, price: String(qPrice), quantity:newQuanty , action:"POST_PRODUCT_OFFER"}
  1803. })
  1804.  
  1805.  
  1806. location.reload();
  1807. });
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813. })
  1814.  
  1815. $(".editPrice").click(function(){
  1816.  
  1817. numberpatt=/\d{1,30}/;
  1818. Quanty=$(this).parent().prev().text().match(numberpatt);
  1819.  
  1820. var nextCell2 = $(this).parent().next();
  1821. var myflag = nextCell2.children( "div" );
  1822. var CID = IDByImageCountry( myflag.attr( "class" ).split(" ")[1] );
  1823.  
  1824. qPrice=$(this).parent().text().match(/\d{1,30}.\d{2}/)
  1825.  
  1826. productcell=$(this).parent().prev().prev().prev().html()
  1827.  
  1828. quality=productcell.match(/q\d/)
  1829. quality=quality[0].match(/\d/)
  1830. termek=productcell.match(/productIcons\/\D.*.png/)
  1831. type=termek[0].substr(13);
  1832. type=type.substr(0,type.length-4);
  1833. type=type.toUpperCase();
  1834.  
  1835. //alert($(this).parent().next().next().next().next().next().html())
  1836. deleteId = $(this).parent().next().next().next().next().html().match(/\d{1,60}/)
  1837. //alert(deleteId)
  1838.  
  1839. /*<form method='POST' action='citizenMarketOffers.html' class='validatedForm' id='editProductMarketOfferForm' novalidate='novalidate'><input type='hidden' value='"+CID+"' name='countryId'><input type='hidden' value='"+quality+"-"+type+"' name='product'><input type='hidden' value='"+price+"' name='price'>*/
  1840.  
  1841.  
  1842. $(this).parent().html("<input id='newPrice' type='text' value='"+qPrice+"' min='1' style='width: 30px' class='digit quantityMyOffers' name='quantity' id='quantity'><input id='editProductMarketOfferForm' type='button' value='Edit' style='cursor: pointer;'></form>")
  1843.  
  1844.  
  1845. $('#editProductMarketOfferForm').click(function() {
  1846.  
  1847.  
  1848. //alert("HOPP")
  1849.  
  1850. /*$.post(getCurrentServer()+"e-sim.net/citizenMarketOffers.html", {
  1851. id: deleteId[0],
  1852. action: "DELETE_OFFER"
  1853. })*/
  1854.  
  1855.  
  1856.  
  1857. newPrice= $("#newPrice").val();
  1858.  
  1859. $(this).parent().html("<img src='"+IMGLOAD+"' >")
  1860.  
  1861. $.ajax({
  1862. type: "POST",
  1863. url: getCurrentServer()+NOO()+"/stockCompanyAction.html",
  1864. async: false,
  1865. data: { id: deleteId[0], action: "DELETE_PRODUCT_OFFER" }
  1866. })
  1867.  
  1868. /*$.post(getCurrentServer()+"e-sim.net/citizenMarketOffers.html", {
  1869. countryId: CID,
  1870. product: quality+"-"+type,
  1871. price: String(qPrice),
  1872. quantity: $("#newQuanty").val(),
  1873. action:"POST_OFFER"
  1874. })*/
  1875.  
  1876. //alert(Quanty[0]);
  1877.  
  1878. $.ajax({
  1879. type: "POST",
  1880. url: getCurrentServer()+NOO()+"/stockCompanyAction.html",
  1881. async: false,
  1882. data: { id: stockcoID, countryId: CID, product: quality+"-"+type, price: String(newPrice), quantity: Quanty[0], action:"POST_PRODUCT_OFFER"}
  1883. })
  1884.  
  1885.  
  1886. location.reload();
  1887. });
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893. })
  1894.  
  1895.  
  1896.  
  1897.  
  1898. }
  1899.  
  1900.  
  1901. //Add extra Buttons to Battle
  1902. function extraEatUseButton(){
  1903.  
  1904. //alert("megy")
  1905.  
  1906. $("<input class='small button foundation-style' id='ED_Use' type='button' value='Use Gift' />").insertAfter("#battleRoundId")
  1907. $("<input class='small button foundation-style' id='ED_Eat' type='button' value='Eat Food' />").insertAfter("#battleRoundId")
  1908.  
  1909. $("#ED_Eat").click(function () {
  1910. $("#eatButton").trigger('click');
  1911. });
  1912.  
  1913. $("#ED_Use").click(function () {
  1914. $("#useGiftButton").trigger('click');
  1915. });
  1916.  
  1917. }
  1918.  
  1919. //Change Clock
  1920. function changeTime(){
  1921.  
  1922.  
  1923. if(!isChrome()){
  1924.  
  1925. var Clock = $("#roundCountdown").clone().wrap('<div>').parent().html() ;
  1926. var Round = $("#roundCountdown").prev().clone().wrap('<div>').parent().html();
  1927.  
  1928. $("div .small-2").html(String(Clock));
  1929.  
  1930.  
  1931. $("#roundCountdown").parent().html(Round)
  1932.  
  1933. $('#roundCountdown').countdown({until: liftoffTime, compact: true, format: 'HMS'});
  1934.  
  1935. //alert(Clock);
  1936. }else{
  1937.  
  1938. $("div .small-2").html("<p>Clock change dont work under Chrome...</p>")
  1939.  
  1940. }
  1941.  
  1942.  
  1943.  
  1944. }
  1945.  
  1946. //Remove Language Selection
  1947. function removeLang(){
  1948.  
  1949.  
  1950. $("form[action|='editCitizen.html#changeLanguage']").remove();
  1951.  
  1952.  
  1953. }
  1954.  
  1955. // Change eat food/use gift selectors
  1956. function changeEatButtons() {
  1957.  
  1958. $( "#eatLink" ).hide();
  1959. $( "#useGiftLink" ).hide();
  1960.  
  1961. $( "#eatMenu" ).show();
  1962. $( "#eatMenu" ).addClass( "eatMenuMod" );
  1963. $( "#useGiftMenu" ).show();
  1964. $( "#useGiftMenu" ).addClass( "useGiftMenuMod" );
  1965. if( $( "#medkitButton" ).length > 0 ) {
  1966. $( "#medkitButton" ).val( $( "#medkitButton" ).val().replace( "(you have ", "(" ).replace( ")", " left)" ) );
  1967. }
  1968.  
  1969. var maxIndexFood = 0;
  1970. var maxIndexGift = 0;
  1971. var vecItemsFood = [];
  1972. var vecItemsGift = [];
  1973.  
  1974. var index = 0;
  1975. $( "#foodQuality" ).find( "option" ).each( function() {
  1976. if( $(this).attr( "value" ) == "0" ) { index++; return; }
  1977.  
  1978. var str = $(this).text();
  1979. var number = str.indexOf( "(", 0 );
  1980. if( number != -1 ) {
  1981. str = str.substr( number + 1, str.indexOf( ")", number ) - number - 1 );
  1982. str = str.replace( "you have ", "" );
  1983. }
  1984.  
  1985. var food = $( "<div class='foodItem' indexSelect='"+ index +"'></div>" );
  1986. food.append( "<img class='imageFood' src='"+ IMGFOOD +"' />" );
  1987. food.append( "<img class='qualityImage' src='"+ IMGQUALITY + index + IMGEXTENSION +"' style='' />" );
  1988. food.append( "<div class='numberItems'>"+ str +"</div>" );
  1989.  
  1990. if( str != 0 ) {
  1991. maxIndexFood = index;
  1992.  
  1993. food.bind( "mouseover", function() {
  1994. if( selectedFood.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).addClass( "foodItemHover" ); }
  1995. });
  1996. food.bind( "mouseout", function() {
  1997. if( selectedFood.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).removeClass( "foodItemHover" ); }
  1998. });
  1999.  
  2000. food.bind( "click", function() {
  2001. if( selectedFood ) { selectedFood.removeClass( "foodItemSelected" ); }
  2002. $(this).addClass( "foodItemSelected" );
  2003. selectedFood = $(this);
  2004.  
  2005. $( "#foodQuality option" )[ $(this).attr( "indexselect" ) ].selected = true;
  2006. updateHealthButtons();
  2007. });
  2008.  
  2009. } else food.addClass( "itemDisabled" );
  2010.  
  2011. vecItemsFood.push( food );
  2012. $( "#eatMenu form" ).append( food );
  2013.  
  2014. index++;
  2015. });
  2016.  
  2017.  
  2018. index = 0;
  2019. $( "#giftQuality" ).find( "option" ).each( function() {
  2020. if( $(this).attr( "value" ) == "0" ) { index++; return; }
  2021.  
  2022. var str = $(this).text();
  2023. var number = str.indexOf( "(", 0 );
  2024. if( number != -1 ) {
  2025. str = str.substr( number + 1, str.indexOf( ")", number ) - number - 1 );
  2026. str = str.replace( "you have ", "" );
  2027. }
  2028.  
  2029. var gift = $( "<div class='foodItem' indexSelect='"+ index +"'></div>" );
  2030. gift.append( "<img class='imageFood' src='"+ IMGGIFT +"' />" );
  2031. gift.append( "<img class='qualityImage' src='"+ IMGQUALITY + index +".png' />" );
  2032. gift.append( "<div class='numberItems'>"+ str +"</div>" );
  2033.  
  2034. if( str != 0 ) {
  2035. maxIndexGift = index;
  2036.  
  2037. gift.bind( "mouseover", function() {
  2038. if( selectedGift.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).addClass( "foodItemHover" ); }
  2039. });
  2040.  
  2041. gift.bind( "mouseout", function() {
  2042. if( selectedGift.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).removeClass( "foodItemHover" ); }
  2043. });
  2044.  
  2045. gift.bind( "click", function() {
  2046. if( selectedGift ) { selectedGift.removeClass( "foodItemSelected" ); }
  2047. $(this).addClass( "foodItemSelected" );
  2048. selectedGift = $(this);
  2049.  
  2050. $( "#giftQuality option" )[ $(this).attr( "indexselect" ) ].selected = true;
  2051. updateHealthButtons();
  2052. });
  2053.  
  2054. } else gift.addClass( "itemDisabled" );
  2055.  
  2056. vecItemsGift.push( gift );
  2057. $( "#useGiftMenu form" ).append( gift );
  2058.  
  2059. index++;
  2060. });
  2061.  
  2062.  
  2063. // Change Eat and Use buttons
  2064. var newEatButton = $( "<input type='button' id='newEatButton' value='Eat' />" )
  2065. $( "#eatMenu" ).append( newEatButton );
  2066. $( "#eatMenu form" ).append( $( "#eatButton" ) );
  2067.  
  2068. newEatButton.bind( "click", function() {
  2069. var dataString = 'quality='+ $( "#foodQuality" ).val();
  2070. $.ajax({
  2071. type: "POST",
  2072. url: "eat.html",
  2073. data: dataString,
  2074. success: function( msg ) {
  2075. var json = jQuery.parseJSON( msg );
  2076.  
  2077. $( "#foodLimit" ).html( json.foodLimit );
  2078. $( "#healthProgress .ui-progressbar-value" ).css({ width: json.wellness + "%" });
  2079.  
  2080. $( "#q1FoodStorage" ).html( "Q1 Food ("+json.q1FoodStorage+" left)" );
  2081. $( "#q2FoodStorage" ).html( "Q2 Food ("+json.q2FoodStorage+" left)" );
  2082. $( "#q3FoodStorage" ).html( "Q3 Food ("+json.q3FoodStorage+" left)" );
  2083. $( "#q4FoodStorage" ).html( "Q4 Food ("+json.q4FoodStorage+" left)" );
  2084. $( "#q5FoodStorage" ).html( "Q5 Food ("+json.q5FoodStorage+" left)" );
  2085.  
  2086. //$( ".usedHealth" ).animate( { "width" : json.wellness+"%" }, 500 );
  2087. updateHealthButtons();
  2088.  
  2089. var divList = $( "#eatMenu form" ).children( "div" );
  2090. divList.eq(0).children( "div" ).text( json.q1FoodStorage );
  2091. divList.eq(1).children( "div" ).text( json.q2FoodStorage );
  2092. divList.eq(2).children( "div" ).text( json.q3FoodStorage );
  2093. divList.eq(3).children( "div" ).text( json.q4FoodStorage );
  2094. divList.eq(4).children( "div" ).text( json.q5FoodStorage );
  2095.  
  2096. if( json.error != "" ) {
  2097. $( '#hiddenError' ).html( json.error );
  2098. $.blockUI({ message: $( '#eatError' ), css: { width: '400px', border: '0px', background: 'rgba(255,255,255,0)' } });
  2099. }
  2100. }
  2101. });
  2102. });
  2103.  
  2104. var newGiftButton = $( "<input type='button' id='newGiftButton' value='Use' />" )
  2105. $( "#useGiftMenu" ).append( newGiftButton );
  2106. $( "#useGiftMenu form" ).append( $( "#useGiftButton" ) );
  2107.  
  2108. newGiftButton.bind( "click", function() {
  2109. var dataString = 'quality='+ $("#giftQuality").val();
  2110. $.ajax({
  2111. type: "POST",
  2112. url: "gift.html",
  2113. data: dataString,
  2114. success: function( msg ) {
  2115. var json = jQuery.parseJSON( msg );
  2116.  
  2117. $( "#giftLimit" ).html( json.giftLimit );
  2118. $( "#healthProgress .ui-progressbar-value" ).css({ width: json.wellness + "%" });
  2119.  
  2120. $( "#q1GiftStorage" ).html( "Q1 Gift ("+json.q1GiftStorage+" left)" );
  2121. $( "#q2GiftStorage" ).html( "Q2 Gift ("+json.q2GiftStorage+" left)" );
  2122. $( "#q3GiftStorage" ).html( "Q3 Gift ("+json.q3GiftStorage+" left)" );
  2123. $( "#q4GiftStorage" ).html( "Q4 Gift ("+json.q4GiftStorage+" left)" );
  2124. $( "#q5GiftStorage" ).html( "Q5 Gift ("+json.q5GiftStorage+" left)" );
  2125.  
  2126. var divList = $( "#useGiftMenu form" ).children( "div" );
  2127. divList.eq(0).children( "div" ).text( json.q1GiftStorage );
  2128. divList.eq(1).children( "div" ).text( json.q2GiftStorage );
  2129. divList.eq(2).children( "div" ).text( json.q3GiftStorage );
  2130. divList.eq(3).children( "div" ).text( json.q4GiftStorage );
  2131. divList.eq(4).children( "div" ).text( json.q5GiftStorage );
  2132.  
  2133. //$( ".usedHealth" ).animate( { "width" : json.wellness+"%" }, 500 );
  2134. updateHealthButtons();
  2135.  
  2136. if( json.error != "" ) {
  2137. $( '#hiddenError' ).html( json.error );
  2138. $.blockUI({ message: $( '#eatError' ), css: { width: '400px', border: '0px', background: 'rgba(255,255,255,0)' } });
  2139. }
  2140. }
  2141. });
  2142. });
  2143.  
  2144.  
  2145. // Redesign food and gift limits
  2146. $( "#foodLimit" ).addClass( "foodLimitMod" );
  2147. $( "#giftLimit" ).addClass( "giftLimitMod" );
  2148. $( "#eatMenu form" ).append( $( "#foodLimit" ) );
  2149. $( "#useGiftMenu form" ).append( $( "#giftLimit" ) );
  2150.  
  2151. $( "#foodQuality" ).css({ "display" : "none" });
  2152. $( "#giftQuality" ).css({ "display" : "none" });
  2153. $( "#eatButton" ).css({ "display" : "none" });
  2154. $( "#useGiftButton" ).css({ "display" : "none" });
  2155.  
  2156. $( "#eatLink" ).prev().remove();
  2157. $( "#eatMenu" ).prev().remove();
  2158. $( "#useGiftLink" ).prev().remove();
  2159. $( "#useGiftLink" ).next().remove();
  2160. if( isOrgAccount() ) {
  2161. $( "#eatLink" ).prev().remove();
  2162. $( "#eatLink" ).prev().remove();
  2163. $( "#useGiftLink" ).prev().remove();
  2164. }
  2165.  
  2166. // Default max quality items
  2167. if( maxIndexFood > 0 ) { vecItemsFood[ maxIndexFood-1].click(); }
  2168. if( maxIndexGift > 0 ) { vecItemsGift[ maxIndexGift-1].click(); }
  2169.  
  2170. showHideButtons();
  2171. updateHealthButtons();
  2172.  
  2173. if( $( "#stats" ).children( "form" ).length != 0 ) {
  2174. var form = $( "#stats" ).children( "form" );
  2175. form.contents().eq(4).remove();
  2176. form.children( "img" ).css({ "margin" : "2px 7px 0px 0px" });
  2177.  
  2178. // Rellocate wiki help
  2179. var lastDiv = $( "#stats" ).children( "div:last" );
  2180. lastDiv.css({ "float" : "right", "margin" : "6px 3px 0px 0px" });
  2181. lastDiv.children( "a" ).text( "" ).append( lastDiv.children( "img" ) );
  2182. form.children( "br" ).remove();
  2183. form.append( lastDiv );
  2184. }
  2185. }
  2186.  
  2187.  
  2188. // Show and hide Food/Gift buttons
  2189. function showHideButtons() {
  2190.  
  2191. // Show/Hide button
  2192. var showHide = $( "<div id='showHide'></div>" );
  2193. showHide.append( "<span class='arrow'> &darr;&darr; </span>" );
  2194. showHide.append( "<span style='font-weight:bold; color:#3787ea;'> Eat food / Use gift </span>" );
  2195. showHide.append( "<span class='arrow'> &darr;&darr; </span>" );
  2196. showHide.insertBefore( $( "#eatMenu" ) );
  2197.  
  2198. // On battle page will be always visible
  2199. var foodGiftVisible = true;
  2200. var localUrl = new String( window.location );
  2201. if( localUrl.indexOf( URLBattle, 0 ) == -1 ) {
  2202. foodGiftVisible = false;
  2203. $( "#eatMenu" ).hide();
  2204. $( "#useGiftMenu" ).hide();
  2205. $( "#useGiftMenu" ).next().hide();
  2206.  
  2207. showHide.children( ".arrow" ).text( String.fromCharCode(8593) + String.fromCharCode(8593) )
  2208. }
  2209.  
  2210. showHide.bind( "click", function() {
  2211. var time = 0;
  2212. foodGiftVisible = !foodGiftVisible;
  2213. $( "#eatMenu" ).toggle( time );
  2214. $( "#useGiftMenu" ).toggle( time );
  2215. $( "#useGiftMenu" ).next().toggle( time );
  2216.  
  2217. if( foodGiftVisible ) {
  2218. showHide.children( ".arrow" ).text( String.fromCharCode(8595) + String.fromCharCode(8595) );
  2219. } else showHide.children( ".arrow" ).text( String.fromCharCode(8593) + String.fromCharCode(8593) );
  2220. });
  2221. }
  2222.  
  2223.  
  2224. // Update health buttons to enable or disable
  2225. function updateHealthButtons() {
  2226.  
  2227. var h = $( "#healthProgress" ).attr( "title" );
  2228. h = parseInt( h.split( "/" )[0] );
  2229. var foodLimit = parseInt( $( "#foodLimit" ).text() );
  2230. var giftLimit = parseInt( $( "#giftLimit" ).text() );
  2231. if( foodLimit == 0 ) {
  2232. disableButton( $( "#newEatButton" ) );
  2233.  
  2234. } else {
  2235. if( selectedFood ) {
  2236. var eatQ = parseInt( selectedFood.attr( "indexselect" ) ) * 10;
  2237. if( (eatQ + h) > 100 ) {
  2238. disableButton( $( "#newEatButton" ) );
  2239. } else {
  2240. enableButton( $( "#newEatButton" ) );
  2241. }
  2242.  
  2243. } else enableButton( $( "#newEatButton" ) );
  2244. }
  2245.  
  2246. if( giftLimit == 0 ) {
  2247. disableButton( $( "#newGiftButton" ) );
  2248.  
  2249. } else {
  2250. if( selectedGift ) {
  2251. var useQ = parseInt( selectedGift.attr( "indexselect" ) ) * 10;
  2252. if( (useQ + h) > 100 ) {
  2253. disableButton( $( "#newGiftButton" ) );
  2254. } else {
  2255. enableButton( $( "#newGiftButton" ) );
  2256. }
  2257.  
  2258. } else enableButton( $( "#newGiftButton" ) );
  2259. }
  2260.  
  2261. updateFightButtons();
  2262. }
  2263.  
  2264.  
  2265. // Disable button
  2266. function disableButton( btn ) {
  2267. btn.attr( "disabled", "disabled" );
  2268. btn.addClass( "buttonDisable" );
  2269. }
  2270.  
  2271.  
  2272. // Enable button
  2273. function enableButton( btn ) {
  2274. btn.removeAttr( "disabled" );
  2275. btn.removeClass( "buttonDisable" );
  2276. }
  2277.  
  2278.  
  2279. // Update fight buttons
  2280. function updateFightButtons() {
  2281.  
  2282. // Only on battle page
  2283. /*if( (new String( window.location )).indexOf( URLBattle, 0 ) >= 0 ) {
  2284.  
  2285. // If is RW
  2286. if( $( ".fightButton2" ).length == 4 ) {
  2287.  
  2288. var btnFight1 = $( ".fightButton2" ).eq(0);
  2289. var btnFight2 = $( ".fightButton2" ).eq(1);
  2290. var btnBk1 = $( ".fightButton2" ).eq(2);
  2291. var btnBk2 = $( ".fightButton2" ).eq(3);
  2292. var h = parseInt( $( "#healthBar" ).text() );
  2293. if( h < 10 ) {
  2294. disableButton( btnFight1 );
  2295. disableButton( btnFight2 );
  2296. disableButton( btnBk1 );
  2297. disableButton( btnBk2 );
  2298.  
  2299. } else if( h < 50 ) {
  2300. enableButton( btnFight1 );
  2301. enableButton( btnFight2 );
  2302. disableButton( btnBk1 );
  2303. disableButton( btnBk2 );
  2304.  
  2305. } else {
  2306. enableButton( btnFight1 );
  2307. enableButton( btnFight2 );
  2308. enableButton( btnBk1 );
  2309. enableButton( btnBk2 );
  2310. }
  2311.  
  2312. } else {
  2313.  
  2314. var btnFight = $( ".fightButton" ).eq(0);
  2315. var btnBk = $( ".fightButton" ).eq(1);
  2316. var h = parseInt( $( "#healthBar" ).text() );
  2317. if( h < 10 ) {
  2318. disableButton( btnFight );
  2319. disableButton( btnBk );
  2320.  
  2321. } else if( h < 50 ) {
  2322. enableButton( btnFight );
  2323. disableButton( btnBk );
  2324.  
  2325. } else {
  2326. enableButton( btnFight );
  2327. enableButton( btnBk );
  2328. }
  2329. }
  2330.  
  2331. // Add update weapon method
  2332. $.blockUI.defaults.onUnblock = function( elem, opts ) { updateHealthButtons(); }
  2333. }*/
  2334. }
  2335.  
  2336.  
  2337. // Add MU fast links
  2338. function addMUFastLinks() {
  2339.  
  2340. // Link to MU
  2341. var linkMU = $( "<a title='Military unit' class='button foundation-style smallhelp only-icon profileButton' href='"+ getCurrentServer() + URLMyMU +"'><img src='"+ IMGMU +"' /></a>" );
  2342. linkMU.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2343.  
  2344. // Link to MU storage
  2345. var linkMUSt = $( "<a title='MU storage' class='button foundation-style smallhelp only-icon profileButton' href='"+ getCurrentServer() + URLMUStorage +"'><img src='"+ IMGPACKAGE +"' /></a>" );
  2346. linkMUSt.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2347.  
  2348. // Link to MU money
  2349. var linkMUMy = $( "<a title='MU money' class='button foundation-style smallhelp only-icon profileButton' href='"+ getCurrentServer() + URLMUMoney +"'><img src='"+ IMGDOLLAR +"' /></a>" );
  2350. linkMUMy.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2351.  
  2352. //------------------------------------------------------
  2353.  
  2354. // Link to Donate MU money
  2355. var linkDMUMy = $( "<a title='Donate money to MU' class='button foundation-style smallhelp only-icon profileButton' href='"+ getCurrentServer() + URLDMUMoney +getMUId()+"'><img src='"+ IMGDMUMy +"' /></a>" );
  2356. linkDMUMy.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2357.  
  2358. // Link to Donate MU product
  2359. var linkDMUPR = $( "<a title='Donate product to MU' class='button foundation-style smallhelp only-icon profileButton' href='"+ getCurrentServer() + URLDMUProduct +getMUId()+"'><img src='"+ IMGDMUPR +"' /></a>" );
  2360. linkDMUPR.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2361.  
  2362. // Link to Donate MU Company
  2363. var linkDMUCP = $( "<a title='Donate Company to MU' class='button foundation-style smallhelp only-icon profileButton' href='"+ getCurrentServer() + URLDMUComp +getMUId()+"'><img src='"+ IMGDMUCP +"' /></a>" );
  2364. linkDMUCP.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2365.  
  2366.  
  2367. //--------------------------------------
  2368. // Link to Mu members
  2369. var linkMUMEMB = $( "<a title='MU Members' class='button foundation-style smallhelp only-icon profileButton' href='"+ getCurrentServer() + URLMUMEMB +getMUId()+"'><img src='"+ IMGMUMEMB +"' /></a>" );
  2370. linkMUMEMB.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2371.  
  2372.  
  2373. // Link to Mu Companys
  2374. var linkMUComp = $( "<a title='MU Campanies' class='button foundation-style smallhelp only-icon profileButton' href='"+ getCurrentServer() + URLMUCOMP +getMUId()+"'><img src='"+ IMGMUCOMP +"' /></a>" );
  2375. linkMUComp.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2376.  
  2377.  
  2378.  
  2379. var content = $( "<div style= font-weight:bold; height:30px;'></div>" );
  2380. content.append( "<hr class='foundation-divider'>" );
  2381.  
  2382. configList = new Array("config_MFB_mu","config_MFB_st","config_MFB_mm","config_MFB_dc","config_MFB_dp","config_MFB_dm","config_MFB_mc","config_MFB_mumem");
  2383.  
  2384. appendList = new Array(linkMU,linkMUSt,linkMUMy,linkDMUCP,linkDMUPR,linkDMUMy,linkMUComp,linkMUMEMB);
  2385.  
  2386. brIndex=0;
  2387.  
  2388. for(i=0;i<configList.length;i++)
  2389. {
  2390. if( getValue( configList[i] ) == "true" ) { content.append( appendList[i] ); brIndex++; }
  2391. if( brIndex == 3 ) {content.append( "<br />" );brIndex=0;}
  2392.  
  2393. }
  2394.  
  2395. /*
  2396. if( getValue( "config_MFB_mu" ) == "true" ) { content.append( linkMU ); }
  2397. if( getValue( "config_MFB_st" ) == "true" ) { content.append( linkMUSt ); }
  2398. if( getValue( "config_MFB_mm" ) == "true" ) { content.append( linkMUMy ); }
  2399.  
  2400. //content.append( "<hr class='foundation-divider'>" );
  2401. content.append( "<br />" );
  2402.  
  2403. if( getValue( "config_MFB_dc" ) == "true" ) { content.append( linkDMUCP ); }
  2404. if( getValue( "config_MFB_dp" ) == "true" ) { content.append( linkDMUPR ); }
  2405. if( getValue( "config_MFB_dm" ) == "true" ) { content.append( linkDMUMy ); }
  2406.  
  2407. //content.append( "<hr class='foundation-divider'>" );
  2408. content.append( "<br />" );
  2409.  
  2410. if( getValue( "config_MFB_mc" ) == "true" ) { content.append( linkMUComp ); }
  2411. if( getValue( "config_MFB_mumem" ) == "true" ) { content.append( linkMUMEMB ); }
  2412.  
  2413. */
  2414.  
  2415. content.insertAfter( $( "#EDLinks div:first" ));
  2416. }
  2417.  
  2418.  
  2419. // Add other fast links
  2420. function addFastLinks() {
  2421.  
  2422. // Link to equipment
  2423. var linkEquip = $( "<a style='padding:2px' class='fastLinks ' href='"+ getCurrentServer() + URLEquipment +"'></a>" );
  2424. linkEquip.append( "<img src='"+ IMGEQUIPMENT +"' />" );
  2425. linkEquip.attr( "title", "Equipment" );
  2426. linkEquip.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2427.  
  2428. // Link to my companies
  2429. var linkComp = $( "<a style='padding:2px' class='fastLinks ' href='"+ getCurrentServer() + URLCompanies +"'></a>" );
  2430. linkComp.append( "<img src='"+ IMGCOMPANY +"' />" );
  2431. linkComp.attr( "title", "My companies" );
  2432. linkComp.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2433.  
  2434. // Future image buttons
  2435. // Link to contracts
  2436. var linkCT = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLContracts +"'><img src='"+ IMGCT +"' /></a>" );
  2437. linkCT.attr( "title", "Contracts" );
  2438. linkCT.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2439.  
  2440. // Link to shares
  2441. var linkSH = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLMyShares +"'><img src='"+ IMGSH +"' /></a>" );
  2442. linkSH.attr( "title", "Shares" );
  2443. linkSH.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2444.  
  2445. // Link to product market
  2446. var linkPM = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLMarket +"'><img src='"+ IMGPM +"' /></a>" );
  2447. linkPM.attr( "title", "Product market" );
  2448. linkPM.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2449.  
  2450. // Link to monetary market
  2451. var linkMM = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLMonetaryMarket +"'><img src='"+ IMGMM +"' /></a>" );
  2452. linkMM.attr( "title", "Monetary market" );
  2453. linkMM.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2454.  
  2455. // Link to Travel
  2456. var linkTV = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLTravel +"'><img src='"+ IMGTV +"' /></a>" );
  2457. linkTV.attr( "title", "Travel" );
  2458. linkTV.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2459.  
  2460. // Link to BUFF
  2461. var linkBUF = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLBUFF +"'><img src='"+ IMGBUFF +"' /></a>" );
  2462. linkBUF.attr( "title", "Buff" );
  2463. linkBUF.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2464.  
  2465. // Link to Newbies
  2466. var linkNB = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLNB +"'><img src='"+ thumbsUp +"' /></a>" );
  2467. linkNB.attr( "title", "New Citizens" );
  2468. linkNB.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  2469.  
  2470.  
  2471. var content = $( "<div style='font-weight:bold; height:auto;'></div>" );
  2472. if( getValue( "config_FB_eq" ) == "true" ) { content.append( linkEquip ); }
  2473. if( getValue( "config_FB_co" ) == "true" ) { content.append( linkComp ); }
  2474. if( getValue( "config_FB_con" ) == "true" ) { content.append( linkCT ); }
  2475. if( getValue( "config_FB_share" ) == "true" ) { content.append( linkSH ); }
  2476. if( getValue( "config_FB_pm" ) == "true" ) { content.append( linkPM ); }
  2477. if( getValue( "config_FB_mm" ) == "true" ) { content.append( linkMM ); }
  2478. if( getValue( "config_FB_trav" ) == "true" ) { content.append( linkTV ); }
  2479. if( getValue( "config_FB_buff" ) == "true" ) { content.append( linkBUF ); }
  2480. if( getValue( "config_FB_newC" ) == "true" ) { content.append( linkNB ); }
  2481.  
  2482. content.insertAfter( $( "#EDLinks div:first" ));
  2483. }
  2484.  
  2485.  
  2486.  
  2487.  
  2488. //MU comp sorter
  2489. function sortMucomp(){
  2490.  
  2491. $(".dataTable").before('<button style="display:none" id="sort" class="sort-table asc">Sort</button>')
  2492.  
  2493. //
  2494.  
  2495.  
  2496.  
  2497. $('.sort-table').click(function(e) {
  2498. var $sort = this;
  2499. var $table = $('.dataTable');
  2500. var $rows = $('tbody > tr',$table);
  2501. $rows.sort(function(a, b){
  2502. var keyA = $('td:eq(1) div div img:eq(0)',a).attr("src");
  2503. //alert(keyA)
  2504. var keyB = $('td:eq(1) div div img:eq(0)',b).attr("src");
  2505. var keyC = $('td:eq(1) div div img:eq(1)',a).attr("src");
  2506. var keyD = $('td:eq(1) div div img:eq(1)',b).attr("src");
  2507.  
  2508. //alert(keyC + "-" + keyD)
  2509.  
  2510. if($($sort).hasClass('asc')){
  2511. if(keyA > keyB){
  2512.  
  2513. return 1
  2514. }
  2515.  
  2516. if(keyA == keyB){
  2517. if(keyC < keyD){
  2518. return 1
  2519. }else{
  2520. return 0
  2521. }
  2522. }
  2523.  
  2524. if(keyA < keyB){
  2525.  
  2526. return 0
  2527. }
  2528.  
  2529.  
  2530. } else {
  2531. return (keyA > keyB) ? 1 : 0;
  2532. }
  2533. });
  2534. $.each($rows, function(index, row){
  2535. $table.append(row);
  2536. });
  2537. e.preventDefault();
  2538. });
  2539.  
  2540. $("#sort").trigger("click");
  2541.  
  2542. }
  2543.  
  2544.  
  2545. // Link Bar
  2546. function linkBar()
  2547. {
  2548.  
  2549. $("body").addClass("myBody")
  2550.  
  2551. /*var css = document.createElement("style");
  2552. css.type = "text/css";
  2553. css.innerHTML = "";
  2554. document.head.appendChild(css);*/
  2555.  
  2556. tabla="<table style=\"border-bottom-style:1px solid;width:900px;margin:auto\"><tr>";
  2557.  
  2558. for(i=1;i<11;i++)
  2559. {
  2560. tabla+="<td id=\"LinkBarButton"+i+"\" stlye=\"border-bottom-style:width:90px;padding-left:1px\">";
  2561.  
  2562. if(getValue("LBT_"+""+i)==null)
  2563. {
  2564. tabla+="<a class=\"newsTabLink\" href=\"#\"><div class=\"LinkBarBut\">-</div></a></td>";
  2565. }else
  2566. {
  2567. tabla+="<a href="+getValue("LB_"+""+i)+"><div class=\"LinkBarBut\">"+getValue("LBT_"+""+i)+"</div></a></td>";
  2568.  
  2569. }
  2570.  
  2571. }
  2572.  
  2573. //class=\"newsTabLink\"
  2574.  
  2575.  
  2576. //tabla+="<td><div style=\"cursor:pointer;\" id=\"del\"><img src=\"http://www.gettyicons.com/free-icons/133/shimmer/png/32/delete_32.png\"></div></td></tr></table>";
  2577.  
  2578. var new_div = document.createElement('div');
  2579. new_div.id = "LinkBar";
  2580. new_div.innerHTML=tabla;
  2581.  
  2582. ab=35;
  2583. document.body.style.paddingTop = ab.toString()+"px"
  2584.  
  2585. $('nav').parent().append(new_div)
  2586.  
  2587. //document.body.insertBefore(new_div, document.body.firstChild);
  2588. //document.body.appendChild(new_div);
  2589.  
  2590. //alert(document.getElementById("LinkBarButton8").innerHTML.length)
  2591.  
  2592. /*for(i=0;i<10;i++)
  2593. {
  2594.  
  2595. button = document.getElementById("LinkBarButton"+""+i);
  2596. if(button.innerHTML.length==67)
  2597. {
  2598. button.addEventListener('click',function() {set(this.id[13]);},true);
  2599. }
  2600.  
  2601. }
  2602.  
  2603. button = document.getElementById("del");
  2604. button.addEventListener('click',clear,true);
  2605.  
  2606. */
  2607. }
  2608.  
  2609. // Get ID player
  2610. function getPlayerID() {
  2611. if( !idPlayer ) {
  2612. var link = $( "#userName" ).attr( "href" );
  2613. if( link ) {
  2614. if( link.split( "id=" ).length == 2 ) {
  2615. idPlayer = link.split( "id=" )[1];
  2616. }
  2617. }
  2618. } return( idPlayer );
  2619. }
  2620.  
  2621.  
  2622. // Get current server
  2623. function getCurrentServer() {
  2624. if( !currentServer ) {
  2625. var localUrl = new String( window.location );
  2626. var ini = localUrl.indexOf( "http://", 0 );
  2627. var end = localUrl.indexOf( ".", 0 );
  2628. currentServer = localUrl.substr( ini, end-ini+1 );
  2629. } return( currentServer );
  2630. }
  2631.  
  2632.  
  2633. // Add version on all pages if not Battlepage
  2634. function addVersion() {
  2635.  
  2636. // Version
  2637. var vers = $( "<div class='version'>" + VERSION + "</div>" );
  2638. var optionVisible = false;
  2639. vers.bind( "click", function() { /* "#maskConfig" ).show(); $( "#configScript" ).show();*/
  2640. $.blockUI({
  2641. message: $('#configScript'),
  2642. css: {
  2643. top: "48px",
  2644. left: ($(window).width() - 600) /2 + 'px',
  2645. width: '600px' ,
  2646. border: "0px",
  2647. position: "absolute",
  2648. textAlign: "left"
  2649.  
  2650. }
  2651. });
  2652.  
  2653. });
  2654.  
  2655. var content = $( "<div id='EDLinks' class='switch foundation-style' style='margin-top:5px; display:block; font-weight:bold; height:auto;'></div>" );
  2656. content.insertAfter( $( "#userMenu div div:first" ) );
  2657. content.append( vers );
  2658.  
  2659.  
  2660. }
  2661.  
  2662.  
  2663. // Add configuration
  2664. function addConfigurationUI() {
  2665.  
  2666. // Add mask and config
  2667. var mask = $( "<div style='background-color:black; opacity:0.5; min-height: 100%;' id='maskConfig'></div>" );
  2668. var configScript = $( "<div role='dialog' style='display: table; outline: 0px none; z-index: 1000; width:600px; ' class='ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-dialog-buttons' id='configScript'></div>" );
  2669.  
  2670.  
  2671.  
  2672.  
  2673. $( "body" ).append( configScript );
  2674.  
  2675. // Title
  2676. configScript.append( "<h2 class='titleConfig'>Configuration "+ VERSION +"</h2>" );
  2677. configScript.append( "<a href='"+ URLSCRIPT +"' target='_blank'>check new version</a>" );
  2678. configScript.append( "<br/>" );
  2679.  
  2680. // Global config
  2681. var globalBlock = $( "<div id='globalBlock'>GLOBAL</div>" );
  2682. var configMoveNotify = createCheckBox( "Move notifications", "configMoveNotifications" );
  2683. globalBlock.append( configMoveNotify );
  2684. //var configEatButtons = createCheckBox( "Food/Gifts buttons", "configEatButtons" );
  2685. //globalBlock.append( configEatButtons );
  2686. var configSkillImprovements = createCheckBox( "Skill Improvements", "configSkillImprovements" );
  2687. globalBlock.append( configSkillImprovements );
  2688. var configRemoveLang = createCheckBox( "Language Slection remove", "configRemoveLang" );
  2689. globalBlock.append( configRemoveLang );
  2690. var configOrgAcc = createCheckBox( "Remove useless items if Org.", "configOrgAcc" );
  2691. globalBlock.append( configOrgAcc );
  2692. var configRemoveUselessFastButtons = createCheckBox( "Remove useless fast buttons.", "configRemoveUselessFastButtons" );
  2693. globalBlock.append( configRemoveUselessFastButtons );
  2694. var configSomeFix = createCheckBox( "Fix some things", "configSomeFix" );
  2695. globalBlock.append( configSomeFix );
  2696. var configSounds = createCheckBox( "Add sound to msg and allert", "configSounds" );
  2697. globalBlock.append( configSounds );
  2698. var configLinkBar = createCheckBox( "Add Link Bar", "configLinkBar" );
  2699. globalBlock.append( configLinkBar );
  2700. var configHideMissionStuff = createCheckBox( "Hide Misson stuffs", "configHideMissionStuff" );
  2701. globalBlock.append( configHideMissionStuff );
  2702. var configHideChat = createCheckBox( "Hide Chat Panel", "configHideChat" );
  2703. globalBlock.append( configHideChat );
  2704.  
  2705.  
  2706. // MU storage
  2707. var muStorageBlock = $( "<div id='muStorageBlock'>MU STORAGE</div>" );
  2708. var muStorageDonateToMe = createCheckBox( "Button: Donate me", "configMUStorageDonateToMe" );
  2709. muStorageBlock.append( muStorageDonateToMe );
  2710. var muStorageSelect = createCheckBox( "Product selection", "configMUStorageSelect" );
  2711. muStorageBlock.append( muStorageSelect );
  2712. var muStorageFastButtons = createCheckBox( "Fast buttons", "configMUStorageFastButtons" );
  2713. muStorageBlock.append( muStorageFastButtons );
  2714. var muStorageDonateImprovements = createCheckBox( "Donate improvements", "configMUStorageDonateImprovements" );
  2715. muStorageBlock.append( muStorageDonateImprovements );
  2716. var muStorageItemCounter = createCheckBox( "Donate counter", "configMUStorageDonateCounter" );
  2717. muStorageBlock.append( muStorageItemCounter );
  2718.  
  2719. // MU money
  2720. var muMoneyBlock = $( "<div id='muMoneyBlock'>MU MONEY</div>" );
  2721. var muMoneyDonateToMe = createCheckBox( "Button: Donate me", "configMUMoneyDonateToMe" );
  2722. muMoneyBlock.append( muMoneyDonateToMe );
  2723. var muMoneyDonateImprovements = createCheckBox( "Donate improvements", "configMUMoneyDonateImprovements" );
  2724. muMoneyBlock.append( muMoneyDonateImprovements );
  2725.  
  2726. // Donate
  2727. var donateBlock = $( "<div id='donateBlock'>DONATE</div>" );
  2728. var donateProduct = createCheckBox( "Product selection", "configDonateProduct" );
  2729. donateBlock.append( donateProduct );
  2730. var donateFastButtons = createCheckBox( "Fast buttons", "configDonateFastButtons" );
  2731. donateBlock.append( donateFastButtons );
  2732.  
  2733. // Battle
  2734. var battleBlock = $( "<div id='battleBlock'>BATTLE</div>" );
  2735. var roundSelector = createCheckBox( "Round selector", "configRoundSelector" );
  2736. battleBlock.append( roundSelector );
  2737. var battleList = createCheckBox( "Battle list", "configBattleList" );
  2738. battleBlock.append( battleList );
  2739. var weaponSelector = createCheckBox( "Weapon selector", "configWeaponSelector" );
  2740. battleBlock.append( weaponSelector );
  2741. var ExtraEatUseButton = createCheckBox( "Add Eat Button", "configExtraEatUseButton" );
  2742. battleBlock.append( ExtraEatUseButton );
  2743. var configTime = createCheckBox( "Change Clock", "configTime" );
  2744. battleBlock.append( configTime );
  2745. var configExtraInfo = createCheckBox( "Extra Info to Wep Selector", "configExtraInfo" );
  2746. battleBlock.append( configExtraInfo );
  2747.  
  2748.  
  2749.  
  2750. // Equipment
  2751. var equipmentBlock = $( "<div id='equipmentBlock'>EQUIPMENT</div>" );
  2752. var removeInterface = createCheckBox( "Remove interface", "configDesignEquipment" );
  2753. equipmentBlock.append( removeInterface );
  2754. var calculatorDamage = createCheckBox( "Damage simulator", "configCalculateDamage" );
  2755. equipmentBlock.append( calculatorDamage );
  2756.  
  2757.  
  2758. // Shares
  2759. var sharesBlock = $( "<div id='sharesBlock'>SHARES</div>" );
  2760. var sharesRedesign = createCheckBox( "Menu redesign", "configSharesMenu" );
  2761. var sharesProductSelection = createCheckBox( "Product selection", "configSharesProductSelection" );
  2762. sharesBlock.append( sharesRedesign );
  2763. sharesBlock.append( sharesProductSelection );
  2764. var configStockcoEditOffers = createCheckBox( "Editable price and quanty", "configStockcoEditOffers" );
  2765. sharesBlock.append( configStockcoEditOffers );
  2766.  
  2767. // Travel
  2768. var travelBlock = $( "<div id='travelBlock'>TRAVEL</div>" );
  2769. var configTravelMenu = createCheckBox( "Ticket selection", "configTravelMenu" );
  2770. travelBlock.append( configTravelMenu );
  2771.  
  2772. // New Citizen
  2773. var NewCitizenBlock = $( "<div id='NewCitizenBlock'>New Citizen</div>" );
  2774. var configNCM = createCheckBox( "One Click Motivation", "configNCM" );
  2775. NewCitizenBlock.append( configNCM );
  2776. var configNRC = createCheckBox( "One Click Motivation at New registered Citizens", "configNRC" );
  2777. NewCitizenBlock.append( configNRC );
  2778.  
  2779.  
  2780.  
  2781.  
  2782. //Article
  2783. var ArticleBlock = $( "<div id='ArticleBlock'>Article</div>" );
  2784. var configBBcode = createCheckBox( "BB codes", "configBBcode" );
  2785. ArticleBlock.append( configBBcode );
  2786.  
  2787. // Search
  2788.  
  2789. var SearchBlock = $( "<div id='SearchBlock'>Cititzen Search</div>" );
  2790. var configEBS = createCheckBox( "Extra Buttons to search", "configEBS" );
  2791. SearchBlock.append( configEBS );
  2792.  
  2793.  
  2794. // Company
  2795. var companyBlock = $( "<div id='companyBlock'>COMPANY</div>" );
  2796. var configCompanyMenu = createCheckBox( "Menu redesign", "configCompanyRedesign" );
  2797. var configCompanyWorkResults = createCheckBox( "Work results", "configCompanyWorkResults" );
  2798. companyBlock.append( configCompanyMenu );
  2799. companyBlock.append( configCompanyWorkResults );
  2800.  
  2801. // Market
  2802. var marketBlock = $( "<div id='marketBlock'>MARKET</div>" );
  2803. var configProductMarketSelection = createCheckBox( "Product selection", "configProductMarketSelection" );
  2804. marketBlock.append( configProductMarketSelection );
  2805. var configProductMarketTable = createCheckBox( "Product table", "configProductMarketTable" );
  2806. marketBlock.append( configProductMarketTable );
  2807. var configProductMarketOffers = createCheckBox( "My offers", "configProductMarketOffers" );
  2808. marketBlock.append( configProductMarketOffers );
  2809. var configEditOffers = createCheckBox( "Editable price and quanty", "configEditOffers" );
  2810. marketBlock.append( configEditOffers );
  2811. var configProductMarketAdvanced = createCheckBox( "Product Market Advanced", "configProductMarketAdvanced" );
  2812. marketBlock.append( configProductMarketAdvanced );
  2813.  
  2814.  
  2815.  
  2816. // Monetary market
  2817. var monetaryMarketBlock = $( "<div id='monetaryMarketBlock'>MONETARY MARKET</div>" );
  2818. var configMonetaryMarketSelection = createCheckBox( "Money selection", "configMonetaryMarketSelection" );
  2819. monetaryMarketBlock.append( configMonetaryMarketSelection );
  2820. var configMonetaryMarketTable = createCheckBox( "Money table", "configMonetaryMarketTable" );
  2821. monetaryMarketBlock.append( configMonetaryMarketTable );
  2822. var configEditPrice= createCheckBox( "Edit Price and Quanty", "configEditPrice" );
  2823. monetaryMarketBlock.append( configEditPrice );
  2824. var configRatioPrice= createCheckBox( "Advanced Ratio and Price", "configRatioPrice" );
  2825. monetaryMarketBlock.append( configRatioPrice );
  2826.  
  2827.  
  2828. //OTHERS
  2829. var OthersBlock = $( "<div id='OthersBlock'>Others</div>" );
  2830. var configProfile= createCheckBox( "Profile - Today DMG", "configProfile" );
  2831. OthersBlock.append( configProfile );
  2832. var configProfileCalc= createCheckBox( "Profile - Calculator", "configProfileCalc" );
  2833. OthersBlock.append( configProfileCalc );
  2834. OthersBlock.append( "<hr /><br />" );
  2835. var configkari= createCheckBox( "Christmass Extra", "configKari" );
  2836. OthersBlock.append( configkari );
  2837.  
  2838. // MU
  2839. //configMUBrodcastMsg
  2840. var MUBlock = $( "<div id='MUBlock'>MU Main</div>" );
  2841. var configMUBrodcastMsg = createCheckBox( "Brodcast MSG", "configMUBrodcastMsg" );
  2842. MUBlock.append( configMUBrodcastMsg );
  2843.  
  2844. // Theme weapon selector
  2845. var weaponSel = $( "<select id='weaponSelectorTheme' class='customSelectList'></select>" );
  2846. weaponSel.append( "<option value='default'>eSim</option>" );
  2847. //weaponSel.append( "<option value='AoE'>Age of empires</option>" );
  2848. //weaponSel.append( "<option value='SW'>Star Wars</option>" );
  2849. //weaponSel.append( "<option value='Pok'>PokĂŠmon</option>" );
  2850. weaponSel.bind( "change", function() {
  2851. setValue( "configWeaponTheme", $(this).val() );
  2852. });
  2853.  
  2854. // Selector of default weapon
  2855. var defaultWeapon = $( "<select id='defaultWeapon' class='customSelectList'></select>" );
  2856. defaultWeapon.append( "<option value='0'>Unarmed</option>" );
  2857. for( var i=1; i<=5; i++ ) { defaultWeapon.append( "<option value='"+i+"'>Q"+i+"</option>" ); }
  2858. defaultWeapon.bind( "change", function() {
  2859. setValue( "configDefaultWeapon", $(this).val() );
  2860. });
  2861.  
  2862. //THEME AND WEP BLock
  2863. var themeAndWep = $( "<div id='themeAndWep'>Theme And Wep<br /></div>" );
  2864. themeAndWep.append( "<b>Theme: </b>" );
  2865. themeAndWep.append( weaponSel );
  2866. weaponSel.val( getValue( "configWeaponTheme" ) );
  2867. themeAndWep.append( "<b>Default weapon: </b>" );
  2868. themeAndWep.append( defaultWeapon );
  2869. defaultWeapon.val( getValue( "configDefaultWeapon" ) );
  2870.  
  2871. // LInkbar
  2872. Linkbar=$('<div id="linkBar"><br>LinkBar Links:</b><br/> 1 Link: <input id="LB_1" type="text" /> Text:<input id="LBT_1" type="text" /><br/>2 Link: <input id="LB_2" type="text" /> Text:<input id="LBT_2" type="text" /><br/>3 Link: <input id="LB_3" type="text" /> Text:<input id="LBT_3" type="text" /><br/>4 Link: <input id="LB_4" type="text" /> Text:<input id="LBT_4" type="text" /><br/>5 Link: <input id="LB_5" type="text" /> Text:<input id="LBT_5" type="text" /><br/>6 Link: <input id="LB_6" type="text" /> Text:<input id="LBT_6" type="text" /><br/>7 Link: <input id="LB_7" type="text" /> Text:<input id="LBT_7" type="text" /><br/>8 Link: <input id="LB_8" type="text" /> Text:<input id="LBT_8" type="text" /><br/>9 Link: <input id="LB_9" type="text" /> Text:<input id="LBT_9" type="text" /><br/>10 Link: <input id="LB_10" type="text" /> Text:<input id="LBT_10" type="text" /><br/></div>')
  2873.  
  2874. // Close button
  2875. //configScript.append( "" );
  2876. var close = $( "<input class='postfix only-icon button foundation-style' style='margin-top:2px' type='button' value='Save and close' />" );
  2877. close.bind( "click", function() { saveLinkBarLinks();$.unblockUI(); $( "#maskConfig" ).hide(); $( "#configScript" ).hide(); });
  2878.  
  2879.  
  2880. //FAST BUTTONS
  2881.  
  2882. var FBBlock = $( "<div id='FBBlock'></div>" );
  2883.  
  2884. var fastLinks = createCheckBox( "Fast Links", "configFastLinks" );
  2885. FBBlock.append( fastLinks );
  2886. FBBlock.append( "<hr />" );
  2887.  
  2888.  
  2889. var config_FB_eq = createCheckBox( "Equipment", "config_FB_eq" );
  2890. FBBlock.append( config_FB_eq );
  2891. //-------------
  2892. var config_FB_co= createCheckBox( "Companys", "config_FB_co" );
  2893. FBBlock.append( config_FB_co);
  2894. //-------------
  2895. var config_FB_con = createCheckBox( "Contract", "config_FB_con" );
  2896. FBBlock.append( config_FB_con );
  2897. //-------------
  2898. var config_FB_share = createCheckBox( "Shares", "config_FB_share" );
  2899. FBBlock.append( config_FB_share );
  2900. //-------------
  2901. var config_FB_pm = createCheckBox( "Product Market", "config_FB_pm" );
  2902. FBBlock.append( config_FB_pm );
  2903. //-------------
  2904. var config_FB_mm = createCheckBox( "Monetary Market", "config_FB_mm" );
  2905. FBBlock.append( config_FB_mm );
  2906. //-------------
  2907. var config_FB_trav = createCheckBox( "Travel", "config_FB_trav" );
  2908. FBBlock.append( config_FB_trav );
  2909. //-------------
  2910. var config_FB_buff = createCheckBox( "Buff", "config_FB_buff" );
  2911. FBBlock.append( config_FB_buff );
  2912. //-------------
  2913. var config_FB_newC = createCheckBox( "New Citizens", "config_FB_newC" );
  2914. FBBlock.append( config_FB_newC );
  2915. //-------------
  2916. //MUFasTBUttons
  2917. FBBlock.append( "<br /><br />" );
  2918. var muFastLinks = createCheckBox( "MU Fast links", "configMUFastLinks" );
  2919. FBBlock.append( muFastLinks );
  2920. FBBlock.append( "<hr />" );
  2921. //-------------
  2922. var config_MFB_mu = createCheckBox( "My Military Unit", "config_MFB_mu" );
  2923. FBBlock.append( config_MFB_mu );
  2924. //-------------
  2925. var config_MFB_st = createCheckBox( "MU Storage", "config_MFB_st" );
  2926. FBBlock.append( config_MFB_st );
  2927. //-------------
  2928. var config_MFB_mm = createCheckBox( "MU Money", "config_MFB_mm" );
  2929. FBBlock.append( config_MFB_mm );
  2930. //-------------
  2931. var config_MFB_dc = createCheckBox( "MU Donate Company", "config_MFB_dc" );
  2932. FBBlock.append( config_MFB_dc );
  2933. //-------------
  2934. var config_MFB_dp = createCheckBox( "MU Donate Product", "config_MFB_dp" );
  2935. FBBlock.append( config_MFB_dp );
  2936. //-------------
  2937. var config_MFB_dm = createCheckBox( "MU Donate Money", "config_MFB_dm" );
  2938. FBBlock.append( config_MFB_dm );
  2939. //-------------
  2940. var config_MFB_mc = createCheckBox( "MU Companys", "config_MFB_mc" );
  2941. FBBlock.append( config_MFB_mc );
  2942. //-------------
  2943. var config_MFB_mumem= createCheckBox( "MU Members", "config_MFB_mumem" );
  2944. FBBlock.append(config_MFB_mumem );
  2945. //-------------
  2946.  
  2947.  
  2948. //configScript.append( "<table align='center' border='0' cellpadding='5' cellspacing='1' style='width: 550px;'><tbody><tr><td id='configScripttabel_1'></td><td id='configScripttabel_2'></td><td id='configScripttabel_3'></td></tr><tr><td id='configScripttabel_4'></td><td id='configScripttabel_5'></td><td id='configScripttabel_6'></td></tr><tr><td id='configScripttabel_7'></td><td id='configScripttabel_8'></td><td id='configScripttabel_9'></td></tr><tr><td id='configScripttabel_10'></td><td id='configScripttabel_11'></td><td id='configScripttabel_12'></td></tr><tr><td id='configScripttabel_13'></td><td id='configScripttabel_14'></td><td id='configScripttabel_15'></td></tr><tr><td id='configScripttabel_16'></td><td id='configScripttabel_17'></td><td id='configScripttabel_18'></td></tr></tbody></table> " );
  2949.  
  2950. configScript.append( '<div id="tabs"></div>');
  2951. $("#tabs").append( '<ul>\
  2952. <li><a href="#globalBlock">Global</a></li>\
  2953. <li><a href="#FBBlock">Fast Links</a></li>\
  2954. <li><a href="#MUBlock">MU Main</a></li>\
  2955. <li><a href="#muStorageBlock">MU Storage</a></li>\
  2956. <li><a href="#muMoneyBlock">MU Money</a></li>\
  2957. <li><a href="#donateBlock">Donate</a></li>\
  2958. <li><a href="#battleBlock">Battle</a></li>\
  2959. <li><a href="#equipmentBlock">Equipment</a></li>\
  2960. <li><a href="#sharesBlock">Shares</a></li>\
  2961. <li><a href="#travelBlock">Travel</a></li>\
  2962. <li><a href="#NewCitizenBlock">New Citizen</a></li>\
  2963. <li><a href="#ArticleBlock">Article</a></li>\
  2964. <li><a href="#SearchBlock">Search</a></li>\
  2965. <li><a href="#companyBlock">Company</a></li>\
  2966. <li><a href="#marketBlock">Product Market</a></li>\
  2967. <li><a href="#monetaryMarketBlock">Monetary Market</a></li>\
  2968. <li><a href="#themeAndWep">Theme And Wep</a></li>\
  2969. <li><a href="#linkBar">LinkBar</a></li>\
  2970. <li><a href="#OthersBlock">Others</a></li>\
  2971. </ul>');
  2972.  
  2973.  
  2974. $("#tabs").append( globalBlock );
  2975. $("#tabs").append( FBBlock );
  2976. $("#tabs").append( battleBlock );
  2977. $("#tabs").append( muStorageBlock );
  2978. $("#tabs").append( donateBlock );
  2979. $("#tabs").append( equipmentBlock );
  2980. $("#tabs").append( muMoneyBlock );
  2981. $("#tabs").append( sharesBlock );
  2982. $("#tabs").append( companyBlock );
  2983. $("#tabs").append( monetaryMarketBlock );
  2984. $("#tabs").append( marketBlock );
  2985. $("#tabs").append( travelBlock );
  2986. $("#tabs").append( SearchBlock );
  2987. $("#tabs").append( NewCitizenBlock );
  2988. $("#tabs").append( ArticleBlock );
  2989. $("#tabs").append( MUBlock );
  2990. $("#tabs").append( themeAndWep );
  2991. $("#tabs").append( Linkbar );
  2992. $("#tabs").append( OthersBlock );
  2993.  
  2994. $( "#tabs" ).tabs().addClass( "ui-tabs-vertical ui-helper-clearfix" );
  2995. $( "#tabs li" ).removeClass( "ui-corner-top" ).addClass( "ui-corner-left" );
  2996.  
  2997. /*$("#configScripttabel_1").append( globalBlock );
  2998. $("#configScripttabel_2").append( battleBlock );
  2999. $("#configScripttabel_3").append( muStorageBlock );
  3000. $("#configScripttabel_4").append( donateBlock );
  3001. $("#configScripttabel_5").append( equipmentBlock );
  3002. $("#configScripttabel_6").append( muMoneyBlock );
  3003. $("#configScripttabel_7").append( sharesBlock );
  3004. $("#configScripttabel_8").append( companyBlock );
  3005. $("#configScripttabel_9").append( monetaryMarketBlock );
  3006. $("#configScripttabel_10").append( marketBlock );
  3007. $("#configScripttabel_11").append( travelBlock );
  3008. $("#configScripttabel_12").append( SearchBlock );
  3009. $("#configScripttabel_13").append( NewCitizenBlock );
  3010. $("#configScripttabel_14").append( ArticleBlock );
  3011. $("#configScripttabel_15").append( MUBlock );
  3012. $("#configScripttabel_16").append( OthersBlock );
  3013. configScript.append( "<b>Theme: </b>" );
  3014. configScript.append( weaponSel );
  3015. weaponSel.val( getValue( "configWeaponTheme" ) );
  3016. configScript.append( "<b>Default weapon: </b>" );
  3017. configScript.append( defaultWeapon );
  3018. defaultWeapon.val( getValue( "configDefaultWeapon" ) );
  3019.  
  3020. configScript.append( Linkbar ); */
  3021. //Visszatöltés
  3022. fillBack()
  3023.  
  3024. configScript.append( close );
  3025.  
  3026. //Bezárás
  3027. $( "#maskConfig" ).hide(); $( "#configScript" ).hide(); /*$.unblockUI();*/
  3028. }
  3029.  
  3030. function fillBack()
  3031. {
  3032.  
  3033. for(i=1;i<11;i++)
  3034. {
  3035. sid="#LB_"+""+i;
  3036. $(sid).val(getValue("LB_"+""+i));
  3037. sid="#LBT_"+""+i;
  3038. $(sid).val(getValue("LBT_"+""+i));
  3039. }
  3040.  
  3041. }
  3042.  
  3043. //saveLinkBarLinks()
  3044. function saveLinkBarLinks()
  3045. {
  3046.  
  3047. //alert("save")
  3048.  
  3049. for(i=1;i<11;i++)
  3050. {
  3051. sid="#LB_"+""+i;
  3052. setValue("LB_"+""+i,$(sid).val());
  3053. sid="#LBT_"+""+i;
  3054. setValue("LBT_"+""+i,$(sid).val());
  3055.  
  3056. }
  3057.  
  3058. }
  3059.  
  3060.  
  3061. // Create checkbox and label
  3062. function createCheckBox( label, configLabel ) {
  3063. var div = $( "<div></div>" );
  3064. var checked = (getValue( configLabel ) == "true") ? "checked='checked'" : "";
  3065. div.append( "<input class='configCheckbox' type='checkbox' "+ checked +" />" );
  3066. div.children( "input" ).bind( "change", function() {
  3067. setValue( configLabel, ($(this).attr( "checked" ) == "checked") );
  3068. });
  3069. div.append( "<span class='configLabelCheckbox'>"+ label +"</span>" );
  3070. div.children( "span" ).bind( "click", function() {
  3071. div.children( "input" ).click();
  3072. div.children( "input" ).change();
  3073. });
  3074. return( div );
  3075. }
  3076.  
  3077.  
  3078. // Rellocate messages notify
  3079. function rellocateMessages() {
  3080.  
  3081. // Relloacte messages
  3082. var plateList = $( "#userMenu" ).children( ".plate" );
  3083. var plate = plateList.last();
  3084. plate.insertAfter( $( "#userName" ).parent().parent() );
  3085.  
  3086. // Remove useless fight button
  3087. var localUrl = new String( window.location );
  3088. // On battle, always remove
  3089. if( localUrl.indexOf( URLBattle, 0 ) >= 0 ) {
  3090. if( plateList.length == 5 ) {
  3091. plateList.eq(1).remove();
  3092. }
  3093. } else {
  3094. if( plateList.length == 5 ) {
  3095. // if Org, always remove
  3096. if( isOrgAccount() ) {
  3097. plateList.eq(1).remove();
  3098. } else {
  3099. plateList.eq(1).find( ".fightIcon" ).parent().remove();
  3100. if( plateList.eq(1).children( "div" ).children( ".button" ).length == 0 ) {
  3101. plateList.eq(1).remove();
  3102. }
  3103. }
  3104. }
  3105. }
  3106. }
  3107.  
  3108.  
  3109. // Update MU orders if changed on main page
  3110. function updateMUOrdersMain() {
  3111.  
  3112. $( ".testDivblue" ).each( function() {
  3113.  
  3114. if( $(this).children( "center" ).length == 2 ) {
  3115.  
  3116. var savedBattle = getValue( "MUSavedBattle" );
  3117. var battle = $(this).find( "a[href^='battle.html?id=']" ).attr( "href" );
  3118. if( !battle ) { return; }
  3119. var side = $("#eventTeamImage b div").attr("class").split(" ")[1];
  3120. //side = side.replace( "small", "medium" );
  3121.  
  3122. if( savedBattle != battle ) {
  3123.  
  3124. // alert(battle +" -- ")
  3125.  
  3126. setValue( "MUSavedBattle", battle );
  3127. setValue( "MUSide", side );
  3128.  
  3129. // Open MU page to check quality and text orders
  3130. $.ajax({
  3131. url: getCurrentServer() + URLMyMU,
  3132. success: function( data ) {
  3133. var table = $( data ).find( "#militaryUnitContainer table" );
  3134. var tr = table.find( "tr" ).eq(0);
  3135. var td = tr.find( "td" ).eq(1);
  3136.  
  3137. var MURank = td.children( "div" ).first().find("table tr:eq(1) td:eq(1)").text().toLowerCase();
  3138.  
  3139.  
  3140. //alert(MURank)
  3141.  
  3142. if( MURank == "novice" ) { setValue( "MURank", "5" );
  3143. } else if( MURank == "regular" ) { setValue( "MURank", "10" );
  3144. } else if( MURank == "veteran" ) { setValue( "MURank", "15" );
  3145. } else if( MURank == "elite" ) { setValue( "MURank", "20" ); }
  3146. }
  3147. });
  3148. }
  3149. }
  3150. });
  3151. }
  3152.  
  3153.  
  3154. // Calculate bonus on battle
  3155. function calculateBonus() {
  3156.  
  3157. $( "#contentRow" ).find( ".biggerFont.blueBox" ).css({ "margin-right" : "26px" });
  3158. $( "#contentRow" ).find( ".biggerFont.redBox" ).css({ "margin-left" : "25px" });
  3159.  
  3160. var divBattle = $( "#contentRow" ).find( ".testDivblue" ).eq(0);
  3161. var divFight = $( "#contentRow" ).find( ".testDivblue" ).eq(1);
  3162. var plate = $( "#stats" ).parent();
  3163. var currentLocation = plate.find( "a[href^='region']" ).attr( "href" ).split( "?id=" );
  3164. if( currentLocation.length > 1 ) { currentLocation = currentLocation[1] }
  3165.  
  3166.  
  3167.  
  3168. var divBattleLocation = $( ".testDivwhite" ).find( "a[href^='region']" );
  3169. if( divBattleLocation.length == 1 ) {
  3170. var battleLocation = divBattleLocation.attr( "href" ).split( "?id=" );
  3171. if( battleLocation.length > 1 ) { battleLocation = battleLocation[1] }
  3172. }
  3173.  
  3174.  
  3175.  
  3176.  
  3177. var bonusMU = 0;
  3178. var muSide = "";
  3179. if( getValue( "MUSavedBattle" ) ) {
  3180. muSide = getValue( "MUSavedBattle" ).split( "?id=" );
  3181. if( muSide.length > 1 ) { muSide = muSide[1] }
  3182. }
  3183.  
  3184.  
  3185. var battleID = getUrlVars()[ "id" ];
  3186.  
  3187. var products = $( ".productList" );
  3188. var numberLocation = 0;
  3189. var bonusSD = 0;
  3190. // Get if SD is on battle
  3191. if( products.length > 0 ) {
  3192. products.find( "img" ).each( function() {
  3193.  
  3194. isDS = $(this).attr( "src" ).split(" ")[0];
  3195. isDS = isDS+""
  3196.  
  3197.  
  3198. if( isDS.indexOf('Defense') != -1 ) {
  3199. var str = $(this).next().attr( "src" );
  3200. str = str.replace( IMGQUALITY, "" ).substring(0, 1);
  3201. bonusSD = parseInt( str ) * 5;
  3202.  
  3203. }
  3204. });
  3205. }
  3206.  
  3207. var travelRW = $( "<div class='blueBox' style='padding:9px 2px; margin:0px 0px 15px 0px;'></div>" );
  3208. var link = $( "<a href='' id='travelLocation' style='cursor:pointer; font-size:13px;'></a>" );
  3209. link.append( "<span style='font-size:11px'>Move to RW location and get +20%</span>" );
  3210. travelRW.append( link );
  3211.  
  3212. var travelLeft = $( "<div class='blueBox' style='padding:6px 2px; margin:0px 0px 15px -6px; width:135px;'></div>" );
  3213. travelLeft.css({ "display" : "inline-block" });
  3214. link = $( "<a href='' id='travelLocationLeft' style='cursor:pointer; font-size:11px;'></a>" );
  3215. link.append( "<span style='font-size:10px'>Move to defender region and get +20%</span>" );
  3216. travelLeft.append( link );
  3217.  
  3218. var travelRight = $( "<div class='redBox' style='padding:6px 2px; margin:0px 1px 15px 0px; width:135px;'></div>" );
  3219. travelRight.css({ "display" : "inline-block", "float" : "right" });
  3220. link = $( "<a href='' id='travelLocationRight' style='cursor:pointer; font-size:11px;'></a>" );
  3221. link.append( "<span style='font-size:10px'>Move to neighbour region and get +20%</span>" );
  3222. travelRight.append( link );
  3223.  
  3224. //
  3225. if( divFight.find( ".fightButton" ).length > 0 )
  3226.  
  3227. var isRW = false;
  3228. var isRW = (divBattleLocation.parent().parent().text().indexOf( "Resistance war", 0 ) > -1);
  3229.  
  3230. pos = $("#showTutorial");
  3231.  
  3232. if( isRW ) {
  3233. if( currentLocation == battleLocation ) { numberLocation = 20; }
  3234.  
  3235. // If can't fight, location is not correct
  3236. if( $( "#weaponQuality" ).length == 0 ) {
  3237. travelRW.insertBefore( pos );
  3238. setTravelLocation( battleLocation, travelRW, travelLeft, travelRight );
  3239. }
  3240.  
  3241. var leftMU = 0;
  3242. var rightMU = 0;
  3243. var sides = $( ".testDivwhite" ).find( ".flags-big" );
  3244.  
  3245. // MU Bonus
  3246. if( battleID == muSide ) { // Correct battle
  3247. if( sides.length == 2 ) {
  3248. // Left defender
  3249. if( sides.eq(0).attr( "class" ).split(" ")[1] == getValue( "MUSide" ) ) {
  3250. leftMU = getValue( "MURank" );
  3251.  
  3252. } else if( sides.eq(1).attr( "class" ).split(" ")[1] == getValue( "MUSide" ) ) {
  3253. rightMU = getValue( "MURank" );
  3254. }
  3255. }
  3256. }
  3257.  
  3258. var leftBlock = createBlockBonus( numberLocation, leftMU, bonusSD );
  3259. leftBlock.attr( "id", "leftBlockBonus" );
  3260. //leftBlock.css({ "margin-top" : "-10px", "margin-left" : "-24px" });
  3261. leftBlock.append("|")
  3262. leftBlock.insertBefore( pos );
  3263.  
  3264. // Only defensive SD
  3265. var rightBlock = createBlockBonus( numberLocation, rightMU, 0 );
  3266. rightBlock.attr( "id", "rightBlockBonus" );
  3267. //rightBlock.css({ "margin-top" : "-10px", "margin-left" : (pos.width()+13)+"px" });
  3268. rightBlock.insertBefore( pos );
  3269.  
  3270. } else {
  3271.  
  3272. var flags = $( ".testDivwhite" ).find( ".flags-big" );
  3273. var defender = flags.eq(0).attr( "class" ).split(" ")[1];
  3274. var attacker = flags.eq(1).attr( "class" ).split(" ")[1];
  3275. var attackerId = IDByImageCountry(attacker)
  3276.  
  3277. // If can't fight, location is not correct
  3278. if( $( "#weaponQuality" ).length == 0 ) {
  3279. travelLeft.insertBefore( pos );
  3280. travelRight.insertBefore( pos );
  3281. setTravelLocation( battleLocation, travelRW, travelLeft, travelRight, attackerId );
  3282. }else{
  3283.  
  3284. var yourSide = pos.find( ".flags-medium" ).attr( "class" ).split(" ")[1];
  3285.  
  3286.  
  3287. }
  3288.  
  3289.  
  3290.  
  3291.  
  3292. bonusMU = 0;
  3293. if( yourSide == attacker ) {
  3294. if( (battleID == muSide) && (yourSide == getValue( "MUSide" )) ) { bonusMU = getValue( "MURank" ); }
  3295.  
  3296.  
  3297.  
  3298. var neighbours = getRegionAPI( battleLocation, currentLocation );
  3299. if(neighbours.indexOf( parseInt(currentLocation) ) != -1){
  3300.  
  3301. numberLocation=20;
  3302.  
  3303. }else{
  3304.  
  3305. numberLocation=0;
  3306. travelRight.insertBefore( pos );
  3307. setTravelLocation( battleLocation, travelRW, travelLeft, travelRight, attackerId );
  3308. }
  3309.  
  3310.  
  3311. var rightBlock = createBlockBonus( numberLocation, bonusMU, 0 );
  3312. rightBlock.attr( "id", "rightBlockBonus" );
  3313. rightBlock.addClass( "rightBonusBlock" );
  3314. //rightBlock.css({ "margin-left" : (pos.width()+7)+"px" });
  3315. rightBlock.insertBefore( pos );
  3316.  
  3317. } else if( yourSide == defender ) {
  3318. if( (battleID == muSide) && (yourSide == getValue( "MUSide" )) ) { bonusMU = getValue( "MURank" ); }
  3319. if( currentLocation == battleLocation ) {
  3320. numberLocation = 20;
  3321.  
  3322. }else{
  3323.  
  3324. numberLocation = 0;
  3325. travelLeft.insertBefore( pos );
  3326. setTravelLocation( battleLocation, travelRW, travelLeft, travelRight, attackerId );
  3327. }
  3328.  
  3329. var leftBlock = createBlockBonus( numberLocation, bonusMU, bonusSD );
  3330. leftBlock.attr( "id", "leftBlockBonus" );
  3331. //leftBlock.css({ "margin-top" : "-10px", "margin-left" : "-23px" });
  3332. leftBlock.insertBefore( pos );
  3333. }
  3334. }
  3335. }
  3336.  
  3337.  
  3338. // Create bonus battle dov
  3339. function createBlockBonus( location, MU, SD ) {
  3340.  
  3341. var block = $( "<div class='bonusBattleBlock'></div>" );
  3342.  
  3343. var bonusLocation = $( "<div class='locationBonus'>"+ location +"%</div>" );
  3344. bonusLocation.attr( "title", "<b>Location bonus</b>" );
  3345. bonusLocation.addClass( (location == 0) ? "redBackground" : "greenBackground" );
  3346. bonusLocation.tooltip({
  3347. tipClass:"smalltooltip",
  3348. position: { my: "center top+4", at: "center bottom" },
  3349. onShow: function() {
  3350. $( ".smalltooltip" ).css({ "text-align" : "center", "width" : "88px", "font-size" : "11px", "padding" : "3px 8px", "margin" : "0px 0px 0px 14px" });
  3351. }
  3352. });
  3353.  
  3354. var bonusMU = $( "<div class='MUBonus'>"+ MU +"%</div>" );
  3355. bonusMU.attr( "title", "<b>Military unit bonus</b>" );
  3356. bonusMU.addClass( (MU == 0) ? "redBackground" : "greenBackground" );
  3357. bonusMU.tooltip({
  3358. tipClass:"smalltooltip",
  3359. position: { my: "center top+4", at: "center bottom" },
  3360. onShow: function() {
  3361. $( ".smalltooltip" ).css({ "text-align" : "center", "width" : "88px", "font-size" : "11px", "padding" : "3px 8px", "margin" : "0px 0px 0px 14px" });
  3362. }
  3363. });
  3364.  
  3365. var bonusSD = $( "<div class='DSBonus' title='<b>Defensive system bonus</b>'>"+ SD +"%</div>" );
  3366. bonusSD.attr( "title", "<b>Defensive system bonus</b>" );
  3367. bonusSD.addClass( (SD == 0) ? "redBackground" : "greenBackground" );
  3368. bonusSD.tooltip({
  3369. tipClass:"smalltooltip",
  3370. position: { my: "center top+4", at: "center bottom" },
  3371. onShow: function() {
  3372. $( ".smalltooltip" ).css({ "text-align" : "center", "width" : "88px", "font-size" : "11px", "padding" : "3px 8px", "margin" : "0px 0px 0px 14px" });
  3373. }
  3374. });
  3375.  
  3376. block.append( bonusLocation );
  3377. block.append( bonusMU );
  3378. block.append( bonusSD );
  3379. return( block );
  3380. }
  3381.  
  3382.  
  3383. // Change weapon battle selector
  3384. function changeWeaponBattle() {
  3385.  
  3386. // First div with selected weapon
  3387. var bigWeapTable="<table id='table1'><tr><td style='width:100%;' id='WepSelect_1' colspan='3'><table><tr><td id='WepSelect_1_1' style='width:30%;'></td><td id='WepSelect_1_2' style='width:70%;'></td></tr></table></td></tr><tr><td id='WepSelect_3' style='width:33%;'></td><td style='width:33%;' id='WepSelect_4'></td><td style='width:33%;' id='WepSelect_5'></td></tr></table><table style='width:100%;' id='table3'><tr><td>Hit type:</td><td>Damage:</td></tr><tr><td id='lastHitType'>-</td><td id='lastdamage'>-</td></tr></table>"
  3388. var bigWeap = $( "<div class='testDivwhite' id='bigWeaponBlock'>"+bigWeapTable+"</div>" );
  3389. var imgWeap = $( "<img id='bigWeaponImg' />" );
  3390.  
  3391. var weapInfo = $( "<div id='weaponsInfo'></div>" );
  3392. weapInfo.append( imgWeap );
  3393. weapInfo.append( "<span id='qualityWeaponInfo'></span>" );
  3394. weapInfo.append( "<span id='availableWeaponInfo'></span>" );
  3395.  
  3396.  
  3397. var dataInfo = $( "<div id='blockInfoDamage'></div>" );
  3398. dataInfo.append( "Fight:<br /><span id='minDamage'></span> / <span id='maxDamage'></span><br/>" );
  3399. dataInfo.append( "Berserk:<br/><span id='bkMinDamage'></span> / <span id='bkMaxDamage'></span>" );
  3400.  
  3401. var equipInfo = $( "<div id='blockEquipInfo'></div>" );
  3402. var lineCritical = $( "<div></div>" );
  3403. var playerCriticalValue = getValue( "playerCritical" ) ? getValue( "playerCritical" ) : 0;
  3404. lineCritical.append( "<span class='percentBattleInfo'>"+ playerCriticalValue +" %</span> " );
  3405. lineCritical.append( "<img src='"+ IMGCRITICAL +"' /><br />" );
  3406. lineCritical.append( "<span id='criticalCounter'>"+getValue("today_crit")+"</span>" );
  3407. //equipInfo.append( lineCritical );
  3408.  
  3409. var lineMiss = $( "<div></div>" );
  3410. var playerMissValue = getValue( "playerMiss" ) ? getValue( "playerMiss" ) : 0;
  3411. lineMiss.append( "<span class='percentBattleInfo'>"+ playerMissValue +" %</span> " );
  3412. lineMiss.append( "<img src='"+ IMGMISS +"' /><br />" );
  3413. lineMiss.append( "<span id='missCounter'>"+getValue("today_miss")+"</span>" );
  3414. //equipInfo.append( lineMiss );
  3415.  
  3416. var lineAvoid = $( "<div></div>" );
  3417. var playerAvoidValue = getValue( "playerAvoid" ) ? getValue( "playerAvoid" ) : 0;
  3418. lineAvoid.append( "<span class='percentBattleInfo'>"+ playerAvoidValue +" %</span> " );
  3419. lineAvoid.append( "<img src='"+ IMGAVOID +"' /><br />" );
  3420. lineAvoid.append( "<span id='avoidCounter'>"+getValue("today_avoid")+"</span>" );
  3421. //equipInfo.append( lineAvoid );
  3422.  
  3423. /*bigWeap.append( imgWeap );
  3424. bigWeap.append( weapInfo );
  3425. bigWeap.append( dataInfo );
  3426. bigWeap.append( equipInfo );*/
  3427.  
  3428. //bigWeap.find("#WepSelect_1").append( imgWeap );
  3429. bigWeap.find("#WepSelect_1_1").append( weapInfo );
  3430. bigWeap.find("#WepSelect_1_2").append( dataInfo );
  3431. bigWeap.find("#WepSelect_3").append( lineCritical );
  3432. bigWeap.find("#WepSelect_4").append( lineAvoid );
  3433. bigWeap.find("#WepSelect_5").append( lineMiss );
  3434.  
  3435.  
  3436.  
  3437. //INFO
  3438. fight_info=$("<img id='fight_info' src='https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/info.png' >")
  3439.  
  3440.  
  3441.  
  3442.  
  3443. fight_info.bind('click', function() {
  3444.  
  3445. $("#table1").slideUp("fast")
  3446. $("#table3").slideUp("fast")
  3447. $("#fight_info").slideUp("fast")
  3448. $("#MUMarketBlock").slideUp("fast")
  3449.  
  3450.  
  3451. $("#bigWeaponBlock").append('<table id="table2" style="width:100%; display: none;"><tbody><tr><td colspan="4">Fight Info</td></tr><tr><td colspan="2">All hit</td><td colspan="2" id="all_hit"></td></tr><tr><td>Type:</td><td>Crit</td><td>Avoid</td><td>Miss</td></tr><tr><td>Hit:</td><td id="crit"></td><td id="avoid"></td><td id="miss"></td></tr><tr><td>Nominal %</td><td id="critN"></td><td id="avoidN"></td><td id="missN"></td></tr><tr><td>Real %</td><td id="critR"></td><td id="avoidR"></td><td id="missR"></td></tr></tbody></table>')
  3452.  
  3453. $('#all_hit').text(getValue("today_all"))
  3454.  
  3455. $("#crit").text(getValue("today_crit"));
  3456. $("#avoid").text(getValue("today_avoid"));
  3457. $("#miss").text(getValue("today_miss"));
  3458.  
  3459. $("#critN").text(playerCriticalValue);
  3460. $("#avoidN").text(playerAvoidValue);
  3461. $("#missN").text(playerMissValue);
  3462.  
  3463. $("#critR").text(((getValue("today_crit")/getValue("today_all"))*100).toFixed(2));
  3464. $("#avoidR").text(((getValue("today_avoid")/getValue("today_all"))*100).toFixed(2));
  3465.  
  3466. if(playerMissValue == 0){
  3467. $("#missR").text("0.00");
  3468. }else{
  3469.  
  3470. $("#missN").text(((getValue("today_miss")/getValue("today_all"))*100).toFixed(2));
  3471. }
  3472.  
  3473. back=$("<img id='fight_back' src='https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/Back.png'>")
  3474.  
  3475. back.bind('click', function() {
  3476.  
  3477. $("#table2").slideUp("fast")
  3478. $("#fight_back").slideUp("fast")
  3479. $("#fight_back").remove();
  3480.  
  3481. $("#table1").slideDown("slow")
  3482. $("#table3").slideDown("slow")
  3483. $("#fight_info").slideDown("slow")
  3484. $("#MUMarketBlock").slideDown("slow")
  3485.  
  3486. });
  3487.  
  3488. $("#bigWeaponBlock").append(back)
  3489. $("#table2").slideDown("slow")
  3490.  
  3491. });
  3492.  
  3493.  
  3494. bigWeap.append( fight_info );
  3495.  
  3496. //Select Hide/Show fight response
  3497.  
  3498. var HideSelectorBlock = $( "<div id='MUMarketBlock'><br /></div>" );
  3499. var configHideResponse = createCheckBox( "Select Hide/Show fight response", "configHideResponse" );
  3500. HideSelectorBlock .append( configHideResponse );
  3501.  
  3502.  
  3503. bigWeap.append( HideSelectorBlock );
  3504.  
  3505.  
  3506. bigWeap.insertBefore( "#weaponQuality" );
  3507.  
  3508.  
  3509.  
  3510.  
  3511. var selectedTheme = getValue( "configWeaponTheme" );
  3512. var defaultWeapon = getValue( "configDefaultWeapon" );
  3513. var index = 0;
  3514. var content = $( "<div id='weaponSelector'></div>" );
  3515. $( "#weaponQuality" ).find( "option" ).each( function() {
  3516.  
  3517. var weapQ = $( "<div class='weaponQualityNewSelector'></div>" );
  3518. if( index == 0 ) {
  3519. if( selectedTheme == "default" ) {
  3520. weapQ.append( "<img class='defaultWeaponQ0' src='"+ IMGWEAPON +"' />" );
  3521. } else weapQ.append( "<img class='"+ selectedTheme +"WeaponQ0' src='"+ eval( selectedTheme+"weaponQ0" ) +"' />" );
  3522. weapQ.addClass( "Q0weaponBox" );
  3523.  
  3524. } else {
  3525. if( selectedTheme == "default" ) {
  3526. weapQ.append( "<img class='defaultWeaponQX' src='"+ IMGWEAPON +"' />" );
  3527. } else weapQ.append( "<img class='"+ selectedTheme +"WeaponQX' src='"+ eval( selectedTheme+"weaponQ"+index ) +"' />" );
  3528. weapQ.addClass( "QXweaponBox" );
  3529. }
  3530.  
  3531. var nWeap = "";
  3532. var str = $(this).text();;
  3533. var pos = str.indexOf( "-50%", 0 );
  3534. if( pos < 0 ) {
  3535. nWeap = str.match(/ [0-9]{1,10}/g);
  3536. weapQ.append( "<div class='QXweaponString'>"+ (index * 20) +"%</div>" );
  3537.  
  3538. } else {
  3539. weapQ.css({ "margin-top" : "0px" });
  3540. weapQ.append( "<div class='Q0weaponString'> -50%<br/> Unarmed </div>" );
  3541. }
  3542.  
  3543. weapQ.attr( "indexselect", index );
  3544. weapQ.attr( "numWeapons", nWeap );
  3545. weapQ.append( "<div class='selectorNumWeapons'>"+ nWeap + "</div>" );
  3546.  
  3547. if( (nWeap == "") || (nWeap > 0) ) {
  3548.  
  3549. /*weapQ.bind( "mouseover", function() {
  3550. if( selectedWeapon.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) {
  3551. $(this).css({ "box-shadow" : "0px 1px 3px 2px #6baef8" });
  3552. }
  3553. });
  3554.  
  3555. weapQ.bind( "mouseout", function() {
  3556. if( selectedWeapon.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) {
  3557. $(this).css({ "box-shadow" : "0px 1px 3px 1px #9bbef8" });
  3558. }
  3559. });*/
  3560.  
  3561. weapQ.bind( "click", function() {
  3562.  
  3563. var quality = parseInt( $(this).attr( "indexselect" ) );
  3564. if( selectedWeapon ) {
  3565. selectedWeapon.removeClass( "selectedWeapon" );
  3566. selectedWeapon.removeClass( "selectedUnarmedWeapon" );
  3567. }
  3568.  
  3569.  
  3570.  
  3571.  
  3572. if( quality == 0 ) {
  3573. $( "#qualityWeaponInfo" ).text( "Unarmed" );
  3574. $( "#availableWeaponInfo" ).text( "" );
  3575. if( selectedTheme == "default" ) {
  3576. $( "#bigWeaponImg" ).attr( "src", IMGWEAPON );
  3577. $( "#bigWeaponImg" ).addClass( "bigWeaponDefault" );
  3578. } else {
  3579. $( "#bigWeaponImg" ).attr( "src", eval( selectedTheme + "weaponQ0Big" ) );
  3580. $( "#bigWeaponImg" ).addClass( "bigWeapon" + selectedTheme );
  3581. }
  3582.  
  3583. } else {
  3584. $( "#qualityWeaponInfo" ).text( "Q" + quality );
  3585. $( "#availableWeaponInfo" ).text( $(this).attr( "numWeapons" ) + " left" );
  3586. if( selectedTheme == "default" ) {
  3587. $( "#bigWeaponImg" ).attr( "src", IMGWEAPON );
  3588. $( "#bigWeaponImg" ).addClass( "bigWeaponDefault" );
  3589. } else {
  3590. $( "#bigWeaponImg" ).attr( "src", eval( selectedTheme + "weaponQ" + quality + "Big" ) );
  3591. $( "#bigWeaponImg" ).addClass( "bigWeapon" + selectedTheme );
  3592. }
  3593.  
  3594. }
  3595.  
  3596. selectedWeapon = $(this);
  3597. selectedWeapon.addClass( (quality == 0) ? "selectedUnarmedWeapon" : "selectedWeapon" );
  3598.  
  3599. $( "#weaponQuality option" ).removeAttr( "selected" );
  3600. $( "#weaponQuality option" )[ quality ].selected = true;
  3601.  
  3602. updateDamage();
  3603. });
  3604.  
  3605. } else weapQ.addClass( "disabledWeapon" );
  3606.  
  3607. // default Q0
  3608. if( (index == 0) || (index == defaultWeapon) ) { weapQ.click(); }
  3609. index++;
  3610. content.append( weapQ );
  3611. });
  3612.  
  3613. content.insertAfter( "#weaponQuality" );
  3614.  
  3615. $( "#weaponQuality" ).parent().children( "b" ).first().remove();
  3616. $( "#weaponQuality" ).parent().children( "br" ).first().remove();
  3617. $( "#weaponQuality" ).parent().children( "br" ).first().remove();
  3618. $( "#weaponQuality" ).css({ "display" : "none" });
  3619.  
  3620. // Add update weapon method, copied from the original method
  3621. $( ".fightButton" ).each( function() {
  3622.  
  3623. var input = $( "<input class='newFightButton' type='submit' />" );
  3624. input.attr( "value", $(this).val() );
  3625. input.attr( "name", $(this).attr( "name" ) );
  3626. input.attr( "style", $(this).attr( "style" ) );
  3627. input.insertBefore( $(this) );
  3628. $(this).hide();
  3629.  
  3630. input.bind( "click", function() {
  3631. var side = $(this)[0].name;
  3632. var value = $(this)[0].value;
  3633. mySendFightRequest(side, value);
  3634.  
  3635.  
  3636. if(getValue("configHideResponse")=="true"){
  3637.  
  3638. //alert(getValue("configHideResponse"))
  3639.  
  3640. $.blockUI({ message: $('#fightStatus'), css: {
  3641. width: '400px',
  3642. top: ($(window).height() - 400) /2 + 'px',
  3643. left: ($(window).width() - 400) /2 + 'px',
  3644. border: '0px',
  3645. background: '#F2F2F2' }
  3646. });
  3647.  
  3648.  
  3649. }else{
  3650.  
  3651. //alert(getValue("configHideResponse"))
  3652. //updateWeaponsNumber();
  3653.  
  3654. }
  3655.  
  3656. return( false );
  3657. });
  3658. });
  3659.  
  3660.  
  3661. }
  3662.  
  3663.  
  3664.  
  3665. // HIDE EXTRA INFOs
  3666. function hideExtraInfo()
  3667. {
  3668.  
  3669. if(getValue("configExtraInfo")=="false")
  3670. {
  3671. alert(getValue("configExtraInfo"))
  3672. $("#table1").hide()
  3673. $("#fight_info").hide()
  3674.  
  3675. }
  3676.  
  3677. }
  3678.  
  3679.  
  3680. function hit_type(type,multip)
  3681. {
  3682.  
  3683. if(type=="crit")
  3684. {
  3685.  
  3686. sv = getValue("today_crit")
  3687. setValue("today_crit",Number(sv)+Number(multip))
  3688.  
  3689. $("#criticalCounter").text(getValue("today_crit"))
  3690.  
  3691. sv = getValue("today_all")
  3692. setValue("today_all",Number(sv)+Number(multip))
  3693.  
  3694.  
  3695. $("#lastHitType").html('<span style="font-family:Arial;font-size:18px;font-style:normal;font-weight:bold;text-decoration:none;text-transform:none;font-variant:small-caps;color:00FF00;">Critical!!!</span>')
  3696.  
  3697. }
  3698.  
  3699. if(type=="miss")
  3700. {
  3701.  
  3702. sv = getValue("today_miss")
  3703. setValue("today_miss",Number(sv)+Number(multip))
  3704.  
  3705. $("#missCounter").text(getValue("today_miss"))
  3706.  
  3707. sv = getValue("today_all")
  3708. setValue("today_all",Number(sv)+Number(multip))
  3709.  
  3710. $("#lastHitType").html('<span style="font-family:Arial;font-size:18px;font-style:normal;font-weight:bold;text-decoration:none;text-transform:none;font-variant:small-caps;color:FF0000;">Miss!!!</span>')
  3711.  
  3712.  
  3713.  
  3714.  
  3715. }
  3716.  
  3717. if(type=="avoid")
  3718. {
  3719.  
  3720. sv = getValue("today_avoid")
  3721. setValue("today_avoid",Number(sv)+Number(multip))
  3722.  
  3723. $("#avoidCounter").text(getValue("today_avoid"))
  3724.  
  3725. sv = getValue("today_all")
  3726. setValue("today_all",Number(sv)+Number(multip))
  3727.  
  3728. $("#lastHitType").html('<span style="font-family:Arial;font-size:18px;font-style:normal;font-weight:bold;text-decoration:none;text-transform:none;font-variant:small-caps;color:00FF00;">Avoid!!!</span>')
  3729. $("#lastHitType").effect( "shake" )
  3730.  
  3731. }
  3732.  
  3733. if(type=="normal")
  3734. {
  3735.  
  3736. sv = getValue("today_all")
  3737. setValue("today_all",Number(sv)+Number(multip))
  3738.  
  3739. //$("#avoidCounter").text(getValue("today_avoid"))
  3740.  
  3741. $("#lastHitType").html('<span style="font-family:Arial;font-size:18px;font-style:normal;font-weight:bold;text-decoration:none;text-transform:none;font-variant:small-caps;color:000000;">Normal...</span>')
  3742.  
  3743. }
  3744.  
  3745.  
  3746. }
  3747.  
  3748. // sendFightRequest from the original page copied and improved
  3749. function mySendFightRequest(side, val) {
  3750. var dataString = 'weaponQuality='+ $("#weaponQuality").val() + '&battleRoundId=' + $("#battleRoundId").val() + '&side='+side+'&value='+val;
  3751. $.ajax({
  3752. type: "POST",
  3753. url: "fight.html",
  3754. data: dataString,
  3755. success: function( msg ) {
  3756.  
  3757.  
  3758.  
  3759. $( "#fightResponse > div" ).replaceWith( msg );
  3760.  
  3761. $( "#fightResponse > div" ).append("<br /><br /><button id='unblockButton' type='submit' class='button foundation-style'>Ok</button><br /><br />")
  3762.  
  3763. //alert(msg)
  3764.  
  3765. // CHECK HIT TYPE
  3766.  
  3767. multip=$(msg).find("#xpGain").text();
  3768.  
  3769. if(multip!=""){
  3770.  
  3771. pattcrit=/Critical hit!/;
  3772. var crit= pattcrit.test(msg);
  3773.  
  3774. pattmiss = /Miss!/
  3775. var miss= pattmiss.test(msg);
  3776.  
  3777. pattavoid=/absorbed/;
  3778. var avoid= pattavoid.test(msg);
  3779.  
  3780.  
  3781. pattnormal=/Normal hit/;
  3782. var normal= pattnormal.test(msg);
  3783.  
  3784.  
  3785. if(normal) hit_type("normal",multip);
  3786. if(crit) hit_type("crit",multip);
  3787. if(miss) hit_type("miss",multip);
  3788. if(avoid) hit_type("avoid",multip);
  3789.  
  3790.  
  3791. //AVOID AND CRIT
  3792.  
  3793. if(avoid && crit){
  3794.  
  3795. $("#lastHitType").html('<span style="font-family:Arial;font-size:18px;font-style:normal;font-weight:bold;text-decoration:blink;text-transform:none;color:00FF00;">AVOID/CRITICAL</span>');
  3796. $("#lastHitType").effect( "shake" )
  3797. }
  3798.  
  3799.  
  3800. //REFRESH LAST DMG
  3801.  
  3802. $("#lastdamage").text(commaNumber($("#DamageDone").text()));
  3803.  
  3804.  
  3805. // Check HIT TYPE
  3806.  
  3807.  
  3808. var healthText = $( "#healthUpdate" ).text();
  3809. if( healthText != "" ) {
  3810. var healthUpdated = healthText.substr( 0, healthText.length-3 );
  3811. if( healthUpdated < 100 ) {
  3812. $( "#healthProgress div.ui-corner-right" ).removeClass( 'ui-corner-right' );
  3813. }
  3814. $( "#healthProgress .ui-progressbar-value" ).animate({ width: healthUpdated + "%" },{ queue: false });
  3815. $( "#healthProgress" ).attr( 'title',healthUpdated+' / 100' );
  3816.  
  3817. $("#actualHealth").text(healthUpdated);
  3818. }
  3819. var rank = parseInt( $("#rankUpdate").text() );
  3820. var rankNext = parseInt( $("#nextLevelRankUpdate").text() );
  3821. var rankCurr = parseInt( $("#currLevelRankUpdate").text() );
  3822. if(rank != null) {
  3823. var rankWidth = Math.round((rank - rankCurr) / (rankNext - rankCurr) * 100);
  3824. $( "#rankProgress .ui-progressbar-value" ).animate({ width: rankWidth + "%" },{ queue: false });
  3825. $( "#rankProgress" ).attr( 'title',rank+' / '+rankNext );
  3826.  
  3827. $("#actualRank").text(rank);
  3828.  
  3829. }
  3830. var xp = parseInt($("#xpUpdate").text());
  3831. var xpNext = parseInt($("#nextLevelXpUpdate").text());
  3832. var xpCurr = parseInt($("#currLevelXpUpdate").text());
  3833. if(xp != null) {
  3834. var xpWidth = Math.round((xp - xpCurr) / (xpNext - xpCurr) * 100);
  3835. $("#xpProgress .ui-progressbar-value").animate({width: xpWidth + "%"},{queue: false});
  3836. $("#xpProgress").attr('title',xp+' / '+xpNext);
  3837.  
  3838. $("#actualXp").text(xp);
  3839. }
  3840. var rankText = $( "#currRankText" ).text();
  3841. var currRankText = $( "#rankText" ).text();
  3842. if( rankText != null && currRankText != null ) {
  3843. if( rankText != currRankText ) {
  3844. $( "#currRankText" ).text( currRankText );
  3845. $( "#rankImage img" ).attr( 'src', $( "#rankImg" ).text() );
  3846. }
  3847. }
  3848.  
  3849.  
  3850. //Refix xp and rank
  3851. configSomeFix();
  3852.  
  3853. }
  3854.  
  3855. $( "#unblockButton" ).bind( "click", function() {
  3856. //alert("haha")
  3857. $.unblockUI();
  3858.  
  3859.  
  3860. });
  3861.  
  3862. updateWeaponsNumber();
  3863. updateHealthButtons();
  3864.  
  3865.  
  3866. }
  3867. });
  3868. }
  3869.  
  3870.  
  3871. // Update damage
  3872. function updateDamage() {
  3873.  
  3874. var minDamage = getValue( "playerMinDamage" );
  3875. var maxDamage = getValue( "playerMaxDamage" );
  3876.  
  3877. var weaponBonus = parseInt( $( "#weaponQuality" ).val() );
  3878. weaponBonus = (weaponBonus == 0) ? 0.5 : (weaponBonus*20 + 100)/100;
  3879.  
  3880. $( "#minDamage" ).text( pointNumber( parseInt(minDamage * weaponBonus) ) );
  3881. $( "#maxDamage" ).text( pointNumber( parseInt(maxDamage * weaponBonus) ) );
  3882.  
  3883. $( "#bkMinDamage" ).text( pointNumber( parseInt(5*minDamage * weaponBonus) ) );
  3884. $( "#bkMaxDamage" ).text( pointNumber( parseInt(5*maxDamage * weaponBonus) ) );
  3885. /*var damage = strength * rank * (quality*20 + 100)/100;
  3886. if( quality == 0 ) { damage = strength * rank / 2; }
  3887.  
  3888. var pos;
  3889. var strDmg = "";
  3890. var strBk = "";
  3891. var strTotal = "";
  3892. var mubonus = 0;
  3893. var locbonus = 0;
  3894. var sdbonus = 0;
  3895.  
  3896. var foodLimit = parseInt( $( "#foodLimit" ).text() );
  3897. var giftLimit = parseInt( $( "#giftLimit" ).text() );
  3898. var health = parseInt( $( "#healthBar" ).text() );
  3899. var nHits = health/10 + 5 * foodLimit + 5 * giftLimit;
  3900.  
  3901. var divBattleLocation = $( ".testDivwhite" ).find( "a[href^='region']" );
  3902. var isRW = (divBattleLocation.parent().text().indexOf( "Resistance war", 0 ) > -1);
  3903.  
  3904. if( $( "#leftBlockBonus" ).length == 1 ) {
  3905. pos = $( "#leftBlockBonus" ).children( "div" );
  3906. mubonus = parseInt( pos.eq(0).text().replace( "%", "" ) );
  3907. locbonus = parseInt( pos.eq(1).text().replace( "%", "" ) );
  3908. sdbonus = parseInt( pos.eq(2).text().replace( "%", "" ) );
  3909.  
  3910. // Order, MU - location - SD
  3911. damage *= (mubonus+100)/100;
  3912. damage *= (locbonus+100)/100;
  3913. damage *= (sdbonus+100)/100;
  3914. strDmg += pointNumber( parseInt( damage ) );
  3915. strBk += pointNumber( parseInt( damage * 5 ) );
  3916. strTotal += pointNumber( parseInt( damage * nHits ) );
  3917. }
  3918.  
  3919. damage = strength * rank * (quality*20 + 100)/100;
  3920. if( quality == 0 ) { damage = strength * rank / 2; }
  3921. if( $( "#rightBlockBonus" ).length == 1 ) {
  3922. pos = $( "#rightBlockBonus" ).children( "div" );
  3923. mubonus = parseInt( pos.eq(0).text().replace( "%", "" ) );
  3924. locbonus = parseInt( pos.eq(1).text().replace( "%", "" ) );
  3925. sdbonus = parseInt( pos.eq(2).text().replace( "%", "" ) );
  3926.  
  3927. // Order, MU - location - SD
  3928. damage *= (mubonus+100)/100;
  3929. damage *= (locbonus+100)/100;
  3930. damage *= (sdbonus+100)/100;
  3931. strDmg = isRW ? strDmg + "&nbsp;&nbsp;|&nbsp;&nbsp;" : strDmg;
  3932. strBk = isRW ? strBk + "&nbsp;&nbsp;|&nbsp;&nbsp;" : strBk;
  3933. strTotal = isRW ? strTotal + "&nbsp;&nbsp;|&nbsp;&nbsp;" : strTotal;
  3934. strDmg += pointNumber( parseInt( damage ) );
  3935. strBk += pointNumber( parseInt( damage*5 ) );
  3936. strTotal += pointNumber( parseInt( damage * nHits ) );
  3937. }
  3938.  
  3939. $( "#dmgCurrent" ).html( "Fight: <b style='font-family:Verdana; font-size:9px;'>"+ strDmg +"</b>" );
  3940. $( "#berserkCurrent" ).html( "Berserk: <b style='font-family:Verdana; font-size:9px;'>"+ strBk +"</b>" );
  3941. $( "#totalDamage" ).html( "Max: <b style='font-family:Verdana; font-size:9px;'>"+ strTotal +"</b>" );*/
  3942. }
  3943.  
  3944.  
  3945. // To add . on numbers
  3946. function pointNumber( n ){
  3947. n = n + "";
  3948. var i = n.length-3;
  3949. while( i > 0 ){ n = n.substring( 0, i )+ "." + n.substring( i, n.length ); i=i-3; }
  3950. return( n );
  3951. }
  3952.  
  3953. // To add , on numbers
  3954. function commaNumber( n ){
  3955. n = n + "";
  3956. var i = n.length-3;
  3957. while( i > 0 ){ n = n.substring( 0, i )+ "," + n.substring( i, n.length ); i=i-3; }
  3958. return( n );
  3959. }
  3960.  
  3961.  
  3962. // Updater number weapons value
  3963. function updateWeaponsNumber() {
  3964. var index = 0;
  3965. $( "#weaponQuality" ).find( "option" ).each( function() {
  3966.  
  3967. var str = $(this).text();
  3968. //alert(str);
  3969. var pos = str.indexOf( "+", 0 );
  3970. if( pos > -1 ) {
  3971. //nWeap = str.substr( pos + 10, str.indexOf( ")", pos ) - pos - 10 );
  3972. nWeap = str.match(/\d{1,20}\)/)[0];
  3973. nWeap = nWeap.slice(0, nWeap.length-1);
  3974. //alert(nWeap);
  3975. $( "#weaponSelector" ).children( "div:eq("+ index +")" ).find( ".selectorNumWeapons" ).text( nWeap );
  3976. $( "#availableWeaponsInfo" ).text( nWeap + "left" );
  3977.  
  3978. if( selectedWeapon.attr( "indexselect" ) == index ) {
  3979. if( nWeap == 0 ) {
  3980. selectedWeapon.unbind( "click" );
  3981. selectedWeapon.unbind( "mouseover" );
  3982. selectedWeapon.unbind( "mouseout" );
  3983. selectedWeapon.addClass( "disabledWeapon" );
  3984. $( "#weaponSelector" ).children( "div" ).eq( 0 ).click();
  3985. }
  3986. }
  3987. }
  3988.  
  3989. index++;
  3990. });
  3991. }
  3992.  
  3993.  
  3994. // Change round selector
  3995. function changeRoundSelector() {
  3996.  
  3997. var block = $( "#command" ).parent();
  3998. block.children().last().remove();
  3999. block.children().last().remove();
  4000. block.children( "br" ).last().remove();
  4001. for( var i=0; i<block.contents().length; i++ ) {
  4002. var item = block.contents().eq(i);
  4003. if( item.text().indexOf( "Show round:" ) >= 0 ) { item.remove(); }
  4004. }
  4005.  
  4006. // Replace any link
  4007. var currentRound = getUrlVars()[ "round" ];
  4008. $( "#command" ).children( "select" ).find( "option" ).each( function() {
  4009. var value = $(this).attr( "value" );
  4010. var battleID = getUrlVars()[ "id" ];
  4011. var url = getCurrentServer() + URLBattle + battleID + "&round=" + value;
  4012. var roundLink = $( "<a style='padding:2px' class='roundSelector' href='"+ url +"' >"+ value + "</a>" );
  4013. if( currentRound ) {
  4014. if( currentRound == value ) {
  4015. roundLink.css({ "color" : "#d14d4d", "font-size" : "15px" });
  4016. }
  4017. }
  4018.  
  4019. // Remove repeated
  4020. block.children( "a" ).each( function() { if( $(this).text() == value ) { $(this).remove(); } });
  4021. block.append( roundLink );
  4022. });
  4023.  
  4024. if( currentRound == undefined ) { block.children( "a" ).last().css({ "color" : "#d14d4d", "font-size" : "15px" }); }
  4025. $( "#command" ).css({ "display" : "none" });
  4026. }
  4027.  
  4028.  
  4029. // Improve MU main page
  4030. function changeMUMainMenu() {
  4031.  
  4032. /*var listBlue = $( "#container" ).find( ".testDivblue" );
  4033. $( "#container" ).find( ".citizenAction" ).css({ "margin-top" : "-7px" });
  4034. listBlue.eq(2).children( "br" ).remove();
  4035. listBlue.eq(2).children( "p" ).remove();
  4036.  
  4037. var descripDiv = $( "#container" ).find( ".testDivblue" ).eq(4);
  4038. var membersDiv = $( "#container" ).find( ".testDivblue" ).eq(3);
  4039. var ordersDiv = $( "#container" ).find( ".testDivblue" ).eq(5);
  4040.  
  4041. ordersDiv.css({ "margin-top" : "0px" });
  4042. ordersDiv.children( "br" ).first().remove();
  4043. descripDiv.css({ "margin-top" : "15px" });
  4044.  
  4045. var leftDiv = $( "<div style='float:left; width:340px; height:100%'></div>" );
  4046. leftDiv.append( ordersDiv );
  4047. leftDiv.append( descripDiv );
  4048.  
  4049. leftDiv.insertBefore( membersDiv );*/
  4050.  
  4051.  
  4052. desc = $("#militaryDescription").html()
  4053. desc_cent = '<center><b style="font-size:17px">Description</b></center><br /><br />'
  4054.  
  4055.  
  4056. order_cent = '<center><b style="font-size:17px">Current orders</b></center><br /><br /><b>Battle:</b>'
  4057. order =$("#militaryDescription").parent().children("div").eq(1).html()
  4058.  
  4059.  
  4060. $(".testDivblue").eq(4).html(order_cent+order+'<hr class="dashedLine">'+desc_cent+desc)
  4061.  
  4062.  
  4063. // Get MU Rank
  4064. getMURank();
  4065. }
  4066.  
  4067.  
  4068. // Get MU rank
  4069. function getMURank() {
  4070.  
  4071. var listBlue = $( "#container" ).find( ".testDivblue" );
  4072. var MURank = listBlue.eq(2).find( ".statsLabelRight" ).eq(1).text().toLowerCase();
  4073. if( MURank == "novice" ) { setValue( "MURank", "5" );
  4074. } else if( MURank == "regular" ) { setValue( "MURank", "10" );
  4075. } else if( MURank == "veteran" ) { setValue( "MURank", "15" );
  4076. } else if( MURank == "elite" ) { setValue( "MURank", "20" ); }
  4077. }
  4078.  
  4079.  
  4080. // Remove first block on MU storage and MU money
  4081. function removeFirstBlock() {
  4082.  
  4083. $( "#contentRow" ).find( ".citizenAction" ).css({ "margin-top" : "-7px" });
  4084. $( "#contentRow" ).find( ".testDivblue" ).eq(1).next().remove();
  4085. var firstBlock = $( "#contentRow" ).find( ".testDivblue" ).eq(2);
  4086. firstBlock.next().remove();
  4087. firstBlock.remove();
  4088. }
  4089.  
  4090.  
  4091. // Order MU member
  4092. function orderMU( idForm, varCheck ) {
  4093.  
  4094. var divPlayers = $( idForm ).children( "div" ).addClass( "divListPlayers" );
  4095.  
  4096. // Save data to order it
  4097. var list = divPlayers.children();
  4098. var tickAll = list[0];
  4099. var playerList = [];
  4100. var names = [];
  4101. var player;
  4102.  
  4103. // Ignore beginning BR
  4104. for( var i=2; i<list.length; i++ ) {
  4105.  
  4106. player = [];
  4107. player[0] = list[i++];
  4108. player[1] = list[i++];
  4109. player[2] = list[i++];
  4110. player[3] = list[i++];
  4111. // Ignore BR
  4112.  
  4113. names.push( player[3].textContent.toLowerCase() );
  4114. playerList.push( player );
  4115. }
  4116.  
  4117. // Remove all children
  4118. divPlayers.children().remove();
  4119. divPlayers.text( "" );
  4120.  
  4121. // Add tickAll button
  4122. $( tickAll ).bind( "click", function() {
  4123. $( ".receipments" ).attr( "checked", "checked" );
  4124. saveCheckedPlayers();
  4125. return false;
  4126. });
  4127. divPlayers.append( tickAll );
  4128.  
  4129. // Add untickAll button
  4130. var untickAll = $( "<input type='submit' id='untickAll' value='Untick all' />" );
  4131. untickAll.bind( "click", function() {
  4132. $( ".receipments" ).removeAttr( "checked" );
  4133. setValue( "lastSelectionMUStorage", "" );
  4134. return false;
  4135. });
  4136. divPlayers.append( untickAll );
  4137.  
  4138. // Add other submit button
  4139. divPlayers.append( "<input id='donateBtn2' type='submit' value='Donate' />" );
  4140. divPlayers.append( "<br/>" );
  4141.  
  4142. // Order array by name
  4143. names.sort();
  4144.  
  4145. // Add ordered members
  4146. var tr, td;
  4147. var table = $( "<table class='playerTable'></table>" );
  4148. divPlayers.append( table );
  4149. for( i=0; i<names.length; i++ ) {
  4150.  
  4151. for( var j=0; j<playerList.length; j++ ) {
  4152.  
  4153. if( names[i] == playerList[j][3].textContent.toLowerCase() ) {
  4154.  
  4155. tr = $( "<tr></tr>" );
  4156. tr.append( $( "<td class='checkPlayer'></td>" ).append( playerList[j][0] ) );
  4157. tr.append( $( "<td class='flagPlayer'></td>" ).append( playerList[j][1] ) );
  4158. tr.append( "<td class='noSkill'></td>" );
  4159. tr.append( $( "<td class='avatarPlayer'></td>" ).append( playerList[j][2] ) );
  4160. tr.append( $( "<td class='namePlayer'></td>" ).append( playerList[j][3] ) );
  4161. tr.append( "<td class='companyName'></td>" );
  4162. tr.append( "<td class='day6'></td>" );
  4163. tr.append( "<td class='day5'></td>" );
  4164. tr.append( "<td class='day4'></td>" );
  4165. tr.append( "<td class='day3'></td>" );
  4166. tr.append( "<td class='day2'></td>" );
  4167. tr.append( "<td class='day1'></td>" );
  4168. tr.append( "<td class='day0'></td>" );
  4169. tr.append( "<td></td>" );
  4170. table.append( tr );
  4171.  
  4172. tr.children( ".namePlayer" ).children( "a" ).attr( "name", playerList[j][3].textContent );
  4173.  
  4174. // Resize player name
  4175. var name = tr.children( ".namePlayer" );
  4176. while( name.height() > (parseInt( name.css( "line-height" ).replace( "px", "" ) ) + 1) ) {
  4177. var str = name.children( "a" ).text().replace( "...", "" );
  4178. name.children( "a" ).text( str.slice( 0, -1 ) + "..." );
  4179. }
  4180. }
  4181. }
  4182. }
  4183.  
  4184.  
  4185. // Check for URL vars
  4186. if( varCheck ) {
  4187. setValue( "lastSelectionMUStorage", varCheck );
  4188. $( ".playerTable" ).find( ".receipments" ).each( function() {
  4189. if( varCheck.length > 0 ) {
  4190. if( varCheck[0] == "1" ) { $(this).attr( "checked", "checked" ); }
  4191. varCheck = varCheck.substr( 1, varCheck.length-1 );
  4192. }
  4193. });
  4194. }
  4195.  
  4196. // Set Checked players
  4197. $( ".playerTable" ).find( ".receipments" ).bind( "change", function() { saveCheckedPlayers(); });
  4198. }
  4199.  
  4200. // Set value of checked people on MU storage
  4201. function saveCheckedPlayers() {
  4202. var check = "";
  4203. $( ".playerTable" ).find( ".receipments" ).each( function() {
  4204. check += ($(this).attr( "checked" )) ? "1" : "0";
  4205. });
  4206. setValue( "lastSelectionMUStorage", check );
  4207. }
  4208.  
  4209.  
  4210. // Add donate me button
  4211. function addDonateToMeButton( idForm ) {
  4212.  
  4213. // Donate me button
  4214. var pos = $( idForm ).children( "center" );
  4215. var donateMe = $( "<input type='submit' id='donateMe' value='Donate me' />" );
  4216. pos.append( donateMe );
  4217.  
  4218. var id;
  4219. var link = $( "#userName" ).attr( "href" );
  4220. var split = link.split( "?id=" );
  4221. if( split.length > 1 ) {
  4222. id = split[1];
  4223. donateMe.bind( "click", function() {
  4224. $( ".receipments" ).removeAttr( "checked" );
  4225. $( ".receipments[value='"+ id +"']" ).attr( "checked", "checked" );
  4226. });
  4227. }
  4228. }
  4229.  
  4230.  
  4231. // Update MU storage donation
  4232. function changeSelectMUStorage( idForm ) {
  4233.  
  4234. var select = $( "#product" );
  4235. var pos = $( ".testDivwhite" );
  4236. var dest = $( "#quantity" );
  4237.  
  4238. // Remove all childrens and add help text
  4239. pos.children().remove();
  4240. pos.addClass( "storageSelectMU" );
  4241. pos.append( "One click to select <b>ONE item</b>.<br/>Double click to select <b>ALL items</b>.<br/>" );
  4242.  
  4243. pos.css({"width":"200px"})
  4244.  
  4245. select.prev().remove();
  4246. //select.css({ "display" : "none" });
  4247.  
  4248. orderSelect( select );
  4249. changeSelect( select, pos, dest, "#aaaaaa" );
  4250. }
  4251.  
  4252.  
  4253.  
  4254. // Change select from params
  4255. function changeSelect( select, placeToAdd, dest, color ) {
  4256.  
  4257. // Add my items
  4258. var selectDonate;
  4259. var index = 1;
  4260. select.find( "option" ).each( function() {
  4261. if( $(this).attr( "value" ) == "" ) { return; }
  4262.  
  4263. var str = $(this).text();
  4264. //alert(str)
  4265. var number = str.indexOf( "(", 0 );
  4266. if( number != -1 ) {
  4267. str = str.substr( number + 1, str.indexOf( ")", number ) - number - 1 );
  4268. mypatttofindnum=/\d{1,45}/g;
  4269. //alert(str)
  4270. str = mypatttofindnum.exec(str);
  4271.  
  4272. }
  4273.  
  4274. var product = $( "<div class='storage productMU'>" );
  4275. product.append( "<div>"+ str +"</div>" );
  4276. var image = $( "<div></div>" )
  4277. product.append( image );
  4278.  
  4279. var storageMU = $( "<div class='storageButton' selectIndex='"+ index +"'></div>" );
  4280. //storageMU.css({ "box-shadow" : "0px 1px 5px 1px " + color });
  4281. storageMU.append( product );
  4282.  
  4283. // Raw resource
  4284. var split = $(this).attr( "value" ).split( "-" );
  4285. if( split.length == 1 ) {
  4286.  
  4287. if( split[0] == "IRON" ) {
  4288. image.append( "<img src='"+ IMGIRON +"' />" );
  4289.  
  4290. } else if( split[0] == "OIL" ) {
  4291. image.append( "<img src='"+ IMGOIL +"' />" );
  4292.  
  4293. } else if( split[0] == "GRAIN" ) {
  4294. image.append( "<img src='"+ IMGGRAIN +"' />" );
  4295.  
  4296. } else if( split[0] == "DIAMONDS" ) {
  4297. image.append( "<img src='"+ IMGDIAMONDS +"' />" );
  4298.  
  4299. } else if( split[0] == "WOOD" ) {
  4300. image.append( "<img src='"+ IMGWOOD +"' />" );
  4301.  
  4302. } else if( split[0] == "STONE" ) {
  4303. image.append( "<img src='"+ IMGSTONE +"' />" );
  4304. }
  4305.  
  4306. product.css({ "height" : "67px" });
  4307. storageMU.css({ "margin" : "10px 4px 8px 10px" });
  4308.  
  4309. } else if( split.length = 2 ) {
  4310.  
  4311. if( split[1] == "WEAPON" ) {
  4312. image.append( "<img src='"+ IMGWEAPON +"' />" );
  4313.  
  4314. } else if( split[1] == "FOOD" ) {
  4315. image.append( "<img src='"+ IMGFOOD +"' />" );
  4316.  
  4317. } else if( split[1] == "TICKET" ) {
  4318. image.append( "<img src='"+ IMGTICKET +"' />" );
  4319.  
  4320. } else if( split[1] == "GIFT" ) {
  4321. image.append( "<img src='"+ IMGGIFT +"' />" );
  4322.  
  4323. } else if( split[1] == "HOUSE" ) {
  4324. image.append( "<img src='"+ IMGHOUSE +"' />" );
  4325.  
  4326. } else if( split[1] == "DEFENSE_SYSTEM" ) {
  4327. image.append( "<img src='"+ IMGDS +"' />" );
  4328.  
  4329. } else if( split[1] == "HOSPITAL" ) {
  4330. image.append( "<img src='"+ IMGHOSPITAL +"' />" );
  4331.  
  4332. } else if( split[1] == "ESTATE" ) {
  4333. image.append( "<img src='"+ IMGESTATE +"' />" );
  4334. }
  4335.  
  4336. image.append( "<img class='qualityMU' src='"+ IMGQUALITY + split[0] + IMGEXTENSION +"' />" );
  4337. product.css({ "height" : "77px" });
  4338. storageMU.css({ "margin" : "6px 4px 2px 10px" });
  4339. }
  4340.  
  4341. // Events
  4342. storageMU.bind( "mouseover", function() {
  4343. if( selectDonate != $(this).attr( "selectIndex" ) ) { $(this).addClass( "storageButtonHover" ); }
  4344. });
  4345. storageMU.bind( "mouseout", function() {
  4346. if( selectDonate != $(this).attr( "selectIndex" ) ) { $(this).removeClass( "storageButtonHover" ); }
  4347. });
  4348.  
  4349. // Click
  4350. storageMU.bind( "click", function() {
  4351.  
  4352. // Deselect current selection
  4353. if( selectDonate == $(this).attr( "selectIndex" ) ) {
  4354.  
  4355. $(this).removeClass( "storageButtonClick" );
  4356. $(this).removeClass( "storageButtonDblClick" );
  4357. select.find( "option" ).removeAttr( "selected" );
  4358. selectDonate = null;
  4359. dest.val( "1" );
  4360.  
  4361. } else {
  4362.  
  4363. // Deselect last item
  4364. if( selectDonate ) {
  4365. var selectedItem = placeToAdd.find( ".storageButton[selectIndex='" + selectDonate + "']" );
  4366. selectedItem.removeClass( "storageButtonClick" );
  4367. selectedItem.removeClass( "storageButtonDblClick" );
  4368. dest.val( "1" );
  4369. }
  4370.  
  4371. $(this).removeClass( "storageButtonHover" );
  4372. $(this).removeClass( "storageButtonDblClick" );
  4373. $(this).addClass( "storageButtonClick" );
  4374. selectDonate = $(this).attr( "selectIndex" );
  4375.  
  4376. select.find( "option" ).removeAttr( "selected" );
  4377. select.find( "option" )[ selectDonate ].selected = true;
  4378. }
  4379. });
  4380.  
  4381. // Doubleclick
  4382. storageMU.bind( "dblclick", function() {
  4383.  
  4384. $(this).removeClass( "storageButtonHover" );
  4385. $(this).removeClass( "storageButtonClick" );
  4386. $(this).addClass( "storageButtonDblClick" );
  4387. selectDonate = $(this).attr( "selectIndex" );
  4388.  
  4389. select.find( "option" ).removeAttr( "selected" );
  4390. select.find( "option" )[ selectDonate ].selected = true;
  4391.  
  4392. dest.val( $(this).text().trim() );
  4393. return( false );
  4394. });
  4395.  
  4396. placeToAdd.append( storageMU );
  4397. index++;
  4398. });
  4399. }
  4400.  
  4401.  
  4402. // Reorder select items
  4403. function orderSelect( select ) {
  4404.  
  4405. var listOptions = [];
  4406. select.find( "option" ).each( function() {
  4407. listOptions.push( $(this) );
  4408. $(this).remove();
  4409. });
  4410.  
  4411. // Order is... Weapons, Food, Gifts, Tickets, Raw and rest
  4412. var newOptionList = new Array(46);
  4413. newOptionList[0] = listOptions[0];
  4414. var rawIndex = 0;
  4415. var otherIndex = 0;
  4416. for( var i=1; i<listOptions.length; i++ ) {
  4417. var item = listOptions[i].attr( "value" ).split( "-" );
  4418. if( item.length == 2 ) {
  4419. var q = parseInt( item[0] ) - 1;
  4420. if( item[1] == "WEAPON" ) { // Index 0 + quality
  4421. newOptionList[ 1 + q ] = listOptions[i];
  4422.  
  4423. } else if( item[1] == "FOOD" ) { // Index 5 + quality
  4424. newOptionList[ 6 + q ] = listOptions[i];
  4425.  
  4426. } else if( item[1] == "GIFT" ) { // Index 10 + quality
  4427. newOptionList[ 11 + q ] = listOptions[i];
  4428.  
  4429. } else if( item[1] == "TICKET" ) { // Index 15 + quality
  4430. newOptionList[ 16 + q ] = listOptions[i];
  4431.  
  4432. } else {
  4433. newOptionList[ 27 + otherIndex ] = listOptions[i];
  4434. otherIndex++;
  4435. }
  4436. } else {
  4437. newOptionList[ 21 + rawIndex ] = listOptions[i];
  4438. rawIndex++;
  4439. }
  4440. }
  4441.  
  4442. // Add ordered items
  4443. for( var i=0; i<newOptionList.length; i++ ) {
  4444. if( newOptionList[i] ) { select.append( newOptionList[i] ); }
  4445. }
  4446.  
  4447. select.find( "option" )[ 0 ].selected = true;
  4448. }
  4449.  
  4450.  
  4451. // Add fast buttons
  4452. function addMUFastButtons( idDest ) {
  4453.  
  4454. var firstFastButton = true;
  4455. $( idDest ).css({ "text-align" : "center" });
  4456.  
  4457. var btn1 = $( "<input class='fastBtn MUfastButtonLeft' type='button' value='1' />" );
  4458. btn1.bind( "click", function() {
  4459. if( firstFastButton ) {
  4460. $( idDest ).attr( "value", "1" );
  4461. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 1 );
  4462. firstFastButton = false;
  4463. });
  4464.  
  4465. var btn5 = $( "<input class='fastBtn MUfastButtonLeft' type='button' value='5' />" );
  4466. btn5.bind( "click", function() {
  4467. if( firstFastButton ) {
  4468. $( idDest ).attr( "value", "5" );
  4469. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 5 );
  4470. firstFastButton = false;
  4471. });
  4472.  
  4473. var btn10 = $( "<input class='fastBtn MUfastButtonLeft' type='button' value='10' />" );
  4474. btn10.bind( "click", function() {
  4475. if( firstFastButton ) {
  4476. $( idDest ).attr( "value", "10" );
  4477. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 10 );
  4478. firstFastButton = false;
  4479. });
  4480.  
  4481. var btn15 = $( "<input class='fastBtn MUfastButtonRight' type='button' value='15' />" );
  4482. btn15.bind( "click", function() {
  4483. if( firstFastButton ) {
  4484. $( idDest ).attr( "value", "15" );
  4485. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 15 );
  4486. firstFastButton = false;
  4487. });
  4488.  
  4489. var btn25 = $( "<input class='fastBtn MUfastButtonRight' type='button' value='25' />" );
  4490. btn25.bind( "click", function() {
  4491. if( firstFastButton ) {
  4492. $( idDest ).attr( "value", "25" );
  4493. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 25 );
  4494. firstFastButton = false;
  4495. });
  4496.  
  4497. var btn50 = $( "<input class='fastBtn MUfastButtonRight' type='button' value='50' />" );
  4498. btn50.bind( "click", function() {
  4499. if( firstFastButton ) {
  4500. $( idDest ).attr( "value", "50" );
  4501. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 50 );
  4502. firstFastButton = false;
  4503. });
  4504.  
  4505. var btn75 = $( "<input class='fastBtn MUfastButton2' type='button' value='75' />" );
  4506. btn75.bind( "click", function() {
  4507. if( firstFastButton ) {
  4508. $( idDest ).attr( "value", "75" );
  4509. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 75 );
  4510. firstFastButton = false;
  4511. });
  4512.  
  4513. var btn100 = $( "<input class='fastBtn MUfastButton2' type='button' value='100' />" );
  4514. btn100.bind( "click", function() {
  4515. if( firstFastButton ) {
  4516. $( idDest ).attr( "value", "100" );
  4517. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 100 );
  4518. firstFastButton = false;
  4519. });
  4520.  
  4521. var btn125 = $( "<input class='fastBtn MUfastButton2' type='button' value='125' />" );
  4522. btn125.bind( "click", function() {
  4523. if( firstFastButton ) {
  4524. $( idDest ).attr( "value", "125" );
  4525. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 125 );
  4526. firstFastButton = false;
  4527. });
  4528.  
  4529. var btn150 = $( "<input class='fastBtn MUfastButton2' type='button' value='150' />" );
  4530. btn150.bind( "click", function() {
  4531. if( firstFastButton ) {
  4532. $( idDest ).attr( "value", "150" );
  4533. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 150 );
  4534. firstFastButton = false;
  4535. });
  4536.  
  4537. // OLD
  4538. /*$( "<br />" ).insertAfter($("#quantity.digit"));
  4539.  
  4540. btn1.insertAfter( idDest );
  4541. btn5.insertAfter( idDest );
  4542. btn10.insertAfter( idDest );
  4543.  
  4544. btn150.insertAfter( idDest );
  4545. btn125.insertAfter( idDest );
  4546. btn100.insertAfter( idDest );
  4547. btn75.insertAfter( idDest );
  4548. //$( "<br/>" ).insertAfter( idDest );
  4549. btn50.insertAfter( idDest );
  4550. btn25.insertAfter( idDest );
  4551. btn15.insertAfter( idDest );*/
  4552.  
  4553.  
  4554. // NEW
  4555. $( "<br id='divider' />" ).insertAfter($("#quantity.digit"));
  4556.  
  4557. btn25.insertAfter($("#divider") );
  4558. btn15.insertAfter($("#divider") );
  4559. btn10.insertAfter($("#divider") );
  4560. btn5.insertAfter( $("#divider") );
  4561. btn1.insertAfter( $("#divider") );
  4562.  
  4563. $( "<br id='divider2' />" ).insertAfter($("#donateProductForm input[value='25']"));
  4564.  
  4565. btn150.insertAfter( $("#divider2") );
  4566. btn125.insertAfter( $("#divider2") );
  4567. btn100.insertAfter( $("#divider2") );
  4568. btn75.insertAfter( $("#divider2") );
  4569. btn50.insertAfter( $("#divider2") );
  4570.  
  4571.  
  4572.  
  4573.  
  4574. }
  4575.  
  4576.  
  4577. // Add update jobs button
  4578. function addUpdateJobsButton( idForm ) {
  4579. savedWorkedList = [];
  4580.  
  4581. // Add button to see more days
  4582. var extended = $( "<input type='button' id='extendedDays' value='Extended'/>" );
  4583. extended.insertAfter( $( "#donateBtn2" ) );
  4584. disableButton( extended );
  4585. extended.bind( "click", function() {
  4586. extendedMU = !extendedMU;
  4587.  
  4588. if( extendedMU ) {
  4589. $( ".companyName" ).hide();
  4590. $( ".day0" ).show();
  4591. $( ".day1" ).show();
  4592. $( ".day2" ).show();
  4593. $( ".day3" ).show();
  4594. $( ".day4" ).show();
  4595. $( ".day5" ).show();
  4596. $( ".day6" ).show();
  4597. } else {
  4598. $( ".companyName" ).show();
  4599. $( ".day0" ).show();
  4600. $( ".day1" ).show();
  4601. $( ".day2" ).hide();
  4602. $( ".day3" ).hide();
  4603. $( ".day4" ).hide();
  4604. $( ".day5" ).hide();
  4605. $( ".day6" ).hide();
  4606. }
  4607. });
  4608.  
  4609. // Add update button
  4610. var update = $( "<input type='button' id='updateWork' value='Update jobs'/>" );
  4611. update.insertAfter( ".testDivwhite" );
  4612. update.bind( "click", function() {
  4613.  
  4614. $(this).val( "Updating... " );
  4615. disableButton( $(this) );
  4616. enableButton( extended );
  4617.  
  4618. // Clean previous results
  4619. $( idForm ).find( ".skill" ).children().remove();
  4620. $( idForm ).find( ".skill" ).addClass( "noSkill" );
  4621. $( idForm ).find( ".skill" ).removeClass( "skill" );
  4622. $( ".companyName" ).children().remove();
  4623. $( ".day0" ).children().remove();
  4624. $( ".day1" ).children().remove();
  4625. $( ".day2" ).children().remove();
  4626. $( ".day3" ).children().remove();
  4627. $( ".day4" ).children().remove();
  4628. $( ".day5" ).children().remove();
  4629. $( ".day6" ).children().remove();
  4630.  
  4631. var idMU = $( ".citizenAction" ).eq(0).children( "a" ).attr( "href" );
  4632. var split = idMU.split( "?id=" );
  4633. if( split.length > 1 ) {
  4634. idMU = split[1];
  4635.  
  4636. // Find every player what company works
  4637. // First MU companies
  4638. $.ajax({
  4639. url: getCurrentServer() + URLMUCompanies + idMU,
  4640. success: function( data ) {
  4641.  
  4642. // Special case
  4643. var cp = $( data ).find( "a[href^='company.html']" );
  4644. if( cp.length == 0 ) {
  4645. enableButton( $( "#updateWork" ) );
  4646. $( "#updateWork" ).val( "Update jobs" );
  4647.  
  4648. } else {
  4649. $( "#updateWork" ).val( "Updating... "+cp.length );
  4650. $( "#updateWork" ).attr( "counter", cp.length );
  4651. }
  4652.  
  4653. for( var i=0; i<cp.length; i++ ) {
  4654. var split = $( cp[i] ).attr( "href" ).split( "?id=" );
  4655. if( split.length > 1 ) { checkCompany( idForm, split[1], i, cp.length-1 ) }
  4656. }
  4657. }
  4658. });
  4659. }
  4660.  
  4661. return( false );
  4662. });
  4663.  
  4664. var needUpdate = false;
  4665. var lastUpdateTime = $( "<div id='lastUpdateTime'></div>" );
  4666. lastUpdateTime.insertAfter( update );
  4667. if( getValue( "muStorageSaveLastTime") ) {
  4668. lastUpdateTime.text( getValue( "muStorageSaveLastTime") );
  4669. var currentDate = (new Date).getDate();
  4670. var lastDate = new Date( getValue( "muStorageSaveLastTime" ) ).getDate();
  4671. var needUpdate = (lastDate != currentDate);
  4672. }
  4673.  
  4674.  
  4675. if( getValue( "muStorageSaveWorkedList") && !needUpdate ) {
  4676.  
  4677. enableButton( extended );
  4678. var workedList = getValue( "muStorageSaveWorkedList").split( "&&" );
  4679.  
  4680. for( var i=0; i<workedList.length; i++ ) {
  4681. var splitList = workedList[i].split( "," );
  4682.  
  4683. var pos = $( idForm ).find( "a[name='"+ splitList[0] +"']" );
  4684. var tr = pos.parent().parent();
  4685.  
  4686. addSkill( tr, splitList[1] );
  4687. tr.find( ".companyName" ).append( "<a href='"+ getCurrentServer() + URLCompany + splitList[2] +"'>"+ splitList[3] +"</a>" );
  4688.  
  4689. var day;
  4690. for( j=0; j<7; j++ ) {
  4691. var t = "-" + j;
  4692. if( j == 0 ) { t = ""; }
  4693.  
  4694. if( splitList[4+j] == "true" ) {
  4695. day = $( "<div class='dayOk' day='"+ j +"'>"+ t +"</div>" );
  4696. tr.find( ".day" + j ).append( day );
  4697. tr.find( "input" ).attr( "workday" + j, "true" );
  4698.  
  4699. } else {
  4700. day = $( "<div class='dayFail' day='"+ j +"'>"+ t +"</div>" );
  4701. tr.find( ".day"+j ).append( day );
  4702. tr.find( "input" ).attr( "workday" + j, "false" );
  4703. }
  4704.  
  4705. // Select only who worked
  4706. day.bind( "click", function() {
  4707. $( ".receipments" ).removeAttr( "checked" );
  4708. $( ".receipments[workday"+ $(this).attr( "day" ) +"='true']" ).attr( "checked", "checked" );
  4709. setCounterText();
  4710. saveCheckedPlayers();
  4711. });
  4712.  
  4713. if( !extendedMU && (j > 1) ) { tr.find( ".day" + j ).hide(); }
  4714. }
  4715. }
  4716. }
  4717. }
  4718.  
  4719.  
  4720. // Check each company
  4721. function checkCompany( idForm, idComp, i, n ) {
  4722.  
  4723. setTimeout( function() {
  4724.  
  4725. $.ajax({
  4726. url: getCurrentServer() + URLCompanyDetails + idComp,
  4727. success: function( data ) {
  4728. checkWorkResults( idComp, idForm, data );
  4729.  
  4730. if( i == n ) {
  4731. enableButton( $( "#updateWork" ) );
  4732. $( "#updateWork" ).val( "Update jobs" );
  4733. $( "#updateWork" ).removeAttr( "counter" );
  4734.  
  4735. setValue( "muStorageSaveWorkedList", savedWorkedList.join( "&&" ) );
  4736. $( "#lastUpdateTime" ).text( new Date().toUTCString() );
  4737. setValue( "muStorageSaveLastTime", new Date().toUTCString() );
  4738.  
  4739. } else {
  4740. var count = parseInt( $( "#updateWork" ).attr( "counter" ) ) - 1;
  4741. $( "#updateWork" ).val( "Updating... " + count );
  4742. $( "#updateWork" ).attr( "counter", count );
  4743. }
  4744. }
  4745. });
  4746.  
  4747. }, 1000*i );
  4748. }
  4749.  
  4750.  
  4751. // Check every company
  4752. function checkWorkResults( idComp, idForm, data ) {
  4753.  
  4754. var table = $( data ).find( "#productivityTable" );
  4755. var original = $( data ).find( "h1" ).text();
  4756. var company = original.substr(original.indexOf(" ") + 1);
  4757. var rows = table.find( "tbody tr" );
  4758. for( var i=1; i<rows.length; i++ ) {
  4759. var player = "";
  4760.  
  4761. var cols = $( rows[i] ).find( "td" );
  4762. if( cols.length > 0 ) {
  4763. var name = $( cols[0] ).find( "a" ).text();
  4764. player = name;
  4765.  
  4766. var pos = $( idForm ).find( "a[name='"+ name +"']" );
  4767. var tr = pos.parent().parent();
  4768. tr.find( ".companyName" ).append( "<a href='"+ getCurrentServer() + URLCompany + idComp +"'>"+ company +"</a>" );
  4769. if( cols.length == 12 ) {
  4770.  
  4771. var skillValue = parseInt( $( cols[1] ).text() );
  4772. addSkill( tr, skillValue );
  4773. player += "," + skillValue + "," + idComp + "," + company;
  4774.  
  4775. // View last 7 days
  4776. var day;
  4777. for( var j=0; j<7; j++ ) {
  4778. var t = "-" + j;
  4779. if( j == 0 ) { t = ""; }
  4780.  
  4781. if( $( cols[11-j] ).find( "img" ).length == 0 ) {
  4782. day = $( "<div class='dayOk' day='"+ j +"'>"+ t +"</div>" );
  4783. tr.find( ".day" + j ).append( day );
  4784. tr.find( "input" ).attr( "workday" + j, "true" );
  4785. player += "," + "true";
  4786.  
  4787. } else {
  4788. day = $( "<div class='dayFail' day='"+ j +"'>"+ t +"</div>" );
  4789. tr.find( ".day"+j ).append( day );
  4790. tr.find( "input" ).attr( "workday" + j, "false" );
  4791. player += "," + "false";
  4792. }
  4793.  
  4794. // Select only who worked
  4795. day.bind( "click", function() {
  4796. $( ".receipments" ).removeAttr( "checked" );
  4797. $( ".receipments[workday"+ $(this).attr( "day" ) +"='true']" ).attr( "checked", "checked" );
  4798. setCounterText();
  4799. saveCheckedPlayers();
  4800. });
  4801.  
  4802. if( !extendedMU && (j > 1) ) { tr.find( ".day" + j ).hide(); }
  4803. }
  4804. }
  4805.  
  4806. savedWorkedList.push( player );
  4807. }
  4808. }
  4809. }
  4810.  
  4811.  
  4812. // Add skill in MU storage list
  4813. function addSkill( tr, skillVal ) {
  4814. var posSkill = tr.find( ".noSkill" );
  4815. posSkill.removeClass( "noSkill" );
  4816. posSkill.addClass( "skill" );
  4817. posSkill.append( "<div>"+ skillVal +"</div>" );
  4818. posSkill.bind( "click", function() {
  4819. var v = $(this).text();
  4820. $( ".skill" ).each( function() {
  4821. if( v == $(this).text() ) { $(this).parent().find( "input" ).attr( "checked", "checked" ); }
  4822. });
  4823. setCounterText();
  4824. saveCheckedPlayers();
  4825. });
  4826. }
  4827.  
  4828.  
  4829. // Add update connection button
  4830. function addUpdateConnectionButton( idForm ) {
  4831.  
  4832. var $online = $( "<input type='submit' id='onlinePlayer' value='Online players' />" );
  4833. $online.insertAfter( ".testDivwhite" );
  4834. $online.bind( "click", function() {
  4835.  
  4836. $.ajax({
  4837. url: getCurrentServer() + URLMyMU,
  4838. success: function( data ) {
  4839.  
  4840. // First clean
  4841. $( idForm ).find( "img[src='"+ IMGOFFLINE +"']" ).remove();
  4842. $( idForm ).find( "img[src='"+ IMGONLINE +"']" ).remove();
  4843.  
  4844. // Add All offline
  4845. $( idForm ).find( "a[href^='profile.html']" ).each( function() {
  4846. var flag = $(this).parent().parent().find( ".currencyFlag" );
  4847. flag.attr( "src", IMGOFFLINE );
  4848. flag.addClass( "imgPlayerOnline" );
  4849. });
  4850.  
  4851. // Replace online players
  4852. $( data ).find( ".tip[src='"+ IMGONLINE +"']" ).each( function() {
  4853. var player = $( idForm ).find( "a[href='"+ $(this).prev().attr( "href" ) + "']" );
  4854. player.parent().parent().find( ".currencyFlag" ).attr( "src", IMGONLINE );
  4855. });
  4856.  
  4857. // Add events
  4858. $( idForm ).find( ".currencyFlag" ).bind( "click", function() {
  4859. $( idForm ).find( ".receipments" ).removeAttr( "checked" );
  4860. $( idForm ).find( "img[src='"+ $(this).attr( "src" ) +"']" ).each( function() {
  4861. $(this).parent().parent().find( "input" ).attr( "checked", "checked" );
  4862. });
  4863. saveCheckedPlayers();
  4864. });
  4865. }
  4866. });
  4867.  
  4868. return( false );
  4869. });
  4870. }
  4871.  
  4872.  
  4873. // Add update connection button
  4874. function addDebuffCheck( idForm ) {
  4875.  
  4876. var $online = $( "<input type='submit' id='debuffPlayer' value='Debuffed players' />" );
  4877. $online.insertAfter( ".testDivwhite" );
  4878. $online.bind( "click", function() {
  4879.  
  4880. $('.namePlayer').each(function() {
  4881.  
  4882. pUrl=getCurrentServer()+$(this).attr('href')
  4883.  
  4884. $.ajax({
  4885. url: pUrl,
  4886. success: function( data ) {
  4887.  
  4888. // First clean
  4889. $( idForm ).find( "img[src='"+ IMGOFFLINE +"']" ).remove();
  4890. $( idForm ).find( "img[src='"+ IMGONLINE +"']" ).remove();
  4891.  
  4892. // Add All offline
  4893. $(this).parent().find("td:first").after("<td class='debuff'><img id='noDebuff' src="+noDebuff+" ></td>")
  4894.  
  4895. // Replace online players
  4896. $( data ).find( ".tip[src='"+ IMGONLINE +"']" ).each( function() {
  4897. var player = $( idForm ).find( "a[href='"+ $(this).prev().attr( "href" ) + "']" );
  4898. player.parent().parent().find( ".currencyFlag" ).attr( "src", IMGONLINE );
  4899. });
  4900.  
  4901. // Add events
  4902. $( idForm ).find( ".currencyFlag" ).bind( "click", function() {
  4903. $( idForm ).find( ".receipments" ).removeAttr( "checked" );
  4904. $( idForm ).find( "img[src='"+ $(this).attr( "src" ) +"']" ).each( function() {
  4905. $(this).parent().parent().find( "input" ).attr( "checked", "checked" );
  4906. });
  4907. saveCheckedPlayers();
  4908. });
  4909. }
  4910. });
  4911.  
  4912.  
  4913. })
  4914.  
  4915.  
  4916.  
  4917.  
  4918. return( false );
  4919. });
  4920. }
  4921.  
  4922.  
  4923. // Count selected members on MU list
  4924. function addCounterMembersMU() {
  4925.  
  4926. var counterDiv = $( "<div style='width:150px; text-align: center; display:inline; padding:2px' id='counterCheck'>No members selected.</div>" )
  4927. counterDiv.insertAfter( ".testDivwhite" );
  4928.  
  4929. var totalDiv = $( "<div style='width:150px; text-align: center; display:inline-block; padding:2px' id='totalDonate'></div>" );
  4930. totalDiv.insertAfter( "#counterCheck" );
  4931.  
  4932. // Add events
  4933. $( ".receipments" ).bind( "change", setCounterText );
  4934.  
  4935. $( "#tickAll" ).bind( "click", setCounterText );
  4936. $( "#untickAll" ).bind( "click", setCounterText );
  4937.  
  4938. $( "#quantity" ).bind( "change", setCounterText );
  4939. $( ".fastBtn" ).bind( "click", setCounterText );
  4940.  
  4941. setCounterText();
  4942. }
  4943.  
  4944.  
  4945. // Set counter checks text
  4946. function setCounterText() {
  4947.  
  4948. var qty = $( "#quantity" ).attr( "value" );
  4949. var n = $( ".receipments:checked" ).length;
  4950. if( n == 0 ) {
  4951. $( "#counterCheck" ).text( "No members selected." );
  4952. $( "#totalDonate" ).text( "" );
  4953.  
  4954. } else if( n == 1 ) {
  4955. $( "#counterCheck" ).text( "Selected 1 member." );
  4956. if( qty > 0 ) {
  4957. if( n*qty == 1 ) {
  4958. $( "#totalDonate" ).text( "Total donate: "+ (n*qty) +" item." );
  4959.  
  4960. } else $( "#totalDonate" ).text( "Total donate: "+ (n*qty) +" items." );
  4961.  
  4962. } else $( "#totalDonate" ).text( "" );
  4963.  
  4964. } else {
  4965. $( "#counterCheck" ).text( "Selected "+n+" members." );
  4966. if( qty > 0 ) {
  4967. $( "#totalDonate" ).text( "Total donate: "+ (n*qty) +" items." );
  4968.  
  4969. } else $( "#totalDonate" ).text( "" );
  4970. }
  4971. }
  4972.  
  4973.  
  4974. // Update player to player donation
  4975. function changeSelectPlayerToPlayer( idForm ) {
  4976.  
  4977. var select = $( "#product" );
  4978. var dest = $( "#quantity" );
  4979. var pos = $( ".testDivblue" ).eq(2);
  4980. var posSelect = $( ".testDivblue" ).eq(4);
  4981.  
  4982. pos.children().remove();
  4983. pos.append( "One click to select <b>ONE item</b>. Double click to select <b>ALL items</b>.<br/><br/>" );
  4984. pos.addClass( "playerToPlayerItem" );
  4985.  
  4986. posSelect.children().first().remove();
  4987. posSelect.children().first().remove();
  4988. posSelect.children().last().remove();
  4989.  
  4990. orderSelect( select );
  4991. changeSelect( select, pos, dest, "#8baed8" );
  4992. }
  4993.  
  4994.  
  4995. // Add fast buttons
  4996. function addFastButtons( idDest ) {
  4997.  
  4998. var firstFastButton = true;
  4999. $( idDest ).css({ "text-align" : "center" });
  5000.  
  5001. var btn1 = $( "<input class='fastBtn FastButtonLeft' type='button' value='1' />" );
  5002. btn1.bind( "click", function() {
  5003. if( firstFastButton ) {
  5004. $( idDest ).attr( "value", "1" );
  5005. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 1 );
  5006. firstFastButton = false;
  5007. });
  5008.  
  5009. var btn5 = $( "<input class='fastBtn FastButtonLeft' type='button' value='5' />" );
  5010. btn5.bind( "click", function() {
  5011. if( firstFastButton ) {
  5012. $( idDest ).attr( "value", "5" );
  5013. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 5 );
  5014. firstFastButton = false;
  5015. });
  5016.  
  5017. var btn10 = $( "<input class='fastBtn FastButtonLeft' type='button' value='10' />" );
  5018. btn10.bind( "click", function() {
  5019. if( firstFastButton ) {
  5020. $( idDest ).attr( "value", "10" );
  5021. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 10 );
  5022. firstFastButton = false;
  5023. });
  5024.  
  5025. var btn15 = $( "<input class='fastBtn FastButtonLeft' type='button' value='15' />" );
  5026. btn15.bind( "click", function() {
  5027. if( firstFastButton ) {
  5028. $( idDest ).attr( "value", "15" );
  5029. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 15 );
  5030. firstFastButton = false;
  5031. });
  5032.  
  5033. var btn25 = $( "<input class='fastBtn FastButtonLeft' type='button' value='25' />" );
  5034. btn25.bind( "click", function() {
  5035. if( firstFastButton ) {
  5036. $( idDest ).attr( "value", "25" );
  5037. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 25 );
  5038. firstFastButton = false;
  5039. });
  5040.  
  5041. var btn50 = $( "<input class='fastBtn FastButtonLeft' type='button' value='50' />" );
  5042. btn50.bind( "click", function() {
  5043. if( firstFastButton ) {
  5044. $( idDest ).attr( "value", "50" );
  5045. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 50 );
  5046. firstFastButton = false;
  5047. });
  5048.  
  5049. var btn75 = $( "<input class='fastBtn FastButtonRight' type='button' value='75' />" );
  5050. btn75.bind( "click", function() {
  5051. if( firstFastButton ) {
  5052. $( idDest ).attr( "value", "75" );
  5053. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 75 );
  5054. firstFastButton = false;
  5055. });
  5056.  
  5057. var btn100 = $( "<input class='fastBtn FastButtonRight' type='button' value='100' />" );
  5058. btn100.bind( "click", function() {
  5059. if( firstFastButton ) {
  5060. $( idDest ).attr( "value", "100" );
  5061. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 100 );
  5062. firstFastButton = false;
  5063. });
  5064.  
  5065. var btn125 = $( "<input class='fastBtn FastButtonRight' type='button' value='125' />" );
  5066. btn125.bind( "click", function() {
  5067. if( firstFastButton ) {
  5068. $( idDest ).attr( "value", "125" );
  5069. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 125 );
  5070. firstFastButton = false;
  5071. });
  5072.  
  5073. var btn150 = $( "<input class='fastBtn FastButtonRight' type='button' value='150' />" );
  5074. btn150.bind( "click", function() {
  5075. if( firstFastButton ) {
  5076. $( idDest ).attr( "value", "150" );
  5077. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 150 );
  5078. firstFastButton = false;
  5079. });
  5080.  
  5081. var btn500 = $( "<input class='fastBtn FastButtonRight' type='button' value='500' />" );
  5082. btn500.bind( "click", function() {
  5083. if( firstFastButton ) {
  5084. $( idDest ).attr( "value", "500" );
  5085. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 500 );
  5086. firstFastButton = false;
  5087. });
  5088.  
  5089. var btn1k = $( "<input class='fastBtn FastButtonRight' type='button' value='1K' />" );
  5090. btn1k.bind( "click", function() {
  5091. if( firstFastButton ) {
  5092. $( idDest ).attr( "value", "1000" );
  5093. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 1000 );
  5094. firstFastButton = false;
  5095. });
  5096.  
  5097. btn1.insertBefore( idDest );
  5098. btn5.insertBefore( idDest );
  5099. btn10.insertBefore( idDest );
  5100. btn15.insertBefore( idDest );
  5101. btn25.insertBefore( idDest );
  5102. btn50.insertBefore( idDest );
  5103.  
  5104. btn1k.insertAfter( idDest );
  5105. btn500.insertAfter( idDest );
  5106. btn150.insertAfter( idDest );
  5107. btn125.insertAfter( idDest );
  5108. btn100.insertAfter( idDest );
  5109. btn75.insertAfter( idDest );
  5110. }
  5111.  
  5112.  
  5113. // Change create contract page
  5114. function changeCreateContract() {
  5115.  
  5116. // Redesign
  5117. $( "#contractsForm" ).parent().css({ "width" : "550px" });
  5118. //$( "#contractsForm" ).next().remove();
  5119. $( "#contractsForm" ).children( "div" ).css({ "display" : "none" });
  5120. $( "#offererSide" ).css({ "display" : "none" });
  5121. $( "#itemTypeList" ).css({ "display" : "none" });
  5122. $( "#contractsForm" ).children( "br" ).remove();
  5123. $( "#contractsForm" ).children( "b" ).remove();
  5124.  
  5125. // Clean some elements from Form
  5126. var input = $( "#contractsForm" ).children( "input" ).eq(2);
  5127.  
  5128. var player = $( "<div id='player' style='float:left; width:49%; height:30px'></div>" );
  5129. player.css({ "background-color" : "#fff", "border-radius" : "4px", "cursor" : "pointer" });
  5130. player.css({ "box-shadow" : "0px 0px 5px rgba(0, 0, 0, 0.5)" });
  5131. var imgPlayerSrc = $( ".testDivwhite" ).eq(0).find( "img" ).eq(1).attr( "src" );
  5132. player.append( "<img src='"+ imgPlayerSrc +"' style='width:30px;' />" );
  5133. var name = $( ".testDivwhite" ).eq(0).find( "a[href^='profile.html']" ).text();
  5134. player.append( "<span style='font-weight:bold; font-size:14px; margin-left:5px; position:relative; top:-10px'>"+ name +"</span>" );
  5135.  
  5136. var dummy = $( "<div id='dummy' style='float:right; width:49%; height:30px'></div>" );
  5137. dummy.css({ "margin" : "0px 0px 0px 1%" });
  5138. dummy.css({ "background-color" : "#fff", "border-radius" : "4px", "cursor" : "pointer" });
  5139. dummy.css({ "box-shadow" : "0px 0px 5px rgba(0, 0, 0, 0.5)" });
  5140. var imgDummySrc = $( ".testDivwhite" ).eq(1).find( "img" ).eq(1).attr( "src" );
  5141. dummy.append( "<img src='"+ imgDummySrc +"' style=' width:30px;' />" );
  5142. dummy.append( "<span style='font-weight:bold; font-size:14px; margin-left:5px; position:relative; top:-10px'>Dummy</span>" );
  5143.  
  5144. var playerBlock = createContractBlock();
  5145. var dummyBlock = createContractBlock();
  5146.  
  5147. player.bind( "click", function() {
  5148. $(this).css({ "background-color" : "#ddd" });
  5149. $("#dummy").css({ "background-color" : "#fff" });
  5150.  
  5151. $("#eqTab").fadeIn()
  5152.  
  5153. $("#offererSide option[value=true]").attr("selected", true);
  5154. $("#offererSide option[value=false]").attr("selected", false);
  5155. });
  5156.  
  5157.  
  5158. dummy.bind( "click", function() {
  5159. $(this).css({ "background-color" : "#ddd" });
  5160. $("#player").css({ "background-color" : "#fff" });
  5161.  
  5162. $("#eqTab").fadeOut()
  5163.  
  5164. $("#offererSide option[value=true]").attr("selected", false);
  5165. $("#offererSide option[value=false]").attr("selected", true);
  5166. });
  5167.  
  5168.  
  5169.  
  5170.  
  5171. player.insertBefore( input );
  5172. dummy.insertBefore( input );
  5173.  
  5174. dummyBlock.css({ "float" : "right" });
  5175.  
  5176.  
  5177.  
  5178. playerBlock.insertBefore( input );
  5179. //dummyBlock.insertBefore( input );
  5180.  
  5181. player.trigger("click");
  5182.  
  5183. }
  5184.  
  5185. // Create contract block
  5186. function createContractBlock() {
  5187.  
  5188. var block = $( "<div id='the_block' style='float:left; width:100%; height:200px;'></div>" );
  5189. block.css({ "background-color" : "#fff", "margin" : "9px 0px 10px 0px", "border-radius" : "4px" });
  5190. block.css({ "box-shadow" : "0px 0px 5px rgba(0, 0, 0, 0.5)" });
  5191.  
  5192. var options = $( "<div style='font-size:12px; font-weight:bold; cursor:pointer; width:510px; height: 23px;margin:auto;'></div>" );
  5193. var moneyTab = $( "<div style='float:left; width:130px; padding:5px 0px; '>MONEY</div>" );
  5194. var productTab = $( "<div style='float:left; width:130px; padding:5px 0px;'>PRODUCT</div>" );
  5195. var debtTab = $( "<div style='float:left; width:125px; padding:5px 0px;'>DEBT</div>" );
  5196. var eqTab = $( "<div id='eqTab' style='float:left; width:125px; padding:5px 0px;'>EQUIPMNET</div>" );
  5197.  
  5198. //-------------------------------------------------
  5199.  
  5200. moneyTab.bind( "mouseover", function() {
  5201. $(this).css({ "background-color" : "#ddd" });
  5202. });
  5203. moneyTab.bind( "mouseout", function() {
  5204. $(this).css({ "background-color" : "#fff" });
  5205. });
  5206.  
  5207. moneyTab.bind( "click", function() {
  5208. $(this).css({ "background-color" : "#00AA33" });
  5209. $("#the_block").css({"height":"200px"});
  5210.  
  5211. $("#itemTypePosition1").attr("selected", true);
  5212. $("#itemTypePosition2").attr("selected", false);
  5213. $("#itemTypePosition3").attr("selected", false);
  5214. $("#itemTypePosition4").attr("selected", false);
  5215. $("#itemTypePosition4").attr("disabled", true);
  5216.  
  5217. money.show()
  5218. product.hide()
  5219. debt.hide()
  5220. eq.hide()
  5221. });
  5222.  
  5223. //-------------------------------------------------
  5224.  
  5225.  
  5226. productTab.bind( "mouseover", function() {
  5227. $(this).css({ "background-color" : "#ddd" });
  5228. });
  5229. productTab.bind( "mouseout", function() {
  5230. $(this).css({ "background-color" : "#fff" });
  5231. });
  5232. productTab.bind( "click", function() {
  5233. $(this).css({ "background-color" : "#00AA33" });
  5234. $("#the_block").css({"height":"230px"});
  5235.  
  5236. $("#itemTypePosition1").attr("selected", false);
  5237. $("#itemTypePosition2").attr("selected", true);
  5238. $("#itemTypePosition3").attr("selected", false);
  5239. $("#itemTypePosition4").attr("selected", false);
  5240. $("#itemTypePosition4").attr("disabled", true);
  5241.  
  5242. money.hide()
  5243. product.show()
  5244. debt.hide()
  5245. eq.hide()
  5246. });
  5247.  
  5248. //-------------------------------------------------//-------
  5249.  
  5250. debtTab.bind( "mouseover", function() {
  5251. $(this).css({ "background-color" : "#ddd" });
  5252. });
  5253. debtTab.bind( "mouseout", function() {
  5254. $(this).css({ "background-color" : "#fff" });
  5255. });
  5256. debtTab.bind( "click", function() {
  5257. $(this).css({ "background-color" : "#00AA33" });
  5258. $("#the_block").css({"height":"200px"});
  5259.  
  5260. $("#itemTypePosition1").attr("selected", false);
  5261. $("#itemTypePosition2").attr("selected", false);
  5262. $("#itemTypePosition3").attr("selected", true);
  5263. $("#itemTypePosition4").attr("selected", false);
  5264. $("#itemTypePosition4").attr("disabled", true);
  5265.  
  5266. money.hide()
  5267. product.hide()
  5268. debt.show()
  5269. eq.hide()
  5270.  
  5271. });
  5272.  
  5273. //-------------------------------------------------//----------
  5274.  
  5275. eqTab.bind( "mouseover", function() {
  5276. $(this).css({ "background-color" : "#ddd" });
  5277. });
  5278. eqTab.bind( "mouseout", function() {
  5279. $(this).css({ "background-color" : "#fff" });
  5280. });
  5281.  
  5282. eqTab.bind( "click", function() {
  5283. $(this).css({ "background-color" : "#00AA33" });
  5284. $("#the_block").css({"height":"200px"});
  5285.  
  5286. $("#itemTypePosition1").attr("selected", false);
  5287. $("#itemTypePosition2").attr("selected", false);
  5288. $("#itemTypePosition3").attr("selected", false);
  5289. $("#itemTypePosition4").attr("selected", true);
  5290. $("#itemTypePosition4").attr("disabled", false);
  5291.  
  5292. money.hide()
  5293. product.hide()
  5294. debt.hide()
  5295. eq.show()
  5296.  
  5297. });
  5298.  
  5299. //-------------------------------------------------
  5300.  
  5301. var money = $( "#MONEYParameters" );
  5302. money.css({ "margin" : "10px auto auto", "border" : "1px solid #ccc", "border-radius" : "4px" });
  5303. money.css({ "background-color" : "#eee", "width" : "360px", "height" : "97px", "padding" : "60px 0px 0px 0px" });
  5304.  
  5305. var product = $( "#PRODUCTParameters" );
  5306. product.css({ "margin" : "10px auto auto", "border" : "1px solid #ccc", "border-radius" : "4px" });
  5307. product.css({ "background-color" : "#eee", "width" : "360px","height" : "180px"});
  5308.  
  5309. var debt = $( "#DEBTParameters" );
  5310. debt.css({ "margin" : "10px auto auto", "border" : "1px solid #ccc", "border-radius" : "4px" });
  5311. debt.css({ "background-color" : "#eee", "width" : "360px", "height" : "155px" });
  5312.  
  5313. var eq = $( "#EQUIPMENTParameters" );
  5314. eq.css({ "margin" : "10px auto auto", "border" : "1px solid #ccc", "border-radius" : "4px" });
  5315. eq.css({ "background-color" : "#eee", "width" : "360px", "height" : "155px" });
  5316.  
  5317.  
  5318. options.append( moneyTab );
  5319. options.append( productTab );
  5320. options.append( debtTab );
  5321. options.append( eqTab );
  5322. block.append( options );
  5323. block.append( money );
  5324. block.append( product );
  5325. block.append( debt );
  5326. block.append( eq );
  5327.  
  5328. money.trigger("click");
  5329.  
  5330. return( block );
  5331. }
  5332.  
  5333.  
  5334. // Change market selectors
  5335. function changeProductSelection() {
  5336.  
  5337. // Remove extra br at the begining
  5338. $( "#contentRow" ).children( "td" ).eq(1).children().eq(1).remove();
  5339.  
  5340. // Redesign product selection in one row
  5341. var divBlock = $( "#productMarketViewForm" ).parent();
  5342. divBlock.addClass( "productMarketViewFormMod" );
  5343. divBlock.children( ":lt(2)" ).remove();
  5344.  
  5345. // Remove useless tags
  5346. $( "#marketProducts" ).children( "p" ).remove();
  5347. $( "#marketProducts" ).addClass( "marketProductsMod" );
  5348.  
  5349. $( "#productMarketViewForm > .productList" ).hide();
  5350. var selectProductMarketItem = null;
  5351. var mycounter=0;
  5352. $( "#marketProducts .productList" ).each( function() {
  5353.  
  5354.  
  5355. mycounter++;
  5356. var related = $(this);
  5357. var product = $( "<div class='productMarketItem'></div>" );
  5358. product.append( "<img src='"+ $(this).find( "img" ).attr( "src" ) +"' />" );
  5359. product.append( "<div class='productLabel'>"+ $(this).find( "label" ).text() +"</div>" );
  5360. $(this).parent().append( product );
  5361.  
  5362. product.bind( "mouseover", function() {
  5363. if( selectProductMarketItem ) {
  5364. if( $(this).text() != selectProductMarketItem.text() ) { $(this).addClass( "productMarketItemHover" ); }
  5365. } else $(this).addClass( "productMarketItemHover" );
  5366. });
  5367.  
  5368. product.bind( "mouseout", function() {
  5369. if( selectProductMarketItem ) {
  5370. if( $(this).text() != selectProductMarketItem.text() ) { $(this).removeClass( "productMarketItemHover" ); }
  5371. } else $(this).removeClass( "productMarketItemHover" );
  5372. });
  5373.  
  5374. product.bind( "click", function() {
  5375. if( selectProductMarketItem && ($(this).text() == selectProductMarketItem.text()) ) {
  5376. $(this).removeClass( "productMarketItemSelected" );
  5377. $( "#resource1" ).attr( "checked", "checked" );
  5378. selectProductMarketItem = null;
  5379.  
  5380. } else {
  5381. if( selectProductMarketItem ) {
  5382. selectProductMarketItem.removeClass( "productMarketItemHover" );
  5383. selectProductMarketItem.removeClass( "productMarketItemSelected" );
  5384. }
  5385. $(this).addClass( "productMarketItemSelected" );
  5386. selectProductMarketItem = $(this);
  5387. related.find( "input" ).attr( "checked", "checked" );
  5388. }
  5389. });
  5390.  
  5391. $(this).hide();
  5392. if( $(this).find( "input" ).attr( "checked" ) ) { product.click(); }
  5393.  
  5394.  
  5395. if(mycounter==7)
  5396. {
  5397.  
  5398.  
  5399. }
  5400. });
  5401.  
  5402. $( "#countryId" ).addClass( "countryIdSelect" );
  5403. $( "#countryId" ).addClass( "customSelectList" );
  5404.  
  5405. // Change quality selection
  5406. var selectedQuality = parseInt( $( "#quality :selected" ).val() );
  5407. var newQuality = $( "<div class='qualityProduct'></div>" );
  5408. $( "#quality option" ).each( function() {
  5409.  
  5410. var v = parseInt( $(this).val() );
  5411. if( v != 0 ) {
  5412. var star = $( "<div class='qualityStar' quality='"+ v +"' ></div>" );
  5413. if( v > selectedQuality ) {
  5414. star.addClass( "qualityStarHover" );
  5415. }
  5416. newQuality.append( star );
  5417.  
  5418. star.bind( "click", function() {
  5419. var q = parseInt( $(this).attr( "quality" ) );
  5420. $(this).parent().children().addClass( "qualityStarHover" );
  5421. if( selectedQuality == q ) {
  5422. selectedQuality = 0;
  5423.  
  5424. } else {
  5425. var current = $(this);
  5426. for( var i=0; i<=q; i++ ) {
  5427. current.removeClass( "qualityStarHover" );
  5428. current = current.prev();
  5429. }
  5430. selectedQuality = q;
  5431. }
  5432.  
  5433. $( "#quality" ).val( selectedQuality );
  5434. });
  5435. }
  5436. });
  5437.  
  5438. newQuality.insertBefore( "#quality" );
  5439. $( "#quality" ).hide();
  5440.  
  5441. $( "#productMarketViewForm" ).children( "br" ).remove();
  5442.  
  5443. // Rellocate help wiki and my offers link
  5444. $( "#productMarketViewForm .biggerFont a" ).addClass( "linkMyOffersProductMarket" );
  5445. var imgWiki = $( "#quality" ).next().next();
  5446. imgWiki.addClass( "imgWikiProductMarket" );
  5447. var linkWiki = imgWiki.next();
  5448. linkWiki.addClass( "linkWikiProductMarket" );
  5449. var imgLinkWiki = $( "<a href='"+ linkWiki.attr( "href" ) +"' target='_blank'></a>" );
  5450. imgLinkWiki.append( imgWiki );
  5451. imgLinkWiki.insertAfter( $( "#productMarketViewForm" ) );
  5452. linkWiki.insertAfter( $( "#productMarketViewForm" ) );
  5453.  
  5454. // Add buy As button on top
  5455. var buyAs = $( "<div class='buyAsSelect'></div>" );
  5456. var select = $( "<select class='customSelectList' ></select>" );
  5457. if( $( "#command" ).first().children( "select" ).length > 0 ) {
  5458. buyAs.append( $( "#command" ).first().contents().eq(0).text() );
  5459. $( "#command" ).first().children( "select" ).children().each( function() {
  5460. select.append( "<option value='"+ $(this).attr( "value" ) +"'>"+ $(this).text() +"</option>" );
  5461. });
  5462.  
  5463. } else {
  5464. buyAs.append( "Buy as:" );
  5465. select.append( "<option value=''> Citizen </option>" );
  5466. select.attr( "disabled", "disabled" );
  5467. }
  5468. buyAs.append( select );
  5469. buyAs.insertAfter( $( "#productMarketViewForm" ).children( "p" ) );
  5470. select.bind( "change", function() {
  5471. $( ".dataTable" ).find( "select" ).val( $(this).val() );
  5472.  
  5473. if( getValue( "configProductMarketTable" ) == "true" ) {
  5474. var color = ($(this).val() != "" ) ? "#fcecec" : "#ecffec";
  5475. var t = $(this).find( ":selected" ).text();
  5476. $( ".dataTable" ).find( "select" ).each( function() {
  5477. $( ".toRemove" ).parent().parent().css({ "background-color" : color });
  5478. $( ".toRemove" ).text( "Buy as "+ t );
  5479. });
  5480. }
  5481. });
  5482. select.first().selected();
  5483. }
  5484.  
  5485.  
  5486. // Change product market table
  5487. function changeProductMarketTable() {
  5488.  
  5489. $( ".dataTable" ).find( "input[type='text']" ).addClass( "inputTextTable" );
  5490. var submit = $( ".dataTable" ).find( "input[type='submit']" ).addClass( "inputSubmitTable" );
  5491. $( ".dataTable" ).find( "input[type='text']" ).bind( "keyup", function() {
  5492. var td = $(this).parent().parent();
  5493. var priceUnit = parseFloat( td.prev().prev().children( ".linkMonetaryMarket" ).next().text() );
  5494. var value = parseFloat( $(this).val() );
  5495. td.prev().children( ".inputPrice" ).text( Math.round( priceUnit * value * 100 ) / 100 );
  5496.  
  5497. });
  5498.  
  5499. // Add buy all button
  5500. var buyAll = $( "<input class='buyAllSubmit' type='submit' value='All' />" );
  5501. buyAll.bind( "click", function() {
  5502. var v = $(this).parent().parent().prev().prev().prev().text();
  5503. $(this).parent().children( "input[type='text']" ).val( v );
  5504. return( false );
  5505. });
  5506. buyAll.insertBefore( submit );
  5507.  
  5508. // Hide buyAs select
  5509. $( ".dataTable" ).find( "select" ).each( function() {
  5510. var cell = $(this).parent();
  5511. var buyAs = $( "<div class='toRemove buyAsTable'>Buy as Citizen</div>" );
  5512.  
  5513. if( getValue( "configProductMarketSelection" ) == "true" ) {
  5514. buyAs.insertBefore( cell.children().first() );
  5515. cell.parent().css({ "background-color" : "#ecffec" });
  5516. cell.contents().eq(0).remove();
  5517. cell.children( "br" ).remove();
  5518. $(this).hide();
  5519.  
  5520. } else $(this).addClass( "customSelectList" );
  5521. });
  5522.  
  5523. // Add help message
  5524. var divT = $( "<div class='helpFlagMessage'>Click on country flag to open the monetary market (only price column)</div>" );
  5525. divT.insertBefore( ".dataTable" );
  5526.  
  5527. // Resize table
  5528. $( ".dataTable" ).addClass( "dataTableMod" );
  5529.  
  5530. // Redesign table
  5531. // Headers
  5532. $( ".dataTable > tbody > tr:first-child > td" ).addClass( "dataTableHeaders" );
  5533. var trHead = $( ".dataTable" ).find( "tr" ).eq(0).children();
  5534. trHead.eq(0).css({ "width" : "70px" });
  5535. trHead.eq(3).text( "Price/unit" );
  5536. $( "<td class='dataTableHeaders'>Price</td>" ).insertAfter( trHead.eq(3) );
  5537.  
  5538. // Product list
  5539. //resizeProductImage( $( ".dataTable" ).find( ".product" ) );
  5540.  
  5541. // Name list and total price
  5542. $( ".dataTable" ).find( "a" ).each( function() {
  5543.  
  5544. // Name redesign
  5545. var cell = $(this).parent();
  5546. cell.children( ".currencyFlag" ).next().remove(); // Remove BR
  5547. cell.children( ".currencyFlag" ).addClass( "dataTableNameFlag" );
  5548.  
  5549. var div = $( "<div class='blockSeller'></div>" );
  5550. var imgSeller = cell.children( "img" ).eq(1);
  5551. imgSeller.addClass( "dataTableSeller" );
  5552. div.append( imgSeller );
  5553.  
  5554. var playerName = $( "<div class='playerName'></div>" ).append( cell.children( ":lt(2)" ) );
  5555. div.append( playerName );
  5556. if( cell.children().length > 0 ) {
  5557. playerName.css({ "margin-top" :"3px" });
  5558.  
  5559. cell.children().eq(0).remove();
  5560. var stockName = $( "<div class='stockName'></div>" ).append( cell.children().eq(0) );
  5561. div.append( stockName );
  5562. }
  5563. cell.append( div );
  5564.  
  5565. var nextCell = cell.next().next();
  5566. var flag = nextCell.children( "div" );
  5567. flag.addClass( "monetaryMarketFlag" );
  5568.  
  5569. // Add link to monetary market
  5570. var url = getCurrentServer() + URLMonetaryMarket + "?buyerCurrencyId="+ IDByImageCountry( flag.attr( "class" ).split(" ")[1] ) +"&sellerCurrencyId=0";
  5571. var link = $( "<a class='linkMonetaryMarket' href='"+ url +"' target='_blank'></a>" );
  5572. link.insertBefore( flag );
  5573. link.append( flag );
  5574.  
  5575. // Total price
  5576. var priceItem = parseFloat( nextCell.children( "b" ).text() );
  5577. var n = ( parseInt( parseInt( cell.next().text() ) * priceItem * 100 ) )/100;
  5578. var money = nextCell.contents().last().text();
  5579. var newCell = $( "<td class='totalPriceProductMarket'><b>"+ n +"</b> "+ money +"</td>" );
  5580. newCell.insertAfter( nextCell );
  5581. newCell.append( "<br/ > Total: <div style='display:inline;width:10px' class='inputPrice'>0</div>" + money );
  5582. });
  5583. }
  5584.  
  5585. //Advanced by CLard
  5586.  
  5587. function calcValueInGold(id, callback) {
  5588.  
  5589. _MM_C_URL = _MM_C_URL.replace("{1}", id);
  5590.  
  5591. jQuery.get(getCurrentServer()+_MM_C_URL, function(data) {
  5592. try {
  5593. //get first row of the dataTable
  5594. var $content = jQuery(data);
  5595. var $table = jQuery(".dataTable", $content);
  5596. if ($table.length > 0) {
  5597. $table = jQuery($table[0]);
  5598. }
  5599.  
  5600. //get the currency
  5601. var c = $table[0].rows[1].cells[2].textContent.trim();
  5602. c = c.substr(c.indexOf("=") + 1, c.indexOf("Gold") - c.indexOf("=") - 1);
  5603.  
  5604. _currencyValue = parseFloat(c);
  5605.  
  5606. //jQuery("#monetaryOfferPost #exchangeRatio").get(0).value = _currencyValue;
  5607.  
  5608. if (callback) {
  5609. callback();
  5610. }
  5611.  
  5612. } catch (e) {
  5613. console.log(e);
  5614. _currencyValue = 0;
  5615. }
  5616. });
  5617. }
  5618.  
  5619.  
  5620. function displayGoldValue() {
  5621.  
  5622. var $table = jQuery(".dataTable");
  5623. var s = "";
  5624.  
  5625. var id = jQuery("#productMarketViewForm #countryId");
  5626. if (id.length > 0) {
  5627. id = id[0].value;
  5628. } else {
  5629. id = _currencyId;
  5630. }
  5631. calcValueInGold(id, displayGoldValue.bind(this, id));
  5632.  
  5633. //console.log("##### Values ######");
  5634. try {
  5635. if ($table.length > 0) {
  5636.  
  5637. //need to get the tax for the selected country ....
  5638. GET_URL=getCurrentServer()+_COUNTRY_URL.replace("{1}", id)
  5639. jQuery.get(GET_URL, function(data) {
  5640. try {
  5641. var taxes = [];
  5642.  
  5643. var dt = jQuery(".dataTable", jQuery(data))[1];
  5644.  
  5645. for (var j=1; j<dt.rows.length;j++) {
  5646. var row = dt.rows[j];
  5647. taxes[j-1] = {"name": dt.rows[j].cells[0].innerHTML.toUpperCase().trim(),
  5648. "value": parseFloat(row.cells[2].innerHTML.toUpperCase().replace("&NBSP;", "").replace("&NBSP;", "").trim()) + parseFloat(row.cells[1].innerHTML.toUpperCase().replace("&NBSP;", "").replace("&NBSP;", "").trim())
  5649. };
  5650. }
  5651.  
  5652. for (var k=1; k< $table[0].rows.length; k++) {
  5653. var $row = $table[0].rows[k];
  5654. var totalProduct = parseFloat($row.cells[2].textContent.trim());
  5655. s = $row.cells[3].textContent.trim();
  5656. if (s.indexOf("GOLD") >= 0) {
  5657. break;
  5658. }
  5659. var price = parseFloat(s.substr(0,s.indexOf(" ")).trim());
  5660. var priceInGold = Math.round((price * _currencyValue)*100000)/100000;
  5661. var totalPrice = Math.round(totalProduct * price * 1000)/1000;
  5662. var totalPriceInGold = Math.round((totalProduct * price * _currencyValue)*100000)/100000;
  5663.  
  5664. //console.log("price:" + price + " ; price in gold:" + priceInGold + " ; total price:" + totalPrice + " ; total in gold:" + totalPriceInGold);
  5665.  
  5666. $row.cells[3].innerHTML = $row.cells[3].innerHTML + " <br> <img src='http://e-sim.home.pl/testura/img/gold.png'><b>" + priceInGold + "</b> GOLD";
  5667. $row.cells[4].innerHTML = " <b>" + totalPriceInGold + "</b> Gold <br/>" + $row.cells[4].innerHTML //+
  5668. //"<br> Total in "+ s.substr(s.indexOf(" ")).trim() +": <b>" + totalPrice + "</b>"
  5669. //$row.cells[5].innerHTML = $row.cells[5].innerHTML +"<br><a style='cursor: pointer;color: #3787EA; font-weight: bold;' id='buyAllYouCan'>Buy All You Can</a>";
  5670.  
  5671.  
  5672. //console.log(taxes);
  5673.  
  5674. for (var h=0;h<taxes.length;h++) {
  5675. //alert(taxes[h].value)
  5676. if ($row.cells[0].innerHTML.toUpperCase().indexOf(taxes[h].name) >= 0) {
  5677. console.log("tx:" + (parseFloat(taxes[h].value) / 100));
  5678.  
  5679. $row.cells[3].innerHTML = $row.cells[3].innerHTML + "<br> <hr class='foundation-divider'> Price without tax: <b>" + (Math.round(((parseFloat(price) / (1 + parseFloat(taxes[h].value) / 100) )) *100000)/100000) + "</b>";
  5680. $row.cells[3].innerHTML = $row.cells[3].innerHTML + " <br> Price(G) without tax: <b>" + (Math.round(((priceInGold / (1 + parseFloat(taxes[h].value) / 100) )) *100000)/100000) + "</b>";
  5681.  
  5682. break;
  5683. }
  5684. }
  5685.  
  5686. jQuery("#buyAllYouCan", jQuery($row)).hover(
  5687. function () {
  5688. $(this).css("color", "#FF3344");
  5689. },
  5690. function () {
  5691. $(this).css("color", "#3787EA");
  5692. }
  5693. );
  5694.  
  5695. jQuery("#buyAllYouCan", jQuery($row)).bind("click", function() {
  5696. try {
  5697.  
  5698. var $this_tr = jQuery(this).closest("tr")[0];
  5699. var totalProd = parseFloat($this_tr.cells[2].textContent.trim());
  5700. var ss = $this_tr.cells[3].textContent.trim();
  5701.  
  5702. var pr = parseFloat(ss.substr(0,ss.indexOf(" ")).trim());
  5703.  
  5704. var $usersAllMoney = jQuery(jQuery("#userMenu .plate")[1]);
  5705. var usersMoney = -1;
  5706. var currency = ss.substr(ss.indexOf(" "), (ss.indexOf("Price") - ss.indexOf(" ")) ).trim();
  5707.  
  5708. var foundIt = false;
  5709. for (var k=1;k<$usersAllMoney[0].childNodes.length;k++) {
  5710. var e = $usersAllMoney[0].childNodes[k];
  5711. if (e.nodeName == "B") {
  5712. usersMoney = e.innerHTML;
  5713. }
  5714. if (e.nodeName == "#text" && e.nodeValue.trim() == currency) {
  5715. foundIt = true;
  5716. break;
  5717. }
  5718. }
  5719.  
  5720. if (!foundIt) {
  5721. usersMoney = -1;
  5722. }
  5723.  
  5724. usersMoney = parseFloat(usersMoney);
  5725.  
  5726. var buyingProds = 0;
  5727. if (usersMoney > 0) {
  5728. buyingProds = parseInt(usersMoney / pr);
  5729.  
  5730. if (buyingProds > totalProd) {
  5731. buyingProds = totalProd;
  5732. }
  5733. }
  5734.  
  5735. jQuery("input[name=quantity]", $this_tr.cells[4]).get(0).value = buyingProds;
  5736. } catch (e) {
  5737. console.log(e);
  5738. }
  5739. });
  5740. }
  5741. } catch (e) {
  5742. console.log(e);
  5743. }
  5744. });
  5745. }
  5746. } catch (e) {
  5747. console.log(e);
  5748. }
  5749.  
  5750. }
  5751.  
  5752.  
  5753.  
  5754.  
  5755. // Redesign product image
  5756. function resizeProductImage( productList ) {
  5757.  
  5758. productList.each( function() {
  5759. var cell = $(this).parent();
  5760. var img = cell.find( "img" );
  5761. cell.children().remove()
  5762.  
  5763. var block = $( "<div style='url('http://e-sim.home.pl/testura/img/stripes.png') repeat scroll 0 0 #3D6571'></div>" );
  5764. //block.append( "<img class='blockProduct 'src='"+ IMGPRODBG +"' />" );
  5765. block.append( img.eq(0).addClass( "productImage" ) );
  5766. if( img.length > 1 ) { block.append( img.eq(1).addClass( "productQuality" ) ); }
  5767.  
  5768. cell.append( block );
  5769. });
  5770. }
  5771.  
  5772.  
  5773. // Relationship between country images and IDs
  5774. /*function ImagesCountryByID( id ) {
  5775.  
  5776. switch( id ) {
  5777. case 1: return( POLAND );
  5778. case 2: return( RUSSIA );
  5779. case 3: return( GERMANY );
  5780. case 4: return( FRANCE );
  5781. case 5: return( SPAIN );
  5782. case 6: return( UK );
  5783. case 7: return( ITALY );
  5784. case 8: return( HUNGARY );
  5785. case 9: return( ROMANIA );
  5786. case 10: return( BULGARIA );
  5787. case 11: return( SERBIA );
  5788. case 12: return( CROATIA );
  5789. case 13: return( BOSNIA );
  5790. case 14: return( GREECE );
  5791. case 15: return( FYROM );
  5792. case 16: return( UKRAINE );
  5793. case 17: return( SWEDEN );
  5794. case 18: return( PORTUGAL );
  5795. case 19: return( LITHUANIA );
  5796. case 20: return( LATVIA );
  5797. case 21: return( SLOVENIA );
  5798. case 22: return( TURKEY );
  5799. case 23: return( BRAZIL );
  5800. case 24: return( ARGENTINA );
  5801. case 25: return( MEXICO );
  5802. case 26: return( USA );
  5803. case 27: return( CANADA );
  5804. case 28: return( CHINA );
  5805. case 29: return( INDONESIA );
  5806. case 30: return( IRAN );
  5807. case 31: return( SOUTHKOREA );
  5808. case 32: return( TAIWAN );
  5809. case 33: return( ISRAEL );
  5810. case 34: return( INDIA );
  5811. case 35: return( AUSTRALIA );
  5812. case 36: return( NETHERLANDS );
  5813. case 37: return( FINLAND );
  5814. case 38: return( IRELAND );
  5815. case 39: return( SWITZERLAND );
  5816. case 40: return( BELGIUM );
  5817. case 41: return( PAKISTAN );
  5818. case 42: return( MALAYSIA );
  5819. case 43: return( NORWAY );
  5820. case 44: return( PERU );
  5821. case 45: return( CHILE );
  5822. case 46: return( COLOMBIA );
  5823. case 51: return( CZECH );
  5824. case 52: return( BELARUS );
  5825. case 53: return( ESTONIA );
  5826. case 54: return( PHILIPPINES );
  5827. }
  5828. }*/
  5829.  
  5830.  
  5831. function IDByImageCountry( img ) {
  5832.  
  5833. switch( img ) {
  5834. case POLAND: return( 1 );
  5835. case RUSSIA: return( 2 );
  5836. case GERMANY: return( 3 );
  5837. case FRANCE: return( 4 );
  5838. case SPAIN: return( 5 );
  5839. case UK: return( 6 );
  5840. case ITALY: return( 7 );
  5841. case HUNGARY: return( 8 );
  5842. case ROMANIA: return( 9 );
  5843. case BULGARIA: return( 10 );
  5844. case SERBIA: return( 11 );
  5845. case CROATIA: return( 12 );
  5846. case BOSNIA: return( 13 );
  5847. case GREECE: return( 14 );
  5848. case FYROM: return( 15 );
  5849. case UKRAINE: return( 16 );
  5850. case SWEDEN: return( 17 );
  5851. case PORTUGAL: return( 18 );
  5852. case LITHUANIA: return( 19 );
  5853. case LATVIA: return( 20 );
  5854. case SLOVENIA: return( 21 );
  5855. case TURKEY: return( 22 );
  5856. case BRAZIL: return( 23 );
  5857. case ARGENTINA: return( 24 );
  5858. case MEXICO: return( 25 );
  5859. case USA: return( 26 );
  5860. case CANADA: return( 27 );
  5861. case CHINA: return( 28 );
  5862. case INDONESIA: return( 29 );
  5863. case IRAN: return( 30 );
  5864. case SOUTHKOREA: return( 31 );
  5865. case TAIWAN: return( 32 );
  5866. case ISRAEL: return( 33 );
  5867. case INDIA: return( 34 );
  5868. case AUSTRALIA: return( 35 );
  5869. case NETHERLANDS: return( 36 );
  5870. case FINLAND: return( 37 );
  5871. case IRELAND: return( 38 );
  5872. case SWITZERLAND: return( 39 );
  5873. case BELGIUM: return( 40 );
  5874. case PAKISTAN: return( 41 );
  5875. case MALAYSIA: return( 42 );
  5876. case NORWAY: return( 43 );
  5877. case PERU: return( 44 );
  5878. case CHILE: return( 45 );
  5879. case COLOMBIA: return( 46 );
  5880. case CZECH: return( 51 );
  5881. case BELARUS: return( 52 );
  5882. case ESTONIA: return( 53 );
  5883. case PHILIPPINES: return( 54 );
  5884. default: return( 0 );
  5885. }
  5886. }
  5887.  
  5888.  
  5889.  
  5890. function IDbyCC( CC ) {
  5891.  
  5892.  
  5893. //prompt("a",CC)
  5894.  
  5895.  
  5896.  
  5897. switch( String(CC) ) {
  5898. case "PLN": return( 1 );
  5899. case "RUB": return( 2 );
  5900. case "DEM": return( 3 );
  5901. case "FRF": return( 4 );
  5902. case "ESP": return( 5 );
  5903. case "GBP": return( 6 );
  5904. case "ITL": return( 7 );
  5905. case "HUF": return( 8 );
  5906. case "RON": return( 9 );
  5907. case "BGN": return( 10 );
  5908. case "RSD": return( 11 );
  5909. case "HRK": return( 12 );
  5910. case "BAM": return( 13 );
  5911. case "GRD": return( 14 );
  5912. case "MKD": return( 15 );
  5913. case "UAH": return( 16 );
  5914. case "SEK": return( 17 );
  5915. case "PTE": return( 18 );
  5916. case "LTL": return( 19 );
  5917. case "LVL": return( 20 );
  5918. case "SIT": return( 21 );
  5919. case "TRY": return( 22 );
  5920. case "BRL": return( 23 );
  5921. case "ARS": return( 24 );
  5922. case "MXN": return( 25 );
  5923. case "USD": return( 26 );
  5924. case "CAD": return( 27 );
  5925. case "CNY": return( 28 );
  5926. case "IDR": return( 29 );
  5927. case "IRR": return( 30 );
  5928. case "KRW": return( 31 );
  5929. case "TWD": return( 32 );
  5930. case "NIS": return( 33 );
  5931. case "INR": return( 34 );
  5932. case "AUD": return( 35 );
  5933. case "NLG": return( 36 );
  5934. case "FIM": return( 37 );
  5935. case "IEP": return( 38 );
  5936. case "CHF": return( 39 );
  5937. case "BEF": return( 40 );
  5938. case "PRK": return( 41 );
  5939. case "MYR": return( 42 );
  5940. case "NOK": return( 43 );
  5941. case "PEN": return( 44 );
  5942. case "CLP": return( 45 );
  5943. case "COP": return( 46 );
  5944. case "CZK": return( 51 );
  5945. case "BYR": return( 52 );
  5946. case "EEK": return( 53 );
  5947. case "PHP": return( 54 );
  5948. default: return( 0 );
  5949. }
  5950. }
  5951.  
  5952. // Change market oferrs
  5953. function changeMarketOffers() {
  5954.  
  5955. var select = $( "#resourceInput" );
  5956. var pos = $( ".storage" ).parent();
  5957. var dest = $( "#quantity" );
  5958.  
  5959. var leftDiv = $( "#productMarketOfferForm" ).parent();
  5960. leftDiv.children().first().remove();
  5961. leftDiv.children().first().remove();
  5962. leftDiv.addClass( "leftDivMyOffers" );
  5963.  
  5964. // Remove all childrens and add help text
  5965. pos.children().remove();
  5966. pos.addClass( "myOffersProduct" );
  5967. pos.append( "One click to select <b>ONE item</b>.<br/>Double click to select <b>ALL items</b>.<br/>" );
  5968.  
  5969. var divBlue = $( "#countryInput" ).parent().parent();
  5970. divBlue.find( "b" ).eq(0).css({ "display" : "inline" });
  5971. divBlue.find( "b" ).eq(1).css({ "display" : "inline" });
  5972.  
  5973. $( "#countryInput" ).addClass( "customSelectList" );
  5974. select.addClass( "customSelectList" );
  5975.  
  5976. firstFastButton = true;
  5977. dest.addClass( "quantityMyOffers" );
  5978. $( "#priceInput" ).addClass( "priceInputMyOffers" );
  5979.  
  5980. var btn10 = $( "<input class='fastBtn FastButtonLeft' type='button' value='10' />" );
  5981. btn10.bind( "click", function() {
  5982. if( firstFastButton ) {
  5983. dest.attr( "value", "10" );
  5984. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 10 );
  5985. firstFastButton = false;
  5986. });
  5987.  
  5988. var btn50 = $( "<input class='fastBtn FastButtonLeft' type='button' value='50' />" );
  5989. btn50.bind( "click", function() {
  5990. if( firstFastButton ) {
  5991. dest.attr( "value", "50" );
  5992. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 50 );
  5993. firstFastButton = false;
  5994. });
  5995.  
  5996. var btn100 = $( "<input class='fastBtn FastButtonRight' type='button' value='100' />" );
  5997. btn100.bind( "click", function() {
  5998. if( firstFastButton ) {
  5999. dest.attr( "value", "100" );
  6000. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 100 );
  6001. firstFastButton = false;
  6002. });
  6003.  
  6004. var btn1000 = $( "<input class='fastBtn FastButtonRight' type='button' value='1K' />" );
  6005. btn1000.bind( "click", function() {
  6006. if( firstFastButton ) {
  6007. dest.attr( "value", "1000" );
  6008. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 1000 );
  6009. firstFastButton = false;
  6010. });
  6011.  
  6012. btn10.insertBefore( dest );
  6013. btn50.insertBefore( dest );
  6014. btn1000.insertAfter( dest );
  6015. btn100.insertAfter( dest );
  6016.  
  6017. orderSelect( select );
  6018. changeSelect( select, pos, dest, "#aaaaaa" );
  6019.  
  6020. $( ".storage" ).bind( "click", function() { setTimeout( mySendPreviewRequest, 500 ); });
  6021. $( "#countryInput" ).unbind( "change" );
  6022. $( "#countryInput" ).bind( "change", function() { mySendPreviewRequest(); });
  6023. $( "#resourceInput" ).unbind( "change" );
  6024. $( "#resourceInput" ).bind( "change", function() { mySendPreviewRequest(); });
  6025. $( "#priceInput" ).unbind( "change" );
  6026. $( "#priceInput" ).bind( "change", function() { mySendPreviewRequest(); });
  6027. $( "#priceInput" ).bind( "keydown", function() { setTimeout( mySendPreviewRequest, 1000 ); });
  6028. }
  6029.  
  6030.  
  6031. // Replace sendPreviewRequest to restyle
  6032. function mySendPreviewRequest() {
  6033. if( !isFormCorrect() ) { return; }
  6034.  
  6035. // If is in the player or in the Stock
  6036. var csFlag;
  6037. var localUrl = new String( window.location );
  6038. if( localUrl.indexOf( URLMarketOffers, 0 ) >= 0 ) {
  6039. csFlag = $( "a[href='pendingCitizenshipApplications.html']" ).prev();
  6040.  
  6041. } else if( localUrl.indexOf( URLStockProducts, 0 ) >= 0 ) {
  6042.  
  6043. csFlag = $("a[href*='stockCompanyAssets.html?id=']").prev().prev().prev().prev().prev().prev();
  6044. //alert(csFlag)
  6045.  
  6046. }
  6047. var citizenship = IDByImageCountry( csFlag.attr( "class" ).split(" ")[1] );
  6048.  
  6049. //alert(citizenship)
  6050.  
  6051. var dataString = 'country=' + $("#countryInput").val() + '&resource=' + $("#resourceInput").val();
  6052. dataString += '&price=' +$("#priceInput").val() + '&citizenship=' + citizenship;
  6053. var resourceType = $("#resourceInput option:selected").text();
  6054. $( "#preview" ).html( "<div class ='previewMyOffers'>Loading tax resource...</div >" );
  6055.  
  6056. $.ajax({
  6057. type: "POST",
  6058. url: "productTaxes.html",
  6059. data: dataString,
  6060. dataType: "html",
  6061. success: function( data ) {
  6062. var preview = $( "#preview" );
  6063. preview.html( data );
  6064. preview.children( ".dataTable" ).addClass( "previewDataTable" );
  6065.  
  6066. var res = $( "<div class='resourceMyOffers'>"+ resourceType + "</div>" );
  6067. var link = getCurrentServer() + URLMarket + "?resource=";
  6068. var splitItem = $("#resourceInput").val().split( "-" );
  6069. if( splitItem.length == 1 ) {
  6070. link += splitItem[0] + "&countryId=" + $("#countryInput").val();
  6071. } else link += splitItem[1] + "&countryId=" + $("#countryInput").val() + "&quality=" + splitItem[0];
  6072. res.append( "<br /><a class='textMyOffers' href='"+ link +"' target='_blank'>Market</a>" );
  6073.  
  6074. link = getCurrentServer() + URLMonetaryMarket + "?buyerCurrencyId="+ $("#countryInput").val() +"&sellerCurrencyId=0";
  6075. res.append( " | <a class='MMMyOffers' href='"+ link +"' target='_blank'>MM link</a>" );
  6076.  
  6077. var flag = preview.find( ".currencyFlag" ).first();
  6078. flag.addClass( "flagMyOffer" );
  6079.  
  6080. // Remove all flags
  6081. preview.find( ".currencyFlag" ).remove();
  6082. res.insertBefore( preview.children().first() );
  6083. flag.insertBefore( preview.children( "b" ).first() );
  6084. preview.children( "b" ).addClass( "titleMyOffers" );
  6085.  
  6086. var thead = preview.children( ".dataTable" ).find( "tr" ).eq(0);
  6087. preview.children( ".dataTable" ).find( "tr" ).eq(1).children().css({ "height" : "25px" });
  6088. thead.children().css({ "height" : "22px" });
  6089. thead.children().eq(0).text( "Gross" );
  6090. thead.children().eq(1).text( "Net" );
  6091. thead.children().eq(3).text( "Tax" );
  6092. }
  6093. });
  6094. }
  6095.  
  6096.  
  6097. // Change monetary market view
  6098. function changeMonetaryMarket() {
  6099.  
  6100. if( $( "#container" ).children().length == 3 ) {
  6101. $( "#container" ).children().last().remove();
  6102. }
  6103. var listBlue = $( "#container" ).find( ".testDivblue" );
  6104. var currentOffersTitle = listBlue.eq(2);
  6105. listBlue.eq(2).hide();
  6106. var currentOffers = listBlue.eq(3);
  6107. var yourOffersTitle = listBlue.eq(4);
  6108. var yourOffers = listBlue.eq(5);
  6109.  
  6110. currentOffers.addClass( "currentOffersMM" );
  6111. yourOffers.addClass( "yourOffersMM" );
  6112. yourOffers.children().last().remove();
  6113.  
  6114. // Custom Selects
  6115. $( "#buy" ).addClass( "customSelectList" );
  6116. $( "#sell" ).addClass( "customSelectList" );
  6117. $( "#offeredMoneyId" ).addClass( "customSelectList" );
  6118. $( "#buyedMoneyId" ).addClass( "customSelectList" );
  6119.  
  6120. // Create new blocks BR
  6121. var block1 = $( "<div class='monetaryMarketTitleBlock'></div>" );
  6122. block1.insertBefore( currentOffersTitle );
  6123. //block1.append( currentOffers );
  6124. block1.append( currentOffersTitle );
  6125.  
  6126.  
  6127. // New button in current offers
  6128. var swapView = $( "<input class='swapView' type='button' value='Swap & View' />" );
  6129. swapView.insertAfter( "#swap2" );
  6130. swapView.bind( "click", function() {
  6131. $( "#swap2" ).click();
  6132. $( "#monetaryMarketView" ).submit();
  6133. });
  6134. $( "#swap2" ).addClass( "swapView" );
  6135. $( "#swap2" ).bind( "click", function() {
  6136. var temp = $( "#offeredMoneyId" ).val();
  6137. $( "#offeredMoneyId" ).val( $( "#buyedMoneyId" ).val() );
  6138. $( "#buyedMoneyId" ).val( temp );
  6139.  
  6140. var currency = "Gold";
  6141. if ( $( "#buyedMoneyId > option:selected" ).text() != "Gold" ) {
  6142. currency = $( "#buyedMoneyId > option:selected" ).text().substr( 0, 3 );
  6143. }
  6144. $( "#offeredRate2" ).text( currency );
  6145.  
  6146. currency = "Gold";
  6147. if ( $( "#offeredMoneyId > option:selected" ).text() != "Gold" ) {
  6148. currency = $( "#offeredMoneyId > option:selected" ).text().substr( 0, 3 );
  6149. }
  6150. $( "#offeredCurrency" ).text( currency );
  6151. $( "#offeredRate1" ).text( currency );
  6152. });
  6153.  
  6154. // Redesign in your offers
  6155. var block2 = $( "<div class='monetaryMarketTitleBlock'></div>" );
  6156. block2.insertBefore( currentOffersTitle );
  6157. block2.append( yourOffersTitle );
  6158. block2.append( currentOffers );
  6159. block2.append( yourOffers );
  6160.  
  6161. $( "#swap1" ).addClass( "swapYourOffers" );
  6162. $( "#swap1" ).bind( "click", function() {
  6163. var temp = $( "#buy" ).val();
  6164. $( "#buy" ).val( $( "#sell" ).val() );
  6165. $( "#sell" ).val( temp );
  6166.  
  6167. if( $( "#offeredMoneyId" ).val() == "0" ) {
  6168. var cc = $( ".monetaryMarketCurrencyBlock" ).find( ".currencySelector[id='"+ $( "#buyedMoneyId" ).val() +"']" );
  6169. var v = "0.0";
  6170. if( cc.length != 0 ) { v = cc.children( "b" ).text(); }
  6171. $( "#value" ).val( v );
  6172.  
  6173. } else $( "#value" ).val( "0.0" );
  6174. });
  6175.  
  6176. $( "#buyedMoneyId" ).next().remove();
  6177. $( "#value" ).addClass( "priceInputMM" );
  6178. $( "#exchangeRatio" ).addClass( "priceInputMM" );
  6179.  
  6180. var blockCurrency = $( "<div class='monetaryMarketCurrencyBlock'></div>" );
  6181. blockCurrency.addClass( "testDivblue" );
  6182. //blockCurrency.append( block1 );
  6183.  
  6184. block1.append( blockCurrency );
  6185.  
  6186. // Add currency block
  6187. var plate = $( "#hiddenMoney" ).parent();
  6188. plate.find( ".flags-small" ).each( function() {
  6189.  
  6190. var id = IDByImageCountry( $(this).attr( "class" ).split(" ")[1] );
  6191. var itemCC = $( "<div class='currencySelector'></div>" );
  6192. itemCC.attr( "id", id );
  6193. if( id == 0 ) { selectedCurrency = itemCC; }
  6194. itemCC.append( "<div class='"+$(this).attr( "class" )+"'></div>" );
  6195. itemCC.append( "<b>"+ $(this).next().text() +" </b>" );
  6196. var currencyName = $( "#buy" ).children( "option[value='"+ id +"']" ).text().split( " " );
  6197. itemCC.append( currencyName[0] );
  6198. blockCurrency.append( itemCC );
  6199.  
  6200. itemCC.bind( "click", function() {
  6201.  
  6202. var idC = $(this).attr( "id" );
  6203. if( (idC != "0") && (idC != selectedCurrency.attr( "id" )) ) {
  6204. if( selectedCurrency ) { selectedCurrency.removeClass( "selectedCurrency" ); }
  6205.  
  6206. if( $( "#buy" ).val() == "0" ) {
  6207. $( "#sell" ).val( idC );
  6208. } else $( "#buy" ).val( idC );
  6209.  
  6210. if( $( "#offeredMoneyId" ).val() == "0" ) {
  6211. $( "#buyedMoneyId" ).val( idC );
  6212. } else $( "#offeredMoneyId" ).val( idC );
  6213.  
  6214. $(this).addClass( "selectedCurrency" );
  6215. selectedCurrency = $(this);
  6216.  
  6217. var currency = "Gold";
  6218. if ( $( "#buyedMoneyId > option:selected" ).text() != "Gold" ) {
  6219. currency = $( "#buyedMoneyId > option:selected" ).text().substr( 0, 3 );
  6220. }
  6221. $( "#offeredRate2" ).text( currency );
  6222.  
  6223. currency = "Gold";
  6224. if ( $( "#offeredMoneyId > option:selected" ).text() != "Gold" ) {
  6225. currency = $( "#offeredMoneyId > option:selected" ).text().substr( 0, 3 );
  6226. }
  6227. $( "#offeredCurrency" ).text( currency );
  6228. $( "#offeredRate1" ).text( currency );
  6229.  
  6230. if( $( "#buyedMoneyId" ).val() == "0" ) {
  6231. $( "#value" ).val( $(this).children( "b" ).text() );
  6232.  
  6233. } else $( "#value" ).val( "0.0" );
  6234. }
  6235. });
  6236. });
  6237.  
  6238. // Add fast buttons
  6239. var idDest = "#value";
  6240. var firstFastButton = true;
  6241. var btn1 = $( "<input class='priceFastButton' type='button' value='1' />" );
  6242. btn1.bind( "click", function() {
  6243. if( firstFastButton ) {
  6244. $( idDest ).attr( "value", "1" );
  6245. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 1 );
  6246. firstFastButton = false;
  6247. });
  6248.  
  6249. var btn5 = $( "<input class='priceFastButton' type='button' value='5' />" );
  6250. btn5.bind( "click", function() {
  6251. if( firstFastButton ) {
  6252. $( idDest ).attr( "value", "5" );
  6253. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 5 );
  6254. firstFastButton = false;
  6255. });
  6256.  
  6257. var btn10 = $( "<input class='priceFastButton' type='button' value='10' />" );
  6258. btn10.bind( "click", function() {
  6259. if( firstFastButton ) {
  6260. $( idDest ).attr( "value", "10" );
  6261. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 10 );
  6262. firstFastButton = false;
  6263. });
  6264.  
  6265. var btn50 = $( "<input class='priceFastButton' type='button' value='50' />" );
  6266. btn50.bind( "click", function() {
  6267. if( firstFastButton ) {
  6268. $( idDest ).attr( "value", "50" );
  6269. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 50 );
  6270. firstFastButton = false;
  6271. });
  6272.  
  6273. var btn100 = $( "<input class='priceFastButton' type='button' value='100' />" );
  6274. btn100.bind( "click", function() {
  6275. if( firstFastButton ) {
  6276. $( idDest ).attr( "value", "100" );
  6277. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 100 );
  6278. firstFastButton = false;
  6279. });
  6280.  
  6281. var btn500 = $( "<input class='priceFastButton' type='button' value='500' />" );
  6282. btn500.bind( "click", function() {
  6283. if( firstFastButton ) {
  6284. $( idDest ).attr( "value", "500" );
  6285. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 500 );
  6286. firstFastButton = false;
  6287. });
  6288.  
  6289. var pos = $( "#offeredRate2" ).next();
  6290. btn1.insertBefore( pos );
  6291. btn5.insertBefore( pos );
  6292. btn10.insertBefore( pos );
  6293. btn50.insertBefore( pos );
  6294. btn100.insertBefore( pos );
  6295. btn500.insertBefore( pos );
  6296.  
  6297. // Add confirm option
  6298. var postButton = $( "<input class='postOfferButton' type='button' value='Post new offer' />" );
  6299. var pos = $( "#monetaryOfferPost" ).children( "center" ).children( "input" );
  6300. postButton.insertBefore( pos );
  6301. pos.hide();
  6302. postButton.click( "click", function() {
  6303. var value = parseFloat( $( "#value" ).val() );
  6304. var change = parseFloat( $( "#exchangeRatio" ).val() );
  6305. var res = confirm( "Sell "+ value +" "+ $( "#offeredCurrency" ).text() +" for "+ (value*change) +" "+ $( "#offeredRate2" ).text() );
  6306. if( res ) { $( "#monetaryOfferPost" ).submit(); }
  6307. });
  6308. }
  6309.  
  6310.  
  6311. // Change monetary market product table
  6312. function changeMonetaryMarketTable() {
  6313.  
  6314. $( ".dataTable" ).find( "input[type='text']" ).addClass( "inputTextTable" );
  6315. var submit = $( ".dataTable" ).find( "input[type='submit']" ).addClass( "inputSubmitTable" );
  6316.  
  6317. // Add buy all button
  6318. var buyAll = $( "<input class='buyAllSubmit' type='submit' value='All' />" );
  6319. buyAll.bind( "click", function() {
  6320. var v = $(this).parent().parent().prev().prev().text().match(/\d{1,10}.\d{1,5}/);
  6321. //alert(v)
  6322. $(this).parent().children( "input[type='text']" ).val( v );
  6323. return( false );
  6324. });
  6325. buyAll.insertBefore( submit );
  6326.  
  6327. // Resize table
  6328. $( ".dataTable" ).addClass( "dataTableMod" );
  6329.  
  6330. // Redesign table
  6331. // Headers
  6332. $( ".dataTable > tbody > tr:first-child > td" ).addClass( "dataTableHeaders" );
  6333. }
  6334.  
  6335.  
  6336. // Add extra links in the shares menu
  6337. function addSharesExtraLinks() {
  6338.  
  6339. var firstRow = true;
  6340. var firstPlate = $( ".testDivwhite" ).first();
  6341. firstPlate.css({ "width" : "570px" });
  6342. firstPlate.children( ".dataTable" ).css({ "width" : "550px" });
  6343. firstPlate.children( ".dataTable:first" ).find( "tr" ).each( function() {
  6344.  
  6345. var td = $( "<td></td>" );
  6346. td.insertAfter( $(this).children().first() );
  6347. if( firstRow ) {
  6348. firstRow = false;
  6349. td.append( "Fast links" );
  6350.  
  6351. } else {
  6352. var idStock = $(this).children().first().find( "a" ).attr( "href" );
  6353. var imgStock = $(this).children().first().find( "img" ).eq(1);
  6354. var linkStock = $( "<a href='"+ idStock +"'></a>" ).insertBefore( imgStock );
  6355. linkStock.append( imgStock );
  6356. var split = idStock.split( "?id=" );
  6357. if( split.length > 1 ) { idStock = split[1]; }
  6358.  
  6359. td.append( "<a style='display:block' href='"+ getCurrentServer() + URLStockMM + idStock +"'>MM offers</a>" );
  6360. td.append( "<a style='display:block' href='"+ getCurrentServer() + URLStockProducts + idStock +"'>Product offers</a>" );
  6361. td.append( "<a style='display:block' href='"+ getCurrentServer() + URLStockDonateMoney + idStock +"'>Donate money</a>" );
  6362. td.append( "<a style='display:block' href='"+ getCurrentServer() + URLStockDonateCompany + idStock +"'>Donate company</a>" );
  6363. td.append( "<a style='display:block' href='"+ getCurrentServer() + URLStockLogs + idStock +"&importance=TRIVIAL '>Logs</a>" );
  6364. }
  6365. });
  6366. }
  6367.  
  6368.  
  6369. // Change stock main div
  6370. function changeStockMainMenu() {
  6371.  
  6372. var listBlue = $( "#contentRow" ).children( "td" ).eq(1).find( ".testDivblue" );
  6373. $( "#contentRow" ).children( "td" ).eq(1).children().eq(1).remove();
  6374.  
  6375. var mainStockInfo = listBlue.eq(0);
  6376. mainStockInfo.children( "br" ).remove();
  6377. mainStockInfo.children( "p" ).remove();
  6378.  
  6379. var rightBlock = mainStockInfo.find( "td" ).eq(1);
  6380. rightBlock.css({ "width" : "350px" });
  6381. rightBlock.children().eq(2).css({ "width" : "70px" });
  6382. rightBlock.children().eq(3).css({ "width" : "275px" });
  6383.  
  6384. var linkWiki = $( "<div class='linkWiki'></div>" );
  6385. var linkImg = $( "<a href='"+ mainStockInfo.children( "a" ).attr( "href" ) +"'></a>" );
  6386. linkWiki.append( linkImg.append( mainStockInfo.children( "img" ) ) );
  6387. linkWiki.append( mainStockInfo.children( "a" ) );
  6388. mainStockInfo.append( linkWiki );
  6389. }
  6390.  
  6391.  
  6392. // Change stock floating divs in the main menu
  6393. function changeStockFloatingDivs() {
  6394.  
  6395. var listWhite = $( "#contentRow" ).children().eq(2).find( ".testDivwhite" );
  6396. var listBlue = $( "#contentRow" ).children().eq(2).find( ".testDivblue" );
  6397.  
  6398. var companyStatute = listWhite.eq(0);
  6399. companyStatute.addClass( "divShareMenu divShareMenuHide" );
  6400. companyStatute.bind( "click", function() {
  6401. if( $(this).hasClass( "divShareMenuHide" ) ) {
  6402. $(this).removeClass( "divShareMenuHide" );
  6403.  
  6404. } else $(this).addClass( "divShareMenuHide" );
  6405. });
  6406.  
  6407. var stockPrice = listWhite.eq(1);
  6408. stockPrice.addClass( "divShareMenu divShareMenuHide" );
  6409. stockPrice.bind( "click", function() {
  6410. if( $(this).hasClass( "divShareMenuHide" ) ) {
  6411. $(this).removeClass( "divShareMenuHide" );
  6412.  
  6413. } else $(this).addClass( "divShareMenuHide" );
  6414. });
  6415.  
  6416. var acts = listBlue.eq(1);
  6417. acts.addClass( "divShareMenu divShareMenuMediumHide" );
  6418. acts.bind( "click", function() {
  6419. if( $(this).hasClass( "divShareMenuMediumHide" ) ) {
  6420. $(this).removeClass( "divShareMenuMediumHide" );
  6421.  
  6422. } else $(this).addClass( "divShareMenuMediumHide" );
  6423. });
  6424.  
  6425. var staff = listBlue.eq(2);
  6426. staff.addClass( "divShareMenu divShareMenuMediumHide" );
  6427. staff.bind( "click", function() {
  6428. if( $(this).hasClass( "divShareMenuMediumHide" ) ) {
  6429. $(this).removeClass( "divShareMenuMediumHide" );
  6430.  
  6431. } else $(this).addClass( "divShareMenuMediumHide" );
  6432. });
  6433.  
  6434. var companies = listBlue.eq(3);
  6435. var shouts = listBlue.eq(4);
  6436. shouts.insertBefore( companies );
  6437. companies.insertBefore( stockPrice );
  6438.  
  6439. var sharesMarket = listWhite.eq(2);
  6440. stockPrice.insertBefore( sharesMarket );
  6441. $( "<br/>" ).insertAfter( stockPrice );
  6442.  
  6443. companies.addClass( "divShareMenuFixed" ).css({ "width" : "340px" });
  6444. shouts.addClass( "divShareMenuFixed" );
  6445.  
  6446. sharesMarket.addClass( "divShareMenuFixed" );
  6447. listWhite.eq(3).addClass( "divShareMenuFixed" );
  6448. }
  6449.  
  6450.  
  6451. // Change product selection in a stock company
  6452. function changeStockProductSelection() {
  6453.  
  6454. var pos = $( ".testDivwhite" );
  6455. var select = $( "#resourceInput" );
  6456. if( select.length == 0 ) {
  6457.  
  6458. pos.addClass( "storageUnselectStock" );
  6459. pos.children( "br" ).remove();
  6460.  
  6461. } else {
  6462. var dest = $( "#resourceInput" ).next().next();
  6463.  
  6464. // Remove all childrens and add help text
  6465. pos.children().remove();
  6466. pos.addClass( "storageSelectStock" );
  6467. pos.append( "One click to select <b>ONE item</b>. Double click to select <b>ALL items</b>.<br/>" );
  6468.  
  6469. var divBlue = $( "#countryInput" ).parent().parent();
  6470. divBlue.addClass( "formSelectStock" );
  6471. divBlue.find( "b" ).eq(0).css({ "display" : "inline" });
  6472. divBlue.find( "b" ).eq(1).css({ "display" : "inline" });
  6473. divBlue.insertAfter( pos );
  6474.  
  6475. $( "#countryInput" ).addClass( "customSelectList" );
  6476. select.addClass( "customSelectList" );
  6477.  
  6478. orderSelect( select );
  6479. changeSelect( select, pos, dest, "#aaaaaa" );
  6480.  
  6481. firstFastButton = true;
  6482. dest.val( "1" );
  6483. dest.addClass( "quantityMyOffers" );
  6484. $( "#priceInput" ).val( "1.0" );
  6485. $( "#priceInput" ).addClass( "priceInputMyOffers" );
  6486.  
  6487. var btn10 = $( "<input class='fastBtn FastButtonLeft' type='button' value='10' />" );
  6488. btn10.bind( "click", function() {
  6489. if( firstFastButton ) {
  6490. dest.attr( "value", "10" );
  6491. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 10 );
  6492. firstFastButton = false;
  6493. });
  6494.  
  6495. var btn50 = $( "<input class='fastBtn FastButtonLeft' type='button' value='50' />" );
  6496. btn50.bind( "click", function() {
  6497. if( firstFastButton ) {
  6498. dest.attr( "value", "50" );
  6499. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 50 );
  6500. firstFastButton = false;
  6501. });
  6502.  
  6503. var btn100 = $( "<input class='fastBtn FastButtonRight' type='button' value='100' />" );
  6504. btn100.bind( "click", function() {
  6505. if( firstFastButton ) {
  6506. dest.attr( "value", "100" );
  6507. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 100 );
  6508. firstFastButton = false;
  6509. });
  6510.  
  6511. var btn1000 = $( "<input class='fastBtn FastButtonRight' type='button' value='1K' />" );
  6512. btn1000.bind( "click", function() {
  6513. if( firstFastButton ) {
  6514. dest.attr( "value", "1000" );
  6515. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 1000 );
  6516. firstFastButton = false;
  6517. });
  6518.  
  6519. btn10.insertBefore( dest );
  6520. btn50.insertBefore( dest );
  6521. btn1000.insertAfter( dest );
  6522. btn100.insertAfter( dest );
  6523.  
  6524. $( ".storage" ).bind( "click", function() { setTimeout( mySendPreviewRequest, 500 ); });
  6525. $( "#countryInput" ).unbind( "change" );
  6526. $( "#countryInput" ).bind( "change", function() { mySendPreviewRequest(); });
  6527. $( "#resourceInput" ).unbind( "change" );
  6528. $( "#resourceInput" ).bind( "change", function() { mySendPreviewRequest(); });
  6529. $( "#priceInput" ).unbind( "change" );
  6530. $( "#priceInput" ).bind( "change", function() { mySendPreviewRequest(); });
  6531. $( "#priceInput" ).bind( "keydown", function() { setTimeout( mySendPreviewRequest, 1000 ); });
  6532. }
  6533. }
  6534.  
  6535.  
  6536. // Change travel menu
  6537. function changeTravelMenu() {
  6538.  
  6539. var minTicket = 0;
  6540. var vecItems = [];
  6541. var plate = $( "#citizenTravelForm" ).parent().addClass( "citizenTravelFormMod" );
  6542. $( "#citizenTravelForm" ).children( "input" ).addClass( "citizenTravelFormInput" );
  6543.  
  6544. $( "#citizenshipSelect" ).addClass( "customSelectList" );
  6545. $( "#regionId" ).addClass( "customSelectList" );
  6546. $( "<br/>" ).insertBefore( $( "#regionId" ).parent() );
  6547.  
  6548. var marginBlock = $( "<div class='centerBlockTravel'></div>" );
  6549. var block = $( "<table class='blockTravel testDivwhite'></table>" );
  6550. marginBlock.append( block );
  6551.  
  6552. var selectedTicket = null;
  6553. $( "#ticketQuality" ).find( "option" ).each( function() {
  6554.  
  6555. var q = $(this).attr( "value" );
  6556. //alert(q)
  6557. var ticket = $( "<td class='ticketTravel' indexselect='"+ q +"'></td>" );
  6558. ticket.append( "<img src='"+ IMGTICKET +"' class='imageTicket' />" );
  6559. ticket.append( "<div class='healthTicket'>- "+ (40 - ((q-1) * 10)) +"</div>" );
  6560. ticket.append( "<img src='"+ IMGQUALITY + $(this).attr( "value" ) +".png' class='imageQuality' />" );
  6561. block.append( ticket );
  6562.  
  6563. // Find number of items
  6564. var n = 0;
  6565. $( "#userMenu" ).find( ".storageMini" ).each( function() {
  6566. var prod = $(this).find( "div:eq(1)" );
  6567. //alert(prod.find("img:eq(1)").attr( "src" ).replace( IMGQUALITY, "" ).replace( IMGEXTENSION, "" ))
  6568. if( prod.find("img:eq(0)").attr("src") == IMGTICKET ) {
  6569. if( q == prod.find("img:eq(1)").attr( "src" ).replace( IMGQUALITY, "" ).replace( IMGEXTENSION, "" ) ) {
  6570. n = parseInt( $(this).text());
  6571. //alert($(this).text());
  6572.  
  6573.  
  6574. }
  6575. }
  6576. });
  6577.  
  6578. ticket.append( "<div class='numberItems'>"+ n +"</div>" );
  6579.  
  6580. if( n > 0 ) {
  6581. if( minTicket == 0 ) { minTicket = q; }
  6582.  
  6583. ticket.bind( "mouseover", function() {
  6584. if( selectedTicket.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).addClass( "ticketHover" ); }
  6585. });
  6586.  
  6587. ticket.bind( "mouseout", function() {
  6588. if( selectedTicket.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).removeClass( "ticketHover" ); }
  6589. });
  6590.  
  6591. ticket.bind( "click", function() {
  6592. if( selectedTicket ) { selectedTicket.removeClass( "ticketSelected" ); }
  6593. selectedTicket = $(this);
  6594. $(this).addClass( "ticketSelected" );
  6595. $( "#ticketQuality option" )[ $(this).attr( "indexselect" )-1 ].selected = true;
  6596. });
  6597.  
  6598. } else ticket.addClass( "disabledTicket" );
  6599. vecItems.push( ticket );
  6600. });
  6601.  
  6602. // Default min ticket
  6603. if( minTicket > 0 ) { vecItems[ minTicket-1].click() }
  6604.  
  6605. $( "<br/>" ).insertAfter( $( "#ticketQuality" ).parent() );
  6606. $( "#ticketQuality" ).prev().remove();
  6607. $( "#ticketQuality" ).prev().remove();
  6608. $( "#ticketQuality" ).css({ "display" : "none" });
  6609. block.insertBefore( $( "#ticketQuality" ) );
  6610.  
  6611. // Check GET vars
  6612. var urlVars = getUrlVars();
  6613. if( (urlVars[ "idc" ] != undefined) && (urlVars[ "idr" ] != undefined) ) {
  6614.  
  6615. $( "#citizenshipSelect" ).val( urlVars[ "idc" ] );
  6616. $.ajax({
  6617. url: "countryRegions.html",
  6618. context: document.body,
  6619. type: "POST",
  6620. data: { countryId : urlVars[ "idc" ] },
  6621. success: function( data ) {
  6622. $( "#regionId" ).find( "option" ).remove();
  6623. var json = jQuery.parseJSON( data );
  6624. for( var i=0; i<json.length; i++ ) {
  6625. $( "#regionId" ).append( "<option value='"+ json[i][0] +"'>"+ json[i][1] +"</option>" );
  6626. }
  6627. $( "#regionId" ).val( urlVars[ "idr" ] );
  6628. }
  6629. });
  6630. }
  6631. }
  6632.  
  6633.  
  6634. // Redesign equipment
  6635. function redesignEquipment() {
  6636.  
  6637. var block = $( ".equipmentName" ).parent();
  6638. var remove = "<div class='removeItem'>CLICK TO REMOVE</div>"
  6639. var formHelmet = $( ".equipmentBox" ).last().next();
  6640. var formVision = formHelmet.next();
  6641. var formArmor = formVision.next();
  6642. var formWeapon = formArmor.next();
  6643. var formOffhand = formWeapon.next();
  6644.  
  6645. // Rellocate equipment interaction
  6646. var helmet = $( ".equipmentName" ).eq(0).addClass( "helmetTitle" );
  6647. $( ".equipmentBox" ).eq(0).append( helmet );
  6648. $( ".equipmentBack" ).eq(0).children().first().append( remove );
  6649. $( ".equipmentBack" ).eq(0).bind( "click", function() { if( formHelmet.is( "form" ) ) { formHelmet.children( "input" ).last().click(); } });
  6650.  
  6651. var vision = $( ".equipmentName" ).eq(1).addClass( "visionTitle" );
  6652. $( ".equipmentBox" ).eq(1).append( vision );
  6653. $( ".equipmentBack" ).eq(1).children().first().append( remove );
  6654. $( ".equipmentBack" ).eq(1).bind( "click", function() { if( formVision.is( "form" ) ) { formVision.children( "input" ).last().click(); } });
  6655.  
  6656. var armor = $( ".equipmentName" ).eq(2).addClass( "armorTitle" );
  6657. $( ".equipmentBox" ).eq(2).append( armor );
  6658. $( ".equipmentBack" ).eq(2).children().first().append( remove );
  6659. $( ".equipmentBack" ).eq(2).bind( "click", function() { if( formArmor.is( "form" ) ) { formArmor.children( "input" ).last().click(); } });
  6660.  
  6661. var weapon = $( ".equipmentName" ).eq(3).addClass( "weaponTitle" );
  6662. $( ".equipmentBox" ).eq(3).append( weapon );
  6663. $( ".equipmentBack" ).eq(3).children().first().append( remove );
  6664. $( ".equipmentBack" ).eq(3).bind( "click", function() { if( formWeapon.is( "form" ) ) { formWeapon.children( "input" ).last().click(); } });
  6665.  
  6666. var offhand = $( ".equipmentName" ).eq(4).addClass( "offhandTitle" );
  6667. $( ".equipmentBox" ).eq(4).append( offhand );
  6668. $( ".equipmentBack" ).eq(4).children().first().append( remove );
  6669. $( ".equipmentBack" ).eq(4).bind( "click", function() { if( formOffhand.is( "form" ) ) { formOffhand.children( "input" ).last().click(); } });
  6670.  
  6671. // Change remove mode
  6672. $( ".equipmentBack" ).each( function() {
  6673. if( !$(this).hasClass( "q0" ) ) {
  6674. $(this).css({ "cursor" : "pointer" });
  6675.  
  6676. $(this).bind( "mouseover", function() { $(this).find( ".removeItem" ).css({ "visibility" : "visible" }); });
  6677. $(this).bind( "mouseout", function() { $(this).find( ".removeItem" ).css({ "visibility" : "hidden" }); });
  6678. }
  6679. });
  6680.  
  6681. block.hide();
  6682. }
  6683.  
  6684.  
  6685. // Calculate equipment damage
  6686. function calculateEquipmentDamage() {
  6687. $( "#profileEquipment" ).parent().css({ "margin-left" : "11px", "height" : "220px" });
  6688.  
  6689. // Get values
  6690. var n = 1000;
  6691. var hitList = [ 0, 50, 100, 155 ];
  6692. var damageSplit = $( "#hitHelp" ).text().split( "/" );
  6693. var minDamage = parseInt( damageSplit[0].replace( ",", "" ) );
  6694. var maxDamage = parseInt( damageSplit[1].replace( ",", "" ) );
  6695. var critical = parseFloat( $( "#criticalHelp" ).text().replace( "%", "" ) );
  6696. var miss = parseFloat( $( "#missHelp" ).text().replace( "%", "" ) );
  6697. var avoid = parseFloat( $( "#avoidHelp" ).text().replace( "%", "" ) );
  6698.  
  6699. // Save all data to use it in the battle page
  6700. setValue( "playerMinDamage", minDamage );
  6701. setValue( "playerMaxDamage", maxDamage );
  6702. setValue( "playerCritical", critical );
  6703. setValue( "playerMiss", miss );
  6704. setValue( "playerAvoid", avoid );
  6705.  
  6706. // Default bonus settins, MU and location active
  6707. var muBonus = 1;
  6708. var locBonus = 1.2;
  6709. var sdBonus = 1;
  6710. var hBonus = 1;
  6711.  
  6712. // Create block
  6713. var block = $( "<div id='blockDamage' class='testDivwhite'></div>" );
  6714. block.append( "<div class='titleDamage'>Average damage in "+ n +" simulations</div>" );
  6715. block.insertBefore( $( "#profileEquipment" ).parent() );
  6716.  
  6717. // Damage block
  6718. var configDamage = $( "<div class='configDamage'></div>" );
  6719.  
  6720. // MU bonus
  6721. var MUCheck = $( "<input id='MUCheck' type='checkBox' class='itemBonus' title='No MU data' />" );
  6722. configDamage.append( "<div class='labelLeftConfig'>MU</div>" );
  6723. configDamage.append( MUCheck );
  6724. // Stupid idea to disable MU tooltip
  6725. if( getValue( "MURank" ) ) {
  6726. muBonus = parseInt( getValue( "MURank" ) );
  6727.  
  6728. } else configDamage.append( "<div style='width:15px; height:15px; position:absolute; margin:-22px 0px 0px 25px;'></div>" );
  6729.  
  6730. // Location bonus
  6731. var locationCheck = $( "<input id='locCheck' type='checkBox' class='itemBonus' checked='checked' />" );
  6732. configDamage.append( "<div class='labelRightConfig'>LOCATION</div>" );
  6733. configDamage.append( locationCheck );
  6734. configDamage.append( "<br/>" );
  6735.  
  6736. // SD bonus
  6737. var sdCheck = $( "<select id='sdCheck' class='itemBonus customSelectList'></select>" );
  6738. for( var i=0; i<=5; i++ ) {
  6739. sdCheck.append( "<option value='"+ 5*i +"'>Q"+ i +"</option>" );
  6740. }
  6741. configDamage.append( "<div class='labelLeftConfig'>SD</div>" );
  6742. configDamage.append( sdCheck );
  6743.  
  6744. // Hospital bonus
  6745. var hCheck= $( "<select id='hCheck' class='itemBonus customSelectList'></select>" );
  6746. for( var i=0; i<=5; i++ ) {
  6747. hCheck.append( "<option value='"+ 5*i +"'>Q"+ i +"</option>" );
  6748. }
  6749. configDamage.append( "<div class='labelRightConfig'>HOSPITAL</div>" );
  6750. configDamage.append( hCheck );
  6751.  
  6752. // Calculate button
  6753. var calculate = $( "<input class='calculateBonus' type='button' value='Calculate' />" );
  6754. configDamage.append( calculate );
  6755.  
  6756. // Fill table
  6757. var tableDamage = $( "<table class='tableDamage'></table>" );
  6758. for( var i=0; i<=5; i++ ) {
  6759. var tr = $( "<tr></tr>" );
  6760. for( var j=0; j<hitList.length; j++ ) {
  6761. if( hitList[j] == 0 ) {
  6762. if( i != 0 ) {
  6763. tr.append( "<td class='tableQuality'>Q"+ i +"</td>" );
  6764. } else tr.append( "<td></td>" );
  6765.  
  6766. } else if( i == 0 ) {
  6767. if( hitList[j] != 0 ) {
  6768. var input = $( "<input class='hitList' type='text' value='"+ hitList[j] +"' maxlength='3' />" );
  6769. var td = $( "<td class='tableHits' title='You can edit this number!'></td>" );
  6770. td.tooltip({ tooltipClass: "tooltipHitDamage", position: { my: "center bottom", at: "center top" } });
  6771. td.append( input );
  6772. tr.append( td );
  6773. } else tr.append( "<td></td>" );
  6774.  
  6775. } else tr.append( "<td class='dataDamage'>0</td>" );
  6776. }
  6777. tableDamage.append( tr );
  6778. }
  6779.  
  6780. block.append( tableDamage );
  6781. block.append( configDamage );
  6782.  
  6783. if( getValue( "MURank" ) ) {
  6784. muBonus = 1 + (parseInt( getValue( "MURank" ) ) / 100);
  6785. $( "#MUCheck" ).attr( "checked", "checked" );
  6786. } else {
  6787. $( "#MUCheck" ).prev().css({ "text-decoration" : "line-through" });
  6788. $( "#MUCheck" ).attr( "disabled", "disabled" );
  6789. }
  6790.  
  6791. updateDamageTable( minDamage, maxDamage, muBonus, locBonus, sdBonus, hBonus, critical, miss, avoid, hitList, n );
  6792.  
  6793. configDamage.find( ".itemBonus" ).bind( "change", function() {
  6794. updateDamageTable( minDamage, maxDamage, muBonus, locBonus, sdBonus, hBonus, critical, miss, avoid, hitList, n );
  6795. });
  6796. configDamage.find( ".calculateBonus" ).bind( "click", function() {
  6797. updateDamageTable( minDamage, maxDamage, muBonus, locBonus, sdBonus, hBonus, critical, miss, avoid, hitList, n );
  6798. });
  6799. }
  6800.  
  6801.  
  6802. // Calculate iteration damage
  6803. function calculateHitsDamage( min, max, mu, loc, sd, h, cr, miss, avoid, weapon, hits, n ) {
  6804. hits = hits * h; // Hospital hits
  6805.  
  6806. // We do it for Berserks
  6807. var nBK = parseInt( hits / 5 );
  6808. var mod = hits % 5;
  6809. var averageDamage = 0;
  6810. var bonus = 100 + (weapon * 20);
  6811. var maxDamage = 0;
  6812. var minDamage = Number.MAX_VALUE;
  6813. for( var j=0; j<n; j++ ) {
  6814. var totalDmg = 0;
  6815.  
  6816. for( var i=0; i<nBK; i++ ) {
  6817. var damage = (min + parseInt((max-min)/2))*5 * bonus/100;
  6818. totalDmg += damage * mu * loc * sd;
  6819.  
  6820. // Critical
  6821. if( Math.random()*100 < cr ) { totalDmg += damage; }
  6822.  
  6823. // Miss
  6824. if( Math.random()*100 < miss ) { totalDmg -= damage; }
  6825.  
  6826. // Avoid
  6827. if( Math.random()*100 < avoid ) { i--; }
  6828. }
  6829.  
  6830. if( mod != 0 ) { totalDmg += (mod * totalDmg / (nBK*5)); }
  6831. maxDamage = maxDamage > totalDmg ? maxDamage : totalDmg;
  6832. minDamage = minDamage < totalDmg ? minDamage : totalDmg;
  6833. averageDamage += totalDmg;
  6834. }
  6835.  
  6836. return( [ parseInt( averageDamage/n ), pointNumber( parseInt( minDamage ) ), pointNumber( parseInt( maxDamage ) ) ] );
  6837. }
  6838.  
  6839.  
  6840. // Update table data
  6841. function updateDamageTable( minDamage, maxDamage, muBonus, locBonus, sdBonus, hBonus, critical, miss, avoid, hitList, n ) {
  6842. locBonus = $( "#locCheck" ).attr( "checked" ) ? 1.2 : 1;
  6843. sdBonus = 1 + parseInt( $( "#sdCheck" ).val() )/100;
  6844. hBonus = 1 + parseInt( $( "#hCheck" ).val() )/100;
  6845. if( $( "#MUCheck" ).attr( "checked" ) ) {
  6846. if( getValue( "MURank" ) ) { muBonus = 1 + (parseInt( getValue( "MURank" ) ) / 100); }
  6847. } else muBonus = 1;
  6848.  
  6849. var table = $( ".tableDamage" );
  6850. for( var i=1; i<=5; i++ ) {
  6851. var tr = table.find( "tr" ).eq(i);
  6852. for( var j=1; j<hitList.length; j++ ) {
  6853. var hits = parseInt( table.find( ".hitList" ).eq(j-1).val() );
  6854. var dmg = calculateHitsDamage( minDamage, maxDamage, muBonus, locBonus, sdBonus, hBonus, critical, miss, avoid, i, hits, n );
  6855. tr.children( "td" ).eq( j ).text( pointNumber( dmg[0] ) );
  6856. tr.children( "td" ).eq( j ).tooltip({ tooltipClass: "tooltipHitDamage", position: { my: "center bottom", at: "center top" } });
  6857. tr.children( "td" ).eq( j ).attr( "title", "<b>"+ dmg[1] +" - "+ dmg[2] +"</b>" );
  6858. }
  6859. }
  6860. }
  6861.  
  6862.  
  6863. // Add update salaries in the company menĂş
  6864. function addCompanyButtons() {
  6865.  
  6866. // Get the country ID
  6867. var countryId = IDByImageCountry( $( "a[href^='region.html']" ).prev().attr('class').split(' ')[1]);
  6868. var workerList = $( ".workerListDiv" );
  6869. var offerList = $( ".offerListDiv" );
  6870.  
  6871. var updateSalaries = $( "<input class='updateSalariesButton' type='button' value='Update salaries'/>" );
  6872. updateSalaries.insertBefore( workerList.children().first() );
  6873. updateSalaries.bind( "click", function() {
  6874.  
  6875. // Clean previous results
  6876. workerList.find( ".redText" ).remove();
  6877. workerList.find( ".greenText" ).remove();
  6878.  
  6879. var i=0;
  6880. var checkedSkills = [];
  6881. workerList.find( ".tableRow" ).each( function() {
  6882.  
  6883. // First get the skill number
  6884. var tdList = $(this).find( "td" );
  6885. var skill = parseInt( tdList.eq(1).text() );
  6886. if( checkedSkills.indexOf( skill ) == -1 ) {
  6887. checkedSkills.push( skill );
  6888.  
  6889. setTimeout( function() {
  6890. $.ajax({
  6891. url: getCurrentServer() + URLJobMarket + "?countryId="+ countryId +"&minimalSkill="+ skill,
  6892. success: function( data ) {
  6893.  
  6894. var trList = $( data ).find( ".dataTable" ).find( "tr" );
  6895. // We take the first row
  6896. var salary = trList.eq(1).find( "td" ).eq(4).children( "b" ).text();
  6897. salary = parseFloat( salary );
  6898.  
  6899. workerList.find( ".workerSkill" + skill ).each( function() {
  6900. var classColor;
  6901. var percent;
  6902. var workerSalary = parseFloat( $(this).children( ".salary" ).children( "b" ).text() );
  6903. if( workerSalary < salary ) {
  6904. classColor = "redText";
  6905. percent = "-" + parseInt((salary / workerSalary -1) * 10000) / 100;
  6906.  
  6907. } else {
  6908. classColor = "greenText";
  6909. percent = "+" + parseInt((workerSalary / salary - 1) * 10000) / 100;
  6910. }
  6911. $(this).append( "<b class='"+ classColor +"'>"+ salary +" ("+ percent +"%)</b>" );
  6912. });
  6913. }
  6914. });
  6915. }, 500*i );
  6916. i++;
  6917. }
  6918. });
  6919. });
  6920.  
  6921. var updateJobs = $( "<input class='updateJobsButton' type='button' value='Update jobs'/>" );
  6922. updateJobs.insertBefore( workerList.children().first() );
  6923. updateJobs.bind( "click", function() {
  6924.  
  6925. var id = getUrlVars()[ "id" ];
  6926. $.ajax({
  6927. url: getCurrentServer() + URLCompanyDetails + id,
  6928. success: function( data ) {
  6929. $( data ).find( "#productivityTable" ).find( "tr" ).each( function() {
  6930. var td = $(this).children( "td" ).last();
  6931. var player = $(this).find( "a" );
  6932. if( player ) {
  6933. var place = workerList.find( "a[href='"+ player.attr( "href" ) +"']" ).parent();
  6934. if( td.children( "div" ).length == 2 ) {
  6935. place.append( "<br/>" );
  6936. place.append( "<b>"+ td.children().eq(1).text().replace( "(", "" ).replace( ")", "" ) +"</b>" );
  6937. place.addClass( "greenBackgroundCompany" );
  6938.  
  6939. } else place.addClass( "redBackgroundCompany" );
  6940. }
  6941. });
  6942. }
  6943. });
  6944. });
  6945. }
  6946.  
  6947.  
  6948. // Improve company interface
  6949. function companyImprovements() {
  6950. if( $( "#minimalSkill option" ).length == 14 ) {
  6951. $( "#minimalSkill" ).append( "<option value='15'>15</option>" );
  6952. $( "#minimalSkill" ).append( "<option value='16'>16</option>" );
  6953. }
  6954.  
  6955. var listBlue = $( "#container" ).find( ".testDivblue" );
  6956. var mainMenu = listBlue.eq(2).find( "table" ).eq(1);
  6957. var rowRemove = mainMenu.find( "tr" ).first().children( "td" ).first();
  6958. rowRemove.next().children().css({ "max-width" : "100%" });
  6959. rowRemove.remove();
  6960.  
  6961. // Get the country ID
  6962. var countryId = IDByImageCountry( $( "a[href^='region.html']" ).prev().attr('class').split(' ')[1] );
  6963.  
  6964. // Rellocate some items
  6965. if( listBlue.length == 6 ) {
  6966.  
  6967. var workerList = listBlue.eq(5);
  6968. var offerList = listBlue.eq(4);
  6969. var uglyBox = listBlue.eq(3);
  6970. var createJob = uglyBox.children().first();
  6971. uglyBox.children().first().remove();
  6972.  
  6973. createJob.insertBefore( uglyBox );
  6974. $( "<br/>" ).insertBefore( uglyBox );
  6975. var divBlock = $( "<div style='display:inline-block; width:100%'></div>" )
  6976. divBlock.insertBefore( uglyBox );
  6977. divBlock.append( offerList );
  6978. divBlock.append( workerList );
  6979. uglyBox.css({ "margin-top" : "15px" });
  6980.  
  6981. createJob.removeClass( "testDivwhite" );
  6982. createJob.addClass( "testDivblue" ).css({ "width" : "680px" });
  6983. createJob.children( "p" ).remove();
  6984.  
  6985. var selectedSkill = null;
  6986. $( "#minimalSkill option" ).each( function() {
  6987.  
  6988. var skill = $( "<div class='skillSelector'>"+ $(this).val() +"</div>" );
  6989. skill.insertBefore( "#minimalSkill" );
  6990.  
  6991. skill.bind( "click", function() {
  6992. if( selectedSkill ) { selectedSkill.removeClass( "skillSelectorSelected" ); }
  6993.  
  6994. selectedSkill = $(this);
  6995. selectedSkill.addClass( "skillSelectorSelected" );
  6996. $( "#minimalSkill" ).val( selectedSkill.text() );
  6997.  
  6998. var link = getCurrentServer() + URLJobMarket + "?countryId="+ countryId +"&minimalSkill="+ $(this).text();
  6999. $( ".companyLinkOffers" ).attr( "href", link );
  7000. });
  7001. });
  7002. $( "#minimalSkill" ).hide();
  7003.  
  7004. var firstLine = $( "#minimalSkill" ).parent();
  7005. firstLine.attr( "colspan", "4" );
  7006. createJob.find( "table" ).css({ "width" : "100%" });
  7007.  
  7008. var tr = $( "<tr></tr>" );
  7009. tr.append( firstLine.next().css({ "width" : "33%" }) );
  7010. var td = $( "<td style='width:18%;'></td>" );
  7011. var link = $( "<a class='companyLinkOffers' href='' target='_blank'>View skill offers</a>" );
  7012. tr.append( td.append( link ) );
  7013. tr.append( firstLine.next().css({ "width" : "17%" }) );
  7014. tr.append( firstLine.next().css({ "width" : "26%" }) );
  7015. firstLine.parent().parent().append( tr );
  7016.  
  7017. $( ".skillSelector" ).first().click();
  7018. $( "#price" ).addClass( "priceInputCompany" );
  7019. $( "#price" ).bind( "focus", function() { $(this).select(); });
  7020. $( "#quantity" ).addClass( "quantityMyOffers" );
  7021. $( "#quantity" ).bind( "focus", function() { $(this).select(); });
  7022.  
  7023. } else {
  7024. var workerList = listBlue.eq(4);
  7025. var offerList = listBlue.eq(3);
  7026. }
  7027.  
  7028. workerList.addClass( "workerListDiv" );
  7029. offerList.addClass( "offerListDiv" );
  7030.  
  7031. // Remove useless space
  7032. mainMenu.children( "p" ).remove();
  7033.  
  7034. // Edit image size
  7035. mainMenu.find( ".productLabelRight" ).css({ "height" : "auto", "width" : "40px" });
  7036. //resizeProductImage( mainMenu.find( ".product" ) );
  7037.  
  7038. // Add extra links to check salaries
  7039. workerList.find( ".tableRow" ).each( function() {
  7040. var tdList = $(this).find( "td" );
  7041. // First get the skill number
  7042. var skill = parseInt( tdList.eq(1).text() );
  7043. var viewLink = $( "<a href='"+ getCurrentServer() + URLJobMarket + "?countryId="+ countryId +"&minimalSkill="+ skill +"'>View</a>" );
  7044. tdList.eq(1).append( "<br/>" );
  7045. tdList.eq(1).append( viewLink );
  7046. tdList.eq(2).addClass( "workerSkill" + skill );
  7047. });
  7048.  
  7049. $( "input[name=newSalary]" ).addClass( "priceInputCompany" );
  7050. $( "input[name=newSalary]" ).bind( "focus", function() { $(this).select(); });
  7051. $( "input[name=salary]" ).addClass( "priceInputCompany" );
  7052. $( "input[name=salary]" ).bind( "focus", function() { $(this).select(); });
  7053. }
  7054.  
  7055.  
  7056. // Improve company work results
  7057. function companyWorkResults() {
  7058.  
  7059. // Redesign first block
  7060. var listBlue = $( "#container" ).find( ".testDivwhite " );
  7061. var mainMenu = listBlue.find( "table" );
  7062. mainMenu.find( ".productLabelRight" ).css({ "height" : "auto", "width" : "40px" });
  7063. resizeProductImage( mainMenu.find( ".product" ) );
  7064.  
  7065. //var rowRemove = mainMenu.find( "tr" ).first().children( "td" ).first();
  7066. //rowRemove.next().children().css({ "max-width" : "100%" });
  7067. //rowRemove.remove();
  7068.  
  7069. // Add button to get salary
  7070. var divConfig = $( "<div class='testDivblue' style='width:500px;'></div>" );
  7071. var buttonUpdate = $( "<input class='companyGetSalary' type='button' value='Calculate'/>" );
  7072. divConfig.append( buttonUpdate );
  7073. divConfig.insertAfter( listBlue.prev() );
  7074.  
  7075. var mainBlock = $( "#container" ).find( ".testDivwhite" );
  7076. var idCompany = getUrlVars()[ "id" ];
  7077. buttonUpdate.bind( "click", function() {
  7078.  
  7079. // Remove previous col
  7080. $( "td.playerSalary" ).remove();
  7081.  
  7082. // Add new col
  7083. var index = 0;
  7084. mainBlock.find( "tr" ).each( function() {
  7085. var td = $( "<td class='playerSalary'></td>" );
  7086. if( index == 0 ) { td.append( "Salary" ); }
  7087. $(this).append( td );
  7088. index++;
  7089. });
  7090.  
  7091. mainBlock.css({ "width" : "785px" });
  7092. mainBlock.find( "table" ).css({ "width" : "100%" });
  7093.  
  7094. $.ajax({
  7095. url: getCurrentServer() + URLCompany + idCompany,
  7096. success: function( data ) {
  7097. var blue = $(data).find( ".testDivblue" );
  7098. //alert(blue.length)
  7099. if( blue.length == 6 ) {
  7100. var playerList = blue.eq(5).find( ".tableRow" );
  7101. } else var playerList = blue.eq(4).find( ".tableRow" );
  7102. checkPlayersSalary( playerList, mainBlock );
  7103. }
  7104. });
  7105. });
  7106. }
  7107.  
  7108.  
  7109. // Check player salary
  7110. function checkPlayersSalary( playerList, block ) {
  7111.  
  7112. playerList.each( function() {
  7113.  
  7114.  
  7115.  
  7116. var player = $(this).find( "a[href^='profile.html']" );
  7117. var content = $(this).find( ".salary" );
  7118. content.removeClass( "salary" );
  7119. if( content.children().length == 3 ) { content.children().last().remove(); }
  7120.  
  7121. block.find( "tr" ).each( function() {
  7122.  
  7123. if( $(this).find( "a[href='"+ player.attr( "href" ) +"']" ).length == 1 ) {
  7124. $(this).find( ".playerSalary" ).append( content );
  7125. $( "<br/>" ).insertBefore( content.children( "b" ) );
  7126. var currency = content.contents().eq(5).text();
  7127.  
  7128. var salary = parseFloat( content.children( "b" ).text() );
  7129. $(this).find( "td" ).each( function() {
  7130. if( $(this).children().length == 2 ) {
  7131. $(this).children().eq(1).css({ "color" : "#009900" });
  7132.  
  7133. var numItems = $(this).children( "div" ).eq(1).text();
  7134. numItems = numItems.replace( "(", "" ).replace( ")", "" );
  7135. numItems = parseFloat( numItems );
  7136.  
  7137. var finalPrice = $( "<div class='finalPrice'>"+ (parseInt( (salary / numItems)*1000 ) / 1000) +"</div>" );
  7138. finalPrice.append( "<br/>" );
  7139. finalPrice.append( "<span> "+ currency +"</span>" );
  7140. $(this).append( finalPrice );
  7141. }
  7142. });
  7143. }
  7144. });
  7145. });
  7146.  
  7147. trNumber=block.find( "tr" ).length
  7148.  
  7149. //alert(trNumber)
  7150.  
  7151. if($('#sum_1').length == 0){
  7152.  
  7153. $('#productivityTable > tbody:last').append('<tr><td colspan="2"><b>Sum:</b></td><td id="sum_1"></td><td id="sum_2"></td><td id="sum_3"></td><td id="sum_4"></td><td id="sum_5"></td><td id="sum_6"></td><td id="sum_7"></td><td id="sum_8"></td><td id="sum_9"></td><td id="sum_10"></td><td id="sum_11"></td></tr>');
  7154.  
  7155. $('#productivityTable > tbody:last').append('<tr><td colspan="2"><b>Avarage:</b></td><td id="avg_1"></td><td id="avg_2"></td><td id="avg_3"></td><td id="avg_4"></td><td id="avg_5"></td><td id="avg_6"></td><td id="avg_7"></td><td id="avg_8"></td><td id="avg_9"></td><td id="avg_10"></td><td id="avg_11"></td></tr>');
  7156.  
  7157. }else{
  7158.  
  7159. $('#productivityTable > tbody tr:last td:last').remove()
  7160. $('#productivityTable > tbody tr:eq(-2) td:last').remove()
  7161.  
  7162. }
  7163.  
  7164. for(i=3;i<13;i++)
  7165. {
  7166.  
  7167.  
  7168.  
  7169. col=$('#productivityTable tr>td:nth-child('+i+')').text()
  7170. col=col.replace(/\t/g, '');
  7171. Productivity=col.match(/[\n\r]\d{3}\.\d{0,2}/g);
  7172. Product=col.match(/\(\d{0,10}\.\d{0,2}\)/g);
  7173.  
  7174. price_one=col.match(/\d{1,5}\.\d{0,3} .../g);
  7175.  
  7176. //alert(Productivity)
  7177.  
  7178. if(Productivity != null)
  7179. {
  7180. Productivity= Productivity.join().match(/\d{0,10}\.\d{0,2}/g);
  7181.  
  7182. //alert(Productivity)
  7183.  
  7184. Sum_productivity=0;
  7185.  
  7186. for(var x = 0; x < Productivity.length; x++)
  7187. {
  7188. Sum_productivity = Sum_productivity + Number(Productivity[x]); //or Sum += scores[x];
  7189. }
  7190.  
  7191. average_productivity = Sum_productivity / Productivity.length;
  7192.  
  7193. }else{
  7194.  
  7195. Sum_productivity=0
  7196. average_productivity=0;
  7197.  
  7198. }
  7199.  
  7200.  
  7201. if(Product != null)
  7202. {
  7203. Product= Product.join().match(/\d{0,10}\.\d{0,2}/g);
  7204.  
  7205. Sum_product=0;
  7206.  
  7207. for(var x = 0; x < Product.length; x++)
  7208. {
  7209. Sum_product = Sum_product + Number(Product[x]); //or Sum += scores[x];
  7210. }
  7211.  
  7212. average_product = Sum_product / Product.length;
  7213.  
  7214. //alert(average_product)
  7215.  
  7216. }else{
  7217.  
  7218. Sum_product=0
  7219. average_product=0;
  7220.  
  7221. }
  7222.  
  7223.  
  7224. if(price_one != null)
  7225. {
  7226.  
  7227. price_one= price_one.join().match(/\d{1,5}\.\d{0,3}/g);
  7228.  
  7229. Sum_price_one=0;
  7230.  
  7231. for(var x = 0; x < price_one.length; x++)
  7232. {
  7233. Sum_price_one = Sum_price_one + Number(price_one[x]); //or Sum += scores[x];
  7234. }
  7235.  
  7236. average_price_one = Sum_price_one / price_one.length;
  7237.  
  7238.  
  7239. }else{
  7240.  
  7241. Sum_price_one=0
  7242. average_price_one=0;
  7243.  
  7244. }
  7245.  
  7246.  
  7247. $('#sum_'+(i-2)).html("<div>"+Sum_productivity.toFixed(2)+"</div><div style='color: rgb(0, 153, 0);font-weight:normal;'>"+Sum_product.toFixed(2)+"</div>")
  7248.  
  7249. $('#avg_'+(i-2)).html("<div>"+average_productivity.toFixed(2)+"</div><div style='color: rgb(0, 153, 0);'>"+average_product.toFixed(2)+"</div><div class='finalPrice'>"+average_price_one.toFixed(4)+"</div>")
  7250.  
  7251.  
  7252.  
  7253.  
  7254. }
  7255.  
  7256. col_sal=$('#productivityTable tr>td:nth-child(13)').text();
  7257. sal=col_sal.match(/\d{1,3}\.\d{0,2}/g)
  7258.  
  7259. Sum_sal=0;
  7260.  
  7261. for(var x = 0; x < sal.length; x++)
  7262. {
  7263. Sum_sal = Sum_sal + Number(sal[x]); //or Sum += scores[x];
  7264. }
  7265.  
  7266. average_sal = Sum_sal / sal.length;
  7267.  
  7268. $('#avg_11').html("<div style='color: rgb(0, 153, 0);'>"+average_sal.toFixed(2)+"</div>")
  7269. $('#sum_11').html("<div style='color: rgb(0, 153, 0);'>"+Sum_sal.toFixed(2)+"</div>")
  7270.  
  7271.  
  7272.  
  7273. //
  7274.  
  7275.  
  7276. }
  7277.  
  7278.  
  7279. // Replace job skill selector
  7280. function jobMarketSkills() {
  7281. if( $( "#minimalSkill option" ).length == 14 ) {
  7282. $( "#minimalSkill" ).append( "<option value='15'>15</option>" );
  7283. $( "#minimalSkill" ).append( "<option value='16'>16</option>" );
  7284. }
  7285.  
  7286. $( "#countryId" ).addClass( "customSelectList" );
  7287. $( "#jobMarketForm" ).parent().css({ "width" : "550px" });
  7288. $( "#jobMarketForm" ).contents().eq(4).remove();
  7289.  
  7290. var selectedSkill = null;
  7291. $( "#minimalSkill option" ).each( function() {
  7292.  
  7293. var skill = $( "<div class='skillSelector'>"+ $(this).val() +"</div>" )
  7294. skill.insertBefore( "#minimalSkill" );
  7295.  
  7296. skill.bind( "click", function() {
  7297. if( selectedSkill ) { selectedSkill.removeClass( "skillSelectorSelected" ); }
  7298.  
  7299. selectedSkill = $(this);
  7300. selectedSkill.addClass( "skillSelectorSelected" );
  7301. $( "#minimalSkill" ).val( selectedSkill.text() );
  7302.  
  7303. var link = getCurrentServer() + URLJobMarket + "?countryId="+ countryId +"&minimalSkill="+ $(this).text();
  7304. $( ".companyLinkOffers" ).attr( "href", link );
  7305. });
  7306.  
  7307. if( $(this).val() == $( "#minimalSkill" ).val() ) { skill.click(); }
  7308. });
  7309.  
  7310. $( "#minimalSkill" ).hide();
  7311. $( "#jobMarketForm" ).children( "input" ).insertAfter( "#countryId" );
  7312. $( "#jobMarketForm" ).children( "input" ).addClass( "showButton" );
  7313. $( "#jobMarketForm" ).parent().children( ":lt(2)" ).remove();
  7314. }
  7315.  
  7316.  
  7317. // Improve battle list interface
  7318. function changeBattleList() {
  7319.  
  7320.  
  7321. var url = "http://e-sim.home.pl/testura/js/jquery.countdown.min.js";
  7322. var script2 = document.createElement("script");
  7323. script2.setAttribute("src", url);
  7324. document.getElementsByTagName("head")[0].appendChild(script2);
  7325.  
  7326.  
  7327. $( "#countryId" ).addClass( "customSelectList" );
  7328. //$( "#sorting" ).prev().remove();
  7329. //$( "#sorting" ).prev().remove();
  7330.  
  7331. var selectedOption = null;
  7332. $( "#sorting option" ).each( function() {
  7333.  
  7334. var sort = $( "<div class='sortTypeSelector'>"+ $(this).text().replace( "Sorting ", "" ) +"</div>" );
  7335. sort.attr( "type", $(this).val() );
  7336. sort.insertBefore( "#sorting" );
  7337.  
  7338. sort.bind( "click", function() {
  7339. if( selectedOption ) { selectedOption.removeClass( "sortTypeSelectorSelected" ); }
  7340.  
  7341. selectedOption = $(this);
  7342. selectedOption.addClass( "sortTypeSelectorSelected" );
  7343. $( "#sorting" ).val( selectedOption.attr( "type" ) );
  7344. });
  7345.  
  7346. if( $(this).val() == $( "#sorting" ).val() ) { sort.click(); }
  7347. });
  7348.  
  7349. $( "#sorting" ).hide();
  7350. $( "#battlesViewForm" ).parent().children().last().remove();
  7351. var updateTime = $( "<input class='updateTimeListBattle' type='button' value='Update Battle List'/>" );
  7352. updateTime.insertAfter( $( "#battlesViewForm" ).parent() );
  7353. updateTime.bind( "click", function() {
  7354.  
  7355. var i=0;
  7356. var y=0;
  7357. $( "#battlesTable" ).find( "tr" ).each( function() {
  7358. var related = $(this);
  7359. var href = $(this).find( "a[href^='battle.html?id=']" );
  7360. if( href.length == 1 ) {
  7361. setTimeout( function() {
  7362. $.ajax({
  7363. url: href.attr( "href" ),
  7364. success: function( data ) {
  7365.  
  7366. // Battle Time
  7367. related.find( ".roundTimeRemain" ).remove();
  7368.  
  7369. var timeremain = "";
  7370.  
  7371. regexp =/liftoffTime\.setHours\(liftoffTime.getHours\(\) \+ (\d{1,2})\)/g
  7372.  
  7373. var hour = regexp.exec(data)
  7374. var hour = hour[1]
  7375.  
  7376.  
  7377. regexp =/liftoffTime\.setMinutes\(liftoffTime.getMinutes\(\) \+ (\d{1,2})\)/g
  7378.  
  7379. var min = regexp.exec(data)
  7380. var min = min[1]
  7381.  
  7382. regexp =/liftoffTime\.setSeconds\(liftoffTime.getSeconds\(\) \+ (\d{1,2})\)/g
  7383. var sec = regexp.exec(data)
  7384. var sec = sec[1]
  7385.  
  7386.  
  7387. hour = "0" + hour;
  7388. min = (min < 10) ? "0"+min : min;
  7389. sec = (sec < 10) ? "0"+sec : sec;
  7390.  
  7391. var lastTD = related.children().last();
  7392. lastTD.removeClass( "roundClean" );
  7393. lastTD.removeClass( "roundLastHour" );
  7394. lastTD.removeClass( "roundLastHalfHour" );
  7395. if( hour == 0 ) {
  7396. if( min < 30 ) {
  7397. lastTD.addClass( "roundLastHalfHour" );
  7398.  
  7399. } else lastTD.addClass( "roundLastHour" );
  7400.  
  7401. } else lastTD.addClass( "roundClean" );
  7402.  
  7403. //hour = "0" + hour;
  7404. //min = (min < 10) ? "0"+min : min;
  7405. //sec = (sec < 10) ? "0"+sec : sec;
  7406. related.children().last().append( "<div class='roundTimeRemain'>"+ hour +":"+ min +":"+ sec +"</div>" );
  7407.  
  7408. //Mini Info
  7409.  
  7410. firstTD = related.children().first();
  7411.  
  7412. subsidy = firstTD.find(".battleDiv").find("div").last().html();
  7413.  
  7414. info = $(data).find("#roundCountdown").parent().parent().parent().html();
  7415.  
  7416. topDef1 = $(data).find("#topDefender1").html();
  7417. topDef2 = $(data).find("#topDefender2").html();
  7418. topDef3 = $(data).find("#topDefender3").html();
  7419.  
  7420. topAtt1 = $(data).find("#topAttacker1").html();
  7421. topAtt2 = $(data).find("#topAttacker2").html();
  7422. topAtt3 = $(data).find("#topAttacker3").html();
  7423.  
  7424. firstTD.html(info+subsidy)
  7425.  
  7426. firstTD.find("#fb-root").parent().prev().html(topDef1+topDef2+topDef3);
  7427. firstTD.find("#fb-root").parent().next().html(topAtt1+topAtt2+topAtt3);
  7428. firstTD.find("#fb-root").parent().remove();
  7429.  
  7430. firstTD.find(".attackerHit").parent().attr("class","foundation-style column-margin-vertical column small-5")
  7431. firstTD.find(".attackerHit").attr("style","float: left; width: 75px; margin-right: 5px")
  7432.  
  7433. firstTD.find(".defenderHit").parent().attr("class","foundation-style column-margin-vertical column small-5")
  7434. firstTD.find(".defenderHit").attr("style","float: right; width: 75px; margin-right: 5px")
  7435.  
  7436.  
  7437. firstTD.find("#defenderScore").parent().parent().attr("class","foundation-style column-margin-vertical column small-5 foundation-text-center")
  7438. firstTD.find("#attackerScore").parent().parent().attr("class","foundation-style column-margin-vertical column small-5 foundation-text-center")
  7439.  
  7440. firstTD.find("a[href*='region.html?id=']").attr("href",href.attr( "href" ))
  7441.  
  7442. firstTD.find('#roundCountdown').attr("id","roundCountdown"+y)
  7443. firstTD.find('#roundCountdown'+y).attr("class","roundCountdown")
  7444. firstTD.find('#roundCountdown'+y).html(hour +":"+ min +":"+ sec)
  7445.  
  7446.  
  7447.  
  7448. /* var eval(liftoffTime+y) = new Date();
  7449. eval(liftoffTime+y).setHours(liftoffTime.getHours() + hour);
  7450. eval(liftoffTime+y).setMinutes(liftoffTime.getMinutes() + min);
  7451. eval(liftoffTime+y).setSeconds(liftoffTime.getSeconds() + sec);
  7452. firstTD.find('#roundCountdown'+y).countdown({until: eval(liftoffTime+y), compact: true, format: 'HMS'});
  7453. */
  7454. y++
  7455.  
  7456. }
  7457. });
  7458.  
  7459.  
  7460.  
  7461. }, 500*i );
  7462.  
  7463. i++;
  7464. }
  7465. });
  7466.  
  7467.  
  7468.  
  7469.  
  7470. });
  7471. }
  7472.  
  7473. //GET URL PARAMETER
  7474. function getURLParameter(url, name) {
  7475. return (RegExp(name + '=' + '(.+?)(&|$)').exec(url)||[,null])[1];
  7476. }
  7477.  
  7478.  
  7479.  
  7480. // motivate
  7481. function motivate(RCID,Type){
  7482.  
  7483. $.post(getCurrentServer()+NOO()+"/motivateCitizen.html?id=" + RCID, {
  7484. id: RCID,
  7485. type: Type
  7486. }, function (data) {
  7487. var patt = /<div style="width:400px;" class="testDivred"><img src="http:\/\/e-sim.home.pl\/testura\/img\/delete.png" style="float: left"\/>/g;
  7488. var result = patt.test(data);
  7489. //prompt("a",data);
  7490. if (result) {
  7491. alert("Something is wrong! ");
  7492. }else{
  7493. alert("OK! You got +1 food limit.");
  7494. location.reload();
  7495. }}
  7496. );
  7497.  
  7498.  
  7499. }
  7500.  
  7501.  
  7502. // getValue as GM_getValue of GM functions
  7503. function getValue( name ) {
  7504. name = getPlayerID() + getCurrentServer() + name;
  7505. var value = (cachedSettings === null ? localStorage.getItem(name) : cachedSettings[name]);
  7506. if( !value || (value === undefined) ) { return( null ); }
  7507. return( value );
  7508. }
  7509.  
  7510.  
  7511. // setValue as GM_setValue of GM functions
  7512. function setValue( name, value ) {
  7513. name = getPlayerID() + getCurrentServer() + name;
  7514. if (cachedSettings === null) {
  7515. localStorage.setItem( name, value );
  7516. } else {
  7517. cachedSettings[name] = value;
  7518. chrome.extension.sendRequest( { name: name, value: value } );
  7519. }
  7520. }
  7521.  
  7522.  
  7523. // Convert location to travel
  7524. function setTravelLocation( id, travelRW, travelLeft, travelRight, attackerId ) {
  7525.  
  7526.  
  7527. var currentDate = (new Date).getDate();
  7528. var lastDate = getValue( "LastUpdateAPIRegion" );
  7529. var needUpdate = (lastDate != currentDate);
  7530. finded=false;
  7531. var value = getValue( "APIRegionJSON" );
  7532. var value2 = getValue( "APIMapJSON" );
  7533. if( value && !needUpdate && value2 ) {
  7534.  
  7535. var json = $.parseJSON( value );
  7536. for( var i=0; i<json.length; i++ ) {
  7537. if( json[i].id == id ) {
  7538. travelRW.children( "a" ).attr( "href", getCurrentServer()+URLTravel+"?idc="+json[i].homeCountry+"&idr="+json[i].id );
  7539. travelRW.children( "a" ).append( "<br/><b>"+ json[i].name +"</b>" );
  7540.  
  7541. travelLeft.children( "a" ).attr( "href", getCurrentServer()+URLTravel+"?idc="+json[i].homeCountry+"&idr="+json[i].id );
  7542. travelLeft.children( "a" ).append( "<br/><b>"+ json[i].name +"</b>" );
  7543.  
  7544.  
  7545. //alert(json[i].neighbours);
  7546. //alert(attackerId);
  7547.  
  7548. //alert("cache")
  7549.  
  7550. // Check neighbours
  7551. for( var j=0; j<json.length; j++ ) {
  7552.  
  7553.  
  7554.  
  7555. if( $.inArray( json[j].id, json[i].neighbours ) != -1 ) {
  7556.  
  7557.  
  7558. //alert(json[j].id+"----"+ json[i].neighbours)
  7559.  
  7560. var json2 = $.parseJSON( value2 );
  7561.  
  7562. for( var x=0; x<json2.length; x++ ) {
  7563.  
  7564. if(json[j].id==json2[x].regionId) {
  7565.  
  7566. // alert(json[j].id+"=="+json2[x].regionId)
  7567.  
  7568. if(json2[x].occupantId == attackerId)
  7569. {
  7570. // alert(json2[x].occupantId +"---"+ attackerId)
  7571.  
  7572. travelRight.children( "a" ).attr( "href", getCurrentServer()+URLTravel+"?idc="+json2[x].occupantId+"&idr="+json[j].id );
  7573. travelRight.children( "a" ).append( "<br/><b>"+ json[j].name +"</b>" );
  7574.  
  7575. finded=true;
  7576. break;
  7577.  
  7578.  
  7579. }
  7580. }
  7581. }
  7582.  
  7583.  
  7584.  
  7585.  
  7586. //alert(json[j].name)
  7587.  
  7588. if(finded) break;
  7589.  
  7590.  
  7591. }
  7592. }
  7593. }
  7594. }
  7595.  
  7596. } else {
  7597.  
  7598. // alert("NET")
  7599.  
  7600.  
  7601. $.ajax({
  7602. url: getCurrentServer() + URLAPIRegion,
  7603. async: false,
  7604. success: function( data ) {
  7605. setValue( "APIRegionJSON", data );
  7606. setValue( "LastUpdateAPIRegion", currentDate );
  7607.  
  7608.  
  7609. var json = $.parseJSON( data );
  7610. for( var i=0; i<json.length; i++ ) {
  7611. if( json[i].id == id ) {
  7612. travelRW.children( "a" ).attr( "href", getCurrentServer()+URLTravel+"?idc="+json[i].homeCountry+"&idr="+json[i].id );
  7613. travelRW.children( "a" ).append( "<br/><b>"+ json[i].name +"</b>" );
  7614.  
  7615. travelLeft.children( "a" ).attr( "href", getCurrentServer()+URLTravel+"?idc="+json[i].homeCountry+"&idr="+json[i].id );
  7616. travelLeft.children( "a" ).append( "<br/><b>"+ json[i].name +"</b>" );
  7617.  
  7618. // Check neighbours
  7619. for( var j=0; j<json.length; j++ ) {
  7620.  
  7621.  
  7622.  
  7623. if( $.inArray( json[j].id, json[i].neighbours ) != -1 ) {
  7624.  
  7625. $.ajax({
  7626. url: getCurrentServer() + URLAPIMap,
  7627. async: false,
  7628. success: function( data2 ) {
  7629.  
  7630. setValue( "APIMapJSON",data2 );
  7631.  
  7632. var json2 = $.parseJSON( data2 );
  7633.  
  7634. for( var x=0; x<json2.length; x++ ) {
  7635.  
  7636. if(json[j].id==json2[x].regionId) {
  7637. if(json2[x].occupantId == attackerId)
  7638. {
  7639. travelRight.children( "a" ).attr( "href", getCurrentServer()+URLTravel+"?idc="+json2[x].occupantId+"&idr="+json[j].id );
  7640. travelRight.children( "a" ).append( "<br/><b>"+ json[j].name +"</b>" );
  7641.  
  7642. finded=true;
  7643. break;
  7644. }
  7645. }
  7646. }
  7647.  
  7648. }})
  7649.  
  7650.  
  7651. //alert(json[j].name)
  7652.  
  7653. if(finded) break;
  7654.  
  7655.  
  7656. }
  7657. }
  7658. }
  7659. }
  7660. }
  7661. });
  7662. }
  7663. }
  7664.  
  7665. //Profile Calc
  7666. function ProfileCalc()
  7667. {
  7668. { //design
  7669. var des = ' \
  7670. <table> \
  7671. <tbody> \
  7672. <tr> \
  7673. <td> \
  7674. <div style="width:70px; height:45px"> \
  7675. <b>Weapons:</b> \
  7676. <br> \
  7677. <select class="foundation-style" id="weaponQ"> \
  7678. <option value="0.5">None</option> \
  7679. <option value="1.2">Q1</option> \
  7680. <option value="1.4">Q2</option> \
  7681. <option value="1.6">Q3</option> \
  7682. <option value="1.8">Q4</option> \
  7683. <option value="2.0">Q5</option> \
  7684. </select> \
  7685. </div> \
  7686. </td> \
  7687. <td> \
  7688. <div style="width:120px; height:45px"> \
  7689. <b style="float:center">Region Building:</b> \
  7690. <br> \
  7691. <select class="foundation-style" id="buildingType" style=""> \
  7692. <option value="1">None</option> \
  7693. <option value="2">DS</option> \
  7694. <option value="3">Hosp.</option> \
  7695. </select> \
  7696. <select class="foundation-style" id="buildingQ" style=""> \
  7697. <option value="0"> </option> \
  7698. <option value="1">Q1</option> \
  7699. <option value="2">Q2</option> \
  7700. <option value="3">Q3</option> \
  7701. <option value="4">Q4</option> \
  7702. <option value="5">Q5</option> \
  7703. </select> \
  7704. </div> \
  7705. </td> \
  7706. <td> \
  7707. <div style="width:50px; height:45px"> \
  7708. <b style="float:center">Food:</b> \
  7709. <br> \
  7710. <input class="foundation-style" type="number" min="0" id="foodNum" value="15" style="max-width : 30px"> \
  7711. </div> \
  7712. </td> \
  7713. <td> \
  7714. <div style="width:50px; height:45px"> \
  7715. <b style="float:center">Gift:</b> \
  7716. <br> \
  7717. <input class="foundation-style" type="number" min="0" id="giftNum" value="15" style="max-width : 30px"> \
  7718. </div> \
  7719. </td> \
  7720. <td> \
  7721. <div style=" width:60px; height:45px"> \
  7722. <b style="float:center">Health:</b> \
  7723. <br> \
  7724. <input class="foundation-style" type="number" min="0" max="100" step="0.5" id="healthNum" value="50" style="max-width : 40px"> \
  7725. </div> \
  7726. </td> \
  7727. </tr> \
  7728. <tr> \
  7729. <td> \
  7730. <div class="statsLabel smallStatsLabel greenLabel" style=""> \
  7731. <b>Region:</b> \
  7732. <input class="foundation-style" type="checkbox" id="regionBonus" value="1.2"> \
  7733. </div> \
  7734. </td> \
  7735. <td> \
  7736. <div class="statsLabel smallStatsLabel greenLabel" style="width:105px"> \
  7737. <b>MU:</b> \
  7738. <input class="foundation-style" type="checkbox" id="muBonus" value="1"> \
  7739. </div> \
  7740. </td> \
  7741. <td> \
  7742. <div class="statsLabel smallStatsLabel greenLabel" style=""> \
  7743. <b>Sewer/Bunker:</b> \
  7744. <input class="foundation-style" type="checkbox" id="swrbunkBonus" value="1.25"> \
  7745. </div> \
  7746. </td> \
  7747. <td> \
  7748. <div class="statsLabel smallStatsLabel greenLabel" style=""> \
  7749. <b>Tank:</b> \
  7750. <input class="foundation-style" type="checkbox" id="tankBonus" value="1.2"> \
  7751. </div> \
  7752. </td> \
  7753. <td> \
  7754. <div class="statsLabel smallStatsLabel greenLabel" style=""> \
  7755. <b>Steroids:</b> \
  7756. <input class="foundation-style" type="checkbox" id="steroidBonus" value="1.2"> \
  7757. </div> \
  7758. </td> \
  7759. </tr> \
  7760. <tr> \
  7761. <td></td> \
  7762. <td> \
  7763. <div class="statsLabel smallStatsLabel redLabel" style=""> \
  7764. <b style="; padding-top:3px">Surrounded:</b> \
  7765. <input class="foundation-style" type="checkbox" id="surroundDebuff" value="0.8" style=""> \
  7766. </div> \
  7767. </td> \
  7768. <td> \
  7769. <div class="statsLabel smallStatsLabel redLabel" style=""> \
  7770. <b>Sewer/Bunker:</b> \
  7771. <input class="foundation-style" type="checkbox" id="swrbunkDebuff" value="0.8"> \
  7772. </div> \
  7773. </td> \
  7774. <td> \
  7775. <div class="statsLabel smallStatsLabel redLabel" style=""> \
  7776. <b>Tank:</b> \
  7777. <input class="foundation-style" type="checkbox" id="tankDebuff" value="1"> \
  7778. </div> \
  7779. </td> \
  7780. <td> \
  7781. <div class="statsLabel smallStatsLabel redLabel" style=""> \
  7782. <b>Steroids:</b> \
  7783. <input class="foundation-style" type="checkbox" id="steroidDebuff" value="0.8"> \
  7784. </div> \
  7785. </td> \
  7786. </tr> \
  7787. <tr> \
  7788. <td colspan="2"> \
  7789. <div style=""> \
  7790. <b>Est. Berserk:</b> \
  7791. <br> \
  7792. <div class="help equipmentBlueBox" style="float:none;margin:auto; width:100px"> \
  7793. <b id="estBerserk">9001</b> \
  7794. </div> \
  7795. </div> \
  7796. </td> \
  7797. <td></td> \
  7798. <td colspan="2"> \
  7799. <div style=" "> \
  7800. <b>Est. Damage:</b> \
  7801. <br> \
  7802. <div class="help equipmentBlueBox" style="margin:auto; width:100px;float:none;"> \
  7803. <b id="estTotal">9001</b> \
  7804. </div> \
  7805. </div> \
  7806. </td> \
  7807. </tr> \
  7808. </tbody> \
  7809. </table> \
  7810. ';
  7811.  
  7812. }
  7813.  
  7814. $.fn.exists = function () {
  7815. return this.length !== 0;
  7816. }
  7817.  
  7818. $( "#profileEquipment" ).parent().css({ "height" : "370px" });
  7819. $( "#profileEquipment" ).parent().append(des);
  7820.  
  7821. var minDmg = parseInt($('#hitHelp b').first().text().replace(',',''));
  7822. var maxDmg = parseInt($('#hitHelp b').last().text().replace(',',''));
  7823. var avgHit = (minDmg + maxDmg) / 2;
  7824.  
  7825. var crit = $('#criticalHelp .equipmentStats').first().text();
  7826. crit = parseFloat(crit.replace('%','')) / 100.0;
  7827.  
  7828. var miss = $('#missHelp .equipmentStats').first().text();
  7829. miss = parseFloat(miss.replace('%','')) / 100.0;
  7830.  
  7831. var avoid = $('#avoidHelp .equipmentStats').first().text();
  7832. avoid = parseFloat(avoid.replace('%','')) / 100.0;
  7833.  
  7834. var muValue = 1.0;
  7835. if($('a[href^="militaryUnit.html?id="]').exists())
  7836. {
  7837. var muID = $('a[href^="militaryUnit.html?id="]').first().attr('href').replace('militaryUnit.html?id=', '');
  7838. var query = 'apiMilitaryUnitById.html?';
  7839. var json = $.getJSON(query, "id="+muID).done(function (data) {
  7840. switch(data.militaryUnitType) {
  7841. case "Novice":
  7842. muValue = 1.05;
  7843. break;
  7844. case "Regular":
  7845. muValue = 1.1;
  7846. break;
  7847. case "Veteran":
  7848. muValue = 1.15;
  7849. break;
  7850. case "Elite":
  7851. muValue = 1.2;
  7852. break;
  7853. }
  7854. });
  7855. }
  7856.  
  7857. function calcMissAvoid( numHits, depth )
  7858. {
  7859. depth++;
  7860. var numHits = numHits * (1 - miss);
  7861. var newHits = numHits * avoid;
  7862. if( depth == 10 ) {
  7863. return numHits;
  7864. } else {
  7865. return numHits + arguments.callee( newHits, depth );
  7866. }
  7867. }
  7868.  
  7869. function calc() {
  7870. var hit = avgHit * parseFloat($("#weaponQ").val());
  7871.  
  7872. if($("#buildingType").val() == 2) {
  7873. hit = hit * (1 + parseInt($("#buildingQ").val()) * 0.05);
  7874. }
  7875.  
  7876. if($("#steroidBonus").is(":checked")) { hit = hit * 1.2; }
  7877. else if($("#steroidDebuff").is(":checked")) { hit = hit * 0.8; }
  7878.  
  7879. if($("#tankBonus").is(":checked")) { hit = hit * 1.2; }
  7880.  
  7881. if($("#swrbunkBonus").is(":checked")) { hit = hit * 1.25; }
  7882. else if($("#swrbunkDebuff").is(":checked")) { hit = hit * 0.8; }
  7883.  
  7884. if($("#muBonus").is(":checked")) { hit = hit * muValue; } //FIX!
  7885.  
  7886. if($("#regionBonus").is(":checked")) { hit = hit * 1.2; }
  7887.  
  7888. if($("#surroundDebuff").is(":checked")) { hit = hit * 0.8; }
  7889.  
  7890. hit = hit * (1 + crit);
  7891. $("#estBerserk").html(commaNumber(Math.round(hit*5)));
  7892.  
  7893. var totalHealth = parseFloat($("#healthNum").val());
  7894. totalHealth += parseInt($("#foodNum").val()) * 50;
  7895. totalHealth += parseInt($("#giftNum").val()) * 50;
  7896.  
  7897. var healthPerHit = 10;
  7898. if($("#buildingType").val() == 3) {
  7899. healthPerHit -= (parseInt($("#buildingQ").val()) * 0.5);
  7900. }
  7901.  
  7902. var totalHits = Math.floor(totalHealth / healthPerHit);
  7903. totalHits = calcMissAvoid( totalHits, 0 );
  7904.  
  7905. var totalDamage = totalHits * hit;
  7906.  
  7907. $("#estTotal").html(commaNumber(Math.round(totalDamage)));
  7908. }
  7909.  
  7910. function cssSetDisabled(item)
  7911. {
  7912. $( item ).parent().css( "background-color", "rgb(219, 219, 219)" );
  7913. $( item ).parent().css( "border", "1px solid rgba(0, 0, 0, 0.7)" );
  7914. $( item ).parent().css( "box-shadow", "0 0 5px rgba(0, 0, 0, 0.5), 0 -12px 12px rgba(144, 169, 1156, 0.2) inset" );
  7915. $( item ).parent().css( "webkit-box-shadow", "0 0 5px rgba(0, 0, 0, 0.5), 0 -12px 12px rgba(144, 169, 1156, 0.2) inset" );
  7916. }
  7917.  
  7918. function cssSetEnabled(item)
  7919. {
  7920. $( item ).parent().removeAttr("style");
  7921. $( item ).parent().attr("style", "");
  7922. if (item == "#surroundDebuff")
  7923. $( item ).parent().attr("style", "; width:125px");
  7924. }
  7925.  
  7926. cssSetDisabled("#tankBonus");
  7927. $("#tankBonus").prop("disabled", true);
  7928. $("#buildingQ").prop("disabled", true);
  7929. calc();
  7930.  
  7931. $("#weaponQ").change( function(){
  7932. if($("#weaponQ").val() != 2.0)
  7933. {
  7934. cssSetDisabled("#tankBonus");
  7935. $("#tankBonus").prop("disabled", true);
  7936. if($("#tankBonus").is(":checked"))
  7937. {
  7938. $("#tankBonus").attr('checked', false);
  7939. cssSetEnabled("#tankDebuff");
  7940. $("#tankDebuff").prop("disabled", false);
  7941. }
  7942. } else {
  7943. cssSetEnabled("#tankBonus");
  7944. $("#tankBonus").prop("disabled", false);
  7945. }
  7946. calc();
  7947. });
  7948. $("#buildingType").change( function(){
  7949. if($("#buildingType").val() == 1)
  7950. {
  7951. $("#buildingQ").prop("disabled", true);
  7952. $("#buildingQ").val("0");
  7953. } else {
  7954. $("#buildingQ").prop("disabled", false);
  7955. }
  7956. calc();
  7957. });
  7958. $("#buildingQ").change( function(){ calc(); });
  7959. $("#foodNum").change( function(){
  7960. if(parseInt($("#foodNum").val()) < 0)
  7961. {
  7962. $("#foodNum").val("0");
  7963. }
  7964. calc();
  7965. });
  7966. $("#giftNum").change( function(){
  7967. if(parseInt($("#giftNum").val()) < 0)
  7968. {
  7969. $("#giftNum").val("0");
  7970. }
  7971. calc();
  7972. });
  7973. $("#healthNum").change( function(){
  7974. if(parseFloat($("#healthNum").val()) < 0)
  7975. {
  7976. $("#healthNum").val("0.0");
  7977. } else if (parseFloat($("#healthNum").val()) > 100.0)
  7978. {
  7979. $("#healthNum").val("100.0");
  7980. }
  7981. calc();
  7982. });
  7983. $("#regionBonus").change( function(){ calc(); });
  7984. $("#muBonus").change( function(){ calc(); });
  7985. $("#swrbunkBonus").change( function(){
  7986. if($("#swrbunkBonus").is(":checked"))
  7987. {
  7988. cssSetDisabled("#swrbunkDebuff");
  7989. $("#swrbunkDebuff").prop("disabled", true);
  7990. cssSetDisabled("#surroundDebuff");
  7991. $("#surroundDebuff").prop("disabled", true);
  7992. } else {
  7993. cssSetEnabled("#swrbunkDebuff");
  7994. $("#swrbunkDebuff").prop("disabled", false);
  7995. cssSetEnabled("#surroundDebuff");
  7996. $("#surroundDebuff").prop("disabled", false);
  7997. }
  7998. calc();
  7999. });
  8000. $("#tankBonus").change( function(){
  8001. if($("#tankBonus").is(":checked"))
  8002. {
  8003. cssSetDisabled("#tankDebuff");
  8004. $("#tankDebuff").prop("disabled", true);
  8005. } else {
  8006. cssSetEnabled("#tankDebuff");
  8007. $("#tankDebuff").prop("disabled", false);
  8008. }
  8009. calc();
  8010. });
  8011. $("#steroidBonus").change( function(){
  8012. if($("#steroidBonus").is(":checked"))
  8013. {
  8014. cssSetDisabled("#steroidDebuff");
  8015. $("#steroidDebuff").prop("disabled", true);
  8016. } else {
  8017. cssSetEnabled("#steroidDebuff");
  8018. $("#steroidDebuff").prop("disabled", false);
  8019. }
  8020. calc();
  8021. });
  8022. $("#surroundDebuff").change( function(){
  8023. if($("#surroundDebuff").is(":checked"))
  8024. {
  8025. cssSetDisabled("#swrbunkBonus");
  8026. $("#swrbunkBonus").prop("disabled", true);
  8027. } else {
  8028. if(!$("#swrbunkDebuff").is(":checked"))
  8029. {
  8030. cssSetEnabled("#swrbunkBonus");
  8031. $("#swrbunkBonus").prop("disabled", false);
  8032. }
  8033. }
  8034. calc();
  8035. });
  8036. $("#swrbunkDebuff").change( function(){
  8037. if($("#swrbunkDebuff").is(":checked"))
  8038. {
  8039. cssSetDisabled("#swrbunkBonus");
  8040. $("#swrbunkBonus").prop("disabled", true);
  8041. } else {
  8042. if(!$("#surroundDebuff").is(":checked"))
  8043. {
  8044. cssSetEnabled("#swrbunkBonus");
  8045. $("#swrbunkBonus").prop("disabled", false);
  8046. }
  8047. }
  8048. calc();
  8049. });
  8050. $("#tankDebuff").change( function(){
  8051. if($("#tankDebuff").is(":checked"))
  8052. {
  8053. cssSetDisabled("#tankBonus");
  8054. $("#weaponQ").prop("disabled", true);
  8055. $("#tankBonus").prop("disabled", true);
  8056. $("#weaponQ").val("0.5");
  8057. } else {
  8058. $("#weaponQ").prop("disabled", false);
  8059. }
  8060. calc();
  8061. });
  8062. $("#steroidDebuff").change( function(){
  8063. if($("#steroidDebuff").is(":checked"))
  8064. {
  8065. cssSetDisabled("#steroidBonus");
  8066. $("#steroidBonus").prop("disabled", true);
  8067. } else {
  8068. cssSetEnabled("#steroidBonus");
  8069. $("#steroidBonus").prop("disabled", false);
  8070. }
  8071. calc();
  8072. });
  8073.  
  8074.  
  8075.  
  8076. }
  8077.  
  8078.  
  8079.  
  8080. // Return Region list from API
  8081. function getRegionAPI( region, current ) {
  8082.  
  8083. var currentDate = (new Date).getDate();
  8084. var lastDate = getValue( "LastUpdateAPIRegion" );
  8085. var needUpdate = (lastDate != currentDate);
  8086.  
  8087. var value = getValue( "APIRegionJSON" );
  8088. if( value && !needUpdate ) {
  8089.  
  8090. var json = $.parseJSON( value );
  8091. for( var i=0; i<json.length; i++ ) {
  8092. if( json[i].id == region ) { return( json[i].neighbours ); }
  8093. }
  8094.  
  8095. } else {
  8096.  
  8097. $.ajax({
  8098. url: getCurrentServer() + URLAPIRegion,
  8099. success: function( data ) {
  8100. setValue( "APIRegionJSON", data );
  8101. setValue( "LastUpdateAPIRegion", currentDate );
  8102.  
  8103. var numberLocation = 0;
  8104. var neighbours = [];
  8105. var json = $.parseJSON( data );
  8106. for( var i=0; i<json.length; i++ ) {
  8107. if( json[i].id == region ) {
  8108. neighbours = json[i].neighbours;
  8109. numberLocation = (neighbours.indexOf( parseInt(current) ) != -1) ? 20 : 0;
  8110. }
  8111. }
  8112.  
  8113. /*var location = $( "#rightBlockBonus" ).find( ".locationBonus" );
  8114. location.text( numberLocation + "%" );
  8115. var color = (numberLocation == 0) ? "#e67171" : "#bed7ba";
  8116. location.css({ "background-color" : color });
  8117.  
  8118. location = $( "#leftBlockBonus" ).find( ".locationBonus" );
  8119. location.text( numberLocation + "%" );
  8120. location.css({ "background-color" : color });*/
  8121. }
  8122. });
  8123. }
  8124.  
  8125. return [];
  8126. }
  8127.  
  8128.  
  8129. // Get URL Vars
  8130. function getUrlVars() {
  8131. var vars = {};
  8132. var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function( m, key, value ) { vars[key] = value; });
  8133. return vars;
  8134. }
  8135. };
  8136.  
  8137. function createResourceVar( name ) {
  8138. var input = document.createElement( "input" );
  8139. input.type = "hidden";
  8140. input.id = name;
  8141. input.value = GM_getResourceURL( name );
  8142. document.body.appendChild( input );
  8143. }
  8144.  
  8145. // Only execute on same frame (iframes with advertisments)
  8146. if( window.top == window.self ) {
  8147.  
  8148. // Inject our CSS
  8149. GM_addStyle( GM_getResourceText( "myCustomCSS" ) );
  8150.  
  8151. // Resources
  8152. createResourceVar( "myQualityStar" );
  8153.  
  8154. var URLBattle = "/battle.html?id=";
  8155. var localUrl = new String( window.location );
  8156. if( localUrl.indexOf( URLBattle, 0 ) >= 0 ) {
  8157.  
  8158. createResourceVar( "AoEweaponQ0" );
  8159. createResourceVar( "AoEweaponQ1" );
  8160. createResourceVar( "AoEweaponQ2" );
  8161. createResourceVar( "AoEweaponQ3" );
  8162. createResourceVar( "AoEweaponQ4" );
  8163. createResourceVar( "AoEweaponQ5" );
  8164. createResourceVar( "AoEweaponQ0Big" );
  8165. createResourceVar( "AoEweaponQ1Big" );
  8166. createResourceVar( "AoEweaponQ2Big" );
  8167. createResourceVar( "AoEweaponQ3Big" );
  8168. createResourceVar( "AoEweaponQ4Big" );
  8169. createResourceVar( "AoEweaponQ5Big" );
  8170.  
  8171. createResourceVar( "SWweaponQ0" );
  8172. createResourceVar( "SWweaponQ1" );
  8173. createResourceVar( "SWweaponQ2" );
  8174. createResourceVar( "SWweaponQ3" );
  8175. createResourceVar( "SWweaponQ4" );
  8176. createResourceVar( "SWweaponQ5" );
  8177. createResourceVar( "SWweaponQ0Big" );
  8178. createResourceVar( "SWweaponQ1Big" );
  8179. createResourceVar( "SWweaponQ2Big" );
  8180. createResourceVar( "SWweaponQ3Big" );
  8181. createResourceVar( "SWweaponQ4Big" );
  8182. createResourceVar( "SWweaponQ5Big" );
  8183.  
  8184. createResourceVar( "PokweaponQ0" );
  8185. createResourceVar( "PokweaponQ1" );
  8186. createResourceVar( "PokweaponQ2" );
  8187. createResourceVar( "PokweaponQ3" );
  8188. createResourceVar( "PokweaponQ4" );
  8189. createResourceVar( "PokweaponQ5" );
  8190. createResourceVar( "PokweaponQ0Big" );
  8191. createResourceVar( "PokweaponQ1Big" );
  8192. createResourceVar( "PokweaponQ2Big" );
  8193. createResourceVar( "PokweaponQ3Big" );
  8194. createResourceVar( "PokweaponQ4Big" );
  8195. createResourceVar( "PokweaponQ5Big" );
  8196. }
  8197.  
  8198.  
  8199.  
  8200.  
  8201.  
  8202. // Inject our main script
  8203. var script = document.createElement( "script" );
  8204. script.type = "text/javascript";
  8205. script.textContent = '(' + main.toString() + ')();';
  8206. document.body.appendChild( script );
  8207. }
Advertisement
Add Comment
Please, Sign In to add comment