From 9dc96c51cb4649d77d09f630a471c30d44876bf3 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Thu, 21 Jun 2018 13:00:33 -0400 Subject: [PATCH 1/2] moved all tor-html related code to one place, hurray for decoupling --- src/Location.js | 4 ++++ src/Prestige.js | 3 --- src/engine.js | 7 ------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Location.js b/src/Location.js index 4b7a15e25..91dbed70d 100644 --- a/src/Location.js +++ b/src/Location.js @@ -280,7 +280,11 @@ function displayLocationContent() { purchase512gb.innerHTML = "Purchase 512GB Server - $" + formatNumber(512*CONSTANTS.BaseCostFor1GBOfRamServer, 2); purchase1tb.innerHTML = "Purchase 1TB Server - $" + formatNumber(1024*CONSTANTS.BaseCostFor1GBOfRamServer, 2); if (!SpecialServerIps.hasOwnProperty("Darkweb Server")) { + purchaseTor.setAttribute("class", "a-link-button"); purchaseTor.innerHTML = "Purchase TOR Router - $" + formatNumber(CONSTANTS.TorRouterCost, 2); + } else { + purchaseTor.setAttribute("class", "a-link-button-bought"); + purchaseTor.innerHTML = "TOR Router - Purchased"; } diff --git a/src/Prestige.js b/src/Prestige.js index 7d3929cc8..78476cf1d 100644 --- a/src/Prestige.js +++ b/src/Prestige.js @@ -191,9 +191,6 @@ function prestigeSourceFile() { } homeComp.cpuCores = 1; - //Darkweb is purchase-able - document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button"); - //Reset favor for Companies for (var member in Companies) { if (Companies.hasOwnProperty(member)) { diff --git a/src/engine.js b/src/engine.js index 02c8b850a..cd282bdc9 100644 --- a/src/engine.js +++ b/src/engine.js @@ -1726,13 +1726,6 @@ let Engine = { Player.sourceFiles[sfIndex].lvl=sfLvl; } }); - - //If DarkWeb already purchased, disable the button - if (SpecialServerIps.hasOwnProperty("Darkweb Server")) { - const purchaseTor = document.getElementById("location-purchase-tor"); - purchaseTor.setAttribute("class", "a-link-button-bought"); - purchaseTor.innerHTML = "TOR Router - Purchased"; - } }, /* Initialization */ From 8f30a2246ca01c8064bff3c2b6f0919e4cb0501e Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Thu, 21 Jun 2018 13:52:34 -0400 Subject: [PATCH 2/2] using classList instead of setAttributes --- src/Location.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Location.js b/src/Location.js index 91dbed70d..ba2b70309 100644 --- a/src/Location.js +++ b/src/Location.js @@ -280,10 +280,12 @@ function displayLocationContent() { purchase512gb.innerHTML = "Purchase 512GB Server - $" + formatNumber(512*CONSTANTS.BaseCostFor1GBOfRamServer, 2); purchase1tb.innerHTML = "Purchase 1TB Server - $" + formatNumber(1024*CONSTANTS.BaseCostFor1GBOfRamServer, 2); if (!SpecialServerIps.hasOwnProperty("Darkweb Server")) { - purchaseTor.setAttribute("class", "a-link-button"); + purchaseTor.classList.add("a-link-button"); + purchaseTor.classList.remove("a-link-button-bought"); purchaseTor.innerHTML = "Purchase TOR Router - $" + formatNumber(CONSTANTS.TorRouterCost, 2); } else { - purchaseTor.setAttribute("class", "a-link-button-bought"); + purchaseTor.classList.remove("a-link-button"); + purchaseTor.classList.add("a-link-button-bought"); purchaseTor.innerHTML = "TOR Router - Purchased"; }