Guest User

Untitled

a guest
Jun 19th, 2014
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 178.60 KB | None | 0 0
  1. // ==UserScript==
  2. // @name EasyDelivery
  3. // @version 0.7.3.7
  4. // @namespace localhost
  5. // @author aMiTo
  6. // @description Easy tool to improve delivery job.
  7. // @match http://*.e-sim.org/*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js
  9. // @resource myCustomCSS https://dl.dropboxusercontent.com/u/67548179/esim-ED/my.css
  10. // @resource myQualityStar https://dl.dropbox.com/u/78035768/eSim/star.png
  11. // @resource AoEweaponQ0 https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ0.png
  12. // @resource AoEweaponQ1 https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ1.png
  13. // @resource AoEweaponQ2 https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ2.png
  14. // @resource AoEweaponQ3 https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ3.png
  15. // @resource AoEweaponQ4 https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ4.png
  16. // @resource AoEweaponQ5 https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ5.png
  17. // @resource AoEweaponQ0Big https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ0.gif
  18. // @resource AoEweaponQ1Big https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ1.gif
  19. // @resource AoEweaponQ2Big https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ2.gif
  20. // @resource AoEweaponQ3Big https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ3.gif
  21. // @resource AoEweaponQ4Big https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ4.gif
  22. // @resource AoEweaponQ5Big https://dl.dropbox.com/u/78035768/eSim/AoE/AoEweaponQ5.gif
  23. // @resource SWweaponQ0 https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ0.png
  24. // @resource SWweaponQ1 https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ1.png
  25. // @resource SWweaponQ2 https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ2.png
  26. // @resource SWweaponQ3 https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ3.png
  27. // @resource SWweaponQ4 https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ4.png
  28. // @resource SWweaponQ5 https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ5.png
  29. // @resource SWweaponQ0Big https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ0.gif
  30. // @resource SWweaponQ1Big https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ1.gif
  31. // @resource SWweaponQ2Big https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ2.gif
  32. // @resource SWweaponQ3Big https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ3.gif
  33. // @resource SWweaponQ4Big https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ4.gif
  34. // @resource SWweaponQ5Big https://dl.dropbox.com/u/78035768/eSim/SW/SWweaponQ5.gif
  35. // @resource PokweaponQ0 https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ0.png
  36. // @resource PokweaponQ1 https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ1.png
  37. // @resource PokweaponQ2 https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ2.png
  38. // @resource PokweaponQ3 https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ3.png
  39. // @resource PokweaponQ4 https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ4.png
  40. // @resource PokweaponQ5 https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ5.png
  41. // @resource PokweaponQ0Big https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ0.gif
  42. // @resource PokweaponQ1Big https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ1.gif
  43. // @resource PokweaponQ2Big https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ2.gif
  44. // @resource PokweaponQ3Big https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ3.gif
  45. // @resource PokweaponQ4Big https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ4.gif
  46. // @resource PokweaponQ5Big https://dl.dropbox.com/u/78035768/eSim/Pok/PokweaponQ5.gif
  47. // @grant GM_getResourceText
  48. // @grant GM_getResourceURL
  49. // @grant GM_addStyle
  50. // ==/UserScript==
  51.  
  52. var main = function () {
  53.  
  54. // CONSTANTS
  55. var VERSION = "E.D. 0.7.3.7";
  56. var URLSCRIPT = "http://userscripts.org/scripts/show/132316";
  57. // CUSTOM IMAGE LINKS
  58. var QUALITYSTAR = "https://dl.dropbox.com/u/78035768/eSim/star.png"
  59. // Theme AoE
  60. var AoEweaponQ0 = $( "#AoEweaponQ0" ).val();
  61. var AoEweaponQ1 = $( "#AoEweaponQ1" ).val();
  62. var AoEweaponQ2 = $( "#AoEweaponQ2" ).val();
  63. var AoEweaponQ3 = $( "#AoEweaponQ3" ).val();
  64. var AoEweaponQ4 = $( "#AoEweaponQ4" ).val();
  65. var AoEweaponQ5 = $( "#AoEweaponQ5" ).val();
  66. var AoEweaponQ0Big = $( "#AoEweaponQ0Big" ).val();
  67. var AoEweaponQ1Big = $( "#AoEweaponQ1Big" ).val();
  68. var AoEweaponQ2Big = $( "#AoEweaponQ2Big" ).val();
  69. var AoEweaponQ3Big = $( "#AoEweaponQ3Big" ).val();
  70. var AoEweaponQ4Big = $( "#AoEweaponQ4Big" ).val();
  71. var AoEweaponQ5Big = $( "#AoEweaponQ5Big" ).val();
  72. // Theme Star Wars
  73. var SWweaponQ0 = $( "#SWweaponQ0" ).val();
  74. var SWweaponQ1 = $( "#SWweaponQ1" ).val();
  75. var SWweaponQ2 = $( "#SWweaponQ2" ).val();
  76. var SWweaponQ3 = $( "#SWweaponQ3" ).val();
  77. var SWweaponQ4 = $( "#SWweaponQ4" ).val();
  78. var SWweaponQ5 = $( "#SWweaponQ5" ).val();
  79. var SWweaponQ0Big = $( "#SWweaponQ0Big" ).val();
  80. var SWweaponQ1Big = $( "#SWweaponQ1Big" ).val();
  81. var SWweaponQ2Big = $( "#SWweaponQ2Big" ).val();
  82. var SWweaponQ3Big = $( "#SWweaponQ3Big" ).val();
  83. var SWweaponQ4Big = $( "#SWweaponQ4Big" ).val();
  84. var SWweaponQ5Big = $( "#SWweaponQ5Big" ).val();
  85. // Theme Pokemon
  86. var PokweaponQ0 = $( "#PokweaponQ0" ).val();
  87. var PokweaponQ1 = $( "#PokweaponQ1" ).val();
  88. var PokweaponQ2 = $( "#PokweaponQ2" ).val();
  89. var PokweaponQ3 = $( "#PokweaponQ3" ).val();
  90. var PokweaponQ4 = $( "#PokweaponQ4" ).val();
  91. var PokweaponQ5 = $( "#PokweaponQ5" ).val();
  92. var PokweaponQ0Big = $( "#PokweaponQ0Big" ).val();
  93. var PokweaponQ1Big = $( "#PokweaponQ1Big" ).val();
  94. var PokweaponQ2Big = $( "#PokweaponQ2Big" ).val();
  95. var PokweaponQ3Big = $( "#PokweaponQ3Big" ).val();
  96. var PokweaponQ4Big = $( "#PokweaponQ4Big" ).val();
  97. var PokweaponQ5Big = $( "#PokweaponQ5Big" ).val();
  98. // API
  99. var URLAPIRanks = "e-sim.org/apiRanks.html";
  100. var URLAPIRegion = "e-sim.org/apiRegions.html";
  101. // URLs
  102. var URLMain = "e-sim.org/index.html";
  103. var URLMyMU = "e-sim.org/myMilitaryUnit.html";
  104. var URLMUMain = "e-sim.org/militaryUnit.html?id=";
  105. var URLMUStorage = "e-sim.org/militaryUnitStorage.html";
  106. var URLMUMoney = "e-sim.org/militaryUnitMoneyAccount.html";
  107. var URLMUCompanies = "e-sim.org/militaryUnitCompanies.html?id=";
  108. var URLDDonatePlayerProduct = "e-sim.org/donateProducts.html?id=";
  109. var URLDonateMUProduct = "e-sim.org/donateProductsToMilitaryUnit.html?id=";
  110. var URLCompanies = "e-sim.org/companies.html";
  111. var URLCompany = "e-sim.org/company.html?id=";
  112. var URLCompanyDetails = "e-sim.org/companyWorkResults.html?id=";
  113. var URLBattle = "e-sim.org/battle.html?id=";
  114. var URLBattleList = "e-sim.org/battles.html";
  115. var URLContracts = "e-sim.org/contracts.html";
  116. var URLContract = "e-sim.org/contract.html?id=";
  117. var URLMarket = "e-sim.org/productMarket.html";
  118. var URLMonetaryMarket = "e-sim.org/monetaryMarket.html";
  119. var URLMarketOffers = "e-sim.org/citizenMarketOffers.html";
  120. var URLJobMarket = "e-sim.org/jobMarket.html";
  121. var URLMyShares = "e-sim.org/myShares.html";
  122. var URLStockCompany = "e-sim.org/stockCompany.html?id=";
  123. var URLStockMM = "e-sim.org/stockCompanyMoney.html?id=";
  124. var URLStockProducts = "e-sim.org/stockCompanyProducts.html?id=";
  125. var URLStockDonateMoney = "e-sim.org/stockCompanyDonateMoney.html?id=";
  126. var URLStockDonateCompany = "e-sim.org/stockCompanyDonateCompany.html?id=";
  127. var URLStockLogs = "e-sim.org/stockCompanyLogs.html?id=";
  128. var URLTravel = "e-sim.org/travel.html";
  129. var URLEquipment = "e-sim.org/equipment.html";
  130. // Image resources
  131. var IMGIRON = "http://e-sim.home.pl/testura/img/productIcons/Iron.png";
  132. var IMGGRAIN = "http://e-sim.home.pl/testura/img/productIcons/Grain.png";
  133. var IMGOIL = "http://e-sim.home.pl/testura/img/productIcons/Oil.png";
  134. var IMGDIAMONDS = "http://e-sim.home.pl/testura/img/productIcons/Diamonds.png";
  135. var IMGWOOD = "http://e-sim.home.pl/testura/img/productIcons/Wood.png";
  136. var IMGSTONE = "http://e-sim.home.pl/testura/img/productIcons/Stone.png";
  137. var IMGWEAPON = "http://e-sim.home.pl/testura/img/productIcons/Weapon.png";
  138. var IMGFOOD = "http://e-sim.home.pl/testura/img/productIcons/Food.png";
  139. var IMGTICKET = "http://e-sim.home.pl/testura/img/productIcons/Ticket.png";
  140. var IMGGIFT = "http://e-sim.home.pl/testura/img/productIcons/Gift.png";
  141. var IMGHOUSE = "http://e-sim.home.pl/testura/img/productIcons/House.png";
  142. var IMGDS = "http://e-sim.home.pl/testura/img/productIcons/Defense System.png";
  143. var IMGHOSPITAL = "http://e-sim.home.pl/testura/img/productIcons/Hospital.png";
  144. var IMGESTATE = "http://e-sim.home.pl/testura/img/productIcons/Estate.png";
  145. var IMGQUALITY = "http://e-sim.home.pl/testura/img/productIcons/q";
  146. var IMGEXTENSION = ".png";
  147. // Image countries
  148. var ARGENTINA = "http://e-sim.home.pl/testura/img/flags/small/Argentina.png";
  149. var AUSTRALIA = "http://e-sim.home.pl/testura/img/flags/small/Australia.png";
  150. var BELARUS = "http://e-sim.home.pl/testura/img/flags/small/Belarus.png";
  151. var BELGIUM = "http://e-sim.home.pl/testura/img/flags/small/Belgium.png";
  152. var BOSNIA = "http://e-sim.home.pl/testura/img/flags/small/Bosnia-and-Herzegovina.png"
  153. var BRAZIL = "http://e-sim.home.pl/testura/img/flags/small/Brazil.png";
  154. var BULGARIA = "http://e-sim.home.pl/testura/img/flags/small/Bulgaria.png";
  155. var CANADA = "http://e-sim.home.pl/testura/img/flags/small/Canada.png";
  156. var CHILE = "http://e-sim.home.pl/testura/img/flags/small/Chile.png";
  157. var CHINA = "http://e-sim.home.pl/testura/img/flags/small/China.png";
  158. var COLOMBIA = "http://e-sim.home.pl/testura/img/flags/small/Colombia.png";
  159. var CROATIA = "http://e-sim.home.pl/testura/img/flags/small/Croatia.png";
  160. var CZECH = "http://e-sim.home.pl/testura/img/flags/small/Czech-Republic.png";
  161. var ESTONIA = "http://e-sim.home.pl/testura/img/flags/small/Estonia.png";
  162. var FINLAND = "http://e-sim.home.pl/testura/img/flags/small/Finland.png";
  163. var FRANCE = "http://e-sim.home.pl/testura/img/flags/small/France.png";
  164. var GERMANY = "http://e-sim.home.pl/testura/img/flags/small/Germany.png";
  165. var GREECE = "http://e-sim.home.pl/testura/img/flags/small/Greece.png";
  166. var HUNGARY = "http://e-sim.home.pl/testura/img/flags/small/Hungary.png";
  167. var INDIA = "http://e-sim.home.pl/testura/img/flags/small/India.png";
  168. var INDONESIA = "http://e-sim.home.pl/testura/img/flags/small/Indonesia.png";
  169. var IRAN = "http://e-sim.home.pl/testura/img/flags/small/Iran.png";
  170. var IRELAND = "http://e-sim.home.pl/testura/img/flags/small/Ireland.png";
  171. var ISRAEL = "http://e-sim.home.pl/testura/img/flags/small/Israel.png";
  172. var ITALY = "http://e-sim.home.pl/testura/img/flags/small/Italy.png";
  173. var LATVIA = "http://e-sim.home.pl/testura/img/flags/small/Latvia.png";
  174. var LITHUANIA = "http://e-sim.home.pl/testura/img/flags/small/Lithuania.png";
  175. var MALAYSIA = "http://e-sim.home.pl/testura/img/flags/small/Malaysia.png";
  176. var MEXICO = "http://e-sim.home.pl/testura/img/flags/small/Mexico.png";
  177. var NETHERLANDS = "http://e-sim.home.pl/testura/img/flags/small/Netherlands.png";
  178. var NORWAY = "http://e-sim.home.pl/testura/img/flags/small/Norway.png";
  179. var PAKISTAN = "http://e-sim.home.pl/testura/img/flags/small/Pakistan.png";
  180. var PERU = "http://e-sim.home.pl/testura/img/flags/small/Peru.png";
  181. var PHILIPPINES = "http://e-sim.home.pl/testura/img/flags/small/Philippines.png";
  182. var POLAND = "http://e-sim.home.pl/testura/img/flags/small/Poland.png";
  183. var PORTUGAL = "http://e-sim.home.pl/testura/img/flags/small/Portugal.png";
  184. var FYROM = "http://e-sim.home.pl/testura/img/flags/small/Republic-of-Macedonia.png";
  185. var ROMANIA = "http://e-sim.home.pl/testura/img/flags/small/Romania.png";
  186. var RUSSIA = "http://e-sim.home.pl/testura/img/flags/small/Russia.png";
  187. var SERBIA = "http://e-sim.home.pl/testura/img/flags/small/Serbia.png";
  188. var SLOVENIA = "http://e-sim.home.pl/testura/img/flags/small/Slovenia.png";
  189. var SOUTHKOREA = "http://e-sim.home.pl/testura/img/flags/small/South-Korea.png";
  190. var SPAIN = "http://e-sim.home.pl/testura/img/flags/small/Spain.png";
  191. var SWEDEN = "http://e-sim.home.pl/testura/img/flags/small/Sweden.png";
  192. var SWITZERLAND = "http://e-sim.home.pl/testura/img/flags/small/Switzerland.png";
  193. var TAIWAN = "http://e-sim.home.pl/testura/img/flags/small/Taiwan.png";
  194. var TURKEY = "http://e-sim.home.pl/testura/img/flags/small/Turkey.png";
  195. var USA = "http://e-sim.home.pl/testura/img/flags/small/USA.png";
  196. var UKRAINE = "http://e-sim.home.pl/testura/img/flags/small/Ukraine.png";
  197. var UK = "http://e-sim.home.pl/testura/img/flags/small/United-Kingdom.png";
  198. // Others Image
  199.  
  200. var IMGSH = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/stock_new_chart_next_graph-20.png"
  201. var IMGTV = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/travels_travel_vector_simple-20.png"
  202. var IMGMM = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/cash_money_dollar_payment_coins_wallet_register.png"
  203. var IMGCT = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/newspaper_edit.png"
  204. var IMGPM = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/Product_basket.png"
  205. var IMGMU = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/Soldier.png"
  206. var IMGPACKAGE = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/icon-gift.gif";
  207. var IMGDOLLAR = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/currency_dollar_pound_money-20.png";
  208. var IMGEQUIPMENT = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/shield_silver.png";
  209. var IMGCOMPANY = "https://dl.dropboxusercontent.com/u/67548179/esim-ED/img/Factory.png";
  210. var IMGONLINE = "http://e-sim.home.pl/testura/img/newOnline.png";
  211. var IMGOFFLINE = "http://e-sim.home.pl/testura/img/newOffline.png";
  212. var IMGPRODBG = "http://e-sim.home.pl/testura/img/productIcons/background.png";
  213. var IMGCRITICAL = "http://e-sim.home.pl/testura/img/equipmentIcons/criticalHit.png";
  214. var IMGMISS = "http://e-sim.home.pl/testura/img/equipmentIcons/reduceMiss.png";
  215. var IMGAVOID = "http://e-sim.home.pl/testura/img/equipmentIcons/avoidDamage.png";
  216.  
  217. // VARS
  218. var cachedSettings = null; // GM friendly function
  219. var currentServer = null;
  220. var selectedFood = null;
  221. var selectedGift = null;
  222. var selectedWeapon = null;
  223. var selectedCurrency = null;
  224. var idPlayer = null;
  225. var extendedMU = false;
  226. var savedWorkedList = [];
  227.  
  228.  
  229. // CODE
  230. function initialize() {
  231. loadConfiguration();
  232.  
  233. var previousSelection = getValue( "lastSelectionMUStorage" );
  234. setValue( "lastSelectionMUStorage", "" );
  235.  
  236. // Do different things on diferents urls
  237. var localUrl = new String( window.location );
  238. if( localUrl.indexOf( URLMain, 0 ) >= 0 ) {
  239.  
  240. //if( !isOrgAccount() ) { updateMUOrdersMain(); }
  241.  
  242. // MU main page
  243. } else if( (localUrl.indexOf( URLMyMU, 0 ) >= 0) || (localUrl.indexOf( URLMUMain, 0 ) >= 0) ) {
  244.  
  245. changeMUMainMenu();
  246.  
  247. // MU storage
  248. } else if( localUrl.indexOf( URLMUStorage, 0 ) >= 0 ) {
  249.  
  250. removeFirstBlock();
  251. if( getValue( "configMUStorageDonateToMe" ) == "true" ) { addDonateToMeButton( "#donateProductForm" ); }
  252. if( getValue( "configMUStorageSelect" ) == "true" ) { changeSelectMUStorage( "#donateProductForm" ); }
  253. if( getValue( "configMUStorageFastButtons" ) == "true" ) { addMUFastButtons( "#quantity" ); }
  254. if( getValue( "configMUStorageDonateImprovements" ) == "true" ) {
  255. orderMU( "#donateProductForm", previousSelection );
  256. addUpdateJobsButton( "#donateProductForm" );
  257. addUpdateConnectionButton( "#donateProductForm" );
  258. }
  259. if( getValue( "configMUStorageDonateCounter" ) == "true" ) { addCounterMembersMU(); }
  260.  
  261. // MU money
  262. } else if( localUrl.indexOf( URLMUMoney, 0 ) >= 0 ) {
  263.  
  264. removeFirstBlock();
  265. if( getValue( "configMUMoneyDonateToMe" ) == "true" ) { addDonateToMeButton( "#donateMoneyForm" ); }
  266. if( getValue( "configMUMoneyDonateImprovements" ) == "true" ) { orderMU( "#donateMoneyForm", "" ); }
  267. //addCounterMembersMU();
  268.  
  269. // Donate player to player
  270. } else if( localUrl.indexOf( URLDDonatePlayerProduct, 0 ) >= 0 ) {
  271.  
  272. if( getValue( "configDonateProduct" ) == "true" ) { changeSelectPlayerToPlayer(); }
  273. if( getValue( "configDonateFastButtons" ) == "true" ) { addFastButtons( "#quantity" ); }
  274.  
  275. // Donate player to MU
  276. } else if( localUrl.indexOf( URLDonateMUProduct, 0 ) >= 0 ) {
  277.  
  278. if( getValue( "configDonateProduct" ) == "true" ) { changeSelectPlayerToPlayer(); }
  279. if( getValue( "configDonateFastButtons" ) == "true" ) { addFastButtons( "#quantity" ); }
  280.  
  281. // Battle weapon selector
  282. } else if( localUrl.indexOf( URLBattle, 0 ) >= 0 ) {
  283.  
  284. if( !isOrgAccount() ) {
  285. calculateBonus();
  286. if( getValue( "configWeaponSelector" ) == "true" ) { changeWeaponBattle(); }
  287. }
  288. if( getValue( "configRoundSelector" ) == "true" ) { changeRoundSelector(); }
  289.  
  290. // Contract creator
  291. } else if( localUrl.indexOf( URLContract, 0 ) >= 0 ) {
  292.  
  293. //changeCreateContract();
  294.  
  295. // Market
  296. } else if( localUrl.indexOf( URLMarket, 0 ) >= 0 ) {
  297.  
  298. if( getValue( "configProductMarketSelection" ) == "true" ) { changeProductSelection(); }
  299. if( getValue( "configProductMarketTable" ) == "true" ) { changeProductMarketTable(); }
  300.  
  301. // Market offers
  302. } else if( localUrl.indexOf( URLMarketOffers, 0 ) >= 0 ) {
  303.  
  304. if( getValue( "configProductMarketOffers" ) == "true" ) { changeMarketOffers(); }
  305.  
  306. // Monetary market improvements
  307. } else if( localUrl.indexOf( URLMonetaryMarket, 0 ) >= 0 ) {
  308.  
  309. if( getValue( "configMonetaryMarketSelection" ) == "true" ) { changeMonetaryMarket(); }
  310. if( getValue( "configMonetaryMarketTable" ) == "true" ) { changeMonetaryMarketTable(); }
  311.  
  312. // My Shares menu
  313. } else if( localUrl.indexOf( URLMyShares, 0 ) >= 0 ) {
  314.  
  315. addSharesExtraLinks();
  316.  
  317. // Shares main menu
  318. } else if( localUrl.indexOf( URLStockCompany, 0 ) >= 0 ) {
  319.  
  320. changeStockMainMenu();
  321. if( getValue( "configSharesMenu" ) == "true" ) { changeStockFloatingDivs(); }
  322.  
  323. // Shares company product
  324. } else if( localUrl.indexOf( URLStockProducts, 0 ) >= 0 ) {
  325.  
  326. changeStockMainMenu();
  327. if( getValue( "configSharesProductSelection" ) == "true" ) { changeStockProductSelection(); }
  328.  
  329. // Travel
  330. } else if( localUrl.indexOf( URLTravel, 0 ) >= 0 ) {
  331.  
  332. if( getValue( "configTravelMenu" ) == "true" ) { changeTravelMenu(); }
  333.  
  334. // Equipment
  335. } else if( localUrl.indexOf( URLEquipment, 0 ) >= 0 ) {
  336.  
  337. if( getValue( "configDesignEquipment" ) == "true" ) { redesignEquipment(); }
  338. if( getValue( "configCalculateDamage" ) == "true" ) { calculateEquipmentDamage(); }
  339.  
  340. // Company
  341. } else if( localUrl.indexOf( URLCompany, 0 ) >= 0 ) {
  342.  
  343. if( getValue( "configCompanyRedesign" ) == "true" ) { companyImprovements(); }
  344. addCompanyButtons();
  345.  
  346. // Company work results
  347. } else if( localUrl.indexOf( URLCompanyDetails, 0 ) >= 0 ) {
  348.  
  349. if( getValue( "configCompanyWorkResults" ) == "true" ) { companyWorkResults(); }
  350.  
  351. // Job market
  352. } else if( localUrl.indexOf( URLJobMarket, 0 ) >= 0 ) {
  353.  
  354. if( getValue( "configSkillImprovements" ) == "true" ) { jobMarketSkills(); }
  355.  
  356. // List of battles
  357. } else if( localUrl.indexOf( URLBattleList, 0 ) >= 0 ) {
  358.  
  359. if( getValue( "configBattleList" ) == "true" ) { changeBattleList(); }
  360. }
  361.  
  362. // Global code
  363. if( $( "form[action='login.html']" ).length == 0 ) {
  364.  
  365. addVersion();
  366. addConfigurationUI();
  367. if( getValue( "configMoveNotifications" ) == "true" ) { rellocateMessages(); }
  368. if( getValue( "configMUFastLinks" ) == "true" ) { addMUFastLinks(); }
  369. if( getValue( "configFastLinks" ) == "true" ) { addFastLinks(); }
  370. if( getValue( "configEatButtons" ) == "true" ) { changeEatButtons(); }
  371. if( getValue( "configRemoveLang" ) == "true" ) {removeLang(); }
  372. if( getValue( "configOrgAcc" ) == "true" ) {OrgAcc(); }
  373. if( getValue( "configRemoveUselessFastButtons" ) == "true" ) {removeUselessFastbuttons(); }
  374.  
  375. //changeProfile();
  376. }
  377.  
  378. // Set all buttons with pointer cursor
  379. $( "body" ).find( "input[type='submit']" ).each( function() { $(this).css({ "cursor" : "pointer" }); });
  380. $( "body" ).find( "input[type='button']" ).each( function() { $(this).css({ "cursor" : "pointer" }); });
  381.  
  382. } initialize();
  383.  
  384.  
  385. // Load configuration from disk or default
  386. function loadConfiguration() {
  387. if( $( "form[action='login.html']" ).length != 0 ) { return; }
  388.  
  389. // Global
  390. if( !getValue( "configFastLinks" ) ) { setValue( "configFastLinks", "true" ); }
  391. if( !getValue( "configMUFastLinks" ) ) { setValue( "configMUFastLinks", "true" ); }
  392. if( !getValue( "configMoveNotifications" ) ) { setValue( "configMoveNotifications", "true" ); }
  393. if( !getValue( "configEatButtons" ) ) { setValue( "configEatButtons", "false" ); }
  394. if( !getValue( "configSkillImprovements" ) ) { setValue( "configSkillImprovements", "true" ); }
  395. if( !getValue( "configRemoveLang" ) ) { setValue( "configRemoveLang", "true" ); }
  396. if( !getValue( "configOrgAcc" ) ) { setValue( "configOrgAcc", "true" ); }
  397. if( !getValue( "configRemoveUselessFastButtons" ) ) { setValue( "configRemoveUselessFastButtons", "true" ); }
  398.  
  399. // MU storage
  400. if( !getValue( "configMUStorageDonateToMe" ) ) { setValue( "configStorageDonateToMe", "true" ); }
  401. if( !getValue( "configMUStorageSelect" ) ) { setValue( "configMUStorageSelect", "true" ); }
  402. if( !getValue( "configMUStorageFastButtons" ) ) { setValue( "configMUStorageFastButtons", "true" ); }
  403. if( !getValue( "configMUStorageDonateImprovements" ) ) { setValue( "configMUStorageDonateImprovements", "true" ); }
  404. if( !getValue( "configMUStorageDonateCounter" ) ) { setValue( "configMUStorageDonateCounter", "true" ); }
  405.  
  406. // MU money
  407. if( !getValue( "configMUMoneyDonateToMe" ) ) { setValue( "configMUMoneyDonateToMe", "true" ); }
  408. if( !getValue( "configMUMoneyDonateImprovements" ) ) { setValue( "configMUMoneyDonateImprovements", "true" ); }
  409.  
  410. // Donate
  411. if( !getValue( "configDonateProduct" ) ) { setValue( "configDonateProduct", "true" ); }
  412. if( !getValue( "configDonateFastButtons" ) ) { setValue( "configDonateFastButtons", "true" ); }
  413.  
  414. // Battle
  415. if( !getValue( "configRoundSelector" ) ) { setValue( "configRoundSelector", "true" ); }
  416. if( !getValue( "configBattleList" ) ) { setValue( "configBattleList", "true" ); }
  417. if( !getValue( "configWeaponSelector" ) ) { setValue( "configWeaponSelector", "true" ); }
  418. if( !getValue( "configWeaponTheme" ) ) { setValue( "configWeaponTheme", "AoE" ); }
  419. if( !getValue( "configDefaultWeapon" ) ) { setValue( "configDefaultWeapon", "1" ); }
  420.  
  421. // Equipment
  422. if( !getValue( "configDesignEquipment" ) ) { setValue( "configDesignEquipment", "true" ); }
  423. if( !getValue( "configCalculateDamage" ) ) { setValue( "configCalculateDamage", "true" ); }
  424.  
  425. // Shares
  426. if( !getValue( "configSharesMenu" ) ) { setValue( "configSharesMenu", "true" ); }
  427. if( !getValue( "configSharesProductSelection" ) ) { setValue( "configSharesProductSelection", "true" ); }
  428.  
  429. // Travel
  430. if( !getValue( "configTravelMenu" ) ) { setValue( "configTravelMenu", "true" ); }
  431.  
  432. // Company
  433. if( !getValue( "configCompanyRedesign" ) ) { setValue( "configCompanyRedesign", "true" ); }
  434. if( !getValue( "configCompanyWorkResults" ) ) { setValue( "configCompanyWorkResults", "true" ); }
  435.  
  436. // Market
  437. if( !getValue( "configProductMarketSelection" ) ) { setValue( "configProductMarketSelection", "true" ); }
  438. if( !getValue( "configProductMarketTable" ) ) { setValue( "configProductMarketTable", "true" ); }
  439. if( !getValue( "configProductMarketOffers" ) ) { setValue( "configProductMarketOffers", "true" ); }
  440.  
  441. // Monetary Market
  442. if( !getValue( "configMonetaryMarketSelection" ) ) { setValue( "configMonetaryMarketSelection", "true" ); }
  443. if( !getValue( "configMonetaryMarketTable" ) ) { setValue( "configMonetaryMarketTable", "true" ); }
  444. }
  445.  
  446.  
  447. // Remove Useless Fast buttons
  448. function removeUselessFastbuttons(){
  449.  
  450. $(".smallHeaderSecond:eq(1)").hide();
  451. $("#userMenu ul:eq(1)").hide();
  452.  
  453. }
  454.  
  455. // Check if is Org account
  456. function isOrgAccount() {
  457.  
  458. if( $("#actualXp").text() == 1 ) { return( true ); }
  459. return( false );
  460. }
  461.  
  462. // Remove useless items if its ORG
  463. function OrgAcc(){
  464.  
  465. if(isOrgAccount()){
  466.  
  467. $("#dailyButton").hide();
  468. $("h4.smallHeaderSecond:first").hide();
  469. $("#numero5").hide();
  470. $(".smallHeader.plateHeader:first").hide();
  471. $(".foundation-divider:eq(2)").hide();
  472.  
  473. }
  474. }
  475.  
  476. //Remove Language Selection
  477. function removeLang(){
  478.  
  479.  
  480. $("form[action|='editCitizen.html#changeLanguage']").remove();
  481.  
  482.  
  483. }
  484. // Change eat food/use gift selectors
  485. function changeEatButtons() {
  486.  
  487. $( "#eatLink" ).hide();
  488. $( "#useGiftLink" ).hide();
  489.  
  490. $( "#eatMenu" ).show();
  491. $( "#eatMenu" ).addClass( "eatMenuMod" );
  492. $( "#useGiftMenu" ).show();
  493. $( "#useGiftMenu" ).addClass( "useGiftMenuMod" );
  494. if( $( "#medkitButton" ).length > 0 ) {
  495. $( "#medkitButton" ).val( $( "#medkitButton" ).val().replace( "(you have ", "(" ).replace( ")", " left)" ) );
  496. }
  497.  
  498. var maxIndexFood = 0;
  499. var maxIndexGift = 0;
  500. var vecItemsFood = [];
  501. var vecItemsGift = [];
  502.  
  503. var index = 0;
  504. $( "#foodQuality" ).find( "option" ).each( function() {
  505. if( $(this).attr( "value" ) == "0" ) { index++; return; }
  506.  
  507. var str = $(this).text();
  508. var number = str.indexOf( "(", 0 );
  509. if( number != -1 ) {
  510. str = str.substr( number + 1, str.indexOf( ")", number ) - number - 1 );
  511. str = str.replace( "you have ", "" );
  512. }
  513.  
  514. var food = $( "<div class='foodItem' indexSelect='"+ index +"'></div>" );
  515. food.append( "<img class='imageFood' src='"+ IMGFOOD +"' />" );
  516. food.append( "<img class='qualityImage' src='"+ IMGQUALITY + index + IMGEXTENSION +"' style='' />" );
  517. food.append( "<div class='numberItems'>"+ str +"</div>" );
  518.  
  519. if( str != 0 ) {
  520. maxIndexFood = index;
  521.  
  522. food.bind( "mouseover", function() {
  523. if( selectedFood.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).addClass( "foodItemHover" ); }
  524. });
  525. food.bind( "mouseout", function() {
  526. if( selectedFood.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).removeClass( "foodItemHover" ); }
  527. });
  528.  
  529. food.bind( "click", function() {
  530. if( selectedFood ) { selectedFood.removeClass( "foodItemSelected" ); }
  531. $(this).addClass( "foodItemSelected" );
  532. selectedFood = $(this);
  533.  
  534. $( "#foodQuality option" )[ $(this).attr( "indexselect" ) ].selected = true;
  535. updateHealthButtons();
  536. });
  537.  
  538. } else food.addClass( "itemDisabled" );
  539.  
  540. vecItemsFood.push( food );
  541. $( "#eatMenu form" ).append( food );
  542.  
  543. index++;
  544. });
  545.  
  546.  
  547. index = 0;
  548. $( "#giftQuality" ).find( "option" ).each( function() {
  549. if( $(this).attr( "value" ) == "0" ) { index++; return; }
  550.  
  551. var str = $(this).text();
  552. var number = str.indexOf( "(", 0 );
  553. if( number != -1 ) {
  554. str = str.substr( number + 1, str.indexOf( ")", number ) - number - 1 );
  555. str = str.replace( "you have ", "" );
  556. }
  557.  
  558. var gift = $( "<div class='foodItem' indexSelect='"+ index +"'></div>" );
  559. gift.append( "<img class='imageFood' src='"+ IMGGIFT +"' />" );
  560. gift.append( "<img class='qualityImage' src='"+ IMGQUALITY + index +".png' />" );
  561. gift.append( "<div class='numberItems'>"+ str +"</div>" );
  562.  
  563. if( str != 0 ) {
  564. maxIndexGift = index;
  565.  
  566. gift.bind( "mouseover", function() {
  567. if( selectedGift.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).addClass( "foodItemHover" ); }
  568. });
  569.  
  570. gift.bind( "mouseout", function() {
  571. if( selectedGift.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).removeClass( "foodItemHover" ); }
  572. });
  573.  
  574. gift.bind( "click", function() {
  575. if( selectedGift ) { selectedGift.removeClass( "foodItemSelected" ); }
  576. $(this).addClass( "foodItemSelected" );
  577. selectedGift = $(this);
  578.  
  579. $( "#giftQuality option" )[ $(this).attr( "indexselect" ) ].selected = true;
  580. updateHealthButtons();
  581. });
  582.  
  583. } else gift.addClass( "itemDisabled" );
  584.  
  585. vecItemsGift.push( gift );
  586. $( "#useGiftMenu form" ).append( gift );
  587.  
  588. index++;
  589. });
  590.  
  591.  
  592. // Change Eat and Use buttons
  593. var newEatButton = $( "<input type='button' id='newEatButton' value='Eat' />" )
  594. $( "#eatMenu" ).append( newEatButton );
  595. $( "#eatMenu form" ).append( $( "#eatButton" ) );
  596.  
  597. newEatButton.bind( "click", function() {
  598. var dataString = 'quality='+ $( "#foodQuality" ).val();
  599. $.ajax({
  600. type: "POST",
  601. url: "eat.html",
  602. data: dataString,
  603. success: function( msg ) {
  604. var json = jQuery.parseJSON( msg );
  605.  
  606. $( "#foodLimit" ).html( json.foodLimit );
  607. $( "#healthProgress .ui-progressbar-value" ).css({ width: json.wellness + "%" });
  608.  
  609. $( "#q1FoodStorage" ).html( "Q1 Food ("+json.q1FoodStorage+" left)" );
  610. $( "#q2FoodStorage" ).html( "Q2 Food ("+json.q2FoodStorage+" left)" );
  611. $( "#q3FoodStorage" ).html( "Q3 Food ("+json.q3FoodStorage+" left)" );
  612. $( "#q4FoodStorage" ).html( "Q4 Food ("+json.q4FoodStorage+" left)" );
  613. $( "#q5FoodStorage" ).html( "Q5 Food ("+json.q5FoodStorage+" left)" );
  614.  
  615. //$( ".usedHealth" ).animate( { "width" : json.wellness+"%" }, 500 );
  616. updateHealthButtons();
  617.  
  618. var divList = $( "#eatMenu form" ).children( "div" );
  619. divList.eq(0).children( "div" ).text( json.q1FoodStorage );
  620. divList.eq(1).children( "div" ).text( json.q2FoodStorage );
  621. divList.eq(2).children( "div" ).text( json.q3FoodStorage );
  622. divList.eq(3).children( "div" ).text( json.q4FoodStorage );
  623. divList.eq(4).children( "div" ).text( json.q5FoodStorage );
  624.  
  625. if( json.error != "" ) {
  626. $( '#hiddenError' ).html( json.error );
  627. $.blockUI({ message: $( '#eatError' ), css: { width: '400px', border: '0px', background: 'rgba(255,255,255,0)' } });
  628. }
  629. }
  630. });
  631. });
  632.  
  633. var newGiftButton = $( "<input type='button' id='newGiftButton' value='Use' />" )
  634. $( "#useGiftMenu" ).append( newGiftButton );
  635. $( "#useGiftMenu form" ).append( $( "#useGiftButton" ) );
  636.  
  637. newGiftButton.bind( "click", function() {
  638. var dataString = 'quality='+ $("#giftQuality").val();
  639. $.ajax({
  640. type: "POST",
  641. url: "gift.html",
  642. data: dataString,
  643. success: function( msg ) {
  644. var json = jQuery.parseJSON( msg );
  645.  
  646. $( "#giftLimit" ).html( json.giftLimit );
  647. $( "#healthProgress .ui-progressbar-value" ).css({ width: json.wellness + "%" });
  648.  
  649. $( "#q1GiftStorage" ).html( "Q1 Gift ("+json.q1GiftStorage+" left)" );
  650. $( "#q2GiftStorage" ).html( "Q2 Gift ("+json.q2GiftStorage+" left)" );
  651. $( "#q3GiftStorage" ).html( "Q3 Gift ("+json.q3GiftStorage+" left)" );
  652. $( "#q4GiftStorage" ).html( "Q4 Gift ("+json.q4GiftStorage+" left)" );
  653. $( "#q5GiftStorage" ).html( "Q5 Gift ("+json.q5GiftStorage+" left)" );
  654.  
  655. var divList = $( "#useGiftMenu form" ).children( "div" );
  656. divList.eq(0).children( "div" ).text( json.q1GiftStorage );
  657. divList.eq(1).children( "div" ).text( json.q2GiftStorage );
  658. divList.eq(2).children( "div" ).text( json.q3GiftStorage );
  659. divList.eq(3).children( "div" ).text( json.q4GiftStorage );
  660. divList.eq(4).children( "div" ).text( json.q5GiftStorage );
  661.  
  662. //$( ".usedHealth" ).animate( { "width" : json.wellness+"%" }, 500 );
  663. updateHealthButtons();
  664.  
  665. if( json.error != "" ) {
  666. $( '#hiddenError' ).html( json.error );
  667. $.blockUI({ message: $( '#eatError' ), css: { width: '400px', border: '0px', background: 'rgba(255,255,255,0)' } });
  668. }
  669. }
  670. });
  671. });
  672.  
  673.  
  674. // Redesign food and gift limits
  675. $( "#foodLimit" ).addClass( "foodLimitMod" );
  676. $( "#giftLimit" ).addClass( "giftLimitMod" );
  677. $( "#eatMenu form" ).append( $( "#foodLimit" ) );
  678. $( "#useGiftMenu form" ).append( $( "#giftLimit" ) );
  679.  
  680. $( "#foodQuality" ).css({ "display" : "none" });
  681. $( "#giftQuality" ).css({ "display" : "none" });
  682. $( "#eatButton" ).css({ "display" : "none" });
  683. $( "#useGiftButton" ).css({ "display" : "none" });
  684.  
  685. $( "#eatLink" ).prev().remove();
  686. $( "#eatMenu" ).prev().remove();
  687. $( "#useGiftLink" ).prev().remove();
  688. $( "#useGiftLink" ).next().remove();
  689. if( isOrgAccount() ) {
  690. $( "#eatLink" ).prev().remove();
  691. $( "#eatLink" ).prev().remove();
  692. $( "#useGiftLink" ).prev().remove();
  693. }
  694.  
  695. // Default max quality items
  696. if( maxIndexFood > 0 ) { vecItemsFood[ maxIndexFood-1].click(); }
  697. if( maxIndexGift > 0 ) { vecItemsGift[ maxIndexGift-1].click(); }
  698.  
  699. showHideButtons();
  700. updateHealthButtons();
  701.  
  702. if( $( "#stats" ).children( "form" ).length != 0 ) {
  703. var form = $( "#stats" ).children( "form" );
  704. form.contents().eq(4).remove();
  705. form.children( "img" ).css({ "margin" : "2px 7px 0px 0px" });
  706.  
  707. // Rellocate wiki help
  708. var lastDiv = $( "#stats" ).children( "div:last" );
  709. lastDiv.css({ "float" : "right", "margin" : "6px 3px 0px 0px" });
  710. lastDiv.children( "a" ).text( "" ).append( lastDiv.children( "img" ) );
  711. form.children( "br" ).remove();
  712. form.append( lastDiv );
  713. }
  714. }
  715.  
  716.  
  717. // Show and hide Food/Gift buttons
  718. function showHideButtons() {
  719.  
  720. // Show/Hide button
  721. var showHide = $( "<div id='showHide'></div>" );
  722. showHide.append( "<span class='arrow'> &darr;&darr; </span>" );
  723. showHide.append( "<span style='font-weight:bold; color:#3787ea;'> Eat food / Use gift </span>" );
  724. showHide.append( "<span class='arrow'> &darr;&darr; </span>" );
  725. showHide.insertBefore( $( "#eatMenu" ) );
  726.  
  727. // On battle page will be always visible
  728. var foodGiftVisible = true;
  729. var localUrl = new String( window.location );
  730. if( localUrl.indexOf( URLBattle, 0 ) == -1 ) {
  731. foodGiftVisible = false;
  732. $( "#eatMenu" ).hide();
  733. $( "#useGiftMenu" ).hide();
  734. $( "#useGiftMenu" ).next().hide();
  735.  
  736. showHide.children( ".arrow" ).text( String.fromCharCode(8593) + String.fromCharCode(8593) )
  737. }
  738.  
  739. showHide.bind( "click", function() {
  740. var time = 0;
  741. foodGiftVisible = !foodGiftVisible;
  742. $( "#eatMenu" ).toggle( time );
  743. $( "#useGiftMenu" ).toggle( time );
  744. $( "#useGiftMenu" ).next().toggle( time );
  745.  
  746. if( foodGiftVisible ) {
  747. showHide.children( ".arrow" ).text( String.fromCharCode(8595) + String.fromCharCode(8595) );
  748. } else showHide.children( ".arrow" ).text( String.fromCharCode(8593) + String.fromCharCode(8593) );
  749. });
  750. }
  751.  
  752.  
  753. // Update health buttons to enable or disable
  754. function updateHealthButtons() {
  755.  
  756. var h = $( "#healthProgress" ).attr( "title" );
  757. h = parseInt( h.split( "/" )[0] );
  758. var foodLimit = parseInt( $( "#foodLimit" ).text() );
  759. var giftLimit = parseInt( $( "#giftLimit" ).text() );
  760. if( foodLimit == 0 ) {
  761. disableButton( $( "#newEatButton" ) );
  762.  
  763. } else {
  764. if( selectedFood ) {
  765. var eatQ = parseInt( selectedFood.attr( "indexselect" ) ) * 10;
  766. if( (eatQ + h) > 100 ) {
  767. disableButton( $( "#newEatButton" ) );
  768. } else {
  769. enableButton( $( "#newEatButton" ) );
  770. }
  771.  
  772. } else enableButton( $( "#newEatButton" ) );
  773. }
  774.  
  775. if( giftLimit == 0 ) {
  776. disableButton( $( "#newGiftButton" ) );
  777.  
  778. } else {
  779. if( selectedGift ) {
  780. var useQ = parseInt( selectedGift.attr( "indexselect" ) ) * 10;
  781. if( (useQ + h) > 100 ) {
  782. disableButton( $( "#newGiftButton" ) );
  783. } else {
  784. enableButton( $( "#newGiftButton" ) );
  785. }
  786.  
  787. } else enableButton( $( "#newGiftButton" ) );
  788. }
  789.  
  790. updateFightButtons();
  791. }
  792.  
  793.  
  794. // Disable button
  795. function disableButton( btn ) {
  796. btn.attr( "disabled", "disabled" );
  797. btn.addClass( "buttonDisable" );
  798. }
  799.  
  800.  
  801. // Enable button
  802. function enableButton( btn ) {
  803. btn.removeAttr( "disabled" );
  804. btn.removeClass( "buttonDisable" );
  805. }
  806.  
  807.  
  808. // Update fight buttons
  809. function updateFightButtons() {
  810.  
  811. // Only on battle page
  812. /*if( (new String( window.location )).indexOf( URLBattle, 0 ) >= 0 ) {
  813.  
  814. // If is RW
  815. if( $( ".fightButton2" ).length == 4 ) {
  816.  
  817. var btnFight1 = $( ".fightButton2" ).eq(0);
  818. var btnFight2 = $( ".fightButton2" ).eq(1);
  819. var btnBk1 = $( ".fightButton2" ).eq(2);
  820. var btnBk2 = $( ".fightButton2" ).eq(3);
  821. var h = parseInt( $( "#healthBar" ).text() );
  822. if( h < 10 ) {
  823. disableButton( btnFight1 );
  824. disableButton( btnFight2 );
  825. disableButton( btnBk1 );
  826. disableButton( btnBk2 );
  827.  
  828. } else if( h < 50 ) {
  829. enableButton( btnFight1 );
  830. enableButton( btnFight2 );
  831. disableButton( btnBk1 );
  832. disableButton( btnBk2 );
  833.  
  834. } else {
  835. enableButton( btnFight1 );
  836. enableButton( btnFight2 );
  837. enableButton( btnBk1 );
  838. enableButton( btnBk2 );
  839. }
  840.  
  841. } else {
  842.  
  843. var btnFight = $( ".fightButton" ).eq(0);
  844. var btnBk = $( ".fightButton" ).eq(1);
  845. var h = parseInt( $( "#healthBar" ).text() );
  846. if( h < 10 ) {
  847. disableButton( btnFight );
  848. disableButton( btnBk );
  849.  
  850. } else if( h < 50 ) {
  851. enableButton( btnFight );
  852. disableButton( btnBk );
  853.  
  854. } else {
  855. enableButton( btnFight );
  856. enableButton( btnBk );
  857. }
  858. }
  859.  
  860. // Add update weapon method
  861. $.blockUI.defaults.onUnblock = function( elem, opts ) { updateHealthButtons(); }
  862. }*/
  863. }
  864.  
  865.  
  866. // Add MU fast links
  867. function addMUFastLinks() {
  868.  
  869. // Link to MU
  870. var linkMU = $( "<a title='Military unit' class='button foundation-style smallhelp only-icon profileButton' href='"+ getCurrentServer() + URLMyMU +"'><img src='"+ IMGMU +"' /></a>" );
  871. linkMU.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top-25", at: "center top" } });
  872.  
  873. // Link to MU storage
  874. var linkMUSt = $( "<a title='MU storage' class='button foundation-style smallhelp only-icon profileButton' href='"+ getCurrentServer() + URLMUStorage +"'><img src='"+ IMGPACKAGE +"' /></a>" );
  875. linkMUSt.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top-25", at: "center top" } });
  876.  
  877. // Link to MU money
  878. var linkMUMy = $( "<a title='MU money' class='button foundation-style smallhelp only-icon profileButton' href='"+ getCurrentServer() + URLMUMoney +"'><img src='"+ IMGDOLLAR +"' /></a>" );
  879. linkMUMy.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top-25", at: "center top" } });
  880.  
  881. var content = $( "<div style= font-weight:bold; height:30px;'></div>" );
  882. content.append( linkMU );
  883. content.append( linkMUSt );
  884. content.append( linkMUMy );
  885. content.insertAfter( $( "#EDLinks div:first" ));
  886. }
  887.  
  888.  
  889. // Add other fast links
  890. function addFastLinks() {
  891.  
  892. // Link to equipment
  893. var linkEquip = $( "<a style='padding:2px' class='fastLinks ' href='"+ getCurrentServer() + URLEquipment +"'></a>" );
  894. linkEquip.append( "<img src='"+ IMGEQUIPMENT +"' />" );
  895. linkEquip.attr( "title", "Equipment" );
  896. linkEquip.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  897.  
  898. // Link to my companies
  899. var linkComp = $( "<a style='padding:2px' class='fastLinks ' href='"+ getCurrentServer() + URLCompanies +"'></a>" );
  900. linkComp.append( "<img src='"+ IMGCOMPANY +"' />" );
  901. linkComp.attr( "title", "My companies" );
  902. linkComp.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  903.  
  904. // Future image buttons
  905. // Link to contracts
  906. var linkCT = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLContracts +"'><img src='"+ IMGCT +"' /></a>" );
  907. linkCT.attr( "title", "Contracts" );
  908. linkCT.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  909.  
  910. // Link to shares
  911. var linkSH = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLMyShares +"'><img src='"+ IMGSH +"' /></a>" );
  912. linkSH.attr( "title", "Shares" );
  913. linkSH.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  914.  
  915. // Link to product market
  916. var linkPM = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLMarket +"'><img src='"+ IMGPM +"' /></a>" );
  917. linkPM.attr( "title", "Product market" );
  918. linkPM.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  919.  
  920. // Link to monetary market
  921. var linkMM = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLMonetaryMarket +"'><img src='"+ IMGMM +"' /></a>" );
  922. linkMM.attr( "title", "Monetary market" );
  923. linkMM.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  924.  
  925. // Link to Travel
  926. var linkTV = $( "<a style='padding:2px' class='fastLinks' href='"+ getCurrentServer() + URLTravel +"'><img src='"+ IMGTV +"' /></a>" );
  927. linkTV.attr( "title", "Travel" );
  928. linkTV.tooltip({ tooltipClass: "tooltipFastButton", position: { my: "center top+4", at: "center bottom" } });
  929.  
  930. var content = $( "<div style='font-weight:bold; height:30px;'></div>" );
  931. content.append( linkEquip );
  932. content.append( linkComp );
  933. content.append( linkCT );
  934. content.append( linkSH );
  935. content.append( linkPM );
  936. content.append( linkMM );
  937. content.append( linkTV );
  938. content.insertAfter( $( "#EDLinks div:first" ));
  939. }
  940.  
  941.  
  942. // Get ID player
  943. function getPlayerID() {
  944. if( !idPlayer ) {
  945. var link = $( "#userImage" ).parent().attr( "href" );
  946. if( link ) {
  947. if( link.split( "id=" ).length == 2 ) {
  948. idPlayer = link.split( "id=" )[1];
  949. }
  950. }
  951. } return( idPlayer );
  952. }
  953.  
  954.  
  955. // Get current server
  956. function getCurrentServer() {
  957. if( !currentServer ) {
  958. var localUrl = new String( window.location );
  959. var ini = localUrl.indexOf( "http://", 0 );
  960. var end = localUrl.indexOf( ".", 0 );
  961. currentServer = localUrl.substr( ini, end-ini+1 );
  962. } return( currentServer );
  963. }
  964.  
  965.  
  966. // Add version on all pages if not Battlepage
  967. function addVersion() {
  968.  
  969. // Version
  970. var vers = $( "<div class='version'>" + VERSION + "</div>" );
  971. var optionVisible = false;
  972. vers.bind( "click", function() { $( "#maskConfig" ).show(); $( "#configScript" ).show(); });
  973.  
  974. var content = $( "<div id='EDLinks' class='switch foundation-style' style='margin-top:5px; display:block; font-weight:bold; height:auto;'></div>" );
  975. content.insertAfter( $( "#userMenu div ul:first" ) );
  976. content.append( vers );
  977.  
  978.  
  979. }
  980.  
  981.  
  982. // Add configuration
  983. function addConfigurationUI() {
  984.  
  985. // Add mask and config
  986. var mask = $( "<div style='background-color:black; opacity:0.5; min-height: 100%;' id='maskConfig'></div>" );
  987. var configScript = $( "<div role='dialog' style='display: table; outline: 0px none; z-index: 1000; width:600px; left: 350px; top: 100px;' class='ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-dialog-buttons' id='configScript'></div>" );
  988. $( "body" ).append( mask );
  989. $( "body" ).append( configScript );
  990.  
  991. // Title
  992. configScript.append( "<h2 class='titleConfig'>Configuration "+ VERSION +"</h2>" );
  993. configScript.append( "<a href='"+ URLSCRIPT +"' target='_blank'>check new version</a>" );
  994. configScript.append( "<br/>" );
  995.  
  996. // Global config
  997. var globalBlock = $( "<div id='globalBlock'>GLOBAL</div>" );
  998. var muFastLinks = createCheckBox( "MU Fast links", "configMUFastLinks" );
  999. globalBlock.append( muFastLinks );
  1000. var fastLinks = createCheckBox( "Fast links", "configFastLinks" );
  1001. globalBlock.append( fastLinks );
  1002. var configMoveNotify = createCheckBox( "Move notifications", "configMoveNotifications" );
  1003. globalBlock.append( configMoveNotify );
  1004. //var configEatButtons = createCheckBox( "Food/Gifts buttons", "configEatButtons" );
  1005. //globalBlock.append( configEatButtons );
  1006. var configSkillImprovements = createCheckBox( "Skill Improvements", "configSkillImprovements" );
  1007. globalBlock.append( configSkillImprovements );
  1008. var configRemoveLang = createCheckBox( "Language Slection remove", "configRemoveLang" );
  1009. globalBlock.append( configRemoveLang );
  1010. var configOrgAcc = createCheckBox( "Remove useless items if Org.", "configOrgAcc" );
  1011. globalBlock.append( configOrgAcc );
  1012. var configRemoveUselessFastButtons = createCheckBox( "Remove useless fast buttons.", "configRemoveUselessFastButtons" );
  1013. globalBlock.append( configRemoveUselessFastButtons );
  1014.  
  1015. // MU storage
  1016. var muStorageBlock = $( "<div id='muStorageBlock'>MU STORAGE</div>" );
  1017. var muStorageDonateToMe = createCheckBox( "Button: Donate me", "configMUStorageDonateToMe" );
  1018. muStorageBlock.append( muStorageDonateToMe );
  1019. var muStorageSelect = createCheckBox( "Product selection", "configMUStorageSelect" );
  1020. muStorageBlock.append( muStorageSelect );
  1021. var muStorageFastButtons = createCheckBox( "Fast buttons", "configMUStorageFastButtons" );
  1022. muStorageBlock.append( muStorageFastButtons );
  1023. var muStorageDonateImprovements = createCheckBox( "Donate improvements", "configMUStorageDonateImprovements" );
  1024. muStorageBlock.append( muStorageDonateImprovements );
  1025. var muStorageItemCounter = createCheckBox( "Donate counter", "configMUStorageDonateCounter" );
  1026. muStorageBlock.append( muStorageItemCounter );
  1027.  
  1028. // MU money
  1029. var muMoneyBlock = $( "<div id='muMoneyBlock'>MU MONEY</div>" );
  1030. var muMoneyDonateToMe = createCheckBox( "Button: Donate me", "configMUMoneyDonateToMe" );
  1031. muMoneyBlock.append( muMoneyDonateToMe );
  1032. var muMoneyDonateImprovements = createCheckBox( "Donate improvements", "configMUMoneyDonateImprovements" );
  1033. muMoneyBlock.append( muMoneyDonateImprovements );
  1034.  
  1035. // Donate
  1036. var donateBlock = $( "<div id='donateBlock'>DONATE</div>" );
  1037. var donateProduct = createCheckBox( "Product selection", "configDonateProduct" );
  1038. donateBlock.append( donateProduct );
  1039. var donateFastButtons = createCheckBox( "Fast buttons", "configDonateFastButtons" );
  1040. donateBlock.append( donateFastButtons );
  1041.  
  1042. // Battle
  1043. var battleBlock = $( "<div id='battleBlock'>BATTLE</div>" );
  1044. var roundSelector = createCheckBox( "Round selector", "configRoundSelector" );
  1045. battleBlock.append( roundSelector );
  1046. var battleList = createCheckBox( "Battle list", "configBattleList" );
  1047. battleBlock.append( battleList );
  1048. var weaponSelector = createCheckBox( "Weapon selector", "configWeaponSelector" );
  1049. battleBlock.append( weaponSelector );
  1050.  
  1051. // Equipment
  1052. var equipmentBlock = $( "<div id='equipmentBlock'>EQUIPMENT</div>" );
  1053. var removeInterface = createCheckBox( "Remove interface", "configDesignEquipment" );
  1054. equipmentBlock.append( removeInterface );
  1055. var calculatorDamage = createCheckBox( "Damage simulator", "configCalculateDamage" );
  1056. equipmentBlock.append( calculatorDamage );
  1057.  
  1058. // Shares
  1059. var sharesBlock = $( "<div id='sharesBlock'>SHARES</div>" );
  1060. var sharesRedesign = createCheckBox( "Menu redesign", "configSharesMenu" );
  1061. var sharesProductSelection = createCheckBox( "Product selection", "configSharesProductSelection" );
  1062. sharesBlock.append( sharesRedesign );
  1063. sharesBlock.append( sharesProductSelection );
  1064.  
  1065. // Travel
  1066. var travelBlock = $( "<div id='travelBlock'>TRAVEL</div>" );
  1067. var configTravelMenu = createCheckBox( "Ticket selection", "configTravelMenu" );
  1068. travelBlock.append( configTravelMenu );
  1069.  
  1070. // Company
  1071. var companyBlock = $( "<div id='travelBlock'>COMPANY</div>" );
  1072. var configCompanyMenu = createCheckBox( "Menu redesign", "configCompanyRedesign" );
  1073. var configCompanyWorkResults = createCheckBox( "Work results", "configCompanyWorkResults" );
  1074. companyBlock.append( configCompanyMenu );
  1075. companyBlock.append( configCompanyWorkResults );
  1076.  
  1077. // Market
  1078. var marketBlock = $( "<div id='marketBlock'>MARKET</div>" );
  1079. var configProductMarketSelection = createCheckBox( "Product selection", "configProductMarketSelection" );
  1080. marketBlock.append( configProductMarketSelection );
  1081. var configProductMarketTable = createCheckBox( "Product table", "configProductMarketTable" );
  1082. marketBlock.append( configProductMarketTable );
  1083. var configProductMarketOffers = createCheckBox( "My offers", "configProductMarketOffers" );
  1084. marketBlock.append( configProductMarketOffers );
  1085.  
  1086. // Monetary market
  1087. var monetaryMarketBlock = $( "<div id='monetaryMarketBlock'>MONETARY MARKET</div>" );
  1088. var configMonetaryMarketSelection = createCheckBox( "Money selection", "configMonetaryMarketSelection" );
  1089. monetaryMarketBlock.append( configMonetaryMarketSelection );
  1090. var configMonetaryMarketTable = createCheckBox( "Money table", "configMonetaryMarketTable" );
  1091. monetaryMarketBlock.append( configMonetaryMarketTable );
  1092.  
  1093. // Theme weapon selector
  1094. var weaponSel = $( "<select id='weaponSelectorTheme' class='customSelectList'></select>" );
  1095. weaponSel.append( "<option value='default'>eSim</option>" );
  1096. weaponSel.append( "<option value='AoE'>Age of empires</option>" );
  1097. weaponSel.append( "<option value='SW'>Star Wars</option>" );
  1098. weaponSel.append( "<option value='Pok'>PokĂŠmon</option>" );
  1099. weaponSel.bind( "change", function() {
  1100. setValue( "configWeaponTheme", $(this).val() );
  1101. });
  1102.  
  1103. // Selector of default weapon
  1104. var defaultWeapon = $( "<select id='defaultWeapon' class='customSelectList'></select>" );
  1105. defaultWeapon.append( "<option value='0'>Unarmed</option>" );
  1106. for( var i=1; i<=5; i++ ) { defaultWeapon.append( "<option value='"+i+"'>Q"+i+"</option>" ); }
  1107. defaultWeapon.bind( "change", function() {
  1108. setValue( "configDefaultWeapon", $(this).val() );
  1109. });
  1110.  
  1111. // Close button
  1112. configScript.append( "<br/>" );
  1113. var close = $( "<input style='margin-top:8px' type='button' value='Save and close' />" );
  1114. close.bind( "click", function() { $( "#maskConfig" ).hide(); $( "#configScript" ).hide(); });
  1115.  
  1116. configScript.append( "<table align='center' border='0' cellpadding='5' cellspacing='1' style='width: 500px;'><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></tbody></table><table align='center' border='0' cellpadding='5' cellspacing='1' style='width: 400px;'><tbody><tr><td id='configScripttabel_10'></td><td id='configScripttabel_11'></td></tr></tbody></table> " );
  1117.  
  1118. $("#configScripttabel_1").append( globalBlock );
  1119. $("#configScripttabel_2").append( battleBlock );
  1120. $("#configScripttabel_3").append( muStorageBlock );
  1121. $("#configScripttabel_4").append( donateBlock );
  1122. $("#configScripttabel_5").append( equipmentBlock );
  1123. $("#configScripttabel_6").append( muMoneyBlock );
  1124. $("#configScripttabel_7").append( sharesBlock );
  1125. $("#configScripttabel_8").append( companyBlock );
  1126. $("#configScripttabel_9").append( monetaryMarketBlock );
  1127. $("#configScripttabel_10").append( marketBlock );
  1128. $("#configScripttabel_11").append( travelBlock );
  1129. configScript.append( "<b>Theme: </b>" );
  1130. configScript.append( weaponSel );
  1131. weaponSel.val( getValue( "configWeaponTheme" ) );
  1132. configScript.append( "<b>Default weapon: </b>" );
  1133. configScript.append( defaultWeapon );
  1134. defaultWeapon.val( getValue( "configDefaultWeapon" ) );
  1135. configScript.append( close );
  1136.  
  1137. //Bezárás
  1138. $( "#maskConfig" ).hide(); $( "#configScript" ).hide()
  1139. }
  1140.  
  1141.  
  1142. // Create checkbox and label
  1143. function createCheckBox( label, configLabel ) {
  1144. var div = $( "<div></div>" );
  1145. var checked = (getValue( configLabel ) == "true") ? "checked='checked'" : "";
  1146. div.append( "<input class='configCheckbox' type='checkbox' "+ checked +" />" );
  1147. div.children( "input" ).bind( "change", function() {
  1148. setValue( configLabel, ($(this).attr( "checked" ) == "checked") );
  1149. });
  1150. div.append( "<span class='configLabelCheckbox'>"+ label +"</span>" );
  1151. div.children( "span" ).bind( "click", function() {
  1152. div.children( "input" ).click();
  1153. div.children( "input" ).change();
  1154. });
  1155. return( div );
  1156. }
  1157.  
  1158.  
  1159. // Rellocate messages notify
  1160. function rellocateMessages() {
  1161.  
  1162. // Relloacte messages
  1163. var plateList = $( "#userMenu" ).children( ".plate" );
  1164. var plate = plateList.last();
  1165. plate.insertAfter( $( "#userName" ).parent().parent() );
  1166.  
  1167. // Remove useless fight button
  1168. var localUrl = new String( window.location );
  1169. // On battle, always remove
  1170. if( localUrl.indexOf( URLBattle, 0 ) >= 0 ) {
  1171. if( plateList.length == 5 ) {
  1172. plateList.eq(1).remove();
  1173. }
  1174. } else {
  1175. if( plateList.length == 5 ) {
  1176. // if Org, always remove
  1177. if( isOrgAccount() ) {
  1178. plateList.eq(1).remove();
  1179. } else {
  1180. plateList.eq(1).find( ".fightIcon" ).parent().remove();
  1181. if( plateList.eq(1).children( "div" ).children( ".button" ).length == 0 ) {
  1182. plateList.eq(1).remove();
  1183. }
  1184. }
  1185. }
  1186. }
  1187. }
  1188.  
  1189.  
  1190. // Update MU orders if changed on main page
  1191. /*function updateMUOrdersMain() {
  1192.  
  1193. $( ".testDivblue" ).each( function() {
  1194.  
  1195. if( $(this).children( "center" ).length == 2 ) {
  1196.  
  1197. var savedBattle = GetValue( "MUSavedBattle" );
  1198. var battle = $(this).find( "a[href^='battle.html?id=']" ).attr( "href" );
  1199. if( !battle ) { return; }
  1200. var side = $(this).children( "center" ).last().find( "img" ).attr( "src" );
  1201. side = side.replace( "small", "medium" );
  1202.  
  1203. if( savedBattle != battle ) {
  1204. SetValue( "MUSavedBattle", battle );
  1205. SetValue( "MUSide", side );
  1206.  
  1207. // Open MU page to check quality and text orders
  1208. $.ajax({
  1209. url: getCurrentServer() + URLMU,
  1210. success: function( data ) {
  1211. var table = $( data ).find( ".testDivblue" ).eq(2).find( "table" );
  1212. var tr = table.find( "tr" ).eq(0);
  1213. var td = tr.find( "td" ).eq(1);
  1214.  
  1215. var MURank = td.children( "div" ).first().contents().eq(5).text().trim().toLowerCase();
  1216. if( MURank == "novice" ) { SetValue( "MURank", "5" );
  1217. } else if( MURank == "regular" ) { SetValue( "MURank", "10" );
  1218. } else if( MURank == "veteran" ) { SetValue( "MURank", "15" );
  1219. } else if( MURank == "elite" ) { SetValue( "MURank", "20" ); }
  1220. }
  1221. });
  1222. }
  1223. }
  1224. });
  1225. }*/
  1226.  
  1227.  
  1228. // Calculate bonus on battle
  1229. function calculateBonus() {
  1230.  
  1231. $( "#contentRow" ).find( ".biggerFont.blueBox" ).css({ "margin-right" : "26px" });
  1232. $( "#contentRow" ).find( ".biggerFont.redBox" ).css({ "margin-left" : "25px" });
  1233.  
  1234. var divBattle = $( "#contentRow" ).find( ".testDivblue" ).eq(0);
  1235. var divFight = $( "#contentRow" ).find( ".testDivblue" ).eq(1);
  1236. /*var plate = $( "#stats" ).parent();
  1237. var currentLocation = plate.find( "a[href^='region']" ).attr( "href" ).split( "?id=" );
  1238. if( currentLocation.length > 1 ) { currentLocation = currentLocation[1] }
  1239.  
  1240. var divBattleLocation = $( ".testDivwhite" ).find( "a[href^='region']" );
  1241. if( divBattleLocation.length == 1 ) {
  1242. var battleLocation = divBattleLocation.attr( "href" ).split( "?id=" );
  1243. if( battleLocation.length > 1 ) { battleLocation = battleLocation[1] }
  1244. }*/
  1245.  
  1246. var bonusMU = 0;
  1247. /*var muSide = "";
  1248. if( GetValue( "MUSavedBattle" ) ) {
  1249. muSide = GetValue( "MUSavedBattle" ).split( "?id=" );
  1250. if( muSide.length > 1 ) { muSide = muSide[1] }
  1251. }
  1252.  
  1253. var battleID = getUrlVars()[ "id" ];
  1254.  
  1255. var products = $( ".productList" );*/
  1256. var numberLocation = 0;
  1257. var bonusSD = 0;
  1258. // Get if SD is on battle
  1259. /*if( products.length > 0 ) {
  1260. products.find( "img" ).each( function() {
  1261. if( $(this).attr( "src" ) == IMGDS ) {
  1262. var str = $(this).next().attr( "src" );
  1263. str = str.replace( IMGQUALITY, "" ).substring(0, 1);
  1264. bonusSD = parseInt( str ) * 5;
  1265. }
  1266. });
  1267. }
  1268.  
  1269. //var travelRW = $( "<div class='testDivblue' style='padding:9px 2px; margin:0px 0px 15px 0px;'></div>" );
  1270. //var link = $( "<a href='' id='travelLocation' style='cursor:pointer; font-size:13px;'></a>" );
  1271. //link.append( "<span style='font-size:11px'>Move to RW location and get +20%</span>" );
  1272. //travelRW.append( link );
  1273.  
  1274. //var travelLeft = $( "<div class='testDivblue' style='padding:6px 2px; margin:0px 0px 15px -30px; width:135px;'></div>" );
  1275. //travelLeft.css({ "display" : "inline-block" });
  1276. //link = $( "<a href='' id='travelLocationLeft' style='cursor:pointer; font-size:11px;'></a>" );
  1277. //link.append( "<span style='font-size:10px'>Move to defender region and get +20%</span>" );
  1278. //travelLeft.append( link );
  1279.  
  1280. //var travelRight = $( "<div class='testDivblue' style='padding:6px 2px; margin:0px -20px 15px 0px; width:135px;'></div>" );
  1281. //travelRight.css({ "display" : "inline-block", "float" : "right" });
  1282. //link = $( "<a href='' id='travelLocationRight' style='cursor:pointer; font-size:11px;'></a>" );
  1283. //link.append( "<span style='font-size:10px'>Move to neighbour region and get +20%</span>" );
  1284. //travelRight.append( link );*/
  1285.  
  1286. //
  1287. if( divFight.find( ".fightButton" ).length > 0 )
  1288.  
  1289. var isRW = false;
  1290. //var isRW = (divBattleLocation.parent().text().indexOf( "Resistance war", 0 ) > -1);
  1291. if( isRW ) {
  1292. //if( currentLocation == battleLocation ) { numberLocation = 20; }
  1293.  
  1294. // If can't fight, location is not correct
  1295. //if( $( "#weaponQuality" ).length == 0 ) {
  1296. // travelRW.insertBefore( pos );
  1297. // setTravelLocation( battleLocation, travelRW, travelLeft, travelRight );
  1298. //}
  1299.  
  1300. var leftMU = 0;
  1301. var rightMU = 0;
  1302. var sides = $( ".testDivwhite" ).find( ".bigFlag" );
  1303.  
  1304. // MU Bonus
  1305. /*if( battleID == muSide ) { // Correct battle
  1306. if( sides.length == 2 ) {
  1307. // Left defender
  1308. if( sides.eq(0).attr( "src" ) == GetValue( "MUSide" ) ) {
  1309. leftMU = GetValue( "MURank" );
  1310.  
  1311. } else if( sides.eq(1).attr( "src" ) == GetValue( "MUSide" ) ) {
  1312. rightMU = GetValue( "MURank" );
  1313. }
  1314. }
  1315. }*/
  1316.  
  1317. /*var leftBlock = createBlockBonus( numberLocation, leftMU, bonusSD );
  1318. leftBlock.attr( "id", "leftBlockBonus" );
  1319. leftBlock.css({ "margin-top" : "-10px", "margin-left" : "-24px" });
  1320. leftBlock.insertBefore( pos );
  1321.  
  1322. // Only defensive SD
  1323. var rightBlock = createBlockBonus( numberLocation, rightMU, 0 );
  1324. rightBlock.attr( "id", "rightBlockBonus" );
  1325. rightBlock.css({ "margin-top" : "-10px", "margin-left" : (pos.width()+13)+"px" });
  1326. rightBlock.insertBefore( pos );*/
  1327.  
  1328. } else {
  1329.  
  1330. /*var yourSide = pos.find( ".bigFlag" ).attr( "src" );
  1331. var flags = $( ".testDivwhite" ).find( ".bigFlag" );
  1332. var defender = flags.eq(0).attr( "src" );
  1333. var attacker = flags.eq(1).attr( "src" );*/
  1334.  
  1335. // If can't fight, location is not correct
  1336. //if( $( "#weaponQuality" ).length == 0 ) {
  1337. // travelLeft.insertBefore( pos );
  1338. // travelRight.insertBefore( pos );
  1339. // setTravelLocation( battleLocation, travelRW, travelLeft, travelRight );
  1340. //}
  1341.  
  1342. bonusMU = 0;
  1343. /*if( yourSide == attacker ) {
  1344. //if( (battleID == muSide) && (yourSide == GetValue( "MUSide" )) ) { bonusMU = GetValue( "MURank" ); }
  1345.  
  1346. //var neighbours = getRegionAPI( battleLocation, currentLocation );
  1347. //numberLocation = (neighbours.indexOf( parseInt(currentLocation) ) != -1) ? 20 : 0;
  1348.  
  1349. var rightBlock = createBlockBonus( numberLocation, bonusMU, 0 );
  1350. rightBlock.attr( "id", "rightBlockBonus" );
  1351. rightBlock.addClass( "rightBonusBlock" );
  1352. rightBlock.css({ "margin-left" : (pos.width()+7)+"px" });
  1353. rightBlock.insertBefore( pos );
  1354.  
  1355. } else if( yourSide == defender ) {
  1356. //if( (battleID == muSide) && (yourSide == GetValue( "MUSide" )) ) { bonusMU = GetValue( "MURank" ); }
  1357. if( currentLocation == battleLocation ) { numberLocation = 20; }
  1358.  
  1359. var leftBlock = createBlockBonus( numberLocation, bonusMU, bonusSD );
  1360. leftBlock.attr( "id", "leftBlockBonus" );
  1361. leftBlock.css({ "margin-top" : "-10px", "margin-left" : "-23px" });
  1362. leftBlock.insertBefore( pos );
  1363. }*/
  1364. }
  1365. }
  1366.  
  1367.  
  1368. // Create bonus battle dov
  1369. function createBlockBonus( location, MU, SD ) {
  1370.  
  1371. var block = $( "<div class='bonusBattleBlock'></div>" );
  1372.  
  1373. var bonusLocation = $( "<div class='locationBonus'>"+ location +"%</div>" );
  1374. bonusLocation.attr( "title", "<b>Location bonus</b>" );
  1375. bonusLocation.addClass( (location == 0) ? "redBackground" : "greenBackground" );
  1376. /*bonusLocation.tooltip({
  1377. tipClass:"smalltooltip",
  1378. position:"center right",
  1379. onShow: function() {
  1380. $( ".smalltooltip" ).css({ "text-align" : "center", "width" : "88px", "font-size" : "11px", "padding" : "3px 8px", "margin" : "0px 0px 0px 4px" });
  1381. }
  1382. });*/
  1383.  
  1384. var bonusMU = $( "<div class='MUBonus'>"+ MU +"%</div>" );
  1385. bonusMU.attr( "title", "<b>Military unit bonus</b>" );
  1386. bonusMU.addClass( (MU == 0) ? "redBackground" : "greenBackground" );
  1387. /*bonusMU.tooltip({
  1388. tipClass:"smalltooltip",
  1389. position:"center right",
  1390. onShow: function() {
  1391. $( ".smalltooltip" ).css({ "text-align" : "center", "width" : "115px", "font-size" : "11px", "padding" : "3px 8px", "margin" : "0px 0px 0px 4px" });
  1392. }
  1393. });*/
  1394.  
  1395. var bonusSD = $( "<div class='DSBonus' title='<b>Defensive system bonus</b>'>"+ SD +"%</div>" );
  1396. bonusSD.attr( "title", "<b>Defensive system bonus</b>" );
  1397. bonusSD.addClass( (SD == 0) ? "redBackground" : "greenBackground" );
  1398. /*bonusSD.tooltip({
  1399. tipClass:"smalltooltip",
  1400. position:"center right",
  1401. onShow: function() {
  1402. $( ".smalltooltip" ).css({ "text-align" : "center", "width" : "145px", "font-size" : "11px", "padding" : "3px 8px", "margin" : "0px 0px 0px 4px" });
  1403. }
  1404. });*/
  1405.  
  1406. block.append( bonusLocation );
  1407. block.append( bonusMU );
  1408. block.append( bonusSD );
  1409. return( block );
  1410. }
  1411.  
  1412.  
  1413. // Change weapon battle selector
  1414. function changeWeaponBattle() {
  1415.  
  1416. // First div with selected weapon
  1417. var bigWeap = $( "<div class='testDivwhite' id='bigWeaponBlock'></div>" );
  1418. var imgWeap = $( "<img id='bigWeaponImg' />" );
  1419.  
  1420. var weapInfo = $( "<div id='weaponsInfo'></div>" );
  1421. weapInfo.append( "<span id='qualityWeaponInfo'></span>" );
  1422. weapInfo.append( "<span id='availableWeaponInfo'></span>" );
  1423.  
  1424. var dataInfo = $( "<div id='blockInfoDamage'></div>" );
  1425. dataInfo.append( "Fight:<br /><span id='minDamage'></span> / <span id='maxDamage'></span><br/>" );
  1426. dataInfo.append( "Berserk:<br/><span id='bkMinDamage'></span> / <span id='bkMaxDamage'></span>" );
  1427.  
  1428. var equipInfo = $( "<div id='blockEquipInfo'></div>" );
  1429. var lineCritical = $( "<div></div>" );
  1430. var playerCriticalValue = getValue( "playerCritical" ) ? getValue( "playerCritical" ) : 0;
  1431. lineCritical.append( "<span class='percentBattleInfo'>"+ playerCriticalValue +"</span>" );
  1432. lineCritical.append( "<img src='"+ IMGCRITICAL +"' />" );
  1433. lineCritical.append( "<span id='criticalCounter'>0</span>" );
  1434. equipInfo.append( lineCritical );
  1435.  
  1436. var lineMiss = $( "<div></div>" );
  1437. var playerMissValue = getValue( "playerMiss" ) ? getValue( "playerMiss" ) : 0;
  1438. lineMiss.append( "<span class='percentBattleInfo'>"+ playerMissValue +"</span>" );
  1439. lineMiss.append( "<img src='"+ IMGMISS +"' />" );
  1440. lineMiss.append( "<span id='missCounter'>0</span>" );
  1441. equipInfo.append( lineMiss );
  1442.  
  1443. var lineAvoid = $( "<div></div>" );
  1444. var playerAvoidValue = getValue( "playerAvoid" ) ? getValue( "playerAvoid" ) : 0;
  1445. lineAvoid.append( "<span class='percentBattleInfo'>"+ playerAvoidValue +"</span>" );
  1446. lineAvoid.append( "<img src='"+ IMGAVOID +"' />" );
  1447. lineAvoid.append( "<span id='avoidCounter'>0</span>" );
  1448. equipInfo.append( lineAvoid );
  1449.  
  1450. bigWeap.append( imgWeap );
  1451. bigWeap.append( weapInfo );
  1452. bigWeap.append( dataInfo );
  1453. bigWeap.append( equipInfo );
  1454.  
  1455. bigWeap.insertBefore( "#weaponQuality" );
  1456.  
  1457. var selectedTheme = getValue( "configWeaponTheme" );
  1458. var defaultWeapon = getValue( "configDefaultWeapon" );
  1459. var index = 0;
  1460. var content = $( "<div id='weaponSelector'></div>" );
  1461. $( "#weaponQuality" ).find( "option" ).each( function() {
  1462.  
  1463. var weapQ = $( "<div class='weaponQualityNewSelector'></div>" );
  1464. if( index == 0 ) {
  1465. if( selectedTheme == "default" ) {
  1466. weapQ.append( "<img class='defaultWeaponQ0' src='"+ IMGWEAPON +"' />" );
  1467. } else weapQ.append( "<img class='"+ selectedTheme +"WeaponQ0' src='"+ eval( selectedTheme+"weaponQ0" ) +"' />" );
  1468. weapQ.addClass( "Q0weaponBox" );
  1469.  
  1470. } else {
  1471. if( selectedTheme == "default" ) {
  1472. weapQ.append( "<img class='defaultWeaponQX' src='"+ IMGWEAPON +"' />" );
  1473. } else weapQ.append( "<img class='"+ selectedTheme +"WeaponQX' src='"+ eval( selectedTheme+"weaponQ"+index ) +"' />" );
  1474. weapQ.addClass( "QXweaponBox" );
  1475. }
  1476.  
  1477. var nWeap = "";
  1478. var str = $(this).text();;
  1479. var pos = str.indexOf( "-50%", 0 );
  1480. if( pos < 0 ) {
  1481. nWeap = str.match(/ [0-9]{1,10}/g);
  1482. weapQ.append( "<div class='QXweaponString'>"+ (index * 20) +"%</div>" );
  1483.  
  1484. } else {
  1485. weapQ.css({ "margin-top" : "0px" });
  1486. weapQ.append( "<div class='Q0weaponString'> -50%<br/> Unarmed </div>" );
  1487. }
  1488.  
  1489. weapQ.attr( "indexselect", index );
  1490. weapQ.attr( "numWeapons", nWeap );
  1491. weapQ.append( "<div class='selectorNumWeapons'>"+ nWeap + "</div>" );
  1492.  
  1493. if( (nWeap == "") || (nWeap > 0) ) {
  1494.  
  1495. /*weapQ.bind( "mouseover", function() {
  1496. if( selectedWeapon.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) {
  1497. $(this).css({ "box-shadow" : "0px 1px 3px 2px #6baef8" });
  1498. }
  1499. });
  1500.  
  1501. weapQ.bind( "mouseout", function() {
  1502. if( selectedWeapon.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) {
  1503. $(this).css({ "box-shadow" : "0px 1px 3px 1px #9bbef8" });
  1504. }
  1505. });*/
  1506.  
  1507. weapQ.bind( "click", function() {
  1508.  
  1509. var quality = parseInt( $(this).attr( "indexselect" ) );
  1510. if( selectedWeapon ) {
  1511. selectedWeapon.removeClass( "selectedWeapon" );
  1512. selectedWeapon.removeClass( "selectedUnarmedWeapon" );
  1513. }
  1514.  
  1515.  
  1516.  
  1517.  
  1518. if( quality == 0 ) {
  1519. $( "#qualityWeaponInfo" ).text( "Unarmed" );
  1520. $( "#availableWeaponInfo" ).text( "" );
  1521. if( selectedTheme == "default" ) {
  1522. $( "#bigWeaponImg" ).attr( "src", IMGWEAPON );
  1523. $( "#bigWeaponImg" ).addClass( "bigWeaponDefault" );
  1524. } else {
  1525. $( "#bigWeaponImg" ).attr( "src", eval( selectedTheme + "weaponQ0Big" ) );
  1526. $( "#bigWeaponImg" ).addClass( "bigWeapon" + selectedTheme );
  1527. }
  1528.  
  1529. } else {
  1530. $( "#qualityWeaponInfo" ).text( "Q" + quality );
  1531. $( "#availableWeaponInfo" ).text( $(this).attr( "numWeapons" ) + " left" );
  1532. if( selectedTheme == "default" ) {
  1533. $( "#bigWeaponImg" ).attr( "src", IMGWEAPON );
  1534. $( "#bigWeaponImg" ).addClass( "bigWeaponDefault" );
  1535. } else {
  1536. $( "#bigWeaponImg" ).attr( "src", eval( selectedTheme + "weaponQ" + quality + "Big" ) );
  1537. $( "#bigWeaponImg" ).addClass( "bigWeapon" + selectedTheme );
  1538. }
  1539.  
  1540. }
  1541.  
  1542. selectedWeapon = $(this);
  1543. selectedWeapon.addClass( (quality == 0) ? "selectedUnarmedWeapon" : "selectedWeapon" );
  1544.  
  1545. $( "#weaponQuality option" ).removeAttr( "selected" );
  1546. $( "#weaponQuality option" )[ quality ].selected = true;
  1547.  
  1548. updateDamage();
  1549. });
  1550.  
  1551. } else weapQ.addClass( "disabledWeapon" );
  1552.  
  1553. // default Q0
  1554. if( (index == 0) || (index == defaultWeapon) ) { weapQ.click(); }
  1555. index++;
  1556. content.append( weapQ );
  1557. });
  1558.  
  1559. content.insertAfter( "#weaponQuality" );
  1560.  
  1561. $( "#weaponQuality" ).parent().children( "b" ).first().remove();
  1562. $( "#weaponQuality" ).parent().children( "br" ).first().remove();
  1563. $( "#weaponQuality" ).parent().children( "br" ).first().remove();
  1564. $( "#weaponQuality" ).css({ "display" : "none" });
  1565.  
  1566. // Add update weapon method, copied from the original method
  1567. $( ".fightButton" ).each( function() {
  1568.  
  1569. var input = $( "<input class='newFightButton' type='submit' />" );
  1570. input.attr( "value", $(this).val() );
  1571. input.attr( "name", $(this).attr( "name" ) );
  1572. input.attr( "style", $(this).attr( "style" ) );
  1573. input.insertBefore( $(this) );
  1574. $(this).hide();
  1575.  
  1576. input.bind( "click", function() {
  1577. var side = $(this)[0].name;
  1578. var value = $(this)[0].value;
  1579. mySendFightRequest(side, value);
  1580. $.blockUI({ message: $('#fightStatus'), css: {
  1581. width: '400px',
  1582. top: ($(window).height() - 400) /2 + 'px',
  1583. left: ($(window).width() - 400) /2 + 'px',
  1584. border: '0px',
  1585. background: 'rgba(0,0,0,0.3)' }
  1586. });
  1587. return( false );
  1588. });
  1589. });
  1590. }
  1591.  
  1592.  
  1593. // sendFightRequest from the original page copied and improved
  1594. function mySendFightRequest(side, val) {
  1595. var dataString = 'weaponQuality='+ $("#weaponQuality").val() + '&battleRoundId=' + $("#battleRoundId").val() + '&side='+side+'&value='+val;
  1596. $.ajax({
  1597. type: "POST",
  1598. url: "fight.html",
  1599. data: dataString,
  1600. success: function( msg ) {
  1601. $( "#fightResponse > div" ).replaceWith( msg );
  1602.  
  1603. var healthText = $( "#healthUpdate" ).text();
  1604. if( healthText != "" ) {
  1605. var healthUpdated = healthText.substr( 0, healthText.length-3 );
  1606. if( healthUpdated < 100 ) {
  1607. $( "#healthProgress div.ui-corner-right" ).removeClass( 'ui-corner-right' );
  1608. }
  1609. $( "#healthProgress .ui-progressbar-value" ).animate({ width: healthUpdated + "%" },{ queue: false });
  1610. $( "#healthProgress" ).attr( 'title',healthUpdated+' / 100' );
  1611. }
  1612. var rank = parseInt( $("#rankUpdate").text() );
  1613. var rankNext = parseInt( $("#nextLevelRankUpdate").text() );
  1614. var rankCurr = parseInt( $("#currLevelRankUpdate").text() );
  1615. if(rank != null) {
  1616. var rankWidth = Math.round((rank - rankCurr) / (rankNext - rankCurr) * 100);
  1617. $( "#rankProgress .ui-progressbar-value" ).animate({ width: rankWidth + "%" },{ queue: false });
  1618. $( "#rankProgress" ).attr( 'title',rank+' / '+rankNext );
  1619. }
  1620. var xp = parseInt($("#xpUpdate").text());
  1621. var xpNext = parseInt($("#nextLevelXpUpdate").text());
  1622. var xpCurr = parseInt($("#currLevelXpUpdate").text());
  1623. if(xp != null) {
  1624. var xpWidth = Math.round((xp - xpCurr) / (xpNext - xpCurr) * 100);
  1625. $("#xpProgress .ui-progressbar-value").animate({width: xpWidth + "%"},{queue: false});
  1626. $("#xpProgress").attr('title',xp+' / '+xpNext);
  1627. }
  1628. var rankText = $( "#currRankText" ).text();
  1629. var currRankText = $( "#rankText" ).text();
  1630. if( rankText != null && currRankText != null ) {
  1631. if( rankText != currRankText ) {
  1632. $( "#currRankText" ).text( currRankText );
  1633. $( "#rankImage img" ).attr( 'src', $( "#rankImg" ).text() );
  1634. }
  1635. }
  1636.  
  1637. $( "#unblockButton" ).bind( "click", function() {
  1638. updateWeaponsNumber();
  1639. updateHealthButtons();
  1640. });
  1641. }
  1642. });
  1643. }
  1644.  
  1645.  
  1646. // Update damage
  1647. function updateDamage() {
  1648.  
  1649. var minDamage = getValue( "playerMinDamage" );
  1650. var maxDamage = getValue( "playerMaxDamage" );
  1651.  
  1652. var weaponBonus = parseInt( $( "#weaponQuality" ).val() );
  1653. weaponBonus = (weaponBonus == 0) ? 0.5 : (weaponBonus*20 + 100)/100;
  1654.  
  1655. $( "#minDamage" ).text( pointNumber( parseInt(minDamage * weaponBonus) ) );
  1656. $( "#maxDamage" ).text( pointNumber( parseInt(maxDamage * weaponBonus) ) );
  1657.  
  1658. $( "#bkMinDamage" ).text( pointNumber( parseInt(5*minDamage * weaponBonus) ) );
  1659. $( "#bkMaxDamage" ).text( pointNumber( parseInt(5*maxDamage * weaponBonus) ) );
  1660. /*var damage = strength * rank * (quality*20 + 100)/100;
  1661. if( quality == 0 ) { damage = strength * rank / 2; }
  1662.  
  1663. var pos;
  1664. var strDmg = "";
  1665. var strBk = "";
  1666. var strTotal = "";
  1667. var mubonus = 0;
  1668. var locbonus = 0;
  1669. var sdbonus = 0;
  1670.  
  1671. var foodLimit = parseInt( $( "#foodLimit" ).text() );
  1672. var giftLimit = parseInt( $( "#giftLimit" ).text() );
  1673. var health = parseInt( $( "#healthBar" ).text() );
  1674. var nHits = health/10 + 5 * foodLimit + 5 * giftLimit;
  1675.  
  1676. var divBattleLocation = $( ".testDivwhite" ).find( "a[href^='region']" );
  1677. var isRW = (divBattleLocation.parent().text().indexOf( "Resistance war", 0 ) > -1);
  1678.  
  1679. if( $( "#leftBlockBonus" ).length == 1 ) {
  1680. pos = $( "#leftBlockBonus" ).children( "div" );
  1681. mubonus = parseInt( pos.eq(0).text().replace( "%", "" ) );
  1682. locbonus = parseInt( pos.eq(1).text().replace( "%", "" ) );
  1683. sdbonus = parseInt( pos.eq(2).text().replace( "%", "" ) );
  1684.  
  1685. // Order, MU - location - SD
  1686. damage *= (mubonus+100)/100;
  1687. damage *= (locbonus+100)/100;
  1688. damage *= (sdbonus+100)/100;
  1689. strDmg += pointNumber( parseInt( damage ) );
  1690. strBk += pointNumber( parseInt( damage * 5 ) );
  1691. strTotal += pointNumber( parseInt( damage * nHits ) );
  1692. }
  1693.  
  1694. damage = strength * rank * (quality*20 + 100)/100;
  1695. if( quality == 0 ) { damage = strength * rank / 2; }
  1696. if( $( "#rightBlockBonus" ).length == 1 ) {
  1697. pos = $( "#rightBlockBonus" ).children( "div" );
  1698. mubonus = parseInt( pos.eq(0).text().replace( "%", "" ) );
  1699. locbonus = parseInt( pos.eq(1).text().replace( "%", "" ) );
  1700. sdbonus = parseInt( pos.eq(2).text().replace( "%", "" ) );
  1701.  
  1702. // Order, MU - location - SD
  1703. damage *= (mubonus+100)/100;
  1704. damage *= (locbonus+100)/100;
  1705. damage *= (sdbonus+100)/100;
  1706. strDmg = isRW ? strDmg + "&nbsp;&nbsp;|&nbsp;&nbsp;" : strDmg;
  1707. strBk = isRW ? strBk + "&nbsp;&nbsp;|&nbsp;&nbsp;" : strBk;
  1708. strTotal = isRW ? strTotal + "&nbsp;&nbsp;|&nbsp;&nbsp;" : strTotal;
  1709. strDmg += pointNumber( parseInt( damage ) );
  1710. strBk += pointNumber( parseInt( damage*5 ) );
  1711. strTotal += pointNumber( parseInt( damage * nHits ) );
  1712. }
  1713.  
  1714. $( "#dmgCurrent" ).html( "Fight: <b style='font-family:Verdana; font-size:9px;'>"+ strDmg +"</b>" );
  1715. $( "#berserkCurrent" ).html( "Berserk: <b style='font-family:Verdana; font-size:9px;'>"+ strBk +"</b>" );
  1716. $( "#totalDamage" ).html( "Max: <b style='font-family:Verdana; font-size:9px;'>"+ strTotal +"</b>" );*/
  1717. }
  1718.  
  1719.  
  1720. // To add . on numbers
  1721. function pointNumber( n ){
  1722. n = n + "";
  1723. var i = n.length-3;
  1724. while( i > 0 ){ n = n.substring( 0, i )+ "." + n.substring( i, n.length ); i=i-3; }
  1725. return( n );
  1726. }
  1727.  
  1728.  
  1729. // Updater number weapons value
  1730. function updateWeaponsNumber() {
  1731. var index = 0;
  1732. $( "#weaponQuality" ).find( "option" ).each( function() {
  1733.  
  1734. var str = $(this).text();
  1735. var pos = str.indexOf( "available ", 0 );
  1736. if( pos > -1 ) {
  1737. nWeap = str.substr( pos + 10, str.indexOf( ")", pos ) - pos - 10 );
  1738. $( "#weaponSelector" ).children( "div:eq("+ index +")" ).find( ".selectorNumWeapons" ).text( nWeap );
  1739. $( "#availableWeaponsInfo" ).text( nWeap + "left" );
  1740.  
  1741. if( selectedWeapon.attr( "indexselect" ) == index ) {
  1742. if( nWeap == 0 ) {
  1743. selectedWeapon.unbind( "click" );
  1744. selectedWeapon.unbind( "mouseover" );
  1745. selectedWeapon.unbind( "mouseout" );
  1746. selectedWeapon.addClass( "disabledWeapon" );
  1747. $( "#weaponSelector" ).children( "div" ).eq( 0 ).click();
  1748. }
  1749. }
  1750. }
  1751.  
  1752. index++;
  1753. });
  1754. }
  1755.  
  1756.  
  1757. // Change round selector
  1758. function changeRoundSelector() {
  1759.  
  1760. var block = $( "#command" ).parent();
  1761. block.children().last().remove();
  1762. block.children().last().remove();
  1763. block.children( "br" ).last().remove();
  1764. for( var i=0; i<block.contents().length; i++ ) {
  1765. var item = block.contents().eq(i);
  1766. if( item.text().indexOf( "Show round:" ) >= 0 ) { item.remove(); }
  1767. }
  1768.  
  1769. // Replace any link
  1770. var currentRound = getUrlVars()[ "round" ];
  1771. $( "#command" ).children( "select" ).find( "option" ).each( function() {
  1772. var value = $(this).attr( "value" );
  1773. var battleID = getUrlVars()[ "id" ];
  1774. var url = getCurrentServer() + URLBattle + battleID + "&round=" + value;
  1775. var roundLink = $( "<a style='padding:2px' class='roundSelector' href='"+ url +"' >"+ value + "</a>" );
  1776. if( currentRound ) {
  1777. if( currentRound == value ) {
  1778. roundLink.css({ "color" : "#d14d4d", "font-size" : "15px" });
  1779. }
  1780. }
  1781.  
  1782. // Remove repeated
  1783. block.children( "a" ).each( function() { if( $(this).text() == value ) { $(this).remove(); } });
  1784. block.append( roundLink );
  1785. });
  1786.  
  1787. if( currentRound == undefined ) { block.children( "a" ).last().css({ "color" : "#d14d4d", "font-size" : "15px" }); }
  1788. $( "#command" ).css({ "display" : "none" });
  1789. }
  1790.  
  1791.  
  1792. // Improve MU main page
  1793. function changeMUMainMenu() {
  1794.  
  1795. var listBlue = $( "#container" ).find( ".testDivblue" );
  1796. $( "#container" ).find( ".citizenAction" ).css({ "margin-top" : "-7px" });
  1797. listBlue.eq(2).children( "br" ).remove();
  1798. listBlue.eq(2).children( "p" ).remove();
  1799.  
  1800. var descripDiv = $( "#container" ).find( ".testDivblue" ).eq(4);
  1801. var membersDiv = $( "#container" ).find( ".testDivblue" ).eq(3);
  1802. var ordersDiv = $( "#container" ).find( ".testDivblue" ).eq(5);
  1803.  
  1804. ordersDiv.css({ "margin-top" : "0px" });
  1805. ordersDiv.children( "br" ).first().remove();
  1806. descripDiv.css({ "margin-top" : "15px" });
  1807.  
  1808. var leftDiv = $( "<div style='float:left; width:340px; height:100%'></div>" );
  1809. leftDiv.append( ordersDiv );
  1810. leftDiv.append( descripDiv );
  1811.  
  1812. leftDiv.insertBefore( membersDiv );
  1813.  
  1814. // Get MU Rank
  1815. getMURank();
  1816. }
  1817.  
  1818.  
  1819. // Get MU rank
  1820. function getMURank() {
  1821.  
  1822. var listBlue = $( "#container" ).find( ".testDivblue" );
  1823. var MURank = listBlue.eq(2).find( ".statsLabelRight" ).eq(1).text().toLowerCase();
  1824. if( MURank == "novice" ) { SetValue( "MURank", "5" );
  1825. } else if( MURank == "regular" ) { setValue( "MURank", "10" );
  1826. } else if( MURank == "veteran" ) { setValue( "MURank", "15" );
  1827. } else if( MURank == "elite" ) { setValue( "MURank", "20" ); }
  1828. }
  1829.  
  1830.  
  1831. // Remove first block on MU storage and MU money
  1832. function removeFirstBlock() {
  1833.  
  1834. $( "#contentRow" ).find( ".citizenAction" ).css({ "margin-top" : "-7px" });
  1835. $( "#contentRow" ).find( ".testDivblue" ).eq(1).next().remove();
  1836. var firstBlock = $( "#contentRow" ).find( ".testDivblue" ).eq(2);
  1837. firstBlock.next().remove();
  1838. firstBlock.remove();
  1839. }
  1840.  
  1841.  
  1842. // Order MU member
  1843. function orderMU( idForm, varCheck ) {
  1844.  
  1845. var divPlayers = $( idForm ).children( "div" ).addClass( "divListPlayers" );
  1846.  
  1847. // Save data to order it
  1848. var list = divPlayers.children();
  1849. var tickAll = list[0];
  1850. var playerList = [];
  1851. var names = [];
  1852. var player;
  1853.  
  1854. // Ignore beginning BR
  1855. for( var i=2; i<list.length; i++ ) {
  1856.  
  1857. player = [];
  1858. player[0] = list[i++];
  1859. player[1] = list[i++];
  1860. player[2] = list[i++];
  1861. player[3] = list[i++];
  1862. // Ignore BR
  1863.  
  1864. names.push( player[3].textContent.toLowerCase() );
  1865. playerList.push( player );
  1866. }
  1867.  
  1868. // Remove all children
  1869. divPlayers.children().remove();
  1870. divPlayers.text( "" );
  1871.  
  1872. // Add tickAll button
  1873. $( tickAll ).bind( "click", function() {
  1874. $( ".receipments" ).attr( "checked", "checked" );
  1875. saveCheckedPlayers();
  1876. return false;
  1877. });
  1878. divPlayers.append( tickAll );
  1879.  
  1880. // Add untickAll button
  1881. var untickAll = $( "<input type='submit' id='untickAll' value='Untick all' />" );
  1882. untickAll.bind( "click", function() {
  1883. $( ".receipments" ).removeAttr( "checked" );
  1884. setValue( "lastSelectionMUStorage", "" );
  1885. return false;
  1886. });
  1887. divPlayers.append( untickAll );
  1888.  
  1889. // Add other submit button
  1890. divPlayers.append( "<input id='donateBtn2' type='submit' value='Donate' />" );
  1891. divPlayers.append( "<br/>" );
  1892.  
  1893. // Order array by name
  1894. names.sort();
  1895.  
  1896. // Add ordered members
  1897. var tr, td;
  1898. var table = $( "<table class='playerTable'></table>" );
  1899. divPlayers.append( table );
  1900. for( i=0; i<names.length; i++ ) {
  1901.  
  1902. for( var j=0; j<playerList.length; j++ ) {
  1903.  
  1904. if( names[i] == playerList[j][3].textContent.toLowerCase() ) {
  1905.  
  1906. tr = $( "<tr></tr>" );
  1907. tr.append( $( "<td class='checkPlayer'></td>" ).append( playerList[j][0] ) );
  1908. tr.append( $( "<td class='flagPlayer'></td>" ).append( playerList[j][1] ) );
  1909. tr.append( "<td class='noSkill'></td>" );
  1910. tr.append( $( "<td class='avatarPlayer'></td>" ).append( playerList[j][2] ) );
  1911. tr.append( $( "<td class='namePlayer'></td>" ).append( playerList[j][3] ) );
  1912. tr.append( "<td class='companyName'></td>" );
  1913. tr.append( "<td class='day6'></td>" );
  1914. tr.append( "<td class='day5'></td>" );
  1915. tr.append( "<td class='day4'></td>" );
  1916. tr.append( "<td class='day3'></td>" );
  1917. tr.append( "<td class='day2'></td>" );
  1918. tr.append( "<td class='day1'></td>" );
  1919. tr.append( "<td class='day0'></td>" );
  1920. tr.append( "<td></td>" );
  1921. table.append( tr );
  1922.  
  1923. tr.children( ".namePlayer" ).children( "a" ).attr( "name", playerList[j][3].textContent );
  1924.  
  1925. // Resize player name
  1926. var name = tr.children( ".namePlayer" );
  1927. while( name.height() > (parseInt( name.css( "line-height" ).replace( "px", "" ) ) + 1) ) {
  1928. var str = name.children( "a" ).text().replace( "...", "" );
  1929. name.children( "a" ).text( str.slice( 0, -1 ) + "..." );
  1930. }
  1931. }
  1932. }
  1933. }
  1934.  
  1935.  
  1936. // Check for URL vars
  1937. if( varCheck ) {
  1938. setValue( "lastSelectionMUStorage", varCheck );
  1939. $( ".playerTable" ).find( ".receipments" ).each( function() {
  1940. if( varCheck.length > 0 ) {
  1941. if( varCheck[0] == "1" ) { $(this).attr( "checked", "checked" ); }
  1942. varCheck = varCheck.substr( 1, varCheck.length-1 );
  1943. }
  1944. });
  1945. }
  1946.  
  1947. // Set Checked players
  1948. $( ".playerTable" ).find( ".receipments" ).bind( "change", function() { saveCheckedPlayers(); });
  1949. }
  1950.  
  1951. // Set value of checked people on MU storage
  1952. function saveCheckedPlayers() {
  1953. var check = "";
  1954. $( ".playerTable" ).find( ".receipments" ).each( function() {
  1955. check += ($(this).attr( "checked" )) ? "1" : "0";
  1956. });
  1957. setValue( "lastSelectionMUStorage", check );
  1958. }
  1959.  
  1960.  
  1961. // Add donate me button
  1962. function addDonateToMeButton( idForm ) {
  1963.  
  1964. // Donate me button
  1965. var pos = $( idForm ).children( "center" );
  1966. var donateMe = $( "<input type='submit' id='donateMe' value='Donate me' />" );
  1967. pos.append( donateMe );
  1968.  
  1969. var id;
  1970. var link = $( "#userName" ).attr( "href" );
  1971. var split = link.split( "?id=" );
  1972. if( split.length > 1 ) {
  1973. id = split[1];
  1974. donateMe.bind( "click", function() {
  1975. $( ".receipments" ).removeAttr( "checked" );
  1976. $( ".receipments[value='"+ id +"']" ).attr( "checked", "checked" );
  1977. });
  1978. }
  1979. }
  1980.  
  1981.  
  1982. // Update MU storage donation
  1983. function changeSelectMUStorage( idForm ) {
  1984.  
  1985. var select = $( "#product" );
  1986. var pos = $( ".testDivwhite" );
  1987. var dest = $( "#quantity" );
  1988.  
  1989. // Remove all childrens and add help text
  1990. pos.children().remove();
  1991. pos.addClass( "storageSelectMU" );
  1992. pos.append( "One click to select <b>ONE item</b>.<br/>Double click to select <b>ALL items</b>.<br/>" );
  1993.  
  1994. pos.css({"width":"200px"})
  1995.  
  1996. select.prev().remove();
  1997. //select.css({ "display" : "none" });
  1998.  
  1999. orderSelect( select );
  2000. changeSelect( select, pos, dest, "#aaaaaa" );
  2001. }
  2002.  
  2003.  
  2004. // Change select from params
  2005. function changeSelect( select, placeToAdd, dest, color ) {
  2006.  
  2007. // Add my items
  2008. var selectDonate;
  2009. var index = 1;
  2010. select.find( "option" ).each( function() {
  2011. if( $(this).attr( "value" ) == "" ) { return; }
  2012.  
  2013. var str = $(this).text();
  2014. //alert(str)
  2015. var number = str.indexOf( "(", 0 );
  2016. if( number != -1 ) {
  2017. str = str.substr( number + 1, str.indexOf( ")", number ) - number - 1 );
  2018. mypatttofindnum=/\d{1,45}/g;
  2019. //alert(str)
  2020. str = mypatttofindnum.exec(str);
  2021.  
  2022. }
  2023.  
  2024. var product = $( "<div class='storage productMU'>" );
  2025. product.append( "<div>"+ str +"</div>" );
  2026. var image = $( "<div></div>" )
  2027. product.append( image );
  2028.  
  2029. var storageMU = $( "<div class='storageButton' selectIndex='"+ index +"'></div>" );
  2030. //storageMU.css({ "box-shadow" : "0px 1px 5px 1px " + color });
  2031. storageMU.append( product );
  2032.  
  2033. // Raw resource
  2034. var split = $(this).attr( "value" ).split( "-" );
  2035. if( split.length == 1 ) {
  2036.  
  2037. if( split[0] == "IRON" ) {
  2038. image.append( "<img src='"+ IMGIRON +"' />" );
  2039.  
  2040. } else if( split[0] == "OIL" ) {
  2041. image.append( "<img src='"+ IMGOIL +"' />" );
  2042.  
  2043. } else if( split[0] == "GRAIN" ) {
  2044. image.append( "<img src='"+ IMGGRAIN +"' />" );
  2045.  
  2046. } else if( split[0] == "DIAMONDS" ) {
  2047. image.append( "<img src='"+ IMGDIAMONDS +"' />" );
  2048.  
  2049. } else if( split[0] == "WOOD" ) {
  2050. image.append( "<img src='"+ IMGWOOD +"' />" );
  2051.  
  2052. } else if( split[0] == "STONE" ) {
  2053. image.append( "<img src='"+ IMGSTONE +"' />" );
  2054. }
  2055.  
  2056. product.css({ "height" : "67px" });
  2057. storageMU.css({ "margin" : "10px 4px 8px 10px" });
  2058.  
  2059. } else if( split.length = 2 ) {
  2060.  
  2061. if( split[1] == "WEAPON" ) {
  2062. image.append( "<img src='"+ IMGWEAPON +"' />" );
  2063.  
  2064. } else if( split[1] == "FOOD" ) {
  2065. image.append( "<img src='"+ IMGFOOD +"' />" );
  2066.  
  2067. } else if( split[1] == "TICKET" ) {
  2068. image.append( "<img src='"+ IMGTICKET +"' />" );
  2069.  
  2070. } else if( split[1] == "GIFT" ) {
  2071. image.append( "<img src='"+ IMGGIFT +"' />" );
  2072.  
  2073. } else if( split[1] == "HOUSE" ) {
  2074. image.append( "<img src='"+ IMGHOUSE +"' />" );
  2075.  
  2076. } else if( split[1] == "DS" ) {
  2077. image.append( "<img src='"+ IMGDS +"' />" );
  2078.  
  2079. } else if( split[1] == "HOSPITAL" ) {
  2080. image.append( "<img src='"+ IMGHOSPITAL +"' />" );
  2081.  
  2082. } else if( split[1] == "ESTATE" ) {
  2083. image.append( "<img src='"+ IMGESTATE +"' />" );
  2084. }
  2085.  
  2086. image.append( "<img class='qualityMU' src='"+ IMGQUALITY + split[0] + IMGEXTENSION +"' />" );
  2087. product.css({ "height" : "77px" });
  2088. storageMU.css({ "margin" : "6px 4px 2px 10px" });
  2089. }
  2090.  
  2091. // Events
  2092. storageMU.bind( "mouseover", function() {
  2093. if( selectDonate != $(this).attr( "selectIndex" ) ) { $(this).addClass( "storageButtonHover" ); }
  2094. });
  2095. storageMU.bind( "mouseout", function() {
  2096. if( selectDonate != $(this).attr( "selectIndex" ) ) { $(this).removeClass( "storageButtonHover" ); }
  2097. });
  2098.  
  2099. // Click
  2100. storageMU.bind( "click", function() {
  2101.  
  2102. // Deselect current selection
  2103. if( selectDonate == $(this).attr( "selectIndex" ) ) {
  2104.  
  2105. $(this).removeClass( "storageButtonClick" );
  2106. $(this).removeClass( "storageButtonDblClick" );
  2107. select.find( "option" ).removeAttr( "selected" );
  2108. selectDonate = null;
  2109. dest.val( "1" );
  2110.  
  2111. } else {
  2112.  
  2113. // Deselect last item
  2114. if( selectDonate ) {
  2115. var selectedItem = placeToAdd.find( ".storageButton[selectIndex='" + selectDonate + "']" );
  2116. selectedItem.removeClass( "storageButtonClick" );
  2117. selectedItem.removeClass( "storageButtonDblClick" );
  2118. dest.val( "1" );
  2119. }
  2120.  
  2121. $(this).removeClass( "storageButtonHover" );
  2122. $(this).removeClass( "storageButtonDblClick" );
  2123. $(this).addClass( "storageButtonClick" );
  2124. selectDonate = $(this).attr( "selectIndex" );
  2125.  
  2126. select.find( "option" ).removeAttr( "selected" );
  2127. select.find( "option" )[ selectDonate ].selected = true;
  2128. }
  2129. });
  2130.  
  2131. // Doubleclick
  2132. storageMU.bind( "dblclick", function() {
  2133.  
  2134. $(this).removeClass( "storageButtonHover" );
  2135. $(this).removeClass( "storageButtonClick" );
  2136. $(this).addClass( "storageButtonDblClick" );
  2137. selectDonate = $(this).attr( "selectIndex" );
  2138.  
  2139. select.find( "option" ).removeAttr( "selected" );
  2140. select.find( "option" )[ selectDonate ].selected = true;
  2141.  
  2142. dest.val( $(this).text().trim() );
  2143. return( false );
  2144. });
  2145.  
  2146. placeToAdd.append( storageMU );
  2147. index++;
  2148. });
  2149. }
  2150.  
  2151.  
  2152. // Reorder select items
  2153. function orderSelect( select ) {
  2154.  
  2155. var listOptions = [];
  2156. select.find( "option" ).each( function() {
  2157. listOptions.push( $(this) );
  2158. $(this).remove();
  2159. });
  2160.  
  2161. // Order is... Weapons, Food, Gifts, Tickets, Raw and rest
  2162. var newOptionList = new Array(46);
  2163. newOptionList[0] = listOptions[0];
  2164. var rawIndex = 0;
  2165. var otherIndex = 0;
  2166. for( var i=1; i<listOptions.length; i++ ) {
  2167. var item = listOptions[i].attr( "value" ).split( "-" );
  2168. if( item.length == 2 ) {
  2169. var q = parseInt( item[0] ) - 1;
  2170. if( item[1] == "WEAPON" ) { // Index 0 + quality
  2171. newOptionList[ 1 + q ] = listOptions[i];
  2172.  
  2173. } else if( item[1] == "FOOD" ) { // Index 5 + quality
  2174. newOptionList[ 6 + q ] = listOptions[i];
  2175.  
  2176. } else if( item[1] == "GIFT" ) { // Index 10 + quality
  2177. newOptionList[ 11 + q ] = listOptions[i];
  2178.  
  2179. } else if( item[1] == "TICKET" ) { // Index 15 + quality
  2180. newOptionList[ 16 + q ] = listOptions[i];
  2181.  
  2182. } else {
  2183. newOptionList[ 27 + otherIndex ] = listOptions[i];
  2184. otherIndex++;
  2185. }
  2186. } else {
  2187. newOptionList[ 21 + rawIndex ] = listOptions[i];
  2188. rawIndex++;
  2189. }
  2190. }
  2191.  
  2192. // Add ordered items
  2193. for( var i=0; i<newOptionList.length; i++ ) {
  2194. if( newOptionList[i] ) { select.append( newOptionList[i] ); }
  2195. }
  2196.  
  2197. select.find( "option" )[ 0 ].selected = true;
  2198. }
  2199.  
  2200.  
  2201. // Add fast buttons
  2202. function addMUFastButtons( idDest ) {
  2203.  
  2204. var firstFastButton = true;
  2205. $( idDest ).css({ "text-align" : "center" });
  2206.  
  2207. var btn1 = $( "<input class='fastBtn MUfastButtonLeft' type='button' value='1' />" );
  2208. btn1.bind( "click", function() {
  2209. if( firstFastButton ) {
  2210. $( idDest ).attr( "value", "1" );
  2211. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 1 );
  2212. firstFastButton = false;
  2213. });
  2214.  
  2215. var btn5 = $( "<input class='fastBtn MUfastButtonLeft' type='button' value='5' />" );
  2216. btn5.bind( "click", function() {
  2217. if( firstFastButton ) {
  2218. $( idDest ).attr( "value", "5" );
  2219. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 5 );
  2220. firstFastButton = false;
  2221. });
  2222.  
  2223. var btn10 = $( "<input class='fastBtn MUfastButtonLeft' type='button' value='10' />" );
  2224. btn10.bind( "click", function() {
  2225. if( firstFastButton ) {
  2226. $( idDest ).attr( "value", "10" );
  2227. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 10 );
  2228. firstFastButton = false;
  2229. });
  2230.  
  2231. var btn15 = $( "<input class='fastBtn MUfastButtonRight' type='button' value='15' />" );
  2232. btn15.bind( "click", function() {
  2233. if( firstFastButton ) {
  2234. $( idDest ).attr( "value", "15" );
  2235. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 15 );
  2236. firstFastButton = false;
  2237. });
  2238.  
  2239. var btn25 = $( "<input class='fastBtn MUfastButtonRight' type='button' value='25' />" );
  2240. btn25.bind( "click", function() {
  2241. if( firstFastButton ) {
  2242. $( idDest ).attr( "value", "25" );
  2243. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 25 );
  2244. firstFastButton = false;
  2245. });
  2246.  
  2247. var btn50 = $( "<input class='fastBtn MUfastButtonRight' type='button' value='50' />" );
  2248. btn50.bind( "click", function() {
  2249. if( firstFastButton ) {
  2250. $( idDest ).attr( "value", "50" );
  2251. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 50 );
  2252. firstFastButton = false;
  2253. });
  2254.  
  2255. var btn75 = $( "<input class='fastBtn MUfastButton2' type='button' value='75' />" );
  2256. btn75.bind( "click", function() {
  2257. if( firstFastButton ) {
  2258. $( idDest ).attr( "value", "75" );
  2259. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 75 );
  2260. firstFastButton = false;
  2261. });
  2262.  
  2263. var btn100 = $( "<input class='fastBtn MUfastButton2' type='button' value='100' />" );
  2264. btn100.bind( "click", function() {
  2265. if( firstFastButton ) {
  2266. $( idDest ).attr( "value", "100" );
  2267. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 100 );
  2268. firstFastButton = false;
  2269. });
  2270.  
  2271. var btn125 = $( "<input class='fastBtn MUfastButton2' type='button' value='125' />" );
  2272. btn125.bind( "click", function() {
  2273. if( firstFastButton ) {
  2274. $( idDest ).attr( "value", "125" );
  2275. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 125 );
  2276. firstFastButton = false;
  2277. });
  2278.  
  2279. var btn150 = $( "<input class='fastBtn MUfastButton2' type='button' value='150' />" );
  2280. btn150.bind( "click", function() {
  2281. if( firstFastButton ) {
  2282. $( idDest ).attr( "value", "150" );
  2283. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 150 );
  2284. firstFastButton = false;
  2285. });
  2286.  
  2287. // OLD
  2288. /*$( "<br />" ).insertAfter($("#quantity.digit"));
  2289.  
  2290. btn1.insertAfter( idDest );
  2291. btn5.insertAfter( idDest );
  2292. btn10.insertAfter( idDest );
  2293.  
  2294. btn150.insertAfter( idDest );
  2295. btn125.insertAfter( idDest );
  2296. btn100.insertAfter( idDest );
  2297. btn75.insertAfter( idDest );
  2298. //$( "<br/>" ).insertAfter( idDest );
  2299. btn50.insertAfter( idDest );
  2300. btn25.insertAfter( idDest );
  2301. btn15.insertAfter( idDest );*/
  2302.  
  2303.  
  2304. // NEW
  2305. $( "<br id='divider' />" ).insertAfter($("#quantity.digit"));
  2306.  
  2307. btn25.insertAfter($("#divider") );
  2308. btn15.insertAfter($("#divider") );
  2309. btn10.insertAfter($("#divider") );
  2310. btn5.insertAfter( $("#divider") );
  2311. btn1.insertAfter( $("#divider") );
  2312.  
  2313. $( "<br id='divider2' />" ).insertAfter($("#donateProductForm input[value='25']"));
  2314.  
  2315. btn150.insertAfter( $("#divider2") );
  2316. btn125.insertAfter( $("#divider2") );
  2317. btn100.insertAfter( $("#divider2") );
  2318. btn75.insertAfter( $("#divider2") );
  2319. btn50.insertAfter( $("#divider2") );
  2320.  
  2321.  
  2322.  
  2323.  
  2324. }
  2325.  
  2326.  
  2327. // Add update jobs button
  2328. function addUpdateJobsButton( idForm ) {
  2329. savedWorkedList = [];
  2330.  
  2331. // Add button to see more days
  2332. var extended = $( "<input type='button' id='extendedDays' value='Extended'/>" );
  2333. extended.insertAfter( $( "#donateBtn2" ) );
  2334. disableButton( extended );
  2335. extended.bind( "click", function() {
  2336. extendedMU = !extendedMU;
  2337.  
  2338. if( extendedMU ) {
  2339. $( ".companyName" ).hide();
  2340. $( ".day0" ).show();
  2341. $( ".day1" ).show();
  2342. $( ".day2" ).show();
  2343. $( ".day3" ).show();
  2344. $( ".day4" ).show();
  2345. $( ".day5" ).show();
  2346. $( ".day6" ).show();
  2347. } else {
  2348. $( ".companyName" ).show();
  2349. $( ".day0" ).show();
  2350. $( ".day1" ).show();
  2351. $( ".day2" ).hide();
  2352. $( ".day3" ).hide();
  2353. $( ".day4" ).hide();
  2354. $( ".day5" ).hide();
  2355. $( ".day6" ).hide();
  2356. }
  2357. });
  2358.  
  2359. // Add update button
  2360. var update = $( "<input type='button' id='updateWork' value='Update jobs'/>" );
  2361. update.insertAfter( ".testDivwhite" );
  2362. update.bind( "click", function() {
  2363.  
  2364. $(this).val( "Updating... " );
  2365. disableButton( $(this) );
  2366. enableButton( extended );
  2367.  
  2368. // Clean previous results
  2369. $( idForm ).find( ".skill" ).children().remove();
  2370. $( idForm ).find( ".skill" ).addClass( "noSkill" );
  2371. $( idForm ).find( ".skill" ).removeClass( "skill" );
  2372. $( ".companyName" ).children().remove();
  2373. $( ".day0" ).children().remove();
  2374. $( ".day1" ).children().remove();
  2375. $( ".day2" ).children().remove();
  2376. $( ".day3" ).children().remove();
  2377. $( ".day4" ).children().remove();
  2378. $( ".day5" ).children().remove();
  2379. $( ".day6" ).children().remove();
  2380.  
  2381. var idMU = $( ".citizenAction" ).eq(0).children( "a" ).attr( "href" );
  2382. var split = idMU.split( "?id=" );
  2383. if( split.length > 1 ) {
  2384. idMU = split[1];
  2385.  
  2386. // Find every player what company works
  2387. // First MU companies
  2388. $.ajax({
  2389. url: getCurrentServer() + URLMUCompanies + idMU,
  2390. success: function( data ) {
  2391.  
  2392. // Special case
  2393. var cp = $( data ).find( "a[href^='company.html']" );
  2394. if( cp.length == 0 ) {
  2395. enableButton( $( "#updateWork" ) );
  2396. $( "#updateWork" ).val( "Update jobs" );
  2397.  
  2398. } else {
  2399. $( "#updateWork" ).val( "Updating... "+cp.length );
  2400. $( "#updateWork" ).attr( "counter", cp.length );
  2401. }
  2402.  
  2403. for( var i=0; i<cp.length; i++ ) {
  2404. var split = $( cp[i] ).attr( "href" ).split( "?id=" );
  2405. if( split.length > 1 ) { checkCompany( idForm, split[1], i, cp.length-1 ) }
  2406. }
  2407. }
  2408. });
  2409. }
  2410.  
  2411. return( false );
  2412. });
  2413.  
  2414. var needUpdate = false;
  2415. var lastUpdateTime = $( "<div id='lastUpdateTime'></div>" );
  2416. lastUpdateTime.insertAfter( update );
  2417. if( getValue( "muStorageSaveLastTime") ) {
  2418. lastUpdateTime.text( getValue( "muStorageSaveLastTime") );
  2419. var currentDate = (new Date).getDate();
  2420. var lastDate = new Date( getValue( "muStorageSaveLastTime" ) ).getDate();
  2421. var needUpdate = (lastDate != currentDate);
  2422. }
  2423.  
  2424.  
  2425. if( getValue( "muStorageSaveWorkedList") && !needUpdate ) {
  2426.  
  2427. enableButton( extended );
  2428. var workedList = getValue( "muStorageSaveWorkedList").split( "&&" );
  2429.  
  2430. for( var i=0; i<workedList.length; i++ ) {
  2431. var splitList = workedList[i].split( "," );
  2432. var pos = $( idForm ).find( "a[name='"+ splitList[0] +"']" );
  2433. var tr = pos.parent().parent();
  2434.  
  2435. addSkill( tr, splitList[1] );
  2436. tr.find( ".companyName" ).append( "<a href='"+ getCurrentServer() + URLCompany + splitList[2] +"'>"+ splitList[3] +"</a>" );
  2437.  
  2438. var day;
  2439. for( j=0; j<7; j++ ) {
  2440. var t = "-" + j;
  2441. if( j == 0 ) { t = ""; }
  2442.  
  2443. if( splitList[4+j] == "true" ) {
  2444. day = $( "<div class='dayOk' day='"+ j +"'>"+ t +"</div>" );
  2445. tr.find( ".day" + j ).append( day );
  2446. tr.find( "input" ).attr( "workday" + j, "true" );
  2447.  
  2448. } else {
  2449. day = $( "<div class='dayFail' day='"+ j +"'>"+ t +"</div>" );
  2450. tr.find( ".day"+j ).append( day );
  2451. tr.find( "input" ).attr( "workday" + j, "false" );
  2452. }
  2453.  
  2454. // Select only who worked
  2455. day.bind( "click", function() {
  2456. $( ".receipments" ).removeAttr( "checked" );
  2457. $( ".receipments[workday"+ $(this).attr( "day" ) +"='true']" ).attr( "checked", "checked" );
  2458. setCounterText();
  2459. saveCheckedPlayers();
  2460. });
  2461.  
  2462. if( !extendedMU && (j > 1) ) { tr.find( ".day" + j ).hide(); }
  2463. }
  2464. }
  2465. }
  2466. }
  2467.  
  2468.  
  2469. // Check each company
  2470. function checkCompany( idForm, idComp, i, n ) {
  2471.  
  2472. setTimeout( function() {
  2473.  
  2474. $.ajax({
  2475. url: getCurrentServer() + URLCompanyDetails + idComp,
  2476. success: function( data ) {
  2477. checkWorkResults( idComp, idForm, data );
  2478.  
  2479. if( i == n ) {
  2480. enableButton( $( "#updateWork" ) );
  2481. $( "#updateWork" ).val( "Update jobs" );
  2482. $( "#updateWork" ).removeAttr( "counter" );
  2483.  
  2484. setValue( "muStorageSaveWorkedList", savedWorkedList.join( "&&" ) );
  2485. $( "#lastUpdateTime" ).text( new Date().toUTCString() );
  2486. setValue( "muStorageSaveLastTime", new Date().toUTCString() );
  2487.  
  2488. } else {
  2489. var count = parseInt( $( "#updateWork" ).attr( "counter" ) ) - 1;
  2490. $( "#updateWork" ).val( "Updating... " + count );
  2491. $( "#updateWork" ).attr( "counter", count );
  2492. }
  2493. }
  2494. });
  2495.  
  2496. }, 1000*i );
  2497. }
  2498.  
  2499.  
  2500. // Check every company
  2501. function checkWorkResults( idComp, idForm, data ) {
  2502.  
  2503. var table = $( data ).find( "#productivityTable" );
  2504. var company = $( data ).find( "#contentRow h1" ).text().replace( "Company", "" );
  2505. var rows = table.find( "tbody tr" );
  2506. for( var i=1; i<rows.length; i++ ) {
  2507. var player = "";
  2508.  
  2509. var cols = $( rows[i] ).find( "td" );
  2510. if( cols.length > 0 ) {
  2511. var name = $( cols[0] ).find( "a" ).text();
  2512. player = name;
  2513.  
  2514. var pos = $( idForm ).find( "a[name='"+ name +"']" );
  2515. var tr = pos.parent().parent();
  2516. tr.find( ".companyName" ).append( "<a href='"+ getCurrentServer() + URLCompany + idComp +"'>"+ company +"</a>" );
  2517. if( cols.length == 12 ) {
  2518.  
  2519. var skillValue = parseInt( $( cols[1] ).text() );
  2520. addSkill( tr, skillValue );
  2521. player += "," + skillValue + "," + idComp + "," + company;
  2522.  
  2523. // View last 7 days
  2524. var day;
  2525. for( var j=0; j<7; j++ ) {
  2526. var t = "-" + j;
  2527. if( j == 0 ) { t = ""; }
  2528.  
  2529. if( $( cols[11-j] ).find( "img" ).length == 0 ) {
  2530. day = $( "<div class='dayOk' day='"+ j +"'>"+ t +"</div>" );
  2531. tr.find( ".day" + j ).append( day );
  2532. tr.find( "input" ).attr( "workday" + j, "true" );
  2533. player += "," + "true";
  2534.  
  2535. } else {
  2536. day = $( "<div class='dayFail' day='"+ j +"'>"+ t +"</div>" );
  2537. tr.find( ".day"+j ).append( day );
  2538. tr.find( "input" ).attr( "workday" + j, "false" );
  2539. player += "," + "false";
  2540. }
  2541.  
  2542. // Select only who worked
  2543. day.bind( "click", function() {
  2544. $( ".receipments" ).removeAttr( "checked" );
  2545. $( ".receipments[workday"+ $(this).attr( "day" ) +"='true']" ).attr( "checked", "checked" );
  2546. setCounterText();
  2547. saveCheckedPlayers();
  2548. });
  2549.  
  2550. if( !extendedMU && (j > 1) ) { tr.find( ".day" + j ).hide(); }
  2551. }
  2552. }
  2553.  
  2554. savedWorkedList.push( player );
  2555. }
  2556. }
  2557. }
  2558.  
  2559.  
  2560. // Add skill in MU storage list
  2561. function addSkill( tr, skillVal ) {
  2562. var posSkill = tr.find( ".noSkill" );
  2563. posSkill.removeClass( "noSkill" );
  2564. posSkill.addClass( "skill" );
  2565. posSkill.append( "<div>"+ skillVal +"</div>" );
  2566. posSkill.bind( "click", function() {
  2567. var v = $(this).text();
  2568. $( ".skill" ).each( function() {
  2569. if( v == $(this).text() ) { $(this).parent().find( "input" ).attr( "checked", "checked" ); }
  2570. });
  2571. setCounterText();
  2572. saveCheckedPlayers();
  2573. });
  2574. }
  2575.  
  2576.  
  2577. // Add update connection button
  2578. function addUpdateConnectionButton( idForm ) {
  2579.  
  2580. var $online = $( "<input type='submit' id='onlinePlayer' value='Online players' />" );
  2581. $online.insertAfter( ".testDivwhite" );
  2582. $online.bind( "click", function() {
  2583.  
  2584. $.ajax({
  2585. url: getCurrentServer() + URLMU,
  2586. success: function( data ) {
  2587.  
  2588. // First clean
  2589. $( idForm ).find( "img[src='"+ IMGOFFLINE +"']" ).remove();
  2590. $( idForm ).find( "img[src='"+ IMGONLINE +"']" ).remove();
  2591.  
  2592. // Add All offline
  2593. $( idForm ).find( "a[href^='profile.html']" ).each( function() {
  2594. var flag = $(this).parent().parent().find( ".currencyFlag" );
  2595. flag.attr( "src", IMGOFFLINE );
  2596. flag.addClass( "imgPlayerOnline" );
  2597. });
  2598.  
  2599. // Replace online players
  2600. $( data ).find( ".tip[src='"+ IMGONLINE +"']" ).each( function() {
  2601. var player = $( idForm ).find( "a[href='"+ $(this).prev().attr( "href" ) + "']" );
  2602. player.parent().parent().find( ".currencyFlag" ).attr( "src", IMGONLINE );
  2603. });
  2604.  
  2605. // Add events
  2606. $( idForm ).find( ".currencyFlag" ).bind( "click", function() {
  2607. $( idForm ).find( ".receipments" ).removeAttr( "checked" );
  2608. $( idForm ).find( "img[src='"+ $(this).attr( "src" ) +"']" ).each( function() {
  2609. $(this).parent().parent().find( "input" ).attr( "checked", "checked" );
  2610. });
  2611. saveCheckedPlayers();
  2612. });
  2613. }
  2614. });
  2615.  
  2616. return( false );
  2617. });
  2618. }
  2619.  
  2620.  
  2621. // Count selected members on MU list
  2622. function addCounterMembersMU() {
  2623.  
  2624. var counterDiv = $( "<div style='width:150px; text-align: center; display:inline; padding:2px' id='counterCheck'>No members selected.</div>" )
  2625. counterDiv.insertAfter( ".testDivwhite" );
  2626.  
  2627. var totalDiv = $( "<div style='width:150px; text-align: center; display:inline-block; padding:2px' id='totalDonate'></div>" );
  2628. totalDiv.insertAfter( "#counterCheck" );
  2629.  
  2630. // Add events
  2631. $( ".receipments" ).bind( "change", setCounterText );
  2632.  
  2633. $( "#tickAll" ).bind( "click", setCounterText );
  2634. $( "#untickAll" ).bind( "click", setCounterText );
  2635.  
  2636. $( "#quantity" ).bind( "change", setCounterText );
  2637. $( ".fastBtn" ).bind( "click", setCounterText );
  2638.  
  2639. setCounterText();
  2640. }
  2641.  
  2642.  
  2643. // Set counter checks text
  2644. function setCounterText() {
  2645.  
  2646. var qty = $( "#quantity" ).attr( "value" );
  2647. var n = $( ".receipments:checked" ).length;
  2648. if( n == 0 ) {
  2649. $( "#counterCheck" ).text( "No members selected." );
  2650. $( "#totalDonate" ).text( "" );
  2651.  
  2652. } else if( n == 1 ) {
  2653. $( "#counterCheck" ).text( "Selected 1 member." );
  2654. if( qty > 0 ) {
  2655. if( n*qty == 1 ) {
  2656. $( "#totalDonate" ).text( "Total donate: "+ (n*qty) +" item." );
  2657.  
  2658. } else $( "#totalDonate" ).text( "Total donate: "+ (n*qty) +" items." );
  2659.  
  2660. } else $( "#totalDonate" ).text( "" );
  2661.  
  2662. } else {
  2663. $( "#counterCheck" ).text( "Selected "+n+" members." );
  2664. if( qty > 0 ) {
  2665. $( "#totalDonate" ).text( "Total donate: "+ (n*qty) +" items." );
  2666.  
  2667. } else $( "#totalDonate" ).text( "" );
  2668. }
  2669. }
  2670.  
  2671.  
  2672. // Update player to player donation
  2673. function changeSelectPlayerToPlayer( idForm ) {
  2674.  
  2675. var select = $( "#product" );
  2676. var dest = $( "#quantity" );
  2677. var pos = $( ".testDivblue" ).eq(2);
  2678. var posSelect = $( ".testDivblue" ).eq(4);
  2679.  
  2680. pos.children().remove();
  2681. pos.append( "One click to select <b>ONE item</b>. Double click to select <b>ALL items</b>.<br/><br/>" );
  2682. pos.addClass( "playerToPlayerItem" );
  2683.  
  2684. posSelect.children().first().remove();
  2685. posSelect.children().first().remove();
  2686. posSelect.children().last().remove();
  2687.  
  2688. orderSelect( select );
  2689. changeSelect( select, pos, dest, "#8baed8" );
  2690. }
  2691.  
  2692.  
  2693. // Add fast buttons
  2694. function addFastButtons( idDest ) {
  2695.  
  2696. var firstFastButton = true;
  2697. $( idDest ).css({ "text-align" : "center" });
  2698.  
  2699. var btn1 = $( "<input class='fastBtn FastButtonLeft' type='button' value='1' />" );
  2700. btn1.bind( "click", function() {
  2701. if( firstFastButton ) {
  2702. $( idDest ).attr( "value", "1" );
  2703. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 1 );
  2704. firstFastButton = false;
  2705. });
  2706.  
  2707. var btn5 = $( "<input class='fastBtn FastButtonLeft' type='button' value='5' />" );
  2708. btn5.bind( "click", function() {
  2709. if( firstFastButton ) {
  2710. $( idDest ).attr( "value", "5" );
  2711. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 5 );
  2712. firstFastButton = false;
  2713. });
  2714.  
  2715. var btn10 = $( "<input class='fastBtn FastButtonLeft' type='button' value='10' />" );
  2716. btn10.bind( "click", function() {
  2717. if( firstFastButton ) {
  2718. $( idDest ).attr( "value", "10" );
  2719. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 10 );
  2720. firstFastButton = false;
  2721. });
  2722.  
  2723. var btn15 = $( "<input class='fastBtn FastButtonLeft' type='button' value='15' />" );
  2724. btn15.bind( "click", function() {
  2725. if( firstFastButton ) {
  2726. $( idDest ).attr( "value", "15" );
  2727. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 15 );
  2728. firstFastButton = false;
  2729. });
  2730.  
  2731. var btn25 = $( "<input class='fastBtn FastButtonLeft' type='button' value='25' />" );
  2732. btn25.bind( "click", function() {
  2733. if( firstFastButton ) {
  2734. $( idDest ).attr( "value", "25" );
  2735. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 25 );
  2736. firstFastButton = false;
  2737. });
  2738.  
  2739. var btn50 = $( "<input class='fastBtn FastButtonLeft' type='button' value='50' />" );
  2740. btn50.bind( "click", function() {
  2741. if( firstFastButton ) {
  2742. $( idDest ).attr( "value", "50" );
  2743. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 50 );
  2744. firstFastButton = false;
  2745. });
  2746.  
  2747. var btn75 = $( "<input class='fastBtn FastButtonRight' type='button' value='75' />" );
  2748. btn75.bind( "click", function() {
  2749. if( firstFastButton ) {
  2750. $( idDest ).attr( "value", "75" );
  2751. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 75 );
  2752. firstFastButton = false;
  2753. });
  2754.  
  2755. var btn100 = $( "<input class='fastBtn FastButtonRight' type='button' value='100' />" );
  2756. btn100.bind( "click", function() {
  2757. if( firstFastButton ) {
  2758. $( idDest ).attr( "value", "100" );
  2759. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 100 );
  2760. firstFastButton = false;
  2761. });
  2762.  
  2763. var btn125 = $( "<input class='fastBtn FastButtonRight' type='button' value='125' />" );
  2764. btn125.bind( "click", function() {
  2765. if( firstFastButton ) {
  2766. $( idDest ).attr( "value", "125" );
  2767. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 125 );
  2768. firstFastButton = false;
  2769. });
  2770.  
  2771. var btn150 = $( "<input class='fastBtn FastButtonRight' type='button' value='150' />" );
  2772. btn150.bind( "click", function() {
  2773. if( firstFastButton ) {
  2774. $( idDest ).attr( "value", "150" );
  2775. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 150 );
  2776. firstFastButton = false;
  2777. });
  2778.  
  2779. var btn500 = $( "<input class='fastBtn FastButtonRight' type='button' value='500' />" );
  2780. btn500.bind( "click", function() {
  2781. if( firstFastButton ) {
  2782. $( idDest ).attr( "value", "500" );
  2783. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 500 );
  2784. firstFastButton = false;
  2785. });
  2786.  
  2787. var btn1k = $( "<input class='fastBtn FastButtonRight' type='button' value='1K' />" );
  2788. btn1k.bind( "click", function() {
  2789. if( firstFastButton ) {
  2790. $( idDest ).attr( "value", "1000" );
  2791. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 1000 );
  2792. firstFastButton = false;
  2793. });
  2794.  
  2795. btn1.insertBefore( idDest );
  2796. btn5.insertBefore( idDest );
  2797. btn10.insertBefore( idDest );
  2798. btn15.insertBefore( idDest );
  2799. btn25.insertBefore( idDest );
  2800. btn50.insertBefore( idDest );
  2801.  
  2802. btn1k.insertAfter( idDest );
  2803. btn500.insertAfter( idDest );
  2804. btn150.insertAfter( idDest );
  2805. btn125.insertAfter( idDest );
  2806. btn100.insertAfter( idDest );
  2807. btn75.insertAfter( idDest );
  2808. }
  2809.  
  2810.  
  2811. // Change create contract page
  2812. /*function changeCreateContract() {
  2813.  
  2814. // Redesign
  2815. $( "#contractsForm" ).parent().css({ "width" : "550px" });
  2816. $( "#contractsForm" ).next().remove();
  2817. //$( "#contractsForm" ).children( "div" ).css({ "display" : "none" });
  2818. //$( "#offererSide" ).css({ "display" : "none" });
  2819. //$( "#itemTypeList" ).css({ "display" : "none" });
  2820. //$( "#contractsForm" ).children( "br" ).remove();
  2821. //$( "#contractsForm" ).children( "b" ).remove();
  2822.  
  2823. // Clean some elements from Form
  2824. var input = $( "#contractsForm" ).children( "input" ).eq(2);
  2825.  
  2826. //var player = $( "<div style='float:left; width:49%; height:30px'></div>" );
  2827. //player.css({ "background-color" : "#fff", "border-radius" : "4px", "cursor" : "pointer" });
  2828. //player.css({ "box-shadow" : "0px 0px 5px rgba(0, 0, 0, 0.5)" });
  2829. //var imgPlayerSrc = $( ".testDivwhite" ).eq(0).find( "img" ).eq(1).attr( "src" );
  2830. //player.append( "<img src='"+ imgPlayerSrc +"' style='width:30px;' />" );
  2831. //var name = $( ".testDivwhite" ).eq(0).find( "a[href^='profile.html']" ).text();
  2832. //player.append( "<span style='font-weight:bold; font-size:14px; margin-left:5px; position:relative; top:-10px'>"+ name +"</span>" );
  2833.  
  2834. //var dummy = $( "<div style='float:left; width:49%; height:30px'></div>" );
  2835. //dummy.css({ "margin" : "0px 0px 0px 1%" });
  2836. //var imgDummySrc = $( ".testDivwhite" ).eq(1).find( "img" ).eq(1).attr( "src" );
  2837. //dummy.append( "<img src='"+ imgDummySrc +"' style='float:right; width:30px;' />" );
  2838. //dummy.append( "<div style='float:right; font-weight:bold; font-size:14px; margin:6px 5px 0px 0px;'>Dummy</div>" );
  2839.  
  2840. //var playerBlock = createContractBlock();
  2841. //var dummyBlock = createContractBlock();
  2842.  
  2843. player.insertBefore( input );
  2844. dummy.insertBefore( input );
  2845. //playerBlock.insertBefore( input );
  2846. //dummyBlock.insertBefore( input );
  2847. }*/
  2848.  
  2849.  
  2850. // Create contract block
  2851. /*function createContractBlock() {
  2852.  
  2853. var block = $( "<div style='float:left; width:100%; height:200px;'></div>" );
  2854. block.css({ "background-color" : "#fff", "margin" : "9px 0px 10px 0px", "border-radius" : "4px" });
  2855. block.css({ "box-shadow" : "0px 0px 5px rgba(0, 0, 0, 0.5)" });
  2856.  
  2857. var options = $( "<div style='font-size:12px; font-weight:bold; cursor:pointer; width:100%; height: 23px;'></div>" );
  2858. var moneyTab = $( "<div style='float:left; width:133px; padding:5px 0px; '>MONEY</div>" );
  2859. var productTab = $( "<div style='float:left; width:134px; padding:5px 0px;'>PRODUCT</div>" );
  2860. var debtTab = $( "<div style='float:left; width:133px; padding:5px 0px;'>DEBT</div>" );
  2861.  
  2862. moneyTab.bind( "mouseover", function() {
  2863. $(this).css({ "background-color" : "#ddd" });
  2864. });
  2865. moneyTab.bind( "mouseout", function() {
  2866. $(this).css({ "background-color" : "#fff" });
  2867. });
  2868.  
  2869. productTab.bind( "mouseover", function() {
  2870. $(this).css({ "background-color" : "#ddd" });
  2871. });
  2872. productTab.bind( "mouseout", function() {
  2873. $(this).css({ "background-color" : "#fff" });
  2874. });
  2875.  
  2876. debtTab.bind( "mouseover", function() {
  2877. $(this).css({ "background-color" : "#ddd" });
  2878. });
  2879. debtTab.bind( "mouseout", function() {
  2880. $(this).css({ "background-color" : "#fff" });
  2881. });
  2882.  
  2883. var money = $( "#MONEYParameters" );
  2884. money.css({ "margin" : "8px 10px 8px 10px", "border" : "1px solid #ccc", "border-radius" : "4px" });
  2885. money.css({ "background-color" : "#eee", "width" : "250px", "height" : "97px", "padding" : "60px 0px 0px 0px" });
  2886.  
  2887. //var product = $( "<div></div>" );
  2888. //$( "#PRODUCTParameters" ).css({ "display" : "block" })
  2889. //product.append( $( "#PRODUCTParameters" ) );
  2890.  
  2891. //var debt = $( "<div></div>" );
  2892. //$( "#DEBTParameters" ).css({ "display" : "block" });
  2893. //debt.append( $( "#DEBTParameters" ) );
  2894.  
  2895. options.append( moneyTab );
  2896. options.append( productTab );
  2897. options.append( debtTab );
  2898. block.append( options );
  2899. block.append( money );
  2900. return( block );
  2901. }*/
  2902.  
  2903.  
  2904. // Change market selectors
  2905. function changeProductSelection() {
  2906.  
  2907. // Remove extra br at the begining
  2908. $( "#contentRow" ).children( "td" ).eq(1).children().eq(1).remove();
  2909.  
  2910. // Redesign product selection in one row
  2911. var divBlock = $( "#productMarketViewForm" ).parent();
  2912. divBlock.addClass( "productMarketViewFormMod" );
  2913. divBlock.children( ":lt(2)" ).remove();
  2914.  
  2915. // Remove useless tags
  2916. $( "#marketProducts" ).children( "p" ).remove();
  2917. $( "#marketProducts" ).addClass( "marketProductsMod" );
  2918.  
  2919. $( "#productMarketViewForm > .productList" ).hide();
  2920. var selectProductMarketItem = null;
  2921. var mycounter=0;
  2922. $( "#marketProducts .productList" ).each( function() {
  2923.  
  2924.  
  2925. mycounter++;
  2926. var related = $(this);
  2927. var product = $( "<div class='productMarketItem'></div>" );
  2928. product.append( "<img src='"+ $(this).find( "img" ).attr( "src" ) +"' />" );
  2929. product.append( "<div class='productLabel'>"+ $(this).find( "label" ).text() +"</div>" );
  2930. $(this).parent().append( product );
  2931.  
  2932. product.bind( "mouseover", function() {
  2933. if( selectProductMarketItem ) {
  2934. if( $(this).text() != selectProductMarketItem.text() ) { $(this).addClass( "productMarketItemHover" ); }
  2935. } else $(this).addClass( "productMarketItemHover" );
  2936. });
  2937.  
  2938. product.bind( "mouseout", function() {
  2939. if( selectProductMarketItem ) {
  2940. if( $(this).text() != selectProductMarketItem.text() ) { $(this).removeClass( "productMarketItemHover" ); }
  2941. } else $(this).removeClass( "productMarketItemHover" );
  2942. });
  2943.  
  2944. product.bind( "click", function() {
  2945. if( selectProductMarketItem && ($(this).text() == selectProductMarketItem.text()) ) {
  2946. $(this).removeClass( "productMarketItemSelected" );
  2947. $( "#resource1" ).attr( "checked", "checked" );
  2948. selectProductMarketItem = null;
  2949.  
  2950. } else {
  2951. if( selectProductMarketItem ) {
  2952. selectProductMarketItem.removeClass( "productMarketItemHover" );
  2953. selectProductMarketItem.removeClass( "productMarketItemSelected" );
  2954. }
  2955. $(this).addClass( "productMarketItemSelected" );
  2956. selectProductMarketItem = $(this);
  2957. related.find( "input" ).attr( "checked", "checked" );
  2958. }
  2959. });
  2960.  
  2961. $(this).hide();
  2962. if( $(this).find( "input" ).attr( "checked" ) ) { product.click(); }
  2963.  
  2964.  
  2965. if(mycounter==7)
  2966. {
  2967.  
  2968.  
  2969. }
  2970. });
  2971.  
  2972. $( "#countryId" ).addClass( "countryIdSelect" );
  2973. $( "#countryId" ).addClass( "customSelectList" );
  2974.  
  2975. // Change quality selection
  2976. var selectedQuality = parseInt( $( "#quality :selected" ).val() );
  2977. var newQuality = $( "<div class='qualityProduct'></div>" );
  2978. $( "#quality option" ).each( function() {
  2979.  
  2980. var v = parseInt( $(this).val() );
  2981. if( v != 0 ) {
  2982. var star = $( "<div class='qualityStar' quality='"+ v +"' ></div>" );
  2983. if( v > selectedQuality ) {
  2984. star.addClass( "qualityStarHover" );
  2985. }
  2986. newQuality.append( star );
  2987.  
  2988. star.bind( "click", function() {
  2989. var q = parseInt( $(this).attr( "quality" ) );
  2990. $(this).parent().children().addClass( "qualityStarHover" );
  2991. if( selectedQuality == q ) {
  2992. selectedQuality = 0;
  2993.  
  2994. } else {
  2995. var current = $(this);
  2996. for( var i=0; i<=q; i++ ) {
  2997. current.removeClass( "qualityStarHover" );
  2998. current = current.prev();
  2999. }
  3000. selectedQuality = q;
  3001. }
  3002.  
  3003. $( "#quality" ).val( selectedQuality );
  3004. });
  3005. }
  3006. });
  3007.  
  3008. newQuality.insertBefore( "#quality" );
  3009. $( "#quality" ).hide();
  3010.  
  3011. $( "#productMarketViewForm" ).children( "br" ).remove();
  3012.  
  3013. // Rellocate help wiki and my offers link
  3014. $( "#productMarketViewForm .biggerFont a" ).addClass( "linkMyOffersProductMarket" );
  3015. var imgWiki = $( "#quality" ).next().next();
  3016. imgWiki.addClass( "imgWikiProductMarket" );
  3017. var linkWiki = imgWiki.next();
  3018. linkWiki.addClass( "linkWikiProductMarket" );
  3019. var imgLinkWiki = $( "<a href='"+ linkWiki.attr( "href" ) +"' target='_blank'></a>" );
  3020. imgLinkWiki.append( imgWiki );
  3021. imgLinkWiki.insertAfter( $( "#productMarketViewForm" ) );
  3022. linkWiki.insertAfter( $( "#productMarketViewForm" ) );
  3023.  
  3024. // Add buy As button on top
  3025. var buyAs = $( "<div class='buyAsSelect'></div>" );
  3026. var select = $( "<select class='customSelectList' ></select>" );
  3027. if( $( "#command" ).first().children( "select" ).length > 0 ) {
  3028. buyAs.append( $( "#command" ).first().contents().eq(0).text() );
  3029. $( "#command" ).first().children( "select" ).children().each( function() {
  3030. select.append( "<option value='"+ $(this).attr( "value" ) +"'>"+ $(this).text() +"</option>" );
  3031. });
  3032.  
  3033. } else {
  3034. buyAs.append( "Buy as:" );
  3035. select.append( "<option value=''> Citizen </option>" );
  3036. select.attr( "disabled", "disabled" );
  3037. }
  3038. buyAs.append( select );
  3039. buyAs.insertAfter( $( "#productMarketViewForm" ).children( "p" ) );
  3040. select.bind( "change", function() {
  3041. $( ".dataTable" ).find( "select" ).val( $(this).val() );
  3042.  
  3043. if( getValue( "configProductMarketTable" ) == "true" ) {
  3044. var color = ($(this).val() != "" ) ? "#fcecec" : "#ecffec";
  3045. var t = $(this).find( ":selected" ).text();
  3046. $( ".dataTable" ).find( "select" ).each( function() {
  3047. $( ".toRemove" ).parent().parent().css({ "background-color" : color });
  3048. $( ".toRemove" ).text( "Buy as "+ t );
  3049. });
  3050. }
  3051. });
  3052. select.first().selected();
  3053. }
  3054.  
  3055.  
  3056. // Change product market table
  3057. function changeProductMarketTable() {
  3058.  
  3059. $( ".dataTable" ).find( "input[type='text']" ).addClass( "inputTextTable" );
  3060. var submit = $( ".dataTable" ).find( "input[type='submit']" ).addClass( "inputSubmitTable" );
  3061. $( ".dataTable" ).find( "input[type='text']" ).bind( "keyup", function() {
  3062. var td = $(this).parent().parent();
  3063. var priceUnit = parseFloat( td.prev().prev().children( ".linkMonetaryMarket" ).next().text() );
  3064. var value = parseFloat( $(this).val() );
  3065. td.prev().children( ".inputPrice" ).text( Math.round( priceUnit * value * 100 ) / 100 );
  3066. });
  3067.  
  3068. // Add buy all button
  3069. var buyAll = $( "<input class='buyAllSubmit' type='submit' value='All' />" );
  3070. buyAll.bind( "click", function() {
  3071. var v = $(this).parent().parent().prev().prev().prev().text();
  3072. $(this).parent().children( "input[type='text']" ).val( v );
  3073. return( false );
  3074. });
  3075. buyAll.insertBefore( submit );
  3076.  
  3077. // Hide buyAs select
  3078. $( ".dataTable" ).find( "select" ).each( function() {
  3079. var cell = $(this).parent();
  3080. var buyAs = $( "<div class='toRemove buyAsTable'>Buy as Citizen</div>" );
  3081.  
  3082. if( getValue( "configProductMarketSelection" ) == "true" ) {
  3083. buyAs.insertBefore( cell.children().first() );
  3084. cell.parent().css({ "background-color" : "#ecffec" });
  3085. cell.contents().eq(0).remove();
  3086. cell.children( "br" ).remove();
  3087. $(this).hide();
  3088.  
  3089. } else $(this).addClass( "customSelectList" );
  3090. });
  3091.  
  3092. // Add help message
  3093. var divT = $( "<div class='helpFlagMessage'>Click on country flag to open the monetary market (only price column)</div>" );
  3094. divT.insertBefore( ".dataTable" );
  3095.  
  3096. // Resize table
  3097. $( ".dataTable" ).addClass( "dataTableMod" );
  3098.  
  3099. // Redesign table
  3100. // Headers
  3101. $( ".dataTable > tbody > tr:first-child > td" ).addClass( "dataTableHeaders" );
  3102. var trHead = $( ".dataTable" ).find( "tr" ).eq(0).children();
  3103. trHead.eq(0).css({ "width" : "70px" });
  3104. trHead.eq(3).text( "Price/unit" );
  3105. $( "<td class='dataTableHeaders'>Price</td>" ).insertAfter( trHead.eq(3) );
  3106.  
  3107. // Product list
  3108. //resizeProductImage( $( ".dataTable" ).find( ".product" ) );
  3109.  
  3110. // Name list and total price
  3111. $( ".dataTable" ).find( "a" ).each( function() {
  3112.  
  3113. // Name redesign
  3114. var cell = $(this).parent();
  3115. cell.children( ".currencyFlag" ).next().remove(); // Remove BR
  3116. cell.children( ".currencyFlag" ).addClass( "dataTableNameFlag" );
  3117.  
  3118. var div = $( "<div class='blockSeller'></div>" );
  3119. var imgSeller = cell.children( "img" ).eq(1);
  3120. imgSeller.addClass( "dataTableSeller" );
  3121. div.append( imgSeller );
  3122.  
  3123. var playerName = $( "<div class='playerName'></div>" ).append( cell.children( ":lt(2)" ) );
  3124. div.append( playerName );
  3125. if( cell.children().length > 0 ) {
  3126. playerName.css({ "margin-top" :"3px" });
  3127.  
  3128. cell.children().eq(0).remove();
  3129. var stockName = $( "<div class='stockName'></div>" ).append( cell.children().eq(0) );
  3130. div.append( stockName );
  3131. }
  3132. cell.append( div );
  3133.  
  3134. var nextCell = cell.next().next();
  3135. var flag = nextCell.children( "img" );
  3136. flag.addClass( "monetaryMarketFlag" );
  3137.  
  3138. // Add link to monetary market
  3139. var url = getCurrentServer() + URLMonetaryMarket + "?buyerCurrencyId="+ IDByImageCountry( flag.attr( "src" ) ) +"&sellerCurrencyId=0";
  3140. var link = $( "<a class='linkMonetaryMarket' href='"+ url +"' target='_blank'></a>" );
  3141. link.insertBefore( flag );
  3142. link.append( flag );
  3143.  
  3144. // Total price
  3145. var priceItem = parseFloat( nextCell.children( "b" ).text() );
  3146. var n = ( parseInt( parseInt( cell.next().text() ) * priceItem * 100 ) )/100;
  3147. var money = nextCell.contents().last().text();
  3148. var newCell = $( "<td class='totalPriceProductMarket'><b>"+ n +"</b> "+ money +"</td>" );
  3149. newCell.insertAfter( nextCell );
  3150. newCell.append( "<div class='inputPrice'>0</div>" );
  3151. });
  3152. }
  3153.  
  3154.  
  3155. // Redesign product image
  3156. function resizeProductImage( productList ) {
  3157.  
  3158. productList.each( function() {
  3159. var cell = $(this).parent();
  3160. var img = cell.find( "img" );
  3161. cell.children().remove()
  3162.  
  3163. var block = $( "<div style='url('http://e-sim.home.pl/testura/img/stripes.png') repeat scroll 0 0 #3D6571'></div>" );
  3164. //block.append( "<img class='blockProduct 'src='"+ IMGPRODBG +"' />" );
  3165. block.append( img.eq(0).addClass( "productImage" ) );
  3166. if( img.length > 1 ) { block.append( img.eq(1).addClass( "productQuality" ) ); }
  3167.  
  3168. cell.append( block );
  3169. });
  3170. }
  3171.  
  3172.  
  3173. // Relationship between country images and IDs
  3174. /*function ImagesCountryByID( id ) {
  3175.  
  3176. switch( id ) {
  3177. case 1: return( POLAND );
  3178. case 2: return( RUSSIA );
  3179. case 3: return( GERMANY );
  3180. case 4: return( FRANCE );
  3181. case 5: return( SPAIN );
  3182. case 6: return( UK );
  3183. case 7: return( ITALY );
  3184. case 8: return( HUNGARY );
  3185. case 9: return( ROMANIA );
  3186. case 10: return( BULGARIA );
  3187. case 11: return( SERBIA );
  3188. case 12: return( CROATIA );
  3189. case 13: return( BOSNIA );
  3190. case 14: return( GREECE );
  3191. case 15: return( FYROM );
  3192. case 16: return( UKRAINE );
  3193. case 17: return( SWEDEN );
  3194. case 18: return( PORTUGAL );
  3195. case 19: return( LITHUANIA );
  3196. case 20: return( LATVIA );
  3197. case 21: return( SLOVENIA );
  3198. case 22: return( TURKEY );
  3199. case 23: return( BRAZIL );
  3200. case 24: return( ARGENTINA );
  3201. case 25: return( MEXICO );
  3202. case 26: return( USA );
  3203. case 27: return( CANADA );
  3204. case 28: return( CHINA );
  3205. case 29: return( INDONESIA );
  3206. case 30: return( IRAN );
  3207. case 31: return( SOUTHKOREA );
  3208. case 32: return( TAIWAN );
  3209. case 33: return( ISRAEL );
  3210. case 34: return( INDIA );
  3211. case 35: return( AUSTRALIA );
  3212. case 36: return( NETHERLANDS );
  3213. case 37: return( FINLAND );
  3214. case 38: return( IRELAND );
  3215. case 39: return( SWITZERLAND );
  3216. case 40: return( BELGIUM );
  3217. case 41: return( PAKISTAN );
  3218. case 42: return( MALAYSIA );
  3219. case 43: return( NORWAY );
  3220. case 44: return( PERU );
  3221. case 45: return( CHILE );
  3222. case 46: return( COLOMBIA );
  3223. case 51: return( CZECH );
  3224. case 52: return( BELARUS );
  3225. case 53: return( ESTONIA );
  3226. case 54: return( PHILIPPINES );
  3227. }
  3228. }*/
  3229.  
  3230.  
  3231. function IDByImageCountry( img ) {
  3232.  
  3233. switch( img ) {
  3234. case POLAND: return( 1 );
  3235. case RUSSIA: return( 2 );
  3236. case GERMANY: return( 3 );
  3237. case FRANCE: return( 4 );
  3238. case SPAIN: return( 5 );
  3239. case UK: return( 6 );
  3240. case ITALY: return( 7 );
  3241. case HUNGARY: return( 8 );
  3242. case ROMANIA: return( 9 );
  3243. case BULGARIA: return( 10 );
  3244. case SERBIA: return( 11 );
  3245. case CROATIA: return( 12 );
  3246. case BOSNIA: return( 13 );
  3247. case GREECE: return( 14 );
  3248. case FYROM: return( 15 );
  3249. case UKRAINE: return( 16 );
  3250. case SWEDEN: return( 17 );
  3251. case PORTUGAL: return( 18 );
  3252. case LITHUANIA: return( 19 );
  3253. case LATVIA: return( 20 );
  3254. case SLOVENIA: return( 21 );
  3255. case TURKEY: return( 22 );
  3256. case BRAZIL: return( 23 );
  3257. case ARGENTINA: return( 24 );
  3258. case MEXICO: return( 25 );
  3259. case USA: return( 26 );
  3260. case CANADA: return( 27 );
  3261. case CHINA: return( 28 );
  3262. case INDONESIA: return( 29 );
  3263. case IRAN: return( 30 );
  3264. case SOUTHKOREA: return( 31 );
  3265. case TAIWAN: return( 32 );
  3266. case ISRAEL: return( 33 );
  3267. case INDIA: return( 34 );
  3268. case AUSTRALIA: return( 35 );
  3269. case NETHERLANDS: return( 36 );
  3270. case FINLAND: return( 37 );
  3271. case IRELAND: return( 38 );
  3272. case SWITZERLAND: return( 39 );
  3273. case BELGIUM: return( 40 );
  3274. case PAKISTAN: return( 41 );
  3275. case MALAYSIA: return( 42 );
  3276. case NORWAY: return( 43 );
  3277. case PERU: return( 44 );
  3278. case CHILE: return( 45 );
  3279. case COLOMBIA: return( 46 );
  3280. case CZECH: return( 51 );
  3281. case BELARUS: return( 52 );
  3282. case ESTONIA: return( 53 );
  3283. case PHILIPPINES: return( 54 );
  3284. default: return( 0 );
  3285. }
  3286. }
  3287.  
  3288.  
  3289. // Change market oferrs
  3290. function changeMarketOffers() {
  3291.  
  3292. var select = $( "#resourceInput" );
  3293. var pos = $( ".storage" ).parent();
  3294. var dest = $( "#quantity" );
  3295.  
  3296. var leftDiv = $( "#productMarketOfferForm" ).parent();
  3297. leftDiv.children().first().remove();
  3298. leftDiv.children().first().remove();
  3299. leftDiv.addClass( "leftDivMyOffers" );
  3300.  
  3301. // Remove all childrens and add help text
  3302. pos.children().remove();
  3303. pos.addClass( "myOffersProduct" );
  3304. pos.append( "One click to select <b>ONE item</b>.<br/>Double click to select <b>ALL items</b>.<br/>" );
  3305.  
  3306. var divBlue = $( "#countryInput" ).parent().parent();
  3307. divBlue.find( "b" ).eq(0).css({ "display" : "inline" });
  3308. divBlue.find( "b" ).eq(1).css({ "display" : "inline" });
  3309.  
  3310. $( "#countryInput" ).addClass( "customSelectList" );
  3311. select.addClass( "customSelectList" );
  3312.  
  3313. firstFastButton = true;
  3314. dest.addClass( "quantityMyOffers" );
  3315. $( "#priceInput" ).addClass( "priceInputMyOffers" );
  3316.  
  3317. var btn10 = $( "<input class='fastBtn FastButtonLeft' type='button' value='10' />" );
  3318. btn10.bind( "click", function() {
  3319. if( firstFastButton ) {
  3320. dest.attr( "value", "10" );
  3321. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 10 );
  3322. firstFastButton = false;
  3323. });
  3324.  
  3325. var btn50 = $( "<input class='fastBtn FastButtonLeft' type='button' value='50' />" );
  3326. btn50.bind( "click", function() {
  3327. if( firstFastButton ) {
  3328. dest.attr( "value", "50" );
  3329. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 50 );
  3330. firstFastButton = false;
  3331. });
  3332.  
  3333. var btn100 = $( "<input class='fastBtn FastButtonRight' type='button' value='100' />" );
  3334. btn100.bind( "click", function() {
  3335. if( firstFastButton ) {
  3336. dest.attr( "value", "100" );
  3337. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 100 );
  3338. firstFastButton = false;
  3339. });
  3340.  
  3341. var btn1000 = $( "<input class='fastBtn FastButtonRight' type='button' value='1K' />" );
  3342. btn1000.bind( "click", function() {
  3343. if( firstFastButton ) {
  3344. dest.attr( "value", "1000" );
  3345. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 1000 );
  3346. firstFastButton = false;
  3347. });
  3348.  
  3349. btn10.insertBefore( dest );
  3350. btn50.insertBefore( dest );
  3351. btn1000.insertAfter( dest );
  3352. btn100.insertAfter( dest );
  3353.  
  3354. orderSelect( select );
  3355. changeSelect( select, pos, dest, "#aaaaaa" );
  3356.  
  3357. $( ".storage" ).bind( "click", function() { setTimeout( mySendPreviewRequest, 500 ); });
  3358. $( "#countryInput" ).unbind( "change" );
  3359. $( "#countryInput" ).bind( "change", function() { mySendPreviewRequest(); });
  3360. $( "#resourceInput" ).unbind( "change" );
  3361. $( "#resourceInput" ).bind( "change", function() { mySendPreviewRequest(); });
  3362. $( "#priceInput" ).unbind( "change" );
  3363. $( "#priceInput" ).bind( "change", function() { mySendPreviewRequest(); });
  3364. $( "#priceInput" ).bind( "keydown", function() { setTimeout( mySendPreviewRequest, 1000 ); });
  3365. }
  3366.  
  3367.  
  3368. // Replace sendPreviewRequest to restyle
  3369. function mySendPreviewRequest() {
  3370. if( !isFormCorrect() ) { return; }
  3371.  
  3372. // If is in the player or in the Stock
  3373. var csFlag;
  3374. var localUrl = new String( window.location );
  3375. if( localUrl.indexOf( URLMarketOffers, 0 ) >= 0 ) {
  3376. csFlag = $( "#eatLink" ).prev().prev().prev();
  3377.  
  3378. } else if( localUrl.indexOf( URLStockProducts, 0 ) >= 0 ) {
  3379. var listBlue = $( "#contentRow" ).children( "td" ).eq(1).find( ".testDivblue" );
  3380. csFlag = listBlue.eq(0).find( "td" ).eq(1).find( ".currencyFlag" ).eq(1);
  3381. }
  3382. var citizenship = IDByImageCountry( csFlag.attr( "src" ) );
  3383.  
  3384.  
  3385. var dataString = 'country=' + $("#countryInput").val() + '&resource=' + $("#resourceInput").val();
  3386. dataString += '&price=' +$("#priceInput").val() + '&citizenship=' + citizenship;
  3387. var resourceType = $("#resourceInput option:selected").text();
  3388. $( "#preview" ).html( "<div class ='previewMyOffers'>Loading tax resource...</div >" );
  3389.  
  3390. $.ajax({
  3391. type: "POST",
  3392. url: "productTaxes.html",
  3393. data: dataString,
  3394. dataType: "html",
  3395. success: function( data ) {
  3396. var preview = $( "#preview" );
  3397. preview.html( data );
  3398. preview.children( ".dataTable" ).addClass( "previewDataTable" );
  3399.  
  3400. var res = $( "<div class='resourceMyOffers'>"+ resourceType + "</div>" );
  3401. var link = getCurrentServer() + URLMarket + "?resource=";
  3402. var splitItem = $("#resourceInput").val().split( "-" );
  3403. if( splitItem.length == 1 ) {
  3404. link += splitItem[0] + "&countryId=" + $("#countryInput").val();
  3405. } else link += splitItem[1] + "&countryId=" + $("#countryInput").val() + "&quality=" + splitItem[0];
  3406. res.append( "<a class='textMyOffers' href='"+ link +"' target='_blank'>Market</a>" );
  3407.  
  3408. link = getCurrentServer() + URLMonetaryMarket + "?buyerCurrencyId="+ $("#countryInput").val() +"&sellerCurrencyId=0";
  3409. res.append( "<a class='MMMyOffers' href='"+ link +"' target='_blank'>MM link</a>" );
  3410.  
  3411. var flag = preview.find( ".currencyFlag" ).first();
  3412. flag.addClass( "flagMyOffer" );
  3413.  
  3414. // Remove all flags
  3415. preview.find( ".currencyFlag" ).remove();
  3416. res.insertBefore( preview.children().first() );
  3417. flag.insertBefore( preview.children( "b" ).first() );
  3418. preview.children( "b" ).addClass( "titleMyOffers" );
  3419.  
  3420. var thead = preview.children( ".dataTable" ).find( "tr" ).eq(0);
  3421. preview.children( ".dataTable" ).find( "tr" ).eq(1).children().css({ "height" : "25px" });
  3422. thead.children().css({ "height" : "22px" });
  3423. thead.children().eq(0).text( "Gross" );
  3424. thead.children().eq(1).text( "Net" );
  3425. thead.children().eq(3).text( "Tax" );
  3426. }
  3427. });
  3428. }
  3429.  
  3430.  
  3431. // Change monetary market view
  3432. function changeMonetaryMarket() {
  3433.  
  3434. if( $( "#container" ).children().length == 3 ) {
  3435. $( "#container" ).children().last().remove();
  3436. }
  3437. var listBlue = $( "#container" ).find( ".testDivblue" );
  3438. var currentOffersTitle = listBlue.eq(2);
  3439. var currentOffers = listBlue.eq(3);
  3440. var yourOffersTitle = listBlue.eq(4);
  3441. var yourOffers = listBlue.eq(5);
  3442.  
  3443. currentOffers.addClass( "currentOffersMM" );
  3444. yourOffers.addClass( "yourOffersMM" );
  3445. yourOffers.children().last().remove();
  3446.  
  3447. // Custom Selects
  3448. $( "#buy" ).addClass( "customSelectList" );
  3449. $( "#sell" ).addClass( "customSelectList" );
  3450. $( "#offeredMoneyId" ).addClass( "customSelectList" );
  3451. $( "#buyedMoneyId" ).addClass( "customSelectList" );
  3452.  
  3453. // Create new blocks BR
  3454. var block1 = $( "<div class='monetaryMarketTitleBlock'></div>" );
  3455. block1.insertBefore( currentOffersTitle );
  3456. //block1.append( currentOffers );
  3457. block1.append( currentOffersTitle );
  3458.  
  3459.  
  3460. // New button in current offers
  3461. var swapView = $( "<input class='swapView' type='button' value='Swap & View' />" );
  3462. swapView.insertAfter( "#swap2" );
  3463. swapView.bind( "click", function() {
  3464. $( "#swap2" ).click();
  3465. $( "#monetaryMarketView" ).submit();
  3466. });
  3467. $( "#swap2" ).addClass( "swapView" );
  3468. $( "#swap2" ).bind( "click", function() {
  3469. var temp = $( "#offeredMoneyId" ).val();
  3470. $( "#offeredMoneyId" ).val( $( "#buyedMoneyId" ).val() );
  3471. $( "#buyedMoneyId" ).val( temp );
  3472.  
  3473. var currency = "Gold";
  3474. if ( $( "#buyedMoneyId > option:selected" ).text() != "Gold" ) {
  3475. currency = $( "#buyedMoneyId > option:selected" ).text().substr( 0, 3 );
  3476. }
  3477. $( "#offeredRate2" ).text( currency );
  3478.  
  3479. currency = "Gold";
  3480. if ( $( "#offeredMoneyId > option:selected" ).text() != "Gold" ) {
  3481. currency = $( "#offeredMoneyId > option:selected" ).text().substr( 0, 3 );
  3482. }
  3483. $( "#offeredCurrency" ).text( currency );
  3484. $( "#offeredRate1" ).text( currency );
  3485. });
  3486.  
  3487. // Redesign in your offers
  3488. var block2 = $( "<div class='monetaryMarketTitleBlock'></div>" );
  3489. block2.insertBefore( currentOffersTitle );
  3490. block2.append( yourOffersTitle );
  3491. block2.append( currentOffers );
  3492. block2.append( yourOffers );
  3493.  
  3494. $( "#swap1" ).addClass( "swapYourOffers" );
  3495. $( "#swap1" ).bind( "click", function() {
  3496. var temp = $( "#buy" ).val();
  3497. $( "#buy" ).val( $( "#sell" ).val() );
  3498. $( "#sell" ).val( temp );
  3499.  
  3500. if( $( "#offeredMoneyId" ).val() == "0" ) {
  3501. var cc = $( ".monetaryMarketCurrencyBlock" ).find( ".currencySelector[id='"+ $( "#buyedMoneyId" ).val() +"']" );
  3502. var v = "0.0";
  3503. if( cc.length != 0 ) { v = cc.children( "b" ).text(); }
  3504. $( "#value" ).val( v );
  3505.  
  3506. } else $( "#value" ).val( "0.0" );
  3507. });
  3508.  
  3509. $( "#buyedMoneyId" ).next().remove();
  3510. $( "#value" ).addClass( "priceInputMM" );
  3511. $( "#exchangeRatio" ).addClass( "priceInputMM" );
  3512.  
  3513. var blockCurrency = $( "<div class='monetaryMarketCurrencyBlock'></div>" );
  3514. blockCurrency.addClass( "testDivblue" );
  3515. //blockCurrency.append( block1 );
  3516.  
  3517. block1.append( blockCurrency );
  3518.  
  3519. // Add currency block
  3520. var plate = $( "#hiddenMoney" ).parent();
  3521. plate.find( ".currencyFlag" ).each( function() {
  3522.  
  3523. var id = IDByImageCountry( $(this).attr( "src" ) );
  3524. var itemCC = $( "<div class='currencySelector'></div>" );
  3525. itemCC.attr( "id", id );
  3526. if( id == 0 ) { selectedCurrency = itemCC; }
  3527. itemCC.append( "<img src='"+ $(this).attr( "src" ) +"' />" );
  3528. itemCC.append( "<b>"+ $(this).next().text() +" </b>" );
  3529. var currencyName = $( "#buy" ).children( "option[value='"+ id +"']" ).text().split( " " );
  3530. itemCC.append( currencyName[0] );
  3531. blockCurrency.append( itemCC );
  3532.  
  3533. itemCC.bind( "click", function() {
  3534.  
  3535. var idC = $(this).attr( "id" );
  3536. if( (idC != "0") && (idC != selectedCurrency.attr( "id" )) ) {
  3537. if( selectedCurrency ) { selectedCurrency.removeClass( "selectedCurrency" ); }
  3538.  
  3539. if( $( "#buy" ).val() == "0" ) {
  3540. $( "#sell" ).val( idC );
  3541. } else $( "#buy" ).val( idC );
  3542.  
  3543. if( $( "#offeredMoneyId" ).val() == "0" ) {
  3544. $( "#buyedMoneyId" ).val( idC );
  3545. } else $( "#offeredMoneyId" ).val( idC );
  3546.  
  3547. $(this).addClass( "selectedCurrency" );
  3548. selectedCurrency = $(this);
  3549.  
  3550. var currency = "Gold";
  3551. if ( $( "#buyedMoneyId > option:selected" ).text() != "Gold" ) {
  3552. currency = $( "#buyedMoneyId > option:selected" ).text().substr( 0, 3 );
  3553. }
  3554. $( "#offeredRate2" ).text( currency );
  3555.  
  3556. currency = "Gold";
  3557. if ( $( "#offeredMoneyId > option:selected" ).text() != "Gold" ) {
  3558. currency = $( "#offeredMoneyId > option:selected" ).text().substr( 0, 3 );
  3559. }
  3560. $( "#offeredCurrency" ).text( currency );
  3561. $( "#offeredRate1" ).text( currency );
  3562.  
  3563. if( $( "#buyedMoneyId" ).val() == "0" ) {
  3564. $( "#value" ).val( $(this).children( "b" ).text() );
  3565.  
  3566. } else $( "#value" ).val( "0.0" );
  3567. }
  3568. });
  3569. });
  3570.  
  3571. // Add fast buttons
  3572. var idDest = "#value";
  3573. var firstFastButton = true;
  3574. var btn1 = $( "<input class='priceFastButton' type='button' value='1' />" );
  3575. btn1.bind( "click", function() {
  3576. if( firstFastButton ) {
  3577. $( idDest ).attr( "value", "1" );
  3578. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 1 );
  3579. firstFastButton = false;
  3580. });
  3581.  
  3582. var btn5 = $( "<input class='priceFastButton' type='button' value='5' />" );
  3583. btn5.bind( "click", function() {
  3584. if( firstFastButton ) {
  3585. $( idDest ).attr( "value", "5" );
  3586. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 5 );
  3587. firstFastButton = false;
  3588. });
  3589.  
  3590. var btn10 = $( "<input class='priceFastButton' type='button' value='10' />" );
  3591. btn10.bind( "click", function() {
  3592. if( firstFastButton ) {
  3593. $( idDest ).attr( "value", "10" );
  3594. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 10 );
  3595. firstFastButton = false;
  3596. });
  3597.  
  3598. var btn50 = $( "<input class='priceFastButton' type='button' value='50' />" );
  3599. btn50.bind( "click", function() {
  3600. if( firstFastButton ) {
  3601. $( idDest ).attr( "value", "50" );
  3602. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 50 );
  3603. firstFastButton = false;
  3604. });
  3605.  
  3606. var btn100 = $( "<input class='priceFastButton' type='button' value='100' />" );
  3607. btn100.bind( "click", function() {
  3608. if( firstFastButton ) {
  3609. $( idDest ).attr( "value", "100" );
  3610. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 100 );
  3611. firstFastButton = false;
  3612. });
  3613.  
  3614. var btn500 = $( "<input class='priceFastButton' type='button' value='500' />" );
  3615. btn500.bind( "click", function() {
  3616. if( firstFastButton ) {
  3617. $( idDest ).attr( "value", "500" );
  3618. } else $( idDest ).attr( "value", parseInt( $( idDest ).attr( "value" ) ) + 500 );
  3619. firstFastButton = false;
  3620. });
  3621.  
  3622. var pos = $( "#offeredRate2" ).next();
  3623. btn1.insertBefore( pos );
  3624. btn5.insertBefore( pos );
  3625. btn10.insertBefore( pos );
  3626. btn50.insertBefore( pos );
  3627. btn100.insertBefore( pos );
  3628. btn500.insertBefore( pos );
  3629.  
  3630. // Add confirm option
  3631. var postButton = $( "<input class='postOfferButton' type='button' value='Post new offer' />" );
  3632. var pos = $( "#monetaryOfferPost" ).children( "center" ).children( "input" );
  3633. postButton.insertBefore( pos );
  3634. pos.hide();
  3635. postButton.click( "click", function() {
  3636. var value = parseFloat( $( "#value" ).val() );
  3637. var change = parseFloat( $( "#exchangeRatio" ).val() );
  3638. var res = confirm( "Sell "+ value +" "+ $( "#offeredCurrency" ).text() +" for "+ (value*change) +" "+ $( "#offeredRate2" ).text() );
  3639. if( res ) { $( "#monetaryOfferPost" ).submit(); }
  3640. });
  3641. }
  3642.  
  3643.  
  3644. // Change monetary market product table
  3645. function changeMonetaryMarketTable() {
  3646.  
  3647. $( ".dataTable" ).find( "input[type='text']" ).addClass( "inputTextTable" );
  3648. var submit = $( ".dataTable" ).find( "input[type='submit']" ).addClass( "inputSubmitTable" );
  3649.  
  3650. // Add buy all button
  3651. var buyAll = $( "<input class='buyAllSubmit' type='submit' value='All' />" );
  3652. buyAll.bind( "click", function() {
  3653. var v = $(this).parent().parent().prev().prev().prev().text();
  3654. $(this).parent().children( "input[type='text']" ).val( v );
  3655. return( false );
  3656. });
  3657. //buyAll.insertBefore( submit );
  3658.  
  3659. // Resize table
  3660. $( ".dataTable" ).addClass( "dataTableMod" );
  3661.  
  3662. // Redesign table
  3663. // Headers
  3664. $( ".dataTable > tbody > tr:first-child > td" ).addClass( "dataTableHeaders" );
  3665. }
  3666.  
  3667.  
  3668. // Add extra links in the shares menu
  3669. function addSharesExtraLinks() {
  3670.  
  3671. var firstRow = true;
  3672. var firstPlate = $( ".testDivwhite" ).first();
  3673. firstPlate.css({ "width" : "570px" });
  3674. firstPlate.children( ".dataTable" ).css({ "width" : "550px" });
  3675. firstPlate.children( ".dataTable" ).find( "tr" ).each( function() {
  3676.  
  3677. var td = $( "<td></td>" );
  3678. td.insertAfter( $(this).children().first() );
  3679. if( firstRow ) {
  3680. firstRow = false;
  3681. td.append( "Fast links" );
  3682.  
  3683. } else {
  3684. var idStock = $(this).children().first().find( "a" ).attr( "href" );
  3685. var imgStock = $(this).children().first().find( "img" ).eq(1);
  3686. var linkStock = $( "<a href='"+ idStock +"'></a>" ).insertBefore( imgStock );
  3687. linkStock.append( imgStock );
  3688. var split = idStock.split( "?id=" );
  3689. if( split.length > 1 ) { idStock = split[1]; }
  3690.  
  3691. td.append( "<a style='display:block' href='"+ getCurrentServer() + URLStockMM + idStock +"'>MM offers</a>" );
  3692. td.append( "<a style='display:block' href='"+ getCurrentServer() + URLStockProducts + idStock +"'>Product offers</a>" );
  3693. td.append( "<a style='display:block' href='"+ getCurrentServer() + URLStockDonateMoney + idStock +"'>Donate money</a>" );
  3694. td.append( "<a style='display:block' href='"+ getCurrentServer() + URLStockDonateCompany + idStock +"'>Donate company</a>" );
  3695. td.append( "<a style='display:block' href='"+ getCurrentServer() + URLStockLogs + idStock +"&importance=TRIVIAL '>Logs</a>" );
  3696. }
  3697. });
  3698. }
  3699.  
  3700.  
  3701. // Change stock main div
  3702. function changeStockMainMenu() {
  3703.  
  3704. var listBlue = $( "#contentRow" ).children( "td" ).eq(1).find( ".testDivblue" );
  3705. $( "#contentRow" ).children( "td" ).eq(1).children().eq(1).remove();
  3706.  
  3707. var mainStockInfo = listBlue.eq(0);
  3708. mainStockInfo.children( "br" ).remove();
  3709. mainStockInfo.children( "p" ).remove();
  3710.  
  3711. var rightBlock = mainStockInfo.find( "td" ).eq(1);
  3712. rightBlock.css({ "width" : "350px" });
  3713. rightBlock.children().eq(2).css({ "width" : "70px" });
  3714. rightBlock.children().eq(3).css({ "width" : "275px" });
  3715.  
  3716. var linkWiki = $( "<div class='linkWiki'></div>" );
  3717. var linkImg = $( "<a href='"+ mainStockInfo.children( "a" ).attr( "href" ) +"'></a>" );
  3718. linkWiki.append( linkImg.append( mainStockInfo.children( "img" ) ) );
  3719. linkWiki.append( mainStockInfo.children( "a" ) );
  3720. mainStockInfo.append( linkWiki );
  3721. }
  3722.  
  3723.  
  3724. // Change stock floating divs in the main menu
  3725. function changeStockFloatingDivs() {
  3726.  
  3727. var listWhite = $( "#contentRow" ).children().eq(2).find( ".testDivwhite" );
  3728. var listBlue = $( "#contentRow" ).children().eq(2).find( ".testDivblue" );
  3729.  
  3730. var companyStatute = listWhite.eq(0);
  3731. companyStatute.addClass( "divShareMenu divShareMenuHide" );
  3732. companyStatute.bind( "click", function() {
  3733. if( $(this).hasClass( "divShareMenuHide" ) ) {
  3734. $(this).removeClass( "divShareMenuHide" );
  3735.  
  3736. } else $(this).addClass( "divShareMenuHide" );
  3737. });
  3738.  
  3739. var stockPrice = listWhite.eq(1);
  3740. stockPrice.addClass( "divShareMenu divShareMenuHide" );
  3741. stockPrice.bind( "click", function() {
  3742. if( $(this).hasClass( "divShareMenuHide" ) ) {
  3743. $(this).removeClass( "divShareMenuHide" );
  3744.  
  3745. } else $(this).addClass( "divShareMenuHide" );
  3746. });
  3747.  
  3748. var acts = listBlue.eq(1);
  3749. acts.addClass( "divShareMenu divShareMenuMediumHide" );
  3750. acts.bind( "click", function() {
  3751. if( $(this).hasClass( "divShareMenuMediumHide" ) ) {
  3752. $(this).removeClass( "divShareMenuMediumHide" );
  3753.  
  3754. } else $(this).addClass( "divShareMenuMediumHide" );
  3755. });
  3756.  
  3757. var staff = listBlue.eq(2);
  3758. staff.addClass( "divShareMenu divShareMenuMediumHide" );
  3759. staff.bind( "click", function() {
  3760. if( $(this).hasClass( "divShareMenuMediumHide" ) ) {
  3761. $(this).removeClass( "divShareMenuMediumHide" );
  3762.  
  3763. } else $(this).addClass( "divShareMenuMediumHide" );
  3764. });
  3765.  
  3766. var companies = listBlue.eq(3);
  3767. var shouts = listBlue.eq(4);
  3768. shouts.insertBefore( companies );
  3769. companies.insertBefore( stockPrice );
  3770.  
  3771. var sharesMarket = listWhite.eq(2);
  3772. stockPrice.insertBefore( sharesMarket );
  3773. $( "<br/>" ).insertAfter( stockPrice );
  3774.  
  3775. companies.addClass( "divShareMenuFixed" ).css({ "width" : "340px" });
  3776. shouts.addClass( "divShareMenuFixed" );
  3777.  
  3778. sharesMarket.addClass( "divShareMenuFixed" );
  3779. listWhite.eq(3).addClass( "divShareMenuFixed" );
  3780. }
  3781.  
  3782.  
  3783. // Change product selection in a stock company
  3784. function changeStockProductSelection() {
  3785.  
  3786. var pos = $( ".testDivwhite" );
  3787. var select = $( "#resourceInput" );
  3788. if( select.length == 0 ) {
  3789.  
  3790. pos.addClass( "storageUnselectStock" );
  3791. pos.children( "br" ).remove();
  3792.  
  3793. } else {
  3794. var dest = $( "#resourceInput" ).next().next();
  3795.  
  3796. // Remove all childrens and add help text
  3797. pos.children().remove();
  3798. pos.addClass( "storageSelectStock" );
  3799. pos.append( "One click to select <b>ONE item</b>. Double click to select <b>ALL items</b>.<br/>" );
  3800.  
  3801. var divBlue = $( "#countryInput" ).parent().parent();
  3802. divBlue.addClass( "formSelectStock" );
  3803. divBlue.find( "b" ).eq(0).css({ "display" : "inline" });
  3804. divBlue.find( "b" ).eq(1).css({ "display" : "inline" });
  3805. divBlue.insertAfter( pos );
  3806.  
  3807. $( "#countryInput" ).addClass( "customSelectList" );
  3808. select.addClass( "customSelectList" );
  3809.  
  3810. orderSelect( select );
  3811. changeSelect( select, pos, dest, "#aaaaaa" );
  3812.  
  3813. firstFastButton = true;
  3814. dest.val( "1" );
  3815. dest.addClass( "quantityMyOffers" );
  3816. $( "#priceInput" ).val( "1.0" );
  3817. $( "#priceInput" ).addClass( "priceInputMyOffers" );
  3818.  
  3819. var btn10 = $( "<input class='fastBtn FastButtonLeft' type='button' value='10' />" );
  3820. btn10.bind( "click", function() {
  3821. if( firstFastButton ) {
  3822. dest.attr( "value", "10" );
  3823. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 10 );
  3824. firstFastButton = false;
  3825. });
  3826.  
  3827. var btn50 = $( "<input class='fastBtn FastButtonLeft' type='button' value='50' />" );
  3828. btn50.bind( "click", function() {
  3829. if( firstFastButton ) {
  3830. dest.attr( "value", "50" );
  3831. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 50 );
  3832. firstFastButton = false;
  3833. });
  3834.  
  3835. var btn100 = $( "<input class='fastBtn FastButtonRight' type='button' value='100' />" );
  3836. btn100.bind( "click", function() {
  3837. if( firstFastButton ) {
  3838. dest.attr( "value", "100" );
  3839. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 100 );
  3840. firstFastButton = false;
  3841. });
  3842.  
  3843. var btn1000 = $( "<input class='fastBtn FastButtonRight' type='button' value='1K' />" );
  3844. btn1000.bind( "click", function() {
  3845. if( firstFastButton ) {
  3846. dest.attr( "value", "1000" );
  3847. } else dest.attr( "value", parseInt( dest.attr( "value" ) ) + 1000 );
  3848. firstFastButton = false;
  3849. });
  3850.  
  3851. btn10.insertBefore( dest );
  3852. btn50.insertBefore( dest );
  3853. btn1000.insertAfter( dest );
  3854. btn100.insertAfter( dest );
  3855.  
  3856. $( ".storage" ).bind( "click", function() { setTimeout( mySendPreviewRequest, 500 ); });
  3857. $( "#countryInput" ).unbind( "change" );
  3858. $( "#countryInput" ).bind( "change", function() { mySendPreviewRequest(); });
  3859. $( "#resourceInput" ).unbind( "change" );
  3860. $( "#resourceInput" ).bind( "change", function() { mySendPreviewRequest(); });
  3861. $( "#priceInput" ).unbind( "change" );
  3862. $( "#priceInput" ).bind( "change", function() { mySendPreviewRequest(); });
  3863. $( "#priceInput" ).bind( "keydown", function() { setTimeout( mySendPreviewRequest, 1000 ); });
  3864. }
  3865. }
  3866.  
  3867.  
  3868. // Change travel menu
  3869. function changeTravelMenu() {
  3870.  
  3871. var minTicket = 0;
  3872. var vecItems = [];
  3873. var plate = $( "#citizenTravelForm" ).parent().addClass( "citizenTravelFormMod" );
  3874. $( "#citizenTravelForm" ).children( "input" ).addClass( "citizenTravelFormInput" );
  3875.  
  3876. $( "#citizenshipSelect" ).addClass( "customSelectList" );
  3877. $( "#regionId" ).addClass( "customSelectList" );
  3878. $( "<br/>" ).insertBefore( $( "#regionId" ).parent() );
  3879.  
  3880. var marginBlock = $( "<div class='centerBlockTravel'></div>" );
  3881. var block = $( "<table class='blockTravel testDivwhite'></table>" );
  3882. marginBlock.append( block );
  3883.  
  3884. var selectedTicket = null;
  3885. $( "#ticketQuality" ).find( "option" ).each( function() {
  3886.  
  3887. var q = $(this).attr( "value" );
  3888. var ticket = $( "<td class='ticketTravel' indexselect='"+ q +"'></td>" );
  3889. ticket.append( "<img src='"+ IMGTICKET +"' class='imageTicket' />" );
  3890. ticket.append( "<div class='healthTicket'>- "+ (40 - ((q-1) * 10)) +"</div>" );
  3891. ticket.append( "<img src='"+ IMGQUALITY + $(this).attr( "value" ) +".png' class='imageQuality' />" );
  3892. block.append( ticket );
  3893.  
  3894. // Find number of items
  3895. var n = 0;
  3896. $( "#userMenu" ).find( ".storageMini" ).each( function() {
  3897. var prod = $(this).find( "img[src='"+ IMGTICKET +"']" );
  3898. //alert("megy")
  3899. if( prod.length == 1 ) {
  3900. if( q == prod.next().attr( "src" ).replace( IMGQUALITY, "" ).replace( IMGEXTENSION, "" ) ) {
  3901. n = parseInt( $(this).text());
  3902. //alert($(this).text());
  3903.  
  3904.  
  3905. }
  3906. }
  3907. });
  3908.  
  3909. ticket.append( "<div class='numberItems'>"+ n +"</div>" );
  3910.  
  3911. if( n > 0 ) {
  3912. if( minTicket == 0 ) { minTicket = q; }
  3913.  
  3914. ticket.bind( "mouseover", function() {
  3915. if( selectedTicket.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).addClass( "ticketHover" ); }
  3916. });
  3917.  
  3918. ticket.bind( "mouseout", function() {
  3919. if( selectedTicket.attr( "indexselect" ) != $(this).attr( "indexselect" ) ) { $(this).removeClass( "ticketHover" ); }
  3920. });
  3921.  
  3922. ticket.bind( "click", function() {
  3923. if( selectedTicket ) { selectedTicket.removeClass( "ticketSelected" ); }
  3924. selectedTicket = $(this);
  3925. $(this).addClass( "ticketSelected" );
  3926. $( "#ticketQuality option" )[ $(this).attr( "indexselect" )-1 ].selected = true;
  3927. });
  3928.  
  3929. } else ticket.addClass( "disabledTicket" );
  3930. vecItems.push( ticket );
  3931. });
  3932.  
  3933. // Default min ticket
  3934. if( minTicket > 0 ) { vecItems[ minTicket-1].click() }
  3935.  
  3936. $( "<br/>" ).insertAfter( $( "#ticketQuality" ).parent() );
  3937. $( "#ticketQuality" ).prev().remove();
  3938. $( "#ticketQuality" ).prev().remove();
  3939. $( "#ticketQuality" ).css({ "display" : "none" });
  3940. block.insertBefore( $( "#ticketQuality" ) );
  3941.  
  3942. // Check GET vars
  3943. var urlVars = getUrlVars();
  3944. if( (urlVars[ "idc" ] != undefined) && (urlVars[ "idr" ] != undefined) ) {
  3945.  
  3946. $( "#citizenshipSelect" ).val( urlVars[ "idc" ] );
  3947. $.ajax({
  3948. url: "countryRegions.html",
  3949. context: document.body,
  3950. type: "POST",
  3951. data: { countryId : urlVars[ "idc" ] },
  3952. success: function( data ) {
  3953. $( "#regionId" ).find( "option" ).remove();
  3954. var json = jQuery.parseJSON( data );
  3955. for( var i=0; i<json.length; i++ ) {
  3956. $( "#regionId" ).append( "<option value='"+ json[i][0] +"'>"+ json[i][1] +"</option>" );
  3957. }
  3958. $( "#regionId" ).val( urlVars[ "idr" ] );
  3959. }
  3960. });
  3961. }
  3962. }
  3963.  
  3964.  
  3965. // Redesign equipment
  3966. function redesignEquipment() {
  3967.  
  3968. var block = $( ".equipmentName" ).parent();
  3969. var remove = "<div class='removeItem'>CLICK TO REMOVE</div>"
  3970. var formHelmet = $( ".equipmentBox" ).last().next();
  3971. var formVision = formHelmet.next();
  3972. var formArmor = formVision.next();
  3973. var formWeapon = formArmor.next();
  3974. var formOffhand = formWeapon.next();
  3975.  
  3976. // Rellocate equipment interaction
  3977. var helmet = $( ".equipmentName" ).eq(0).addClass( "helmetTitle" );
  3978. $( ".equipmentBox" ).eq(0).append( helmet );
  3979. $( ".equipmentBack" ).eq(0).children().first().append( remove );
  3980. $( ".equipmentBack" ).eq(0).bind( "click", function() { if( formHelmet.is( "form" ) ) { formHelmet.children( "input" ).last().click(); } });
  3981.  
  3982. var vision = $( ".equipmentName" ).eq(1).addClass( "visionTitle" );
  3983. $( ".equipmentBox" ).eq(1).append( vision );
  3984. $( ".equipmentBack" ).eq(1).children().first().append( remove );
  3985. $( ".equipmentBack" ).eq(1).bind( "click", function() { if( formVision.is( "form" ) ) { formVision.children( "input" ).last().click(); } });
  3986.  
  3987. var armor = $( ".equipmentName" ).eq(2).addClass( "armorTitle" );
  3988. $( ".equipmentBox" ).eq(2).append( armor );
  3989. $( ".equipmentBack" ).eq(2).children().first().append( remove );
  3990. $( ".equipmentBack" ).eq(2).bind( "click", function() { if( formArmor.is( "form" ) ) { formArmor.children( "input" ).last().click(); } });
  3991.  
  3992. var weapon = $( ".equipmentName" ).eq(3).addClass( "weaponTitle" );
  3993. $( ".equipmentBox" ).eq(3).append( weapon );
  3994. $( ".equipmentBack" ).eq(3).children().first().append( remove );
  3995. $( ".equipmentBack" ).eq(3).bind( "click", function() { if( formWeapon.is( "form" ) ) { formWeapon.children( "input" ).last().click(); } });
  3996.  
  3997. var offhand = $( ".equipmentName" ).eq(4).addClass( "offhandTitle" );
  3998. $( ".equipmentBox" ).eq(4).append( offhand );
  3999. $( ".equipmentBack" ).eq(4).children().first().append( remove );
  4000. $( ".equipmentBack" ).eq(4).bind( "click", function() { if( formOffhand.is( "form" ) ) { formOffhand.children( "input" ).last().click(); } });
  4001.  
  4002. // Change remove mode
  4003. $( ".equipmentBack" ).each( function() {
  4004. if( !$(this).hasClass( "q0" ) ) {
  4005. $(this).css({ "cursor" : "pointer" });
  4006.  
  4007. $(this).bind( "mouseover", function() { $(this).find( ".removeItem" ).css({ "visibility" : "visible" }); });
  4008. $(this).bind( "mouseout", function() { $(this).find( ".removeItem" ).css({ "visibility" : "hidden" }); });
  4009. }
  4010. });
  4011.  
  4012. block.hide();
  4013. }
  4014.  
  4015.  
  4016. // Calculate equipment damage
  4017. function calculateEquipmentDamage() {
  4018. $( "#profileEquipment" ).parent().css({ "margin-left" : "11px", "height" : "220px" });
  4019.  
  4020. // Get values
  4021. var n = 1000;
  4022. var hitList = [ 0, 50, 100, 155 ];
  4023. var damageSplit = $( "#hitHelp" ).text().split( "/" );
  4024. var minDamage = parseInt( damageSplit[0].replace( ",", "" ) );
  4025. var maxDamage = parseInt( damageSplit[1].replace( ",", "" ) );
  4026. var critical = parseFloat( $( "#criticalHelp" ).text().replace( "%", "" ) );
  4027. var miss = parseFloat( $( "#missHelp" ).text().replace( "%", "" ) );
  4028. var avoid = parseFloat( $( "#avoidHelp" ).text().replace( "%", "" ) );
  4029.  
  4030. // Save all data to use it in the battle page
  4031. setValue( "playerMinDamage", minDamage );
  4032. setValue( "playerMaxDamage", maxDamage );
  4033. setValue( "playerCritical", critical );
  4034. setValue( "playerMiss", miss );
  4035. setValue( "playerAvoid", avoid );
  4036.  
  4037. // Default bonus settins, MU and location active
  4038. var muBonus = 1;
  4039. var locBonus = 1.2;
  4040. var sdBonus = 1;
  4041. var hBonus = 1;
  4042.  
  4043. // Create block
  4044. var block = $( "<div id='blockDamage' class='testDivwhite'></div>" );
  4045. block.append( "<div class='titleDamage'>Average damage in "+ n +" simulations</div>" );
  4046. block.insertBefore( $( "#profileEquipment" ).parent() );
  4047.  
  4048. // Damage block
  4049. var configDamage = $( "<div class='configDamage'></div>" );
  4050.  
  4051. // MU bonus
  4052. var MUCheck = $( "<input id='MUCheck' type='checkBox' class='itemBonus' title='No MU data' />" );
  4053. configDamage.append( "<div class='labelLeftConfig'>MU</div>" );
  4054. configDamage.append( MUCheck );
  4055. // Stupid idea to disable MU tooltip
  4056. if( getValue( "MURank" ) ) {
  4057. muBonus = parseInt( getValue( "MURank" ) );
  4058.  
  4059. } else configDamage.append( "<div style='width:15px; height:15px; position:absolute; margin:-22px 0px 0px 25px;'></div>" );
  4060.  
  4061. // Location bonus
  4062. var locationCheck = $( "<input id='locCheck' type='checkBox' class='itemBonus' checked='checked' />" );
  4063. configDamage.append( "<div class='labelRightConfig'>LOCATION</div>" );
  4064. configDamage.append( locationCheck );
  4065. configDamage.append( "<br/>" );
  4066.  
  4067. // SD bonus
  4068. var sdCheck = $( "<select id='sdCheck' class='itemBonus customSelectList'></select>" );
  4069. for( var i=0; i<=5; i++ ) {
  4070. sdCheck.append( "<option value='"+ 5*i +"'>Q"+ i +"</option>" );
  4071. }
  4072. configDamage.append( "<div class='labelLeftConfig'>SD</div>" );
  4073. configDamage.append( sdCheck );
  4074.  
  4075. // Hospital bonus
  4076. var hCheck= $( "<select id='hCheck' class='itemBonus customSelectList'></select>" );
  4077. for( var i=0; i<=5; i++ ) {
  4078. hCheck.append( "<option value='"+ 5*i +"'>Q"+ i +"</option>" );
  4079. }
  4080. configDamage.append( "<div class='labelRightConfig'>HOSPITAL</div>" );
  4081. configDamage.append( hCheck );
  4082.  
  4083. // Calculate button
  4084. var calculate = $( "<input class='calculateBonus' type='button' value='Calculate' />" );
  4085. configDamage.append( calculate );
  4086.  
  4087. // Fill table
  4088. var tableDamage = $( "<table class='tableDamage'></table>" );
  4089. for( var i=0; i<=5; i++ ) {
  4090. var tr = $( "<tr></tr>" );
  4091. for( var j=0; j<hitList.length; j++ ) {
  4092. if( hitList[j] == 0 ) {
  4093. if( i != 0 ) {
  4094. tr.append( "<td class='tableQuality'>Q"+ i +"</td>" );
  4095. } else tr.append( "<td></td>" );
  4096.  
  4097. } else if( i == 0 ) {
  4098. if( hitList[j] != 0 ) {
  4099. var input = $( "<input class='hitList' type='text' value='"+ hitList[j] +"' maxlength='3' />" );
  4100. var td = $( "<td class='tableHits' title='You can edit this number!'></td>" );
  4101. td.tooltip({ tooltipClass: "tooltipHitDamage", position: { my: "center bottom", at: "center top" } });
  4102. td.append( input );
  4103. tr.append( td );
  4104. } else tr.append( "<td></td>" );
  4105.  
  4106. } else tr.append( "<td class='dataDamage'>0</td>" );
  4107. }
  4108. tableDamage.append( tr );
  4109. }
  4110.  
  4111. block.append( tableDamage );
  4112. block.append( configDamage );
  4113.  
  4114. if( getValue( "MURank" ) ) {
  4115. muBonus = 1 + (parseInt( getValue( "MURank" ) ) / 100);
  4116. $( "#MUCheck" ).attr( "checked", "checked" );
  4117. } else {
  4118. $( "#MUCheck" ).prev().css({ "text-decoration" : "line-through" });
  4119. $( "#MUCheck" ).attr( "disabled", "disabled" );
  4120. }
  4121.  
  4122. updateDamageTable( minDamage, maxDamage, muBonus, locBonus, sdBonus, hBonus, critical, miss, avoid, hitList, n );
  4123.  
  4124. configDamage.find( ".itemBonus" ).bind( "change", function() {
  4125. updateDamageTable( minDamage, maxDamage, muBonus, locBonus, sdBonus, hBonus, critical, miss, avoid, hitList, n );
  4126. });
  4127. configDamage.find( ".calculateBonus" ).bind( "click", function() {
  4128. updateDamageTable( minDamage, maxDamage, muBonus, locBonus, sdBonus, hBonus, critical, miss, avoid, hitList, n );
  4129. });
  4130. }
  4131.  
  4132.  
  4133. // Calculate iteration damage
  4134. function calculateHitsDamage( min, max, mu, loc, sd, h, cr, miss, avoid, weapon, hits, n ) {
  4135. hits = hits * h; // Hospital hits
  4136.  
  4137. // We do it for Berserks
  4138. var nBK = parseInt( hits / 5 );
  4139. var mod = hits % 5;
  4140. var averageDamage = 0;
  4141. var bonus = 100 + (weapon * 20);
  4142. var maxDamage = 0;
  4143. var minDamage = Number.MAX_VALUE;
  4144. for( var j=0; j<n; j++ ) {
  4145. var totalDmg = 0;
  4146.  
  4147. for( var i=0; i<nBK; i++ ) {
  4148. var damage = (min + parseInt((max-min)/2))*5 * bonus/100;
  4149. totalDmg += damage * mu * loc * sd;
  4150.  
  4151. // Critical
  4152. if( Math.random()*100 < cr ) { totalDmg += damage; }
  4153.  
  4154. // Miss
  4155. if( Math.random()*100 < miss ) { totalDmg -= damage; }
  4156.  
  4157. // Avoid
  4158. if( Math.random()*100 < avoid ) { i--; }
  4159. }
  4160.  
  4161. if( mod != 0 ) { totalDmg += (mod * totalDmg / (nBK*5)); }
  4162. maxDamage = maxDamage > totalDmg ? maxDamage : totalDmg;
  4163. minDamage = minDamage < totalDmg ? minDamage : totalDmg;
  4164. averageDamage += totalDmg;
  4165. }
  4166.  
  4167. return( [ parseInt( averageDamage/n ), pointNumber( parseInt( minDamage ) ), pointNumber( parseInt( maxDamage ) ) ] );
  4168. }
  4169.  
  4170.  
  4171. // Update table data
  4172. function updateDamageTable( minDamage, maxDamage, muBonus, locBonus, sdBonus, hBonus, critical, miss, avoid, hitList, n ) {
  4173. locBonus = $( "#locCheck" ).attr( "checked" ) ? 1.2 : 1;
  4174. sdBonus = 1 + parseInt( $( "#sdCheck" ).val() )/100;
  4175. hBonus = 1 + parseInt( $( "#hCheck" ).val() )/100;
  4176. if( $( "#MUCheck" ).attr( "checked" ) ) {
  4177. if( getValue( "MURank" ) ) { muBonus = 1 + (parseInt( getValue( "MURank" ) ) / 100); }
  4178. } else muBonus = 1;
  4179.  
  4180. var table = $( ".tableDamage" );
  4181. for( var i=1; i<=5; i++ ) {
  4182. var tr = table.find( "tr" ).eq(i);
  4183. for( var j=1; j<hitList.length; j++ ) {
  4184. var hits = parseInt( table.find( ".hitList" ).eq(j-1).val() );
  4185. var dmg = calculateHitsDamage( minDamage, maxDamage, muBonus, locBonus, sdBonus, hBonus, critical, miss, avoid, i, hits, n );
  4186. tr.children( "td" ).eq( j ).text( pointNumber( dmg[0] ) );
  4187. tr.children( "td" ).eq( j ).tooltip({ tooltipClass: "tooltipHitDamage", position: { my: "center bottom", at: "center top" } });
  4188. tr.children( "td" ).eq( j ).attr( "title", "<b>"+ dmg[1] +" - "+ dmg[2] +"</b>" );
  4189. }
  4190. }
  4191. }
  4192.  
  4193.  
  4194. // Add update salaries in the company menĂş
  4195. function addCompanyButtons() {
  4196.  
  4197. // Get the country ID
  4198. var countryId = IDByImageCountry( $( "a[href^='region.html']" ).prev().attr( "src" ) );
  4199. var workerList = $( ".workerListDiv" );
  4200. var offerList = $( ".offerListDiv" );
  4201.  
  4202. var updateSalaries = $( "<input class='updateSalariesButton' type='button' value='Update salaries'/>" );
  4203. updateSalaries.insertBefore( workerList.children().first() );
  4204. updateSalaries.bind( "click", function() {
  4205.  
  4206. // Clean previous results
  4207. workerList.find( ".redText" ).remove();
  4208. workerList.find( ".greenText" ).remove();
  4209.  
  4210. var i=0;
  4211. var checkedSkills = [];
  4212. workerList.find( ".tableRow" ).each( function() {
  4213.  
  4214. // First get the skill number
  4215. var tdList = $(this).find( "td" );
  4216. var skill = parseInt( tdList.eq(1).text() );
  4217. if( checkedSkills.indexOf( skill ) == -1 ) {
  4218. checkedSkills.push( skill );
  4219.  
  4220. setTimeout( function() {
  4221. $.ajax({
  4222. url: getCurrentServer() + URLJobMarket + "?countryId="+ countryId +"&minimalSkill="+ skill,
  4223. success: function( data ) {
  4224.  
  4225. var trList = $( data ).find( ".dataTable" ).find( "tr" );
  4226. // We take the first row
  4227. var salary = trList.eq(1).find( "td" ).eq(4).children( "b" ).text();
  4228. salary = parseFloat( salary );
  4229.  
  4230. workerList.find( ".workerSkill" + skill ).each( function() {
  4231. var classColor;
  4232. var percent;
  4233. var workerSalary = parseFloat( $(this).children( ".salary" ).children( "b" ).text() );
  4234. if( workerSalary < salary ) {
  4235. classColor = "redText";
  4236. percent = "-" + parseInt((salary / workerSalary -1) * 10000) / 100;
  4237.  
  4238. } else {
  4239. classColor = "greenText";
  4240. percent = "+" + parseInt((workerSalary / salary - 1) * 10000) / 100;
  4241. }
  4242. $(this).append( "<b class='"+ classColor +"'>"+ salary +" ("+ percent +"%)</b>" );
  4243. });
  4244. }
  4245. });
  4246. }, 500*i );
  4247. i++;
  4248. }
  4249. });
  4250. });
  4251.  
  4252. var updateJobs = $( "<input class='updateJobsButton' type='button' value='Update jobs'/>" );
  4253. updateJobs.insertBefore( workerList.children().first() );
  4254. updateJobs.bind( "click", function() {
  4255.  
  4256. var id = getUrlVars()[ "id" ];
  4257. $.ajax({
  4258. url: getCurrentServer() + URLCompanyDetails + id,
  4259. success: function( data ) {
  4260. $( data ).find( "#productivityTable" ).find( "tr" ).each( function() {
  4261. var td = $(this).children( "td" ).last();
  4262. var player = $(this).find( "a" );
  4263. if( player ) {
  4264. var place = workerList.find( "a[href='"+ player.attr( "href" ) +"']" ).parent();
  4265. if( td.children( "div" ).length == 2 ) {
  4266. place.append( "<br/>" );
  4267. place.append( "<b>"+ td.children().eq(1).text().replace( "(", "" ).replace( ")", "" ) +"</b>" );
  4268. place.addClass( "greenBackgroundCompany" );
  4269.  
  4270. } else place.addClass( "redBackgroundCompany" );
  4271. }
  4272. });
  4273. }
  4274. });
  4275. });
  4276. }
  4277.  
  4278.  
  4279. // Improve company interface
  4280. function companyImprovements() {
  4281. if( $( "#minimalSkill option" ).length == 14 ) {
  4282. $( "#minimalSkill" ).append( "<option value='15'>15</option>" );
  4283. $( "#minimalSkill" ).append( "<option value='16'>16</option>" );
  4284. }
  4285.  
  4286. var listBlue = $( "#container" ).find( ".testDivblue" );
  4287. var mainMenu = listBlue.eq(2).find( "table" ).eq(1);
  4288. var rowRemove = mainMenu.find( "tr" ).first().children( "td" ).first();
  4289. rowRemove.next().children().css({ "max-width" : "100%" });
  4290. rowRemove.remove();
  4291.  
  4292. // Get the country ID
  4293. var countryId = IDByImageCountry( $( "a[href^='region.html']" ).prev().attr( "src" ) );
  4294.  
  4295. // Rellocate some items
  4296. if( listBlue.length == 6 ) {
  4297.  
  4298. var workerList = listBlue.eq(5);
  4299. var offerList = listBlue.eq(4);
  4300. var uglyBox = listBlue.eq(3);
  4301. var createJob = uglyBox.children().first();
  4302. uglyBox.children().first().remove();
  4303.  
  4304. createJob.insertBefore( uglyBox );
  4305. $( "<br/>" ).insertBefore( uglyBox );
  4306. var divBlock = $( "<div style='display:inline-block; width:100%'></div>" )
  4307. divBlock.insertBefore( uglyBox );
  4308. divBlock.append( offerList );
  4309. divBlock.append( workerList );
  4310. uglyBox.css({ "margin-top" : "15px" });
  4311.  
  4312. createJob.removeClass( "testDivwhite" );
  4313. createJob.addClass( "testDivblue" ).css({ "width" : "680px" });
  4314. createJob.children( "p" ).remove();
  4315.  
  4316. var selectedSkill = null;
  4317. $( "#minimalSkill option" ).each( function() {
  4318.  
  4319. var skill = $( "<div class='skillSelector'>"+ $(this).val() +"</div>" );
  4320. skill.insertBefore( "#minimalSkill" );
  4321.  
  4322. skill.bind( "click", function() {
  4323. if( selectedSkill ) { selectedSkill.removeClass( "skillSelectorSelected" ); }
  4324.  
  4325. selectedSkill = $(this);
  4326. selectedSkill.addClass( "skillSelectorSelected" );
  4327. $( "#minimalSkill" ).val( selectedSkill.text() );
  4328.  
  4329. var link = getCurrentServer() + URLJobMarket + "?countryId="+ countryId +"&minimalSkill="+ $(this).text();
  4330. $( ".companyLinkOffers" ).attr( "href", link );
  4331. });
  4332. });
  4333. $( "#minimalSkill" ).hide();
  4334.  
  4335. var firstLine = $( "#minimalSkill" ).parent();
  4336. firstLine.attr( "colspan", "4" );
  4337. createJob.find( "table" ).css({ "width" : "100%" });
  4338.  
  4339. var tr = $( "<tr></tr>" );
  4340. tr.append( firstLine.next().css({ "width" : "33%" }) );
  4341. var td = $( "<td style='width:18%;'></td>" );
  4342. var link = $( "<a class='companyLinkOffers' href='' target='_blank'>View skill offers</a>" );
  4343. tr.append( td.append( link ) );
  4344. tr.append( firstLine.next().css({ "width" : "17%" }) );
  4345. tr.append( firstLine.next().css({ "width" : "26%" }) );
  4346. firstLine.parent().parent().append( tr );
  4347.  
  4348. $( ".skillSelector" ).first().click();
  4349. $( "#price" ).addClass( "priceInputCompany" );
  4350. $( "#price" ).bind( "focus", function() { $(this).select(); });
  4351. $( "#quantity" ).addClass( "quantityMyOffers" );
  4352. $( "#quantity" ).bind( "focus", function() { $(this).select(); });
  4353.  
  4354. } else {
  4355. var workerList = listBlue.eq(4);
  4356. var offerList = listBlue.eq(3);
  4357. }
  4358.  
  4359. workerList.addClass( "workerListDiv" );
  4360. offerList.addClass( "offerListDiv" );
  4361.  
  4362. // Remove useless space
  4363. mainMenu.children( "p" ).remove();
  4364.  
  4365. // Edit image size
  4366. mainMenu.find( ".productLabelRight" ).css({ "height" : "auto", "width" : "40px" });
  4367. //resizeProductImage( mainMenu.find( ".product" ) );
  4368.  
  4369. // Add extra links to check salaries
  4370. workerList.find( ".tableRow" ).each( function() {
  4371. var tdList = $(this).find( "td" );
  4372. // First get the skill number
  4373. var skill = parseInt( tdList.eq(1).text() );
  4374. var viewLink = $( "<a href='"+ getCurrentServer() + URLJobMarket + "?countryId="+ countryId +"&minimalSkill="+ skill +"'>View</a>" );
  4375. tdList.eq(1).append( "<br/>" );
  4376. tdList.eq(1).append( viewLink );
  4377. tdList.eq(2).addClass( "workerSkill" + skill );
  4378. });
  4379.  
  4380. $( "input[name=newSalary]" ).addClass( "priceInputCompany" );
  4381. $( "input[name=newSalary]" ).bind( "focus", function() { $(this).select(); });
  4382. $( "input[name=salary]" ).addClass( "priceInputCompany" );
  4383. $( "input[name=salary]" ).bind( "focus", function() { $(this).select(); });
  4384. }
  4385.  
  4386.  
  4387. // Improve company work results
  4388. function companyWorkResults() {
  4389.  
  4390. // Redesign first block
  4391. var listBlue = $( "#container" ).find( ".testDivblue" );
  4392. var mainMenu = listBlue.eq(2).find( "table" ).eq(1);
  4393. mainMenu.find( ".productLabelRight" ).css({ "height" : "auto", "width" : "40px" });
  4394. resizeProductImage( mainMenu.find( ".product" ) );
  4395.  
  4396. var rowRemove = mainMenu.find( "tr" ).first().children( "td" ).first();
  4397. rowRemove.next().children().css({ "max-width" : "100%" });
  4398. rowRemove.remove();
  4399.  
  4400. // Add button to get salary
  4401. var divConfig = $( "<div class='testDivblue' style='width:500px;'></div>" );
  4402. var buttonUpdate = $( "<input class='companyGetSalary' type='button' value='Get salary'/>" );
  4403. divConfig.append( buttonUpdate );
  4404. divConfig.insertAfter( listBlue.eq(2).next() );
  4405.  
  4406. var mainBlock = $( "#container" ).find( ".testDivwhite" );
  4407. var idCompany = getUrlVars()[ "id" ];
  4408. buttonUpdate.bind( "click", function() {
  4409.  
  4410. // Remove previous col
  4411. mainBlock.find( ".playerSalary" ).remove();
  4412.  
  4413. // Add new col
  4414. var index = 0;
  4415. mainBlock.find( "tr" ).each( function() {
  4416. var td = $( "<td class='playerSalary'></td>" );
  4417. if( index == 0 ) { td.append( "Salary" ); }
  4418. $(this).append( td );
  4419. index++;
  4420. });
  4421.  
  4422. mainBlock.css({ "width" : "730px" });
  4423. mainBlock.find( "table" ).css({ "width" : "720px" });
  4424.  
  4425. $.ajax({
  4426. url: getCurrentServer() + URLCompany + idCompany,
  4427. success: function( data ) {
  4428. var blue = $(data).find( "#container" ).find( ".testDivblue" );
  4429. if( blue.length == 6 ) {
  4430. var playerList = blue.eq(5).find( ".tableRow" );
  4431. } else var playerList = blue.eq(4).find( ".tableRow" );
  4432. checkPlayersSalary( playerList, mainBlock );
  4433. }
  4434. });
  4435. });
  4436. }
  4437.  
  4438.  
  4439. // Check player salary
  4440. function checkPlayersSalary( playerList, block ) {
  4441.  
  4442. playerList.each( function() {
  4443.  
  4444. var player = $(this).find( "a[href^='profile.html']" );
  4445. var content = $(this).find( ".salary" );
  4446. content.removeClass( "salary" );
  4447. if( content.children().length == 3 ) { content.children().last().remove(); }
  4448.  
  4449. block.find( "tr" ).each( function() {
  4450. if( $(this).find( "a[href='"+ player.attr( "href" ) +"']" ).length == 1 ) {
  4451. $(this).find( ".playerSalary" ).append( content );
  4452. $( "<br/>" ).insertBefore( content.children( "b" ) );
  4453. var currency = content.contents().eq(4).text();
  4454.  
  4455. var salary = parseFloat( content.children( "b" ).text() );
  4456. $(this).find( "td" ).each( function() {
  4457. if( $(this).children().length == 2 ) {
  4458. $(this).children().eq(1).css({ "color" : "#009900" });
  4459.  
  4460. var numItems = $(this).children( "div" ).eq(1).text();
  4461. numItems = numItems.replace( "(", "" ).replace( ")", "" );
  4462. numItems = parseFloat( numItems );
  4463.  
  4464. var finalPrice = $( "<div class='finalPrice'>"+ (parseInt( (salary / numItems)*1000 ) / 1000) +"</div>" );
  4465. finalPrice.append( "<br/>" );
  4466. finalPrice.append( "<span> "+ currency +"</span>" );
  4467. $(this).append( finalPrice );
  4468. }
  4469. });
  4470. }
  4471. });
  4472. });
  4473. }
  4474.  
  4475.  
  4476. // Replace job skill selector
  4477. function jobMarketSkills() {
  4478. if( $( "#minimalSkill option" ).length == 14 ) {
  4479. $( "#minimalSkill" ).append( "<option value='15'>15</option>" );
  4480. $( "#minimalSkill" ).append( "<option value='16'>16</option>" );
  4481. }
  4482.  
  4483. $( "#countryId" ).addClass( "customSelectList" );
  4484. $( "#jobMarketForm" ).parent().css({ "width" : "550px" });
  4485. $( "#jobMarketForm" ).contents().eq(4).remove();
  4486.  
  4487. var selectedSkill = null;
  4488. $( "#minimalSkill option" ).each( function() {
  4489.  
  4490. var skill = $( "<div class='skillSelector'>"+ $(this).val() +"</div>" )
  4491. skill.insertBefore( "#minimalSkill" );
  4492.  
  4493. skill.bind( "click", function() {
  4494. if( selectedSkill ) { selectedSkill.removeClass( "skillSelectorSelected" ); }
  4495.  
  4496. selectedSkill = $(this);
  4497. selectedSkill.addClass( "skillSelectorSelected" );
  4498. $( "#minimalSkill" ).val( selectedSkill.text() );
  4499.  
  4500. var link = getCurrentServer() + URLJobMarket + "?countryId="+ countryId +"&minimalSkill="+ $(this).text();
  4501. $( ".companyLinkOffers" ).attr( "href", link );
  4502. });
  4503.  
  4504. if( $(this).val() == $( "#minimalSkill" ).val() ) { skill.click(); }
  4505. });
  4506.  
  4507. $( "#minimalSkill" ).hide();
  4508. $( "#jobMarketForm" ).children( "input" ).insertAfter( "#countryId" );
  4509. $( "#jobMarketForm" ).children( "input" ).addClass( "showButton" );
  4510. $( "#jobMarketForm" ).parent().children( ":lt(2)" ).remove();
  4511. }
  4512.  
  4513.  
  4514. // Improve battle list interface
  4515. function changeBattleList() {
  4516.  
  4517. $( "#countryId" ).addClass( "customSelectList" );
  4518. //$( "#sorting" ).prev().remove();
  4519. //$( "#sorting" ).prev().remove();
  4520.  
  4521. var selectedOption = null;
  4522. $( "#sorting option" ).each( function() {
  4523.  
  4524. var sort = $( "<div class='sortTypeSelector'>"+ $(this).text().replace( "Sorting ", "" ) +"</div>" );
  4525. sort.attr( "type", $(this).val() );
  4526. sort.insertBefore( "#sorting" );
  4527.  
  4528. sort.bind( "click", function() {
  4529. if( selectedOption ) { selectedOption.removeClass( "sortTypeSelectorSelected" ); }
  4530.  
  4531. selectedOption = $(this);
  4532. selectedOption.addClass( "sortTypeSelectorSelected" );
  4533. $( "#sorting" ).val( selectedOption.attr( "type" ) );
  4534. });
  4535.  
  4536. if( $(this).val() == $( "#sorting" ).val() ) { sort.click(); }
  4537. });
  4538.  
  4539. $( "#sorting" ).hide();
  4540. $( "#battlesViewForm" ).parent().children().last().remove();
  4541. var updateTime = $( "<input class='updateTimeListBattle' type='button' value='Update time'/>" );
  4542. updateTime.insertAfter( $( "#battlesViewForm" ).parent() );
  4543. updateTime.bind( "click", function() {
  4544.  
  4545. var i=0;
  4546. $( "#battlesTable" ).find( "tr" ).each( function() {
  4547. var related = $(this);
  4548. var href = $(this).find( "a[href^='battle.html?id=']" );
  4549. if( href.length == 1 ) {
  4550. setTimeout( function() {
  4551. $.ajax({
  4552. url: href.attr( "href" ),
  4553. success: function( data ) {
  4554. related.find( ".roundTimeRemain" ).remove();
  4555.  
  4556. var startPos = data.indexOf( "http://e-sim.home.pl/testura/js/jquery.countdown.min.js", 0 );
  4557. var hourIni = data.indexOf( "getHours() +", startPos ) + (new String("getHours() +")).length;
  4558. var hourEnd = data.indexOf( ");", hourIni );
  4559. var hour = parseInt( data.substr( hourIni, hourEnd-hourIni ) );
  4560.  
  4561. var minIni = data.indexOf( "getMinutes() +", startPos ) + (new String("getMinutes() +")).length;
  4562. var minEnd = data.indexOf( ");", minIni );
  4563. var min = parseInt( data.substr( minIni, minEnd-minIni ) );
  4564.  
  4565. var secIni = data.indexOf( "getSeconds() +", startPos ) + (new String("getSeconds() +")).length;
  4566. var secEnd = data.indexOf( ");", secIni );
  4567. var sec = parseInt( data.substr( secIni, secEnd-secIni ) );
  4568.  
  4569. var lastTD = related.children().last();
  4570. lastTD.removeClass( "roundClean" );
  4571. lastTD.removeClass( "roundLastHour" );
  4572. lastTD.removeClass( "roundLastHalfHour" );
  4573. if( hour == 0 ) {
  4574. if( min < 30 ) {
  4575. lastTD.addClass( "roundLastHalfHour" );
  4576.  
  4577. } else lastTD.addClass( "roundLastHour" );
  4578.  
  4579. } else lastTD.addClass( "roundClean" );
  4580.  
  4581. hour = "0" + hour;
  4582. min = (min < 10) ? "0"+min : min;
  4583. sec = (sec < 10) ? "0"+sec : sec;
  4584. related.children().last().append( "<div class='roundTimeRemain'>"+ hour +":"+ min +":"+ sec +"</div>" );
  4585. }
  4586. });
  4587. }, 500*i );
  4588.  
  4589. i++;
  4590. }
  4591. });
  4592. });
  4593. }
  4594.  
  4595.  
  4596. // getValue as GM_getValue of GM functions
  4597. function getValue( name ) {
  4598. name = getPlayerID() + getCurrentServer() + name;
  4599. var value = (cachedSettings === null ? localStorage.getItem(name) : cachedSettings[name]);
  4600. if( !value || (value === undefined) ) { return( null ); }
  4601. return( value );
  4602. }
  4603.  
  4604.  
  4605. // setValue as GM_setValue of GM functions
  4606. function setValue( name, value ) {
  4607. name = getPlayerID() + getCurrentServer() + name;
  4608. if (cachedSettings === null) {
  4609. localStorage.setItem( name, value );
  4610. } else {
  4611. cachedSettings[name] = value;
  4612. chrome.extension.sendRequest( { name: name, value: value } );
  4613. }
  4614. }
  4615.  
  4616.  
  4617. // Convert location to travel
  4618. /*function setTravelLocation( id, travelRW, travelLeft, travelRight ) {
  4619.  
  4620. var currentDate = (new Date).getDate();
  4621. var lastDate = GetValue( "LastUpdateAPIRegion" );
  4622. var needUpdate = (lastDate != currentDate);
  4623.  
  4624. var value = GetValue( "APIRegionJSON" );
  4625. if( value && !needUpdate ) {
  4626.  
  4627. var json = $.parseJSON( value );
  4628. for( var i=0; i<json.length; i++ ) {
  4629. if( json[i].id == id ) {
  4630. travelRW.children( "a" ).attr( "href", "http://"+URLTravel+"?idc="+json[i].homeCountry+"&idr="+json[i].id );
  4631. travelRW.children( "a" ).append( "<br/><b>"+ json[i].name +"</b>" );
  4632.  
  4633. travelLeft.children( "a" ).attr( "href", "http://"+URLTravel+"?idc="+json[i].homeCountry+"&idr="+json[i].id );
  4634. travelLeft.children( "a" ).append( "<br/><b>"+ json[i].name +"</b>" );
  4635.  
  4636. // Check neighbours
  4637. for( var j=0; j<json.length; j++ ) {
  4638. if( json[i].neighbours.indexOf( json[j].id ) ) {
  4639.  
  4640. }
  4641. }
  4642. }
  4643. }
  4644.  
  4645. } else {
  4646.  
  4647. $.ajax({
  4648. url: getCurrentServer() + URLAPIRegion,
  4649. success: function( data ) {
  4650. SetValue( "APIRegionJSON", data );
  4651. SetValue( "LastUpdateAPIRegion", currentDate );
  4652.  
  4653. var json = $.parseJSON( data );
  4654. for( var i=0; i<json.length; i++ ) {
  4655. if( json[i].id == id ) {
  4656. travelRW.children( "a" ).attr( "href", "http://"+URLTravel+"?idc="+json[i].homeCountry+"&idr="+json[i].id );
  4657. travelRW.children( "a" ).append( "<br/><b>"+ json[i].name +"</b>" );
  4658.  
  4659. travelLeft.children( "a" ).attr( "href", "http://"+URLTravel+"?idc="+json[i].homeCountry+"&idr="+json[i].id );
  4660. travelLeft.children( "a" ).append( "<br/><b>"+ json[i].name +"</b>" );
  4661.  
  4662. // Check neighbours
  4663.  
  4664. }
  4665. }
  4666. }
  4667. });
  4668. }
  4669. }*/
  4670.  
  4671.  
  4672. // Return Region list from API
  4673. function getRegionAPI( region, current ) {
  4674.  
  4675. var currentDate = (new Date).getDate();
  4676. var lastDate = getValue( "LastUpdateAPIRegion" );
  4677. var needUpdate = (lastDate != currentDate);
  4678.  
  4679. var value = getValue( "APIRegionJSON" );
  4680. if( value && !needUpdate ) {
  4681.  
  4682. var json = $.parseJSON( value );
  4683. for( var i=0; i<json.length; i++ ) {
  4684. if( json[i].id == region ) { return( json[i].neighbours ); }
  4685. }
  4686.  
  4687. } else {
  4688.  
  4689. $.ajax({
  4690. url: getCurrentServer() + URLAPIRegion,
  4691. success: function( data ) {
  4692. setValue( "APIRegionJSON", data );
  4693. setValue( "LastUpdateAPIRegion", currentDate );
  4694.  
  4695. var numberLocation = 0;
  4696. var neighbours = [];
  4697. var json = $.parseJSON( data );
  4698. for( var i=0; i<json.length; i++ ) {
  4699. if( json[i].id == region ) {
  4700. neighbours = json[i].neighbours;
  4701. numberLocation = (neighbours.indexOf( parseInt(current) ) != -1) ? 20 : 0;
  4702. }
  4703. }
  4704.  
  4705. /*var location = $( "#rightBlockBonus" ).find( ".locationBonus" );
  4706. location.text( numberLocation + "%" );
  4707. var color = (numberLocation == 0) ? "#e67171" : "#bed7ba";
  4708. location.css({ "background-color" : color });
  4709.  
  4710. location = $( "#leftBlockBonus" ).find( ".locationBonus" );
  4711. location.text( numberLocation + "%" );
  4712. location.css({ "background-color" : color });*/
  4713. }
  4714. });
  4715. }
  4716.  
  4717. return [];
  4718. }
  4719.  
  4720.  
  4721. // Get URL Vars
  4722. function getUrlVars() {
  4723. var vars = {};
  4724. var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function( m, key, value ) { vars[key] = value; });
  4725. return vars;
  4726. }
  4727. };
  4728.  
  4729. function createResourceVar( name ) {
  4730. var input = document.createElement( "input" );
  4731. input.type = "hidden";
  4732. input.id = name;
  4733. input.value = GM_getResourceURL( name );
  4734. document.body.appendChild( input );
  4735. }
  4736.  
  4737. // Only execute on same frame (iframes with advertisments)
  4738. if( window.top == window.self ) {
  4739.  
  4740. // Inject our CSS
  4741. GM_addStyle( GM_getResourceText( "myCustomCSS" ) );
  4742.  
  4743. // Resources
  4744. createResourceVar( "myQualityStar" );
  4745.  
  4746. var URLBattle = "e-sim.org/battle.html?id=";
  4747. var localUrl = new String( window.location );
  4748. if( localUrl.indexOf( URLBattle, 0 ) >= 0 ) {
  4749.  
  4750. createResourceVar( "AoEweaponQ0" );
  4751. createResourceVar( "AoEweaponQ1" );
  4752. createResourceVar( "AoEweaponQ2" );
  4753. createResourceVar( "AoEweaponQ3" );
  4754. createResourceVar( "AoEweaponQ4" );
  4755. createResourceVar( "AoEweaponQ5" );
  4756. createResourceVar( "AoEweaponQ0Big" );
  4757. createResourceVar( "AoEweaponQ1Big" );
  4758. createResourceVar( "AoEweaponQ2Big" );
  4759. createResourceVar( "AoEweaponQ3Big" );
  4760. createResourceVar( "AoEweaponQ4Big" );
  4761. createResourceVar( "AoEweaponQ5Big" );
  4762.  
  4763. createResourceVar( "SWweaponQ0" );
  4764. createResourceVar( "SWweaponQ1" );
  4765. createResourceVar( "SWweaponQ2" );
  4766. createResourceVar( "SWweaponQ3" );
  4767. createResourceVar( "SWweaponQ4" );
  4768. createResourceVar( "SWweaponQ5" );
  4769. createResourceVar( "SWweaponQ0Big" );
  4770. createResourceVar( "SWweaponQ1Big" );
  4771. createResourceVar( "SWweaponQ2Big" );
  4772. createResourceVar( "SWweaponQ3Big" );
  4773. createResourceVar( "SWweaponQ4Big" );
  4774. createResourceVar( "SWweaponQ5Big" );
  4775.  
  4776. createResourceVar( "PokweaponQ0" );
  4777. createResourceVar( "PokweaponQ1" );
  4778. createResourceVar( "PokweaponQ2" );
  4779. createResourceVar( "PokweaponQ3" );
  4780. createResourceVar( "PokweaponQ4" );
  4781. createResourceVar( "PokweaponQ5" );
  4782. createResourceVar( "PokweaponQ0Big" );
  4783. createResourceVar( "PokweaponQ1Big" );
  4784. createResourceVar( "PokweaponQ2Big" );
  4785. createResourceVar( "PokweaponQ3Big" );
  4786. createResourceVar( "PokweaponQ4Big" );
  4787. createResourceVar( "PokweaponQ5Big" );
  4788. }
  4789.  
  4790. // Inject our main script
  4791. var script = document.createElement( "script" );
  4792. script.type = "text/javascript";
  4793. script.textContent = '(' + main.toString() + ')();';
  4794. document.body.appendChild( script );
  4795. }
Advertisement
Add Comment
Please, Sign In to add comment