MH Timers+

Handy script to keep track of the various MH location timers

当前为 2019-08-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name MH Timers+
  3. // @author Warden Slayer - Warden Slayer#2302
  4. // @namespace https://greasyfork.org/en/users/227259-wardenslayer
  5. // @version 1.2.1
  6. // @description Handy script to keep track of the various MH location timers
  7. // @include https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js
  8. // @include http://www.mousehuntgame.com/*
  9. // @include https://www.mousehuntgame.com/*
  10. // @grant GM_setClipboard
  11. // ==/UserScript==
  12. $(document).ready(function() {
  13. console.log("MH Timers+");
  14. buildTimerBox();
  15. buildControlPanels();
  16. startTimers();
  17. });
  18.  
  19. function buildTimerBox() {
  20. if ($(".timerBox").length > 0) return;
  21. var container = $("#mousehuntContainer");
  22. var timerBox = document.createElement("div");
  23. timerBox.classList.add("timerBox");
  24. $(timerBox).css({
  25. 'background-image': "url('https://www.toptal.com/designers/subtlepatterns/patterns/interlaced.png')"
  26. });
  27. $(timerBox).css({
  28. 'height': 112 + "px",
  29. 'padding': 2 + "px"
  30. });
  31. let forbiddenGrove = buildForbiddenGrove();
  32. let balacksCove = buildBalacksCove();
  33. let seasonalGarden = buildSeasonalGarden();
  34. let toxicSpill = buildToxicSpill();
  35. timerBox.appendChild(forbiddenGrove)
  36. timerBox.appendChild(balacksCove)
  37. timerBox.appendChild(seasonalGarden)
  38. timerBox.appendChild(toxicSpill)
  39. $(forbiddenGrove).css({
  40. 'float': 'left'
  41. })
  42. $(balacksCove).css({
  43. 'float': 'left',
  44. 'marginLeft': 1 + "px"
  45. })
  46. $(seasonalGarden).css({
  47. 'float': 'left',
  48. 'marginLeft': 1 + "px"
  49. })
  50. $(toxicSpill).css({
  51. 'float': 'left',
  52. 'marginLeft': 1 + "px"
  53. })
  54. //LAST
  55. container.prepend(timerBox)
  56. }
  57.  
  58. function buildControlPanels() {
  59. var timerBox = $(".timerBox");
  60. //FG
  61. var forbiddenGroveControlPanel = document.createElement("div");
  62. forbiddenGroveControlPanel.classList.add("forbiddenGroveControlPanel");
  63. var forbiddenGroveButton = document.createElement("button");
  64. forbiddenGroveButton.id = "forbiddenGroveButton";
  65. forbiddenGroveButton.innerText = "Travel";
  66. forbiddenGroveButton.addEventListener("click", travelToGrove);
  67. forbiddenGroveControlPanel.appendChild(forbiddenGroveButton);
  68. $(forbiddenGroveControlPanel).css({
  69. 'float': 'left',
  70. 'width': '21.5%'
  71. })
  72. $(forbiddenGroveButton).css({
  73. 'width': '75px',
  74. 'float': 'left',
  75. 'marginRight': 5 + "px"
  76. })
  77. var forbiddenGroveCb = document.createElement('input');
  78. forbiddenGroveCb.type = "checkbox";
  79. forbiddenGroveCb.name = "forbiddenGroveCb";
  80. forbiddenGroveCb.value = "value";
  81. forbiddenGroveCb.id = "forbiddenGroveCb";
  82. if (localStorage.getItem('RemindGrove') == "Y") {
  83. forbiddenGroveCb.checked = "Yes";
  84. } else {
  85. forbiddenGroveCb.checked = "";
  86. }
  87. var forbiddenGroveCbLabel = document.createElement('label')
  88. forbiddenGroveCbLabel.htmlFor = "forbiddenGroveCbLabel";
  89. forbiddenGroveCbLabel.appendChild(document.createTextNode('Remind '));
  90. forbiddenGroveControlPanel.appendChild(forbiddenGroveCbLabel);
  91. forbiddenGroveControlPanel.appendChild(forbiddenGroveCb)
  92. $(forbiddenGroveCbLabel).css({
  93. 'float': 'left',
  94. 'fontSize': "14px",
  95. 'width': '45px',
  96. })
  97. $(forbiddenGroveCb).css({
  98. 'float': 'left',
  99. 'width': '20px'
  100. })
  101. timerBox.append(forbiddenGroveControlPanel);
  102. //BC
  103. var balacksCoveControlPanel = document.createElement("div");
  104. balacksCoveControlPanel.classList.add("balacksCoveControlPanel");
  105. var balacksCoveButton = document.createElement("button");
  106. balacksCoveButton.id = "balacksCoveButton";
  107. balacksCoveButton.innerText = "Travel";
  108. balacksCoveButton.addEventListener("click", travelToCove);
  109. balacksCoveControlPanel.appendChild(balacksCoveButton);
  110. $(balacksCoveControlPanel).css({
  111. 'float': 'left',
  112. 'width': '25%',
  113. 'marginLeft': 5 + "px"
  114. })
  115. $(balacksCoveButton).css({
  116. 'width': '75px',
  117. 'float': 'left',
  118. 'marginRight': 5 + "px"
  119. })
  120. var balacksCoveCb = document.createElement('input');
  121. balacksCoveCb.type = "checkbox";
  122. balacksCoveCb.name = "balacksCoveCb";
  123. balacksCoveCb.value = "value";
  124. balacksCoveCb.id = "balacksCoveCb";
  125. if (localStorage.getItem('RemindCove') == "Y") {
  126. balacksCoveCb.checked = "Yes";
  127. } else {
  128. balacksCoveCb.checked = "";
  129. }
  130. var balacksCoveCbLabel = document.createElement('label')
  131. balacksCoveCbLabel.htmlFor = "balacksCoveCbLabel";
  132. balacksCoveCbLabel.appendChild(document.createTextNode('Remind '));
  133. balacksCoveControlPanel.appendChild(balacksCoveCbLabel);
  134. balacksCoveControlPanel.appendChild(balacksCoveCb)
  135. $(balacksCoveCbLabel).css({
  136. 'float': 'left',
  137. 'fontSize': "14px",
  138. 'width': '45px',
  139. })
  140. $(balacksCoveCb).css({
  141. 'float': 'left',
  142. 'width': '20px'
  143. })
  144. timerBox.append(balacksCoveControlPanel);
  145. //SG
  146. var seasonalGardenControlPanel = document.createElement("div");
  147. seasonalGardenControlPanel.classList.add("seasonalGardenControlPanel");
  148. var seasonalGardenButton = document.createElement("button");
  149. seasonalGardenButton.id = "seasonalGardenButton";
  150. seasonalGardenButton.innerText = "Travel";
  151. seasonalGardenButton.addEventListener("click", travelToGarden);
  152. seasonalGardenControlPanel.appendChild(seasonalGardenButton);
  153. $(seasonalGardenControlPanel).css({
  154. 'float': 'left',
  155. 'width': '24%',
  156. 'marginLeft': 5 + "px"
  157. })
  158. $(seasonalGardenButton).css({
  159. 'width': '75px',
  160. 'float': 'left',
  161. 'marginRight': 5 + "px"
  162. })
  163. var seasonalGardenCb = document.createElement('input');
  164. seasonalGardenCb.type = "checkbox";
  165. seasonalGardenCb.name = "seasonalGardenCb";
  166. seasonalGardenCb.value = "value";
  167. seasonalGardenCb.id = "seasonalGardenCb";
  168. if (localStorage.getItem('RemindGarden') == "Y") {
  169. seasonalGardenCb.checked = "Yes";
  170. } else {
  171. seasonalGardenCb.checked = "";
  172. }
  173. var seasonalGardenCbLabel = document.createElement('label')
  174. seasonalGardenCbLabel.htmlFor = "seasonalGardenCbLabel";
  175. seasonalGardenCbLabel.appendChild(document.createTextNode('Remind '));
  176. seasonalGardenControlPanel.appendChild(seasonalGardenCbLabel);
  177. seasonalGardenControlPanel.appendChild(seasonalGardenCb)
  178. $(seasonalGardenCbLabel).css({
  179. 'float': 'left',
  180. 'fontSize': "14px",
  181. 'width': '45px',
  182. })
  183. $(seasonalGardenCb).css({
  184. 'float': 'left',
  185. 'width': '20px'
  186. })
  187. timerBox.append(seasonalGardenControlPanel);
  188. //TS
  189. var toxicSpillControlPanel = document.createElement("div");
  190. toxicSpillControlPanel.classList.add("toxicSpillControlPanel");
  191. var toxicSpillButton = document.createElement("button");
  192. toxicSpillButton.id = "toxicSpillButton";
  193. toxicSpillButton.innerText = "Travel";
  194. toxicSpillButton.addEventListener("click", travelToSpill);
  195. toxicSpillControlPanel.appendChild(toxicSpillButton);
  196. $(toxicSpillControlPanel).css({
  197. 'float': 'left',
  198. 'width': '24%',
  199. 'marginLeft': 10 + "px"
  200. })
  201. $(toxicSpillButton).css({
  202. 'width': '75px',
  203. 'float': 'left',
  204. 'marginRight': 5 + "px"
  205. })
  206. var toxicSpillCb = document.createElement('input');
  207. toxicSpillCb.type = "checkbox";
  208. toxicSpillCb.name = "toxicSpillCb";
  209. toxicSpillCb.value = "value";
  210. toxicSpillCb.id = "toxicSpillCb";
  211. if (localStorage.getItem('RemindSpill') == "Y") {
  212. toxicSpillCb.checked = "Yes";
  213. } else {
  214. toxicSpillCb.checked = "";
  215. }
  216. var toxicSpillCbLabel = document.createElement('label')
  217. toxicSpillCbLabel.htmlFor = "toxicSpillCbLabel";
  218. toxicSpillCbLabel.appendChild(document.createTextNode('Remind '));
  219. toxicSpillControlPanel.appendChild(toxicSpillCbLabel);
  220. toxicSpillControlPanel.appendChild(toxicSpillCb)
  221. $(toxicSpillCbLabel).css({
  222. 'float': 'left',
  223. 'fontSize': "14px",
  224. 'width': '45px',
  225. })
  226. $(toxicSpillCb).css({
  227. 'float': 'left',
  228. 'width': '20px'
  229. })
  230. timerBox.append(toxicSpillControlPanel);
  231. }
  232.  
  233. function startTimers() {
  234. localStorage.setItem("mainTimer", 0);
  235. runTimers();
  236. }
  237.  
  238. function runTimers() {
  239. updateText();
  240. var myTimer = setInterval(updateText, 300000);
  241. }
  242.  
  243. function updateText() {
  244. if ($(".forbiddenGrove").length > 0) updateForbiddenGroveTimer();
  245. if ($(".balacksCove").length > 0) updateBalacksCoveTimer();
  246. if ($(".seasonalGarden").length > 0) updateSeasonalGardenTimer();
  247. if ($(".toxicSpill").length > 0) updateToxicSpillTimer();
  248. }
  249. //===================================== Forbidden Grove ======================================
  250. function buildForbiddenGrove() {
  251. if ($(".forbiddenGrove").length > 0) return;
  252. var timerBox = $(".timerBox");
  253. var forbiddenGrove = document.createElement("div");
  254. forbiddenGrove.classList.add("forbiddenGrove");
  255. $(forbiddenGrove).css({
  256. 'border': '1px solid black',
  257. 'width': '21%',
  258. 'height': '75%',
  259. 'padding': 2 + "px"
  260. });
  261. //Header
  262. var forbiddenGroveHeader = document.createElement("div");
  263. forbiddenGroveHeader.classList.add("forbiddenGroveHeader");
  264. var forbiddenGroveHeaderLabel = document.createElement("div");
  265. forbiddenGroveHeaderLabel.classList.add("forbiddenGroveHeaderLabel");
  266. var forbiddenGroveHeaderLabelText = document.createTextNode("Forbidden Grove is:");
  267. forbiddenGroveHeaderLabel.appendChild(forbiddenGroveHeaderLabelText);
  268. var forbiddenGroveHeaderValue = document.createElement("div");
  269. forbiddenGroveHeaderValue.classList.add("forbiddenGroveHeaderValue");
  270. var forbiddenGroveHeaderValueText = document.createTextNode("Open");
  271. forbiddenGroveHeaderValue.appendChild(forbiddenGroveHeaderValueText);
  272. $(forbiddenGroveHeaderLabel).css({
  273. 'float': 'left',
  274. 'font-weight': 700,
  275. "marginRight": "5px"
  276. })
  277. $(forbiddenGroveHeaderValue).css({
  278. "marginLeft": "100px"
  279. });
  280. forbiddenGroveHeader.appendChild(forbiddenGroveHeaderLabel);
  281. forbiddenGroveHeader.appendChild(forbiddenGroveHeaderValue);
  282. //Close
  283. var forbiddenGroveCloses = document.createElement("div");
  284. forbiddenGroveCloses.classList.add("forbiddenGroveCloses");
  285. var forbiddenGroveClosesLabel = document.createElement("div");
  286. forbiddenGroveClosesLabel.classList.add("forbiddenGroveClosesLabel");
  287. var forbiddenGroveClosesLabelText = document.createTextNode("Closes in:");
  288. forbiddenGroveClosesLabel.appendChild(forbiddenGroveClosesLabelText);
  289. var forbiddenGroveClosesValue = document.createElement("div");
  290. forbiddenGroveClosesValue.classList.add("forbiddenGroveClosesValue");
  291. var forbiddenGroveClosesValueText = document.createTextNode("?");
  292. forbiddenGroveClosesValue.appendChild(forbiddenGroveClosesValueText);
  293. $(forbiddenGroveClosesLabel).css({
  294. 'float': 'left',
  295. 'font-weight': 700,
  296. "marginRight": "5px"
  297. })
  298. $(forbiddenGroveClosesValue).css("marginLeft", "50px");
  299. forbiddenGroveCloses.appendChild(forbiddenGroveClosesLabel);
  300. forbiddenGroveCloses.appendChild(forbiddenGroveClosesValue);
  301. //Open
  302. var forbiddenGroveOpens = document.createElement("div");
  303. forbiddenGroveOpens.classList.add("forbiddenGroveOpens");
  304. var forbiddenGroveOpensLabel = document.createElement("div");
  305. forbiddenGroveOpensLabel.classList.add("forbiddenGroveOpensLabel");
  306. var forbiddenGroveOpensLabelText = document.createTextNode("Opens in:");
  307. forbiddenGroveOpensLabel.appendChild(forbiddenGroveOpensLabelText);
  308. var forbiddenGroveOpensValue = document.createElement("div");
  309. forbiddenGroveOpensValue.classList.add("forbiddenGroveOpensValue");
  310. var forbiddenGroveOpensValueText = document.createTextNode("??");
  311. forbiddenGroveOpensValue.appendChild(forbiddenGroveOpensValueText);
  312. $(forbiddenGroveOpensLabel).css({
  313. 'float': 'left',
  314. 'font-weight': 700,
  315. "marginRight": "5px"
  316. })
  317. $(forbiddenGroveOpensValue).css("marginLeft", "50px");
  318. forbiddenGroveOpens.appendChild(forbiddenGroveOpensLabel);
  319. forbiddenGroveOpens.appendChild(forbiddenGroveOpensValue);
  320.  
  321. //Append
  322. forbiddenGrove.appendChild(forbiddenGroveHeader);
  323. forbiddenGrove.appendChild(forbiddenGroveCloses);
  324. forbiddenGrove.appendChild(forbiddenGroveOpens);
  325. return forbiddenGrove;
  326. }
  327.  
  328. function updateForbiddenGroveTimer() {
  329. if ($(".forbiddenGrove").length < 1) return;
  330. var forbiddenGrove = $(".forbiddenGrove");
  331. var firstGroveOpen = 1285704000;
  332. var now = todayNow();
  333. let timePassedHours = (now - firstGroveOpen) / 3600;
  334. var rotaionLenght = 20;
  335. var rotationsExact = timePassedHours / rotaionLenght;
  336. var rotationsInteger = Math.trunc(rotationsExact);
  337. var partialrotation = (rotationsExact - rotationsInteger) * rotaionLenght;
  338. if (partialrotation < 16) {
  339. //Open
  340. $(".forbiddenGroveHeaderValue").text(" OPEN");
  341. var timeCloses = (16 - partialrotation).toPrecision(4);
  342. var closesHours = Math.trunc(timeCloses);
  343. var closesMinutes = Math.ceil((timeCloses - closesHours) * 60);
  344. $(".forbiddenGroveClosesValue").text(closesHours + "h " + closesMinutes + "m");
  345. $(".forbiddenGroveOpensLabel").text("Opens Again in:");
  346. $(".forbiddenGroveOpensValue").text((closesHours + 4) + "h " + closesMinutes + "m");
  347. forbiddenGrove.append($(".forbiddenGroveOpens"))
  348. if ((closesHours == 0) && (closesMinutes <= 15) && (localStorage.getItem('RemindGrove') == "Y")) {
  349. if (confirm('The forbidden grove is closing soon, travel there now?') == true) {
  350. travelToGrove();
  351. }
  352. }
  353. } else {
  354. //Closed
  355. $(".forbiddenGroveHeaderValue").text("CLOSED")
  356. var timeOpens = (rotaionLenght - partialrotation).toPrecision(4);
  357. var opensHours = Math.trunc(timeOpens);
  358. var opensMinutes = Math.ceil((timeOpens - opensHours) * 60);
  359. $(".forbiddenGroveOpensValue").text(opensHours + "h " + opensMinutes + "m");
  360. $(".forbiddenGroveClosesLabel").text("Next Close in:");
  361. $(".forbiddenGroveClosesValue").text((opensHours + 16) + "h " + opensMinutes + "m");
  362. forbiddenGrove.append($(".forbiddenGroveCloses"))
  363. if ((opensHours == 0) && (opensMinutes <= 15) && (localStorage.getItem('RemindGrove') == "Y")) {
  364. if (confirm('The forbidden grove is opening soon, travel there now?') == true) {
  365. travelToGrove();
  366. }
  367. }
  368. }
  369. }
  370. $(document).on('change', '#forbiddenGroveCb', function() {
  371. if (this.checked) {
  372. localStorage.setItem('RemindGrove', "Y")
  373. this.checked = "Yes";
  374. } else {
  375. localStorage.setItem('RemindGrove', "N")
  376. this.checked = "";
  377. }
  378. })
  379.  
  380. //====================================== Balacks's Cove ======================================
  381. function buildBalacksCove() {
  382. if ($(".balacksCove").length > 0) return;
  383. var timerBox = $(".timerBox");
  384. var balacksCove = document.createElement("div");
  385. balacksCove.classList.add("balacksCove");
  386. $(balacksCove).css({
  387. 'border': '1px solid black',
  388. 'width': '25%',
  389. 'height': '75%',
  390. 'padding': 2 + "px"
  391. });
  392. //Header
  393. var balacksCoveHeader = document.createElement("div");
  394. balacksCoveHeader.classList.add("balacksCoveHeader");
  395. var balacksCoveHeaderLabel = document.createElement("div");
  396. balacksCoveHeaderLabel.classList.add("balacksCoveHeaderLabel");
  397. var balacksCoveHeaderLabelText = document.createTextNode("Balack's Cove Tide is:");
  398. balacksCoveHeaderLabel.appendChild(balacksCoveHeaderLabelText);
  399. var balacksCoveHeaderValue = document.createElement("div");
  400. balacksCoveHeaderValue.classList.add("balacksCoveHeaderValue");
  401. var balacksCoveHeaderValueText = document.createTextNode("Low");
  402. balacksCoveHeaderValue.appendChild(balacksCoveHeaderValueText);
  403. $(balacksCoveHeaderLabel).css({
  404. 'float': 'left',
  405. 'font-weight': 700,
  406. "marginRight": "5px"
  407. })
  408. $(balacksCoveHeaderValue).css({
  409. "marginLeft": "100px"
  410. });
  411. balacksCoveHeader.appendChild(balacksCoveHeaderLabel);
  412. balacksCoveHeader.appendChild(balacksCoveHeaderValue);
  413. //Low
  414. var balacksCoveLow = document.createElement("div");
  415. balacksCoveLow.classList.add("balacksCoveLow");
  416. var balacksCoveLowLabel = document.createElement("div");
  417. balacksCoveLowLabel.classList.add("balacksCoveLowLabel");
  418. var balacksCoveLowLabelText = document.createTextNode("Low Tide in:");
  419. balacksCoveLowLabel.appendChild(balacksCoveLowLabelText);
  420. var balacksCoveLowValue = document.createElement("div");
  421. balacksCoveLowValue.classList.add("balacksCoveLowValue");
  422. var balacksCoveLowValueText = document.createTextNode("?");
  423. balacksCoveLowValue.appendChild(balacksCoveLowValueText);
  424. $(balacksCoveLowLabel).css({
  425. 'float': 'left',
  426. 'font-weight': 700,
  427. "marginRight": "5px"
  428. })
  429. $(balacksCoveLowValue).css("marginLeft", "50px");
  430. balacksCoveLow.appendChild(balacksCoveLowLabel);
  431. balacksCoveLow.appendChild(balacksCoveLowValue);
  432. //Medium
  433. var balacksCoveMid = document.createElement("div");
  434. balacksCoveMid.classList.add("balacksCoveMid");
  435. var balacksCoveMidLabel = document.createElement("div");
  436. balacksCoveMidLabel.classList.add("balacksCoveMidLabel");
  437. var balacksCoveMidLabelText = document.createTextNode("Mid Tide in:");
  438. balacksCoveMidLabel.appendChild(balacksCoveMidLabelText);
  439. var balacksCoveMidValue = document.createElement("div");
  440. balacksCoveMidValue.classList.add("balacksCoveMidValue");
  441. var balacksCoveMidValueText = document.createTextNode("??");
  442. balacksCoveMidValue.appendChild(balacksCoveMidValueText);
  443. $(balacksCoveMidLabel).css({
  444. 'float': 'left',
  445. 'font-weight': 700,
  446. "marginRight": "5px"
  447. })
  448. $(balacksCoveMidValue).css("marginLeft", "50px");
  449. balacksCoveMid.appendChild(balacksCoveMidLabel);
  450. balacksCoveMid.appendChild(balacksCoveMidValue);
  451. //High
  452. var balacksCoveHigh = document.createElement("div");
  453. balacksCoveHigh.classList.add("balacksCoveHigh");
  454. var balacksCoveHighLabel = document.createElement("div");
  455. balacksCoveHighLabel.classList.add("balacksCoveHighLabel");
  456. var balacksCoveHighLabelText = document.createTextNode("High Tide in:");
  457. balacksCoveHighLabel.appendChild(balacksCoveHighLabelText);
  458. var balacksCoveHighValue = document.createElement("div");
  459. balacksCoveHighValue.classList.add("balacksCoveHighValue");
  460. var balacksCoveHighValueText = document.createTextNode("??");
  461. balacksCoveHighValue.appendChild(balacksCoveHighValueText);
  462. $(balacksCoveHighLabel).css({
  463. 'float': 'left',
  464. 'font-weight': 700,
  465. "marginRight": "5px"
  466. })
  467. $(balacksCoveHighValue).css("marginLeft", "50px");
  468. balacksCoveHigh.appendChild(balacksCoveHighLabel);
  469. balacksCoveHigh.appendChild(balacksCoveHighValue);
  470. //Append
  471. balacksCove.appendChild(balacksCoveHeader);
  472. balacksCove.appendChild(balacksCoveLow);
  473. balacksCove.appendChild(balacksCoveMid);
  474. balacksCove.appendChild(balacksCoveHigh);
  475. return balacksCove;
  476. }
  477.  
  478. function updateBalacksCoveTimer() {
  479. if ($(".balacksCove").length < 1) return;
  480. var balacksCove = $(".balacksCove");
  481. var firstCoveLow = 1294680060;
  482. var now = todayNow();
  483. let timePassedHours = (now - firstCoveLow) / 3600;
  484. var rotaionLenght = 18.6666666666666666666666666666666666666667;
  485. var rotationsExact = timePassedHours / rotaionLenght;
  486. var rotationsInteger = Math.trunc(rotationsExact);
  487. var partialrotation = (rotationsExact - rotationsInteger) * rotaionLenght;
  488. if (partialrotation < 16) {
  489. //Low
  490. $(".balacksCoveHeaderValue").text("LOW");
  491. var timeMid = (16 - partialrotation).toPrecision(4);
  492. var midHours = Math.trunc(timeMid);
  493. var midMinutes = Math.ceil((timeMid - midHours) * 60);
  494. $(".balacksCoveMidValue").text(midHours + "h " + midMinutes + "m");
  495. $(".balacksCoveMidLabel").text("Mid-Filling in:")
  496. $(".balacksCoveHighValue").text((midHours + 1) + "h " + midMinutes + "m");
  497. $(".balacksCoveLowLabel").text("Low Again in:");
  498. var lowHours = midHours + 2;
  499. var lowMinutes = midMinutes + 40;
  500. if (lowMinutes >= 60) {
  501. lowMinutes = lowMinutes - 60;
  502. lowHours++;
  503. }
  504. $(".balacksCoveLowValue").text((lowHours) + "h " + (lowMinutes) + "m");
  505. balacksCove.append($(".balacksCoveLow"))
  506. if ((midHours == 0) && (midMinutes <= 15) && (localStorage.getItem('RemindCove') == "Y")) {
  507. if (confirm('It will be mid tide soon, travel there now?') == true) {
  508. travelToCove();
  509. }
  510. }
  511. } else if ((partialrotation >= 16) && (partialrotation < 17)) {
  512. //Mid (flooding)
  513. $(".balacksCoveHeaderValue").text("MID-Flooding");
  514. var timeHigh = (17 - partialrotation).toPrecision(4);
  515. var highHours = Math.trunc(timeHigh);
  516. var highMinutes = Math.ceil((timeHigh - highHours) * 60);
  517. $(".balacksCoveHighValue").text((highHours) + "h " + highMinutes + "m");
  518. $(".balacksCoveMidLabel").text("Mid-Ebbing in:")
  519. var midHours = highHours;
  520. var midMinutes = highMinutes + 40;
  521. if (midMinutes >= 60) {
  522. midMinutes = midMinutes - 60;
  523. midHours++;
  524. }
  525. $(".balacksCoveMidValue").text(midHours + "h " + midMinutes + "m");
  526. $(".balacksCoveLowLabel").text("Low Tide in:");
  527. $(".balacksCoveLowValue").text((midHours + 1) + "h " + (midMinutes) + "m");
  528. balacksCove.append($(".balacksCoveMid"))
  529. balacksCove.append($(".balacksCoveLow"))
  530. if ((highHours == 0) && (highMinutes <= 15) && (localStorage.getItem('RemindCove') == "Y")) {
  531. if (confirm('It will be high tide soon, travel there now?') == true) {
  532. travelToCove();
  533. }
  534. }
  535. } else if ((partialrotation >= 17) && (partialrotation < 17.6666666667)) {
  536. //High
  537. $(".balacksCoveHeaderValue").text("HIGH");
  538. var timeMid = (17.6666666667 - partialrotation).toPrecision(4);
  539. var midHours = Math.trunc(timeMid);
  540. var midMinutes = Math.ceil((timeMid - midHours) * 60);
  541. $(".balacksCoveMidValue").text((midHours) + "h " + midMinutes + "m");
  542. $(".balacksCoveMidLabel").text("Mid-Ebbing in:")
  543. $(".balacksCoveLowLabel").text("Low Tide in:")
  544. $(".balacksCoveLowValue").text((midHours + 1) + "h " + midMinutes + "m");
  545. $(".balacksCoveHigh").hide();
  546. balacksCove.append($(".balacksCoveLow"))
  547. if ((midHours == 0) && (midMinutes <= 15) && (localStorage.getItem('RemindCove') == "Y")) {
  548. if (confirm('It will be mid tide soon, travel there now?') == true) {
  549. travelToCove();
  550. }
  551. }
  552. } else if (partialrotation >= 17.6666666667) {
  553. //Mid (ebbing)
  554. $(".balacksCoveHeaderValue").text("MID-Ebbing");
  555. var timeLow = (rotaionLenght - partialrotation).toPrecision(4);
  556. var lowHours = Math.trunc(timeLow);
  557. var lowMinutes = Math.ceil((timeLow - lowHours) * 60);
  558. $(".balacksCoveLowLabel").text("Low Tide in:")
  559. $(".balacksCoveLowValue").text((lowHours) + "h " + lowMinutes + "m");
  560. $(".balacksCoveMidLabel").text("Mid-Filling in:")
  561. $(".balacksCoveMidValue").text(lowHours + 16 + "h " + lowMinutes + "m");
  562. $(".balacksCoveHighLabel").text("High Tide in:");
  563. $(".balacksCoveHighValue").text(lowHours + 17 + "h " + (lowMinutes) + "m");
  564. balacksCove.append($(".balacksCoveHigh").show())
  565. if ((lowHours == 0) && (lowMinutes <= 15) && (localStorage.getItem('RemindCove') == "Y")) {
  566. if (confirm('It will be low tide soon, travel there now?') == true) {
  567. travelToCove();
  568. }
  569. }
  570. }
  571. }
  572.  
  573. $(document).on('change', '#balacksCoveCb', function() {
  574. if (this.checked) {
  575. localStorage.setItem('RemindCove', "Y")
  576. this.checked = "Yes";
  577. } else {
  578. localStorage.setItem('RemindCove', "N")
  579. this.checked = "";
  580. }
  581. })
  582. //====================================== Seasonal Garden ======================================
  583. function buildSeasonalGarden() {
  584. if ($(".seasonalGarden").length > 0) return;
  585. var timerBox = $(".timerBox");
  586. var seasonalGarden = document.createElement("div");
  587. seasonalGarden.classList.add("seasonalGarden");
  588. $(seasonalGarden).css({
  589. 'border': '1px solid black',
  590. 'width': '24%',
  591. 'height': '75%',
  592. 'padding': 2 + "px"
  593. });
  594. //Header
  595. var seasonalGardenHeader = document.createElement("div");
  596. seasonalGardenHeader.classList.add("seasonalGardenHeader");
  597. var seasonalGardenHeaderLabel = document.createElement("div");
  598. seasonalGardenHeaderLabel.classList.add("seasonalGardenHeaderLabel");
  599. var seasonalGardenHeaderLabelText = document.createTextNode("Current Garden Season:");
  600. seasonalGardenHeaderLabel.appendChild(seasonalGardenHeaderLabelText);
  601. var seasonalGardenHeaderValue = document.createElement("div");
  602. seasonalGardenHeaderValue.classList.add("seasonalGardenHeaderValue");
  603. var seasonalGardenHeaderValueText = document.createTextNode("FALL");
  604. seasonalGardenHeaderValue.appendChild(seasonalGardenHeaderValueText);
  605. $(seasonalGardenHeaderLabel).css({
  606. 'float': 'left',
  607. 'font-weight': 700,
  608. "marginRight": "5px"
  609. })
  610. $(seasonalGardenHeaderValue).css({
  611. "marginLeft": "100px"
  612. });
  613. seasonalGardenHeader.appendChild(seasonalGardenHeaderLabel);
  614. seasonalGardenHeader.appendChild(seasonalGardenHeaderValue);
  615. //Fall
  616. var seasonalGardenFall = document.createElement("div");
  617. seasonalGardenFall.classList.add("seasonalGardenFall");
  618. var seasonalGardenFallLabel = document.createElement("div");
  619. seasonalGardenFallLabel.classList.add("seasonalGardenFallLabel");
  620. var seasonalGardenFallLabelText = document.createTextNode("Fall in:");
  621. seasonalGardenFallLabel.appendChild(seasonalGardenFallLabelText);
  622. var seasonalGardenFallValue = document.createElement("div");
  623. seasonalGardenFallValue.classList.add("seasonalGardenFallValue");
  624. var seasonalGardenFallValueText = document.createTextNode("?");
  625. seasonalGardenFallValue.appendChild(seasonalGardenFallValueText);
  626. $(seasonalGardenFallLabel).css({
  627. 'float': 'left',
  628. 'font-weight': 700,
  629. "marginRight": "5px"
  630. })
  631. $(seasonalGardenFallValue).css("marginLeft", "50px");
  632. seasonalGardenFall.appendChild(seasonalGardenFallLabel);
  633. seasonalGardenFall.appendChild(seasonalGardenFallValue);
  634. //Winter
  635. var seasonalGardenWinter = document.createElement("div");
  636. seasonalGardenWinter.classList.add("seasonalGardenWinter");
  637. var seasonalGardenWinterLabel = document.createElement("div");
  638. seasonalGardenWinterLabel.classList.add("seasonalGardenWinterLabel");
  639. var seasonalGardenWinterLabelText = document.createTextNode("Winter in:");
  640. seasonalGardenWinterLabel.appendChild(seasonalGardenWinterLabelText);
  641. var seasonalGardenWinterValue = document.createElement("div");
  642. seasonalGardenWinterValue.classList.add("seasonalGardenWinterValue");
  643. var seasonalGardenWinterValueText = document.createTextNode("?");
  644. seasonalGardenWinterValue.appendChild(seasonalGardenWinterValueText);
  645. $(seasonalGardenWinterLabel).css({
  646. 'float': 'left',
  647. 'font-weight': 700,
  648. "marginRight": "5px"
  649. })
  650. $(seasonalGardenWinterValue).css("marginLeft", "50px");
  651. seasonalGardenWinter.appendChild(seasonalGardenWinterLabel);
  652. seasonalGardenWinter.appendChild(seasonalGardenWinterValue);
  653. //Spring
  654. var seasonalGardenSpring = document.createElement("div");
  655. seasonalGardenSpring.classList.add("seasonalGardenSpring");
  656. var seasonalGardenSpringLabel = document.createElement("div");
  657. seasonalGardenSpringLabel.classList.add("seasonalGardenSpringLabel");
  658. var seasonalGardenSpringLabelText = document.createTextNode("Spring in:");
  659. seasonalGardenSpringLabel.appendChild(seasonalGardenSpringLabelText);
  660. var seasonalGardenSpringValue = document.createElement("div");
  661. seasonalGardenSpringValue.classList.add("seasonalGardenSpringValue");
  662. var seasonalGardenSpringValueText = document.createTextNode("?");
  663. seasonalGardenSpringValue.appendChild(seasonalGardenSpringValueText);
  664. $(seasonalGardenSpringLabel).css({
  665. 'float': 'left',
  666. 'font-weight': 700,
  667. "marginRight": "5px"
  668. })
  669. $(seasonalGardenSpringValue).css("marginLeft", "50px");
  670. seasonalGardenSpring.appendChild(seasonalGardenSpringLabel);
  671. seasonalGardenSpring.appendChild(seasonalGardenSpringValue);
  672. //Summer
  673. var seasonalGardenSummer = document.createElement("div");
  674. seasonalGardenSummer.classList.add("seasonalGardenSummer");
  675. var seasonalGardenSummerLabel = document.createElement("div");
  676. seasonalGardenSummerLabel.classList.add("seasonalGardenSummerLabel");
  677. var seasonalGardenSummerLabelText = document.createTextNode("Summer in:");
  678. seasonalGardenSummerLabel.appendChild(seasonalGardenSummerLabelText);
  679. var seasonalGardenSummerValue = document.createElement("div");
  680. seasonalGardenSummerValue.classList.add("seasonalGardenSummerValue");
  681. var seasonalGardenSummerValueText = document.createTextNode("?");
  682. seasonalGardenSummerValue.appendChild(seasonalGardenSummerValueText);
  683. $(seasonalGardenSummerLabel).css({
  684. 'float': 'left',
  685. 'font-weight': 700,
  686. "marginRight": "5px"
  687. })
  688. $(seasonalGardenSummerValue).css("marginLeft", "50px");
  689. seasonalGardenSummer.appendChild(seasonalGardenSummerLabel);
  690. seasonalGardenSummer.appendChild(seasonalGardenSummerValue);
  691. //Append
  692. seasonalGarden.appendChild(seasonalGardenHeader);
  693. seasonalGarden.appendChild(seasonalGardenFall);
  694. seasonalGarden.appendChild(seasonalGardenWinter);
  695. seasonalGarden.appendChild(seasonalGardenSpring);
  696. seasonalGarden.appendChild(seasonalGardenSummer);
  697. return seasonalGarden;
  698. }
  699.  
  700. function updateSeasonalGardenTimer() {
  701. if ($(".seasonalGarden").length < 1) return;
  702. var seasonalGarden = $(".seasonalGarden");
  703. var firstFall = 288000;
  704. var now = todayNow();
  705. let timePassedHours = (now - firstFall) / 3600;
  706. var rotaionLenght = 320;
  707. var rotationsExact = timePassedHours / rotaionLenght;
  708. var rotationsInteger = Math.trunc(rotationsExact);
  709. var partialrotation = (rotationsExact - rotationsInteger) * rotaionLenght;
  710. var fallObj = new season(0, 0, 0);
  711. var winterObj = new season(0, 0, 0);
  712. var springObj = new season(0, 0, 0);
  713. var summerObj = new season(0, 0, 0);
  714. if (partialrotation < 80) {
  715. //Summer
  716. $(".seasonalGardenHeaderValue").text("SUMMER");
  717. var timeFall = (80 - partialrotation).toPrecision(4);
  718. fallObj.hours = Math.floor(timeFall);
  719. fallObj.minutes = Math.ceil((timeFall - fallObj.hours) * 60);
  720. fallObj = convertToDyHrMn(0, fallObj.hours, fallObj.minutes);
  721. winterObj = convertToDyHrMn(fallObj.days + 3, fallObj.hours + 8, fallObj.minutes);
  722. springObj = convertToDyHrMn(winterObj.days + 3, winterObj.hours + 8, winterObj.minutes)
  723. summerObj = convertToDyHrMn(springObj.days + 3, springObj.hours + 8, springObj.minutes);
  724. $(".seasonalGardenFallLabel").text("Next Summer in:")
  725. $(".seasonalGardenWinterLabel").text("Winter in:")
  726. $(".seasonalGardenSpringLabel").text("Spring in:")
  727. $(".seasonalGardenSummerLabel").text("Summer in:")
  728. seasonalGarden.append($(".seasonalGardenFall"));
  729. seasonalGarden.append($(".seasonalGardenWinter"));
  730. seasonalGarden.append($(".seasonalGardenSpring"));
  731. seasonalGarden.append($(".seasonalGardenSummer"));
  732. if ((fallObj.hours == 0) && (fallObj.minutes <= 15) && (localStorage.getItem('RemindGarden') == "Y")) {
  733. if (confirm('It will be fall in the garden soon, travel there now?') == true) {
  734. travelToGarden();
  735. }
  736. }
  737. } else if ((partialrotation >= 80) && (partialrotation < 160)) {
  738. //Fall
  739. $(".seasonalGardenHeaderValue").text("FALL");
  740. var timeWinter = (160 - partialrotation).toPrecision(4);
  741. winterObj.hours = Math.floor(timeWinter);
  742. winterObj.minutes = Math.ceil((timeWinter - winterObj.hours) * 60);
  743. winterObj = convertToDyHrMn(0, winterObj.hours, winterObj.minutes);
  744. springObj = convertToDyHrMn(winterObj.days + 3, winterObj.hours + 8, winterObj.minutes)
  745. summerObj = convertToDyHrMn(springObj.days + 3, springObj.hours + 8, springObj.minutes)
  746. fallObj = convertToDyHrMn(summerObj.days + 3, summerObj.hours + 8, summerObj.minutes);
  747. $(".seasonalGardenFallLabel").text("Next Fall in:")
  748. $(".seasonalGardenWinterLabel").text("Winter in:")
  749. $(".seasonalGardenSpringLabel").text("Spring in:")
  750. $(".seasonalGardenSummerLabel").text("Summer in:")
  751. seasonalGarden.append($(".seasonalGardenWinter"));
  752. seasonalGarden.append($(".seasonalGardenSpring"));
  753. seasonalGarden.append($(".seasonalGardenSummer"));
  754. seasonalGarden.append($(".seasonalGardenFall"));
  755. if ((winterObj.hours == 0) && (winterObj.minutes <= 15) && (localStorage.getItem('RemindGarden') == "Y")) {
  756. if (confirm('It will be winter in the garden soon, travel there now?') == true) {
  757. travelToGarden();
  758. }
  759. }
  760. } else if ((partialrotation >= 160) && (partialrotation < 240)) {
  761. //Winter
  762. $(".seasonalGardenHeaderValue").text("WINTER");
  763. var timeSpring = (240 - partialrotation).toPrecision(4);
  764. springObj.hours = Math.floor(timeSpring);
  765. springObj.minutes = Math.ceil((timeSpring - springObj.hours) * 60);
  766. springObj = convertToDyHrMn(0, springObj.hours, springObj.minutes)
  767. summerObj = convertToDyHrMn(springObj.days + 3, springObj.hours + 8, springObj.minutes);
  768. fallObj = convertToDyHrMn(summerObj.days + 3, summerObj.hours + 8, summerObj.minutes);
  769. winterObj = convertToDyHrMn(fallObj.days + 3, fallObj.hours + 8, fallObj.minutes);
  770. $(".seasonalGardenFallLabel").text("Fall in:")
  771. $(".seasonalGardenWinterLabel").text("Next Winter in:")
  772. $(".seasonalGardenSpringLabel").text("Spring in:")
  773. $(".seasonalGardenSummerLabel").text("Summer in:")
  774. seasonalGarden.append($(".seasonalGardenSpring"));
  775. seasonalGarden.append($(".seasonalGardenSummer"));
  776. seasonalGarden.append($(".seasonalGardenFall"));
  777. seasonalGarden.append($(".seasonalGardenWinter"));
  778. if ((springObj.hours == 0) && (springObj.minutes <= 15) && (localStorage.getItem('RemindGarden') == "Y")) {
  779. if (confirm('It will be spring in the garden soon, travel there now?') == true) {
  780. travelToGarden();
  781. }
  782. }
  783. } else {
  784. //Spring
  785. $(".seasonalGardenHeaderValue").text("SPRING");
  786. var timeSummer = (320 - partialrotation).toPrecision(4);
  787. summerObj.hours = Math.floor(timeSummer);
  788. summerObj.minutes = Math.ceil((timeSummer - summerObj.hours) * 60);
  789. summerObj = convertToDyHrMn(0, summerObj.hours, summerObj.minutes)
  790. fallObj = convertToDyHrMn(summerObj.days + 3, summerObj.hours + 8, summerObj.minutes);
  791. winterObj = convertToDyHrMn(fallObj.days + 3, fallObj.hours + 8, fallObj.minutes);
  792. springObj = convertToDyHrMn(winterObj.days + 3, winterObj.hours + 8, winterObj.minutes);
  793. $(".seasonalGardenFallLabel").text("Fall in:")
  794. $(".seasonalGardenWinterLabel").text("Winter in:")
  795. $(".seasonalGardenSpringLabel").text("Next Spring in:")
  796. $(".seasonalGardenSummerLabel").text("Summer in:")
  797. seasonalGarden.append($(".seasonalGardenSummer"));
  798. seasonalGarden.append($(".seasonalGardenFall"));
  799. seasonalGarden.append($(".seasonalGardenWinter"));
  800. seasonalGarden.append($(".seasonalGardenSpring"));
  801. if ((summerObj.hours == 0) && (summerObj.minutes <= 15) && (localStorage.getItem('RemindGarden') == "Y")) {
  802. if (confirm('It will be summer in the garden soon, travel there now?') == true) {
  803. travelToGarden();
  804. }
  805. }
  806. }
  807. $(".seasonalGardenFallValue").text(fallObj.days + "d " + fallObj.hours + "h " + fallObj.minutes + "m");
  808. $(".seasonalGardenWinterValue").text(winterObj.days + "d " + winterObj.hours + "h " + winterObj.minutes + "m");
  809. $(".seasonalGardenSpringValue").text(springObj.days + "d " + springObj.hours + "h " + springObj.minutes + "m");
  810. $(".seasonalGardenSummerValue").text(summerObj.days + "d " + summerObj.hours + "h " + summerObj.minutes + "m");
  811. }
  812.  
  813. function season(days, hours, minutes) {
  814. this.days = days;
  815. this.hours = hours;
  816. this.minutes = minutes;
  817. }
  818. $(document).on('change', '#seasonalGardenCb', function() {
  819. if (this.checked) {
  820. localStorage.setItem('RemindGarden', "Y")
  821. this.checked = "Yes";
  822. } else {
  823. localStorage.setItem('RemindGarden', "N")
  824. this.checked = "";
  825. }
  826. })
  827. //====================================== Toxic Spill ======================================
  828. function buildToxicSpill() {
  829. if ($(".toxicSpill").length > 0) return;
  830. var timerBox = $(".timerBox");
  831. var toxicSpill = document.createElement("div");
  832. toxicSpill.classList.add("toxicSpill");
  833. $(toxicSpill).css({
  834. 'border': '1px solid black',
  835. 'width': '26%',
  836. 'height': '75%',
  837. 'padding': 2 + "px"
  838. });
  839. //Header
  840. var toxicSpillHeader = document.createElement("div");
  841. toxicSpillHeader.classList.add("toxicSpillHeader");
  842. var toxicSpillHeaderLabel = document.createElement("div");
  843. toxicSpillHeaderLabel.classList.add("toxicSpillHeaderLabel");
  844. var toxicSpillHeaderLabelText = document.createTextNode("Current Spill Level:");
  845. toxicSpillHeaderLabel.appendChild(toxicSpillHeaderLabelText);
  846. var toxicSpillHeaderValue = document.createElement("div");
  847. toxicSpillHeaderValue.classList.add("toxicSpillHeaderValue");
  848. var toxicSpillHeaderValueText = document.createTextNode("Archduke");
  849. toxicSpillHeaderValue.appendChild(toxicSpillHeaderValueText);
  850. $(toxicSpillHeaderLabel).css({
  851. 'float': 'left',
  852. 'font-weight': 700,
  853. "marginRight": "5px"
  854. })
  855. $(toxicSpillHeaderValue).css({
  856. "marginLeft": "100px"
  857. });
  858. toxicSpillHeader.appendChild(toxicSpillHeaderLabel);
  859. toxicSpillHeader.appendChild(toxicSpillHeaderValue);
  860. //Hero
  861. var toxicSpillHero = document.createElement("div");
  862. toxicSpillHero.classList.add("toxicSpillHero");
  863. var toxicSpillHeroLabel = document.createElement("div");
  864. toxicSpillHeroLabel.classList.add("toxicSpillHeroLabel");
  865. var toxicSpillHeroLabelText = document.createTextNode("Hero in:");
  866. toxicSpillHeroLabel.appendChild(toxicSpillHeroLabelText);
  867. var toxicSpillHeroValue = document.createElement("div");
  868. toxicSpillHeroValue.classList.add("toxicSpillHeroValue");
  869. var toxicSpillHeroValueText = document.createTextNode("?");
  870. toxicSpillHeroValue.appendChild(toxicSpillHeroValueText);
  871. $(toxicSpillHeroLabel).css({
  872. 'float': 'left',
  873. 'font-weight': 700,
  874. "marginRight": "5px"
  875. })
  876. $(toxicSpillHeroValue).css("marginLeft", "50px");
  877. toxicSpillHero.appendChild(toxicSpillHeroLabel);
  878. toxicSpillHero.appendChild(toxicSpillHeroValue);
  879. //Knight
  880. var toxicSpillKnight = document.createElement("div");
  881. toxicSpillKnight.classList.add("toxicSpillKnight");
  882. var toxicSpillKnightLabel = document.createElement("div");
  883. toxicSpillKnightLabel.classList.add("toxicSpillKnightLabel");
  884. var toxicSpillKnightLabelText = document.createTextNode("Knight in:");
  885. toxicSpillKnightLabel.appendChild(toxicSpillKnightLabelText);
  886. var toxicSpillKnightValue = document.createElement("div");
  887. toxicSpillKnightValue.classList.add("toxicSpillKnightValue");
  888. var toxicSpillKnightValueText = document.createTextNode("?");
  889. toxicSpillKnightValue.appendChild(toxicSpillKnightValueText);
  890. $(toxicSpillKnightLabel).css({
  891. 'float': 'left',
  892. 'font-weight': 700,
  893. "marginRight": "5px"
  894. })
  895. $(toxicSpillKnightValue).css("marginLeft", "50px");
  896. toxicSpillKnight.appendChild(toxicSpillKnightLabel);
  897. toxicSpillKnight.appendChild(toxicSpillKnightValue);
  898. //Lord
  899. var toxicSpillLord = document.createElement("div");
  900. toxicSpillLord.classList.add("toxicSpillLord");
  901. var toxicSpillLordLabel = document.createElement("div");
  902. toxicSpillLordLabel.classList.add("toxicSpillLordLabel");
  903. var toxicSpillLordLabelText = document.createTextNode("Lord in:");
  904. toxicSpillLordLabel.appendChild(toxicSpillLordLabelText);
  905. var toxicSpillLordValue = document.createElement("div");
  906. toxicSpillLordValue.classList.add("toxicSpillLordValue");
  907. var toxicSpillLordValueText = document.createTextNode("?");
  908. toxicSpillLordValue.appendChild(toxicSpillLordValueText);
  909. $(toxicSpillLordLabel).css({
  910. 'float': 'left',
  911. 'font-weight': 700,
  912. "marginRight": "5px"
  913. })
  914. $(toxicSpillLordValue).css("marginLeft", "50px");
  915. toxicSpillLord.appendChild(toxicSpillLordLabel);
  916. toxicSpillLord.appendChild(toxicSpillLordValue);
  917. //Baron
  918. var toxicSpillBaron = document.createElement("div");
  919. toxicSpillBaron.classList.add("toxicSpillBaron");
  920. var toxicSpillBaronLabel = document.createElement("div");
  921. toxicSpillBaronLabel.classList.add("toxicSpillBaronLabel");
  922. var toxicSpillBaronLabelText = document.createTextNode("Baron in:");
  923. toxicSpillBaronLabel.appendChild(toxicSpillBaronLabelText);
  924. var toxicSpillBaronValue = document.createElement("div");
  925. toxicSpillBaronValue.classList.add("toxicSpillBaronValue");
  926. var toxicSpillBaronValueText = document.createTextNode("?");
  927. toxicSpillBaronValue.appendChild(toxicSpillBaronValueText);
  928. $(toxicSpillBaronLabel).css({
  929. 'float': 'left',
  930. 'font-weight': 700,
  931. "marginRight": "5px"
  932. })
  933. $(toxicSpillBaronValue).css("marginLeft", "50px");
  934. toxicSpillBaron.appendChild(toxicSpillBaronLabel);
  935. toxicSpillBaron.appendChild(toxicSpillBaronValue);
  936. //Count
  937. var toxicSpillCount = document.createElement("div");
  938. toxicSpillCount.classList.add("toxicSpillCount");
  939. var toxicSpillCountLabel = document.createElement("div");
  940. toxicSpillCountLabel.classList.add("toxicSpillCountLabel");
  941. var toxicSpillCountLabelText = document.createTextNode("Count in:");
  942. toxicSpillCountLabel.appendChild(toxicSpillCountLabelText);
  943. var toxicSpillCountValue = document.createElement("div");
  944. toxicSpillCountValue.classList.add("toxicSpillCountValue");
  945. var toxicSpillCountValueText = document.createTextNode("?");
  946. toxicSpillCountValue.appendChild(toxicSpillCountValueText);
  947. $(toxicSpillCountLabel).css({
  948. 'float': 'left',
  949. 'font-weight': 700,
  950. "marginRight": "5px"
  951. })
  952. $(toxicSpillCountValue).css("marginLeft", "50px");
  953. toxicSpillCount.appendChild(toxicSpillCountLabel);
  954. toxicSpillCount.appendChild(toxicSpillCountValue);
  955. //Duke
  956. var toxicSpillDuke = document.createElement("div");
  957. toxicSpillDuke.classList.add("toxicSpillDuke");
  958. var toxicSpillDukeLabel = document.createElement("div");
  959. toxicSpillDukeLabel.classList.add("toxicSpillDukeLabel");
  960. var toxicSpillDukeLabelText = document.createTextNode("Duke in:");
  961. toxicSpillDukeLabel.appendChild(toxicSpillDukeLabelText);
  962. var toxicSpillDukeValue = document.createElement("div");
  963. toxicSpillDukeValue.classList.add("toxicSpillDukeValue");
  964. var toxicSpillDukeValueText = document.createTextNode("?");
  965. toxicSpillDukeValue.appendChild(toxicSpillDukeValueText);
  966. $(toxicSpillDukeLabel).css({
  967. 'float': 'left',
  968. 'font-weight': 700,
  969. "marginRight": "5px"
  970. })
  971. $(toxicSpillDukeValue).css("marginLeft", "50px");
  972. toxicSpillDuke.appendChild(toxicSpillDukeLabel);
  973. toxicSpillDuke.appendChild(toxicSpillDukeValue);
  974. //Grand Duke
  975. var toxicSpillGrandDuke = document.createElement("div");
  976. toxicSpillGrandDuke.classList.add("toxicSpillGrandDuke");
  977. var toxicSpillGrandDukeLabel = document.createElement("div");
  978. toxicSpillGrandDukeLabel.classList.add("toxicSpillGrandDukeLabel");
  979. var toxicSpillGrandDukeLabelText = document.createTextNode("Grand Duke in:");
  980. toxicSpillGrandDukeLabel.appendChild(toxicSpillGrandDukeLabelText);
  981. var toxicSpillGrandDukeValue = document.createElement("div");
  982. toxicSpillGrandDukeValue.classList.add("toxicSpillGrandDukeValue");
  983. var toxicSpillGrandDukeValueText = document.createTextNode("?");
  984. toxicSpillGrandDukeValue.appendChild(toxicSpillGrandDukeValueText);
  985. $(toxicSpillGrandDukeLabel).css({
  986. 'float': 'left',
  987. 'font-weight': 700,
  988. "marginRight": "5px"
  989. })
  990. $(toxicSpillGrandDukeValue).css("marginLeft", "50px");
  991. toxicSpillGrandDuke.appendChild(toxicSpillGrandDukeLabel);
  992. toxicSpillGrandDuke.appendChild(toxicSpillGrandDukeValue);
  993. //Archduke
  994. var toxicSpillArchduke = document.createElement("div");
  995. toxicSpillArchduke.classList.add("toxicSpillArchduke");
  996. var toxicSpillArchdukeLabel = document.createElement("div");
  997. toxicSpillArchdukeLabel.classList.add("toxicSpillArchdukeLabel");
  998. var toxicSpillArchdukeLabelText = document.createTextNode("Archduke in:");
  999. toxicSpillArchdukeLabel.appendChild(toxicSpillArchdukeLabelText);
  1000. var toxicSpillArchdukeValue = document.createElement("div");
  1001. toxicSpillArchdukeValue.classList.add("toxicSpillArchdukeValue");
  1002. var toxicSpillArchdukeValueText = document.createTextNode("?");
  1003. toxicSpillArchdukeValue.appendChild(toxicSpillArchdukeValueText);
  1004. $(toxicSpillArchdukeLabel).css({
  1005. 'float': 'left',
  1006. 'font-weight': 700,
  1007. "marginRight": "5px"
  1008. })
  1009. $(toxicSpillArchdukeValue).css("marginLeft", "50px");
  1010. toxicSpillArchduke.appendChild(toxicSpillArchdukeLabel);
  1011. toxicSpillArchduke.appendChild(toxicSpillArchdukeValue);
  1012. //Append
  1013. toxicSpill.appendChild(toxicSpillHeader);
  1014. toxicSpill.appendChild(toxicSpillHero);
  1015. toxicSpill.appendChild(toxicSpillKnight);
  1016. toxicSpill.appendChild(toxicSpillLord);
  1017. toxicSpill.appendChild(toxicSpillBaron);
  1018. toxicSpill.appendChild(toxicSpillCount);
  1019. toxicSpill.appendChild(toxicSpillDuke);
  1020. toxicSpill.appendChild(toxicSpillGrandDuke);
  1021. toxicSpill.appendChild(toxicSpillArchduke);
  1022. return toxicSpill;
  1023. }
  1024.  
  1025. function updateToxicSpillTimer() {
  1026. if ($(".toxicSpill").length < 1) return;
  1027. var toxicSpill = $(".toxicSpill");
  1028. $(".toxicSpill").children().show();
  1029. var firstHero = 1503597600;
  1030. var now = todayNow();
  1031. let timePassedHours = (now - firstHero) / 3600;
  1032. var rotaionLenght = 302;
  1033. var rotationsExact = timePassedHours / rotaionLenght;
  1034. var rotationsInteger = Math.floor(rotationsExact);
  1035. var partialrotation = (rotationsExact - rotationsInteger) * rotaionLenght;
  1036. var heroObj = new season(0, 0, 0);
  1037. var knightObj = new season(0, 0, 0);
  1038. var lordObj = new season(0, 0, 0);
  1039. var baronObj = new season(0, 0, 0);
  1040. var countObj = new season(0, 0, 0);
  1041. var dukeObj = new season(0, 0, 0);
  1042. var granddukeObj = new season(0, 0, 0);
  1043. var archdukeObj = new season(0, 0, 0);
  1044. if (partialrotation < 15) {
  1045. //Hero Rising
  1046. $(".toxicSpillHeaderValue").text("HERO-RISING");
  1047. var timeKnight = (15 - partialrotation).toPrecision(4);
  1048. knightObj.hours = Math.floor(timeKnight);
  1049. knightObj.minutes = Math.ceil((timeKnight - knightObj.hours) * 60);
  1050. knightObj = convertToDyHrMn(0, knightObj.hours, knightObj.minutes);
  1051. lordObj = convertToDyHrMn(knightObj.days, knightObj.hours + 16, knightObj.minutes);
  1052. baronObj = convertToDyHrMn(lordObj.days, lordObj.hours + 18, lordObj.minutes);
  1053. countObj = convertToDyHrMn(baronObj.days, baronObj.hours + 18, baronObj.minutes);
  1054. dukeObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1055. $(".toxicSpillKnightLabel").text("Knight in:");
  1056. $(".toxicSpillLordLabel").text("Lord in:");
  1057. $(".toxicSpillBaronLabel").text("Baron in:");
  1058. $(".toxicSpillCountLabel").text("Count in:");
  1059. $(".toxicSpillDukeLabel").text("Duke in:");
  1060. toxicSpill.append($(".toxicSpillKnight"));
  1061. toxicSpill.append($(".toxicSpillLord"));
  1062. toxicSpill.append($(".toxicSpillBaron"));
  1063. toxicSpill.append($(".toxicSpillCount"));
  1064. toxicSpill.append($(".toxicSpillDuke"));
  1065. $(".toxicSpillHero").hide();
  1066. $(".toxicSpillGrandDuke").hide();
  1067. $(".toxicSpillArchduke").hide();
  1068. if ((knightObj.hours == 0) && (knightObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1069. if (confirm('It will be Knight level soon at the toxic spill, travel there now?') == true) {
  1070. travelToSpill();
  1071. }
  1072. }
  1073. } else if (partialrotation >= 15 && partialrotation < 31) {
  1074. //Knight Rising
  1075. $(".toxicSpillHeaderValue").text("KNIGHT-RISING");
  1076. var timeLord = (31 - partialrotation).toPrecision(4);
  1077. lordObj.hours = Math.floor(timeLord);
  1078. lordObj.minutes = Math.ceil((timeLord - lordObj.hours) * 60);
  1079. lordObj = convertToDyHrMn(0, lordObj.hours, lordObj.minutes);
  1080. baronObj = convertToDyHrMn(lordObj.days, lordObj.hours + 18, lordObj.minutes);
  1081. countObj = convertToDyHrMn(baronObj.days, baronObj.hours + 18, baronObj.minutes);
  1082. dukeObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1083. granddukeObj = convertToDyHrMn(dukeObj.days + 1, dukeObj.hours, dukeObj.minutes);
  1084. $(".toxicSpillLordLabel").text("Lord in:");
  1085. $(".toxicSpillBaronLabel").text("Baron in:");
  1086. $(".toxicSpillCountLabel").text("Count in:");
  1087. $(".toxicSpillDukeLabel").text("Duke in:");
  1088. $(".toxicSpillGrandDukeLabel").text("Grand Duke in:");
  1089. toxicSpill.append($(".toxicSpillLord"));
  1090. toxicSpill.append($(".toxicSpillBaron"));
  1091. toxicSpill.append($(".toxicSpillCount"));
  1092. toxicSpill.append($(".toxicSpillDuke"));
  1093. toxicSpill.append($(".toxicSpillGrandDuke"));
  1094. $(".toxicSpillHero").hide();
  1095. $(".toxicSpillKnight").hide();
  1096. $(".toxicSpillArchduke").hide();
  1097. if ((lordObj.hours == 0) && (lordObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1098. if (confirm('It will be Lord level soon at the toxic spill, travel there now?') == true) {
  1099. travelToSpill();
  1100. }
  1101. }
  1102. } else if (partialrotation >= 31 && partialrotation < 49) {
  1103. //Lord Rising
  1104. $(".toxicSpillHeaderValue").text("LORD-RISING");
  1105. var timeBaron = (49 - partialrotation).toPrecision(4);
  1106. baronObj.hours = Math.floor(timeBaron);
  1107. baronObj.minutes = Math.ceil((timeBaron - baronObj.hours) * 60);
  1108. baronObj = convertToDyHrMn(0, baronObj.hours, baronObj.minutes);
  1109. countObj = convertToDyHrMn(baronObj.days, baronObj.hours + 18, baronObj.minutes);
  1110. dukeObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1111. granddukeObj = convertToDyHrMn(dukeObj.days + 1, dukeObj.hours, dukeObj.minutes);
  1112. archdukeObj = convertToDyHrMn(granddukeObj.days + 1, granddukeObj.hours, granddukeObj.minutes);
  1113. $(".toxicSpillBaronLabel").text("Baron in:");
  1114. $(".toxicSpillCountLabel").text("Count in:");
  1115. $(".toxicSpillDukeLabel").text("Duke in:");
  1116. $(".toxicSpillGrandDukeLabel").text("Grand Duke in:");
  1117. $(".toxicSpillArchdukeLabel").text("Archduke in:");
  1118. toxicSpill.append($(".toxicSpillBaron"));
  1119. toxicSpill.append($(".toxicSpillCount"));
  1120. toxicSpill.append($(".toxicSpillDuke"));
  1121. toxicSpill.append($(".toxicSpillGrandDuke"));
  1122. toxicSpill.append($(".toxicSpillArchduke"));
  1123. $(".toxicSpillHero").hide();
  1124. $(".toxicSpillKnight").hide();
  1125. $(".toxicSpillLord").hide();
  1126. if ((baronObj.hours == 0) && (baronObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1127. if (confirm('It will be Baron level soon at the toxic spill, travel there now?') == true) {
  1128. travelToSpill();
  1129. }
  1130. }
  1131. } else if (partialrotation >= 49 && partialrotation < 67) {
  1132. //Baron Rising
  1133. $(".toxicSpillHeaderValue").text("BARON-RISING");
  1134. var timeCount = (67 - partialrotation).toPrecision(4);
  1135. countObj.hours = Math.floor(timeCount);
  1136. countObj.minutes = Math.ceil((timeCount - countObj.hours) * 60);
  1137. countObj = convertToDyHrMn(0, countObj.hours, countObj.minutes);
  1138. dukeObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1139. granddukeObj = convertToDyHrMn(dukeObj.days + 1, dukeObj.hours, dukeObj.minutes);
  1140. archdukeObj = convertToDyHrMn(granddukeObj.days + 1, granddukeObj.hours, granddukeObj.minutes);
  1141. countObj = convertToDyHrMn(archdukeObj.days + 3, archdukeObj.hours, archdukeObj.minutes);
  1142. baronObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1143. $(".toxicSpillGrandDukeLabel").text("Grand Duke in:");
  1144. $(".toxicSpillArchdukeLabel").text("Archduke in:");
  1145. $(".toxicSpillDukeLabel").text("Duke in:");
  1146. $(".toxicSpillCountLabel").text("Count in:");
  1147. $(".toxicSpillBaronLabel").text("Baron Falling in:");
  1148. toxicSpill.append($(".toxicSpillCount"));
  1149. toxicSpill.append($(".toxicSpillDuke"));
  1150. toxicSpill.append($(".toxicSpillGrandDuke"));
  1151. toxicSpill.append($(".toxicSpillArchduke"));
  1152. toxicSpill.append($(".toxicSpillBaron"));
  1153. $(".toxicSpillHero").hide();
  1154. $(".toxicSpillKnight").hide();
  1155. $(".toxicSpillLord").hide();
  1156. if ((countObj.hours == 0) && (countObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1157. if (confirm('It will be Count level soon at the toxic spill, travel there now?') == true) {
  1158. travelToSpill();
  1159. }
  1160. }
  1161. } else if (partialrotation >= 67 && partialrotation < 91) {
  1162. //Count Rising
  1163. $(".toxicSpillHeaderValue").text("COUNT-RISING");
  1164. var timeDuke = (91 - partialrotation).toPrecision(4);
  1165. dukeObj.hours = Math.floor(timeDuke);
  1166. dukeObj.minutes = Math.ceil((timeDuke - dukeObj.hours) * 60);
  1167. dukeObj = convertToDyHrMn(0, dukeObj.hours, dukeObj.minutes);
  1168. granddukeObj = convertToDyHrMn(dukeObj.days + 1, dukeObj.hours, dukeObj.minutes);
  1169. archdukeObj = convertToDyHrMn(granddukeObj.days + 1, granddukeObj.hours, granddukeObj.minutes);
  1170. countObj = convertToDyHrMn(archdukeObj.days + 3, archdukeObj.hours, archdukeObj.minutes);
  1171. baronObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1172. $(".toxicSpillGrandDukeLabel").text("Grand Duke in:");
  1173. $(".toxicSpillArchdukeLabel").text("Archduke in:");
  1174. $(".toxicSpillDukeLabel").text("Duke in:");
  1175. $(".toxicSpillCountLabel").text("Count Falling in:");
  1176. $(".toxicSpillBaronLabel").text("Baron in:");
  1177. toxicSpill.append($(".toxicSpillDuke"));
  1178. toxicSpill.append($(".toxicSpillGrandDuke"));
  1179. toxicSpill.append($(".toxicSpillArchduke"));
  1180. toxicSpill.append($(".toxicSpillCount"));
  1181. toxicSpill.append($(".toxicSpillBaron"));
  1182. $(".toxicSpillHero").hide();
  1183. $(".toxicSpillKnight").hide();
  1184. $(".toxicSpillLord").hide();
  1185. if ((dukeObj.hours == 0) && (dukeObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1186. if (confirm('It will be Duke level soon at the toxic spill, travel there now?') == true) {
  1187. travelToSpill();
  1188. }
  1189. }
  1190. } else if (partialrotation >= 91 && partialrotation < 115) {
  1191. //Duke Rising
  1192. $(".toxicSpillHeaderValue").text("DUKE-RISING");
  1193. var timeGrandDuke = (115 - partialrotation).toPrecision(4);
  1194. granddukeObj.hours = Math.floor(timeGrandDuke);
  1195. granddukeObj.minutes = Math.ceil((timeGrandDuke - granddukeObj.hours) * 60);
  1196. granddukeObj = convertToDyHrMn(0, granddukeObj.hours, granddukeObj.minutes);
  1197. archdukeObj = convertToDyHrMn(granddukeObj.days + 1, granddukeObj.hours, granddukeObj.minutes);
  1198. dukeObj = convertToDyHrMn(archdukeObj.days + 2, archdukeObj.hours, archdukeObj.minutes);
  1199. countObj = convertToDyHrMn(dukeObj.days + 1, dukeObj.hours + 10, dukeObj.minutes);
  1200. baronObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1201. $(".toxicSpillGrandDukeLabel").text("Grand Duke in:");
  1202. $(".toxicSpillArchdukeLabel").text("Archduke in:");
  1203. $(".toxicSpillDukeLabel").text("Duke Falling in:");
  1204. $(".toxicSpillCountLabel").text("Count in:");
  1205. $(".toxicSpillBaronLabel").text("Baron in:");
  1206. toxicSpill.append($(".toxicSpillGrandDuke"));
  1207. toxicSpill.append($(".toxicSpillArchduke"));
  1208. toxicSpill.append($(".toxicSpillDuke"));
  1209. toxicSpill.append($(".toxicSpillCount"));
  1210. toxicSpill.append($(".toxicSpillBaron"));
  1211. $(".toxicSpillHero").hide();
  1212. $(".toxicSpillKnight").hide();
  1213. $(".toxicSpillLord").hide();
  1214. if ((granddukeObj.hours == 0) && (granddukeObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1215. if (confirm('It will be Grand Duke level soon at the toxic spill, travel there now?') == true) {
  1216. travelToSpill();
  1217. }
  1218. }
  1219. } else if (partialrotation >= 115 && partialrotation < 139) {
  1220. //Grand Duke Rising
  1221. $(".toxicSpillHeaderValue").text("GD-RISING");
  1222. var timeArchduke = (139 - partialrotation).toPrecision(4);
  1223. archdukeObj.hours = Math.floor(timeArchduke);
  1224. archdukeObj.minutes = Math.ceil((timeArchduke - archdukeObj.hours) * 60);
  1225. archdukeObj = convertToDyHrMn(0, archdukeObj.hours, archdukeObj.minutes);
  1226. granddukeObj = convertToDyHrMn(archdukeObj.days, archdukeObj.hours + 24, archdukeObj.minutes);
  1227. dukeObj = convertToDyHrMn(0, granddukeObj.hours + 24, granddukeObj.minutes);
  1228. countObj = convertToDyHrMn(dukeObj.days + 1, dukeObj.hours + 10, dukeObj.minutes);
  1229. baronObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1230. $(".toxicSpillArchdukeLabel").text("Archduke in:");
  1231. $(".toxicSpillGrandDukeLabel").text("GD Falling in:");
  1232. $(".toxicSpillDukeLabel").text("Duke in:");
  1233. $(".toxicSpillCountLabel").text("Count in:");
  1234. $(".toxicSpillBaronLabel").text("Baron in:");
  1235. toxicSpill.append($(".toxicSpillArchduke"));
  1236. toxicSpill.append($(".toxicSpillGrandDuke"));
  1237. toxicSpill.append($(".toxicSpillDuke"));
  1238. toxicSpill.append($(".toxicSpillCount"));
  1239. toxicSpill.append($(".toxicSpillBaron"));
  1240. $(".toxicSpillHero").hide();
  1241. $(".toxicSpillKnight").hide();
  1242. $(".toxicSpillLord").hide();
  1243. if ((granddukeObj.hours == 0) && (granddukeObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1244. if (confirm('It will be Grand Duke level soon at the toxic spill, travel there now?') == true) {
  1245. travelToSpill();
  1246. }
  1247. }
  1248. } else if (partialrotation >= 139 && partialrotation < 151) {
  1249. //Archduke Rising
  1250. $(".toxicSpillHeaderValue").text("AD-RISING");
  1251. var timeArchduke = (151 - partialrotation).toPrecision(4);
  1252. archdukeObj.hours = Math.floor(timeArchduke);
  1253. archdukeObj.minutes = Math.ceil((timeArchduke - archdukeObj.hours) * 60);
  1254. archdukeObj = convertToDyHrMn(0, archdukeObj.hours, archdukeObj.minutes);
  1255. granddukeObj = convertToDyHrMn(archdukeObj.days, archdukeObj.hours + 12, archdukeObj.minutes);
  1256. dukeObj = convertToDyHrMn(0, granddukeObj.hours + 24, granddukeObj.minutes);
  1257. countObj = convertToDyHrMn(dukeObj.days + 1, dukeObj.hours + 10, dukeObj.minutes);
  1258. baronObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1259. $(".toxicSpillArchdukeLabel").text("AD Falling in:");
  1260. $(".toxicSpillGrandDukeLabel").text("Grand Duke in:");
  1261. $(".toxicSpillDukeLabel").text("Duke in:");
  1262. $(".toxicSpillCountLabel").text("Count in:");
  1263. $(".toxicSpillBaronLabel").text("Baron in:");
  1264. toxicSpill.append($(".toxicSpillArchduke"));
  1265. toxicSpill.append($(".toxicSpillGrandDuke"));
  1266. toxicSpill.append($(".toxicSpillDuke"));
  1267. toxicSpill.append($(".toxicSpillCount"));
  1268. toxicSpill.append($(".toxicSpillBaron"));
  1269. $(".toxicSpillHero").hide();
  1270. $(".toxicSpillKnight").hide();
  1271. $(".toxicSpillLord").hide();
  1272. } else if (partialrotation >= 151 && partialrotation < 163) {
  1273. //Archduke Falling
  1274. $(".toxicSpillHeaderValue").text("AD-FALLING");
  1275. var timeGDuke = (163 - partialrotation).toPrecision(4);
  1276. granddukeObj.hours = Math.floor(timeGDuke);
  1277. granddukeObj.minutes = Math.ceil((timeGDuke - granddukeObj.hours) * 60);
  1278. granddukeObj = convertToDyHrMn(0, granddukeObj.hours, granddukeObj.minutes);
  1279. dukeObj = convertToDyHrMn(0, granddukeObj.hours + 24, granddukeObj.minutes);
  1280. countObj = convertToDyHrMn(dukeObj.days + 1, dukeObj.hours + 10, dukeObj.minutes);
  1281. baronObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1282. lordObj = convertToDyHrMn(baronObj.days, baronObj.hours + 18, baronObj.minutes);
  1283. $(".toxicSpillGrandDukeLabel").text("Grand Duke in:");
  1284. $(".toxicSpillDukeLabel").text("Duke in:");
  1285. $(".toxicSpillCountLabel").text("Count in:");
  1286. $(".toxicSpillBaronLabel").text("Baron in:");
  1287. $(".toxicSpillLordLabel").text("Lord in:");
  1288. toxicSpill.append($(".toxicSpillGrandDuke"));
  1289. toxicSpill.append($(".toxicSpillDuke"));
  1290. toxicSpill.append($(".toxicSpillCount"));
  1291. toxicSpill.append($(".toxicSpillBaron"));
  1292. toxicSpill.append($(".toxicSpillLord"));
  1293. $(".toxicSpillHero").hide();
  1294. $(".toxicSpillKnight").hide();
  1295. $(".toxicSpillArchduke").hide();
  1296. if ((granddukeObj.hours == 0) && (granddukeObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1297. if (confirm('It will be Grand Duke level soon at the toxic spill, travel there now?') == true) {
  1298. travelToSpill();
  1299. }
  1300. }
  1301. } else if (partialrotation >= 163 && partialrotation < 187) {
  1302. //Grand Duke Falling
  1303. $(".toxicSpillHeaderValue").text("GD-FALLING");
  1304. var timeDuke = (187 - partialrotation).toPrecision(4);
  1305. dukeObj.hours = Math.floor(timeDuke);
  1306. dukeObj.minutes = Math.ceil((timeDuke - dukeObj.hours) * 60);
  1307. dukeObj = convertToDyHrMn(0, dukeObj.hours, dukeObj.minutes);
  1308. countObj = convertToDyHrMn(dukeObj.days + 1, dukeObj.hours + 10, dukeObj.minutes);
  1309. baronObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1310. lordObj = convertToDyHrMn(baronObj.days, baronObj.hours + 18, baronObj.minutes);
  1311. knightObj = convertToDyHrMn(lordObj.days, lordObj.hours + 18, lordObj.minutes);
  1312. $(".toxicSpillDukeLabel").text("Duke in:");
  1313. $(".toxicSpillCountLabel").text("Count in:");
  1314. $(".toxicSpillBaronLabel").text("Baron in:");
  1315. $(".toxicSpillLordLabel").text("Lord in:");
  1316. $(".toxicSpillKnightLabel").text("Knight in:");
  1317. toxicSpill.append($(".toxicSpillDuke"));
  1318. toxicSpill.append($(".toxicSpillCount"));
  1319. toxicSpill.append($(".toxicSpillBaron"));
  1320. toxicSpill.append($(".toxicSpillLord"));
  1321. toxicSpill.append($(".toxicSpillKnight"));
  1322. $(".toxicSpillHero").hide();
  1323. $(".toxicSpillGrandDuke").hide();
  1324. $(".toxicSpillArchduke").hide();
  1325. if ((dukeObj.hours == 0) && (dukeObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1326. if (confirm('It will be Duke level soon at the toxic spill, travel there now?') == true) {
  1327. travelToSpill();
  1328. }
  1329. }
  1330. } else if (partialrotation >= 187 && partialrotation < 211) {
  1331. //Duke Falling
  1332. $(".toxicSpillHeaderValue").text("DUKE-FALLING");
  1333. var timeCount = (211 - partialrotation).toPrecision(4);
  1334. countObj.hours = Math.floor(timeCount);
  1335. countObj.minutes = Math.ceil((timeCount - countObj.hours) * 60);
  1336. countObj = convertToDyHrMn(0, countObj.hours, countObj.minutes);
  1337. baronObj = convertToDyHrMn(countObj.days + 1, countObj.hours, countObj.minutes);
  1338. lordObj = convertToDyHrMn(baronObj.days, baronObj.hours + 18, baronObj.minutes);
  1339. knightObj = convertToDyHrMn(lordObj.days, lordObj.hours + 18, lordObj.minutes);
  1340. heroObj = convertToDyHrMn(knightObj.days, knightObj.hours + 16, knightObj.minutes);
  1341. $(".toxicSpillCountLabel").text("Count in:");
  1342. $(".toxicSpillBaronLabel").text("Baron in:");
  1343. $(".toxicSpillLordLabel").text("Lord in:");
  1344. $(".toxicSpillKnightLabel").text("Knight in:");
  1345. $(".toxicSpillHeroLabel").text("Hero in:");
  1346. toxicSpill.append($(".toxicSpillCount"));
  1347. toxicSpill.append($(".toxicSpillBaron"));
  1348. toxicSpill.append($(".toxicSpillLord"));
  1349. toxicSpill.append($(".toxicSpillKnight"));
  1350. toxicSpill.append($(".toxicSpillHero"));
  1351. $(".toxicSpillDuke").hide();
  1352. $(".toxicSpillGrandDuke").hide();
  1353. $(".toxicSpillArchduke").hide();
  1354. if ((countObj.hours == 0) && (countObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1355. if (confirm('It will be Count level soon at the toxic spill, travel there now?') == true) {
  1356. travelToSpill();
  1357. }
  1358. }
  1359. } else if (partialrotation >= 211 && partialrotation < 235) {
  1360. //Count Falling
  1361. $(".toxicSpillHeaderValue").text("COUNT-FALLING");
  1362. var timeBaron = (235 - partialrotation).toPrecision(4);
  1363. baronObj.hours = Math.floor(timeBaron);
  1364. baronObj.minutes = Math.ceil((timeBaron - baronObj.hours) * 60);
  1365. baronObj = convertToDyHrMn(0, baronObj.hours, baronObj.minutes);
  1366. lordObj = convertToDyHrMn(baronObj.days, baronObj.hours + 18, baronObj.minutes);
  1367. knightObj = convertToDyHrMn(lordObj.days, lordObj.hours + 18, lordObj.minutes);
  1368. heroObj = convertToDyHrMn(knightObj.days, knightObj.hours + 16, knightObj.minutes);
  1369. countObj = convertToDyHrMn(heroObj.days + 3, heroObj.hours + 10, heroObj.minutes);
  1370. $(".toxicSpillBaronLabel").text("Baron in:");
  1371. $(".toxicSpillLordLabel").text("Lord in:");
  1372. $(".toxicSpillKnightLabel").text("Knight in:");
  1373. $(".toxicSpillHeroLabel").text("Hero in:");
  1374. $(".toxicSpillCountLabel").text("Count Rising in:");
  1375. toxicSpill.append($(".toxicSpillBaron"));
  1376. toxicSpill.append($(".toxicSpillLord"));
  1377. toxicSpill.append($(".toxicSpillKnight"));
  1378. toxicSpill.append($(".toxicSpillHero"));
  1379. toxicSpill.append($(".toxicSpillCount"));
  1380. $(".toxicSpillDuke").hide();
  1381. $(".toxicSpillGrandDuke").hide();
  1382. $(".toxicSpillArchduke").hide();
  1383. if ((baronObj.hours == 0) && (baronObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1384. if (confirm('It will be Baron level soon at the toxic spill, travel there now?') == true) {
  1385. travelToSpill();
  1386. }
  1387. }
  1388. } else if (partialrotation >= 235 && partialrotation < 253) {
  1389. //Baron Falling
  1390. $(".toxicSpillHeaderValue").text("BARON-FALLING");
  1391. var timeLord = (253 - partialrotation).toPrecision(4);
  1392. lordObj.hours = Math.floor(timeLord);
  1393. lordObj.minutes = Math.ceil((timeLord - lordObj.hours) * 60);
  1394. lordObj = convertToDyHrMn(0, lordObj.hours, lordObj.minutes);
  1395. knightObj = convertToDyHrMn(lordObj.days, lordObj.hours + 18, lordObj.minutes);
  1396. heroObj = convertToDyHrMn(knightObj.days, knightObj.hours + 16, knightObj.minutes);
  1397. baronObj = convertToDyHrMn(heroObj.days + 2, heroObj.hours + 16, heroObj.minutes);
  1398. countObj = convertToDyHrMn(baronObj.days, baronObj.hours + 18, baronObj.minutes);
  1399. $(".toxicSpillCountLabel").text("Count in:");
  1400. $(".toxicSpillBaronLabel").text("Baron Rising in:");
  1401. $(".toxicSpillLordLabel").text("Lord in:");
  1402. $(".toxicSpillKnightLabel").text("Knight in:");
  1403. $(".toxicSpillHeroLabel").text("Hero in:");
  1404. toxicSpill.append($(".toxicSpillLord"));
  1405. toxicSpill.append($(".toxicSpillKnight"));
  1406. toxicSpill.append($(".toxicSpillHero"));
  1407. toxicSpill.append($(".toxicSpillBaron"));
  1408. toxicSpill.append($(".toxicSpillCount"));
  1409. $(".toxicSpillDuke").hide();
  1410. $(".toxicSpillGrandDuke").hide();
  1411. $(".toxicSpillArchduke").hide();
  1412. if ((lordObj.hours == 0) && (lordObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1413. if (confirm('It will be Lord level soon at the toxic spill, travel there now?') == true) {
  1414. travelToSpill();
  1415. }
  1416. }
  1417. } else if (partialrotation >= 253 && partialrotation < 271) {
  1418. //Lord Falling
  1419. $(".toxicSpillHeaderValue").text("LORD-FALLING");
  1420. var timeKnight = (271 - partialrotation).toPrecision(4);
  1421. knightObj.hours = Math.floor(timeKnight);
  1422. knightObj.minutes = Math.ceil((timeKnight - knightObj.hours) * 60);
  1423. knightObj = convertToDyHrMn(0, knightObj.hours, knightObj.minutes);
  1424. heroObj = convertToDyHrMn(knightObj.days, knightObj.hours + 16, knightObj.minutes);
  1425. lordObj = convertToDyHrMn(heroObj.days + 1, heroObj.hours + 22, heroObj.minutes);
  1426. baronObj = convertToDyHrMn(lordObj.days, lordObj.hours + 18, lordObj.minutes);
  1427. countObj = convertToDyHrMn(baronObj.days, baronObj.hours + 18, baronObj.minutes);
  1428. $(".toxicSpillCountLabel").text("Count in:");
  1429. $(".toxicSpillBaronLabel").text("Baron in:");
  1430. $(".toxicSpillLordLabel").text("Lord Rising in:");
  1431. $(".toxicSpillKnightLabel").text("Knight in:");
  1432. $(".toxicSpillHeroLabel").text("Hero in:");
  1433. toxicSpill.append($(".toxicSpillKnight"));
  1434. toxicSpill.append($(".toxicSpillHero"));
  1435. toxicSpill.append($(".toxicSpillLord"));
  1436. toxicSpill.append($(".toxicSpillBaron"));
  1437. toxicSpill.append($(".toxicSpillCount"));
  1438. $(".toxicSpillDuke").hide();
  1439. $(".toxicSpillGrandDuke").hide();
  1440. $(".toxicSpillArchduke").hide();
  1441. if ((knightObj.hours == 0) && (knightObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1442. if (confirm('It will be Knight level soon at the toxic spill, travel there now?') == true) {
  1443. travelToSpill();
  1444. }
  1445. }
  1446. } else if (partialrotation >= 271 && partialrotation < 287) {
  1447. //Knight Falling
  1448. $(".toxicSpillHeaderValue").text("KNIGHT-FALLING");
  1449. var timeHero = (287 - partialrotation).toPrecision(4);
  1450. heroObj.hours = Math.floor(timeHero);
  1451. heroObj.minutes = Math.ceil((timeHero - heroObj.hours) * 60);
  1452. heroObj = convertToDyHrMn(0, heroObj.hours, heroObj.minutes);
  1453. knightObj = convertToDyHrMn(heroObj.days + 1, heroObj.hours + 6, heroObj.minutes);
  1454. lordObj = convertToDyHrMn(knightObj.days, knightObj.hours + 16, knightObj.minutes);
  1455. baronObj = convertToDyHrMn(lordObj.days, lordObj.hours + 18, lordObj.minutes);
  1456. countObj = convertToDyHrMn(baronObj.days, baronObj.hours + 18, baronObj.minutes);
  1457. $(".toxicSpillCountLabel").text("Count in:");
  1458. $(".toxicSpillBaronLabel").text("Baron in:");
  1459. $(".toxicSpillLordLabel").text("Lord in:");
  1460. $(".toxicSpillKnightLabel").text("Knight Rising in:");
  1461. $(".toxicSpillHeroLabel").text("Hero in:");
  1462. toxicSpill.append($(".toxicSpillHero"));
  1463. toxicSpill.append($(".toxicSpillKnight"));
  1464. toxicSpill.append($(".toxicSpillLord"));
  1465. toxicSpill.append($(".toxicSpillBaron"));
  1466. toxicSpill.append($(".toxicSpillCount"));
  1467. $(".toxicSpillDuke").hide();
  1468. $(".toxicSpillGrandDuke").hide();
  1469. $(".toxicSpillArchduke").hide();
  1470. if ((heroObj.hours == 0) && (heroObj.minutes <= 15) && (localStorage.getItem('RemindSpill') == "Y")) {
  1471. if (confirm('It will be Hero level soon at the toxic spill, travel there now?') == true) {
  1472. travelToSpill();
  1473. }
  1474. }
  1475. } else if (partialrotation >= 287 && partialrotation < 302) {
  1476. //Hero Falling
  1477. $(".toxicSpillHeaderValue").text("HERO-FALLING");
  1478. var timeHero = (302 - partialrotation).toPrecision(4);
  1479. heroObj.hours = Math.floor(timeHero);
  1480. heroObj.minutes = Math.ceil((timeHero - heroObj.hours) * 60);
  1481. heroObj = convertToDyHrMn(0, heroObj.hours, heroObj.minutes);
  1482. knightObj = convertToDyHrMn(heroObj.days, heroObj.hours + 15, heroObj.minutes);
  1483. lordObj = convertToDyHrMn(knightObj.days, knightObj.hours + 16, knightObj.minutes);
  1484. baronObj = convertToDyHrMn(lordObj.days, lordObj.hours + 18, lordObj.minutes);
  1485. countObj = convertToDyHrMn(baronObj.days, baronObj.hours + 18, baronObj.minutes);
  1486. $(".toxicSpillCountLabel").text("Count in:");
  1487. $(".toxicSpillBaronLabel").text("Baron in:");
  1488. $(".toxicSpillLordLabel").text("Lord in:");
  1489. $(".toxicSpillKnightLabel").text("Knight in:");
  1490. $(".toxicSpillHeroLabel").text("Hero Rising in:");
  1491. toxicSpill.append($(".toxicSpillHero"));
  1492. toxicSpill.append($(".toxicSpillKnight"));
  1493. toxicSpill.append($(".toxicSpillLord"));
  1494. toxicSpill.append($(".toxicSpillBaron"));
  1495. toxicSpill.append($(".toxicSpillCount"));
  1496. $(".toxicSpillDuke").hide();
  1497. $(".toxicSpillGrandDuke").hide();
  1498. $(".toxicSpillArchduke").hide();
  1499. } else {
  1500. //WTF are we?
  1501. }
  1502. $(".toxicSpillArchdukeValue").text(archdukeObj.days + "d " + archdukeObj.hours + "h " + archdukeObj.minutes + "m");
  1503. $(".toxicSpillGrandDukeValue").text(granddukeObj.days + "d " + granddukeObj.hours + "h " + granddukeObj.minutes + "m");
  1504. $(".toxicSpillDukeValue").text(dukeObj.days + "d " + dukeObj.hours + "h " + dukeObj.minutes + "m");
  1505. $(".toxicSpillCountValue").text(countObj.days + "d " + countObj.hours + "h " + countObj.minutes + "m");
  1506. $(".toxicSpillBaronValue").text(baronObj.days + "d " + baronObj.hours + "h " + baronObj.minutes + "m");
  1507. $(".toxicSpillLordValue").text(lordObj.days + "d " + lordObj.hours + "h " + lordObj.minutes + "m");
  1508. $(".toxicSpillKnightValue").text(knightObj.days + "d " + knightObj.hours + "h " + knightObj.minutes + "m");
  1509. $(".toxicSpillHeroValue").text(heroObj.days + "d " + heroObj.hours + "h " + heroObj.minutes + "m");
  1510. //https://mhwiki.hitgrab.com/wiki/index.php/Toxic_Spill#Pollution_Levels
  1511. }
  1512.  
  1513. function spillLevel(days, hours, minutes) {
  1514. this.days = days;
  1515. this.hours = hours;
  1516. this.minutes = minutes;
  1517. }
  1518.  
  1519. $(document).on('change', '#toxicSpillCb', function() {
  1520. if (this.checked) {
  1521. localStorage.setItem('RemindSpill', "Y")
  1522. this.checked = "Yes";
  1523. } else {
  1524. localStorage.setItem('RemindSpill', "N")
  1525. this.checked = "";
  1526. }
  1527. })
  1528. //============================================================================================
  1529. function todayNow() {
  1530. var today = new Date();
  1531. var todayEpoch = today.getTime() / 1000.0;
  1532. return todayEpoch;
  1533. }
  1534.  
  1535. function convertToDyHrMn(days, hours, minutes) {
  1536. if (hours >= 24) {
  1537. var daysExact = hours / 24;
  1538. var daysTrunc = Math.floor(daysExact);
  1539. var partialDays = daysExact - daysTrunc;
  1540. hours = Math.floor(partialDays * 24);
  1541. days = daysTrunc + days;
  1542. }
  1543. return {
  1544. days,
  1545. hours,
  1546. minutes
  1547. }
  1548. }
  1549.  
  1550. function travelToGrove() {
  1551. app.pages.TravelPage.travel("forbidden_grove");
  1552. }
  1553.  
  1554. function travelToCove() {
  1555. app.pages.TravelPage.travel("balacks_cove");
  1556. }
  1557.  
  1558. function travelToGarden() {
  1559. app.pages.TravelPage.travel("seasonal_garden");
  1560. }
  1561.  
  1562. function travelToSpill(destination) {
  1563. app.pages.TravelPage.travel("pollution_outbreak");
  1564. }