mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 01:23:49 +01:00
Addded Perk class, Traveling functionality, fixed bugs with script logging and terminal commands
This commit is contained in:
parent
3ecbed1351
commit
52297268f6
@ -56,11 +56,17 @@ TESTING TODO:
|
||||
Augmentations
|
||||
|
||||
Make it so that a script cannot be edited if it is running
|
||||
|
||||
+ Traveling
|
||||
|
||||
Script logging functionality? Logs to internal "log file" (property of script itself)
|
||||
Can see log with tail.
|
||||
Should add something where if you click it in the "Active Scripts" GUI you can see the logs too
|
||||
|
||||
Seems to work fine
|
||||
Tasks TODO:
|
||||
New server hostname in Purchase Server Pop-up Box needs limits..don't think the ones set in HTML work
|
||||
|
||||
Tutorial and help - INTERACTIVE TUTORIAL
|
||||
Secret Servers
|
||||
|
||||
@ -68,7 +74,7 @@ Tasks TODO:
|
||||
|
||||
Create new menu page for purchased servers
|
||||
|
||||
Gyms + Traveling
|
||||
Gyms - Later..don't need for MVP
|
||||
|
||||
Update CONSTANTS.HelpText
|
||||
Account for Max possible int when gaining exp (it will overflow)
|
||||
|
14
index.html
14
index.html
@ -22,6 +22,7 @@
|
||||
<script src="utils/PurchaseServerBox.js"></script>
|
||||
<script src="utils/FactionInvitationBox.js"></script>
|
||||
<script src="utils/PurchaseAugmentationBox.js"></script>
|
||||
<script src="utils/TravelBox.js"></script>
|
||||
|
||||
<!-- Netscript -->
|
||||
<script src="src/netscript/NetScriptWorker.js"></script>
|
||||
@ -45,6 +46,7 @@
|
||||
<script src="src/PurchaseServers.js"></script>
|
||||
<script src="src/CreateProgram.js"></script>
|
||||
<script src="src/Augmentations.js"></script>
|
||||
<script src="src/Perk.js"></script>
|
||||
|
||||
<script src="src/engine.js"></script>
|
||||
|
||||
@ -466,6 +468,9 @@
|
||||
<a href="#" id="location-purchase-1tb" class="a-link-button"> Purchase 1TB Server - $600,000,000</a>
|
||||
|
||||
<!-- Travel agency -->
|
||||
<p id="location-travel-agency-text">
|
||||
From here, you can travel to any other city! A ticket costs $1,000,000.
|
||||
</p>
|
||||
<a href="#" id="location-travel-to-aevum" class="a-link-button"> Travel to Aevum </a>
|
||||
<a href="#" id="location-travel-to-chongqing" class="a-link-button"> Travel to Chongqing</a>
|
||||
<a href="#" id="location-travel-to-sector12" class="a-link-button"> Travel to Sector-12</a>
|
||||
@ -495,6 +500,15 @@
|
||||
<span id="purchase-server-box-cancel"> Cancel </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Travel Pop-up Box -->
|
||||
<div id="travel-box-container">
|
||||
<div id="travel-box-content".
|
||||
<p id="travel-box-text"> </p>
|
||||
<span id="travel-box-confirm"> Yes </span>
|
||||
<span id="travel-box-cancel"> No </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Purchase Augmentation Pop-up Box -->
|
||||
<div id="purchase-augmentation-box-container">
|
||||
|
@ -34,7 +34,7 @@ CONSTANTS = {
|
||||
"rm Delete a script/program from the machine. (WARNING: Permanent)<br>" +
|
||||
"run [script/program] Execute a program or a script<br>" +
|
||||
"scan See 'netstat' command<br>" +
|
||||
"tail [script] Display script logs (logs contain details about active scripts)"
|
||||
"tail [script] Display script logs (logs contain details about active scripts)" +
|
||||
"telnet [ip/hostname] See 'connect' command<br>" +
|
||||
"top Display all running scripts and their RAM usage<br>",
|
||||
|
||||
@ -64,7 +64,7 @@ CONSTANTS = {
|
||||
"will have very high security and will need many ports opened. In order to open ports on another " +
|
||||
"server, you will need to run programs that attack the server to open specific ports. These programs " +
|
||||
"can be coded once your hacking skill gets high enough, or they can be purchased if you can find " +
|
||||
"a seller. <br><br>"
|
||||
"a seller. <br><br>" +
|
||||
"In order to determine how many ports need to be opened to successfully NUKE a server, connect to " +
|
||||
"that server and run the 'analyze' command. This will also show you which ports have already been " +
|
||||
"opened. <br>" +
|
||||
@ -95,7 +95,7 @@ CONSTANTS = {
|
||||
"ps - Displays all scripts that are actively running on the current server<br>" +
|
||||
"run [script] - Run a script <br>" +
|
||||
"tail [script] - Displays a script's logs<br>" +
|
||||
"top - Displays all active scripts and their RAM usage <br><br>"
|
||||
"top - Displays all active scripts and their RAM usage <br><br>",
|
||||
TutorialTravelingText:"There are six major cities in the world that you are able to travel to: <br> " +
|
||||
" Aevum<br>" +
|
||||
" Chongqing<br>" +
|
||||
@ -105,7 +105,7 @@ CONSTANTS = {
|
||||
" Volhaven<br>" +
|
||||
"To travel between cities, visit your current city's travel agency through the 'World' page. " +
|
||||
"From the travel agency you can travel to any other city. Doing so costs money. <br>" +
|
||||
"Each city has its own set of companies and unique locations. "
|
||||
"Each city has its own set of companies and unique locations. ",
|
||||
TutorialJobsText: "Hacking is not the only way to gain money and experience! Located around the world are many " +
|
||||
"different companies which you can work for. By working for a company you can earn money, " +
|
||||
"train your various labor skills, and unlock powerful passive perks. <br> " +
|
||||
@ -122,7 +122,7 @@ CONSTANTS = {
|
||||
"other actions such as using your terminal or visiting other locations (However, note that any scripts you have " +
|
||||
"running on servers will continue to run as you work!). It is possible to cancel your work shift before the " +
|
||||
"8 hours is up, but doing so will result in you gaining only half of all of the money, experience, and reputation " +
|
||||
"that you had earned up to that point. <br>"
|
||||
"that you had earned up to that point. <br>" +
|
||||
"As you continue to work at a company, you will gain more and more reputation at that company. When your stats " +
|
||||
"and reputation are high enough, you can get a promotion. You can apply for a promotion on the company page, just like " +
|
||||
"you applied for the job originally. Higher positions at a company provide better salaries and stat gains",
|
||||
|
@ -30,7 +30,7 @@ function displayCreateProgramContent() {
|
||||
portHackALink.style.display = "block";
|
||||
portHackALink.addEventListener("click", function() {
|
||||
createProgram(Programs.PortHackProgram);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//BruteSSH
|
||||
@ -39,7 +39,7 @@ function displayCreateProgramContent() {
|
||||
bruteSshALink.style.display = "block";
|
||||
bruteSshALink.addEventListener("click", function() {
|
||||
createProgram(Programs.BruteSSHProgram);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//FTPCrack
|
||||
@ -48,34 +48,34 @@ function displayCreateProgramContent() {
|
||||
ftpCrackALink.style.display = "block";
|
||||
ftpCrackALink.addEventListener("click", function() {
|
||||
createProgram(Programs.FTPCrackProgram);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//relaySMTP
|
||||
if (Player.getHomeComputer().programs.indexOf(Programs.RelaySMTPProgram == -1 &&
|
||||
if (Player.getHomeComputer().programs.indexOf(Programs.RelaySMTPProgram) == -1 &&
|
||||
Player.hacking_skill >= 300) {
|
||||
relaySmtpALink.style.display = "block";
|
||||
relaySmtpAlink.addEventListener("click", function() {
|
||||
createProgram(Programs.RelaySMTPProgram);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//HTTPWorm
|
||||
if (Player.getHomeComputer().programs.indexOf(Programs.HTTPWormProgram == -1 &&
|
||||
if (Player.getHomeComputer().programs.indexOf(Programs.HTTPWormProgram) == -1 &&
|
||||
Player.hacking_skill >= 500) {
|
||||
httpWormALink.style.display = "block";
|
||||
httpWormALink.addEventListener("click", function() {
|
||||
createProgram(Programs.HTTPWormProgram);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//SQLInject
|
||||
if (Player.getHomeComputer().programs.indexOf(Programs.SQLInjectProgram == -1 &&
|
||||
if (Player.getHomeComputer().programs.indexOf(Programs.SQLInjectProgram) == -1 &&
|
||||
Player.hacking_skill >= 750) {
|
||||
sqlInjectALink.style.display = "block";
|
||||
sqlInjectALink.addEventListener("click", function() {
|
||||
createProgram(Programs.SQLInjectProgram);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,6 +116,7 @@ displayLocationContent = function() {
|
||||
var purchase512gb = document.getElementById("location-purchase-512gb");
|
||||
var purchase1tb = document.getElementById("location-purchase-1tb");
|
||||
|
||||
var travelAgencyText = document.getElementById("location-travel-agency-text");
|
||||
var travelToAevum = document.getElementById("location-travel-to-aevum");
|
||||
var travelToChongqing = document.getElementById("location-travel-to-chongqing");
|
||||
var travelToSector12 = document.getElementById("location-travel-to-sector12");
|
||||
@ -173,6 +174,7 @@ displayLocationContent = function() {
|
||||
purchase512gb.style.display = "none";
|
||||
purchase1tb.style.display = "none";
|
||||
|
||||
travelAgencyText.style.display = "none";
|
||||
travelToAevum.style.display = "none";
|
||||
travelToChongqing.style.display = "none";
|
||||
travelToSector12.style.display = "none";
|
||||
@ -221,6 +223,7 @@ displayLocationContent = function() {
|
||||
|
||||
switch (loc) {
|
||||
case Locations.AevumTravelAgency:
|
||||
travelAgencyText.style.display = "block";
|
||||
travelToChongqing.style.display = "block";
|
||||
travelToSector12.style.display = "block";
|
||||
travelToNewTokyo.style.display = "block";
|
||||
@ -356,6 +359,7 @@ displayLocationContent = function() {
|
||||
break;
|
||||
|
||||
case Locations.ChongqingTravelAgency:
|
||||
travelAgencyText.style.display = "block";
|
||||
travelToAevum.style.display = "block";
|
||||
travelToSector12.style.display = "block";
|
||||
travelToNewTokyo.style.display = "block";
|
||||
@ -387,6 +391,7 @@ displayLocationContent = function() {
|
||||
|
||||
|
||||
case Locations.Sector12TravelAgency:
|
||||
travelAgencyText.style.display = "block";
|
||||
travelToAevum.style.display = "block";
|
||||
travelToChongqing.style.display = "block";
|
||||
travelToNewTokyo.style.display = "block";
|
||||
@ -528,6 +533,7 @@ displayLocationContent = function() {
|
||||
break;
|
||||
|
||||
case Locations.NewTokyoTravelAgency:
|
||||
travelAgencyText.style.display = "block";
|
||||
travelToAevum.style.display = "block";
|
||||
travelToChongqing.style.display = "block";
|
||||
travelToSector12.style.display = "block";
|
||||
@ -573,7 +579,8 @@ displayLocationContent = function() {
|
||||
break;
|
||||
|
||||
|
||||
case Locations.IshimaTravelAgency:
|
||||
case Locations.IshimaTravelAgency:
|
||||
travelAgencyText.style.display = "block";
|
||||
travelToAevum.style.display = "block";
|
||||
travelToChongqing.style.display = "block";
|
||||
travelToSector12.style.display = "block";
|
||||
@ -624,8 +631,7 @@ displayLocationContent = function() {
|
||||
break;
|
||||
|
||||
case Locations.VolhavenTravelAgency:
|
||||
locationInfo.innerHTML = Companies[loc].info;
|
||||
|
||||
travelAgencyText.style.display = "block";
|
||||
travelToAevum.style.display = "block";
|
||||
travelToChongqing.style.display = "block";
|
||||
travelToSector12.style.display = "block";
|
||||
@ -1225,4 +1231,40 @@ initLocationButtons = function() {
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
travelToAevum.addEventListener("click", function() {
|
||||
travelBoxCreate(Locations.Aevum, 1000000);
|
||||
});
|
||||
|
||||
travelToChongqing.addEventListener("click", function() {
|
||||
travelBoxCreate(Locations.Chongqing, 1000000);
|
||||
});
|
||||
|
||||
travelToSector12.addEventListener("click", function() {
|
||||
travelBoxCreate(Locations.Sector12, 1000000);
|
||||
});
|
||||
|
||||
travelToNewTokyo.addEventListener("click", function() {
|
||||
travelBoxCreate(Locations.NewTokyo, 1000000);
|
||||
});
|
||||
|
||||
travelToIshima.addEventListener("click", function() {
|
||||
travelBoxCreate(Locations.Ishima, 1000000);
|
||||
});
|
||||
|
||||
travelToVolhaven.addEventListener("click", function() {
|
||||
travelBoxCreate(Locations.Volhaven, 1000000);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
travelToCity = function(destCityName, cost) {
|
||||
if (cost > Player.money) {
|
||||
dialogBoxCreate("You cannot afford to travel to " + destCityName);
|
||||
return;
|
||||
}
|
||||
Player.money -= cost;
|
||||
|
||||
Player.city = destCityName;
|
||||
dialogBoxCreate("You are now in " + destCityName + "!");
|
||||
Engine.loadWorldContent();
|
||||
}
|
@ -1,7 +1,4 @@
|
||||
/* Worker code, contains Netscript scripts that are actually running */
|
||||
//TODO Need some way to stop scripts. Idea: Put a flag in the environment, we can setActive
|
||||
//this flag from outside. If the evaluate() function sees that flag it rejects the current
|
||||
// Promise. We can catch that rejection and stop the script.
|
||||
/* Worker code, contains Netscript scripts that are actually running */
|
||||
|
||||
//TODO Tested For and while and generic call statements. Have not tested if statements
|
||||
|
||||
|
@ -61,8 +61,8 @@ function PlayerObject() {
|
||||
|
||||
//Money
|
||||
this.money = 0;
|
||||
this.total_money = 0;
|
||||
this.lifetime_money = 0;
|
||||
this.total_money = 0; //Total money ever earned
|
||||
this.lifetime_money = 0; //Total money ever earned
|
||||
|
||||
//IP Address of Starting (home) computer
|
||||
this.homeComputer = "";
|
||||
@ -140,7 +140,7 @@ PlayerObject.prototype.init = function() {
|
||||
this.currentServer = t_homeComp.ip;
|
||||
AddToAllServers(t_homeComp);
|
||||
|
||||
this.getHomeComputer().programs.push(CONSTANTS.PortHackProgram);
|
||||
this.getHomeComputer().programs.push(Programs.NukeProgram);
|
||||
}
|
||||
|
||||
PlayerObject.prototype.getCurrentServer = function() {
|
||||
@ -648,7 +648,7 @@ PlayerObject.prototype.createProgramWork = function(numCycles) {
|
||||
var txt = document.getElementById("work-in-progress-text");
|
||||
txt.innerHTML = "You are currently working on coding " + programName + ".<br><br> " +
|
||||
"You have been working for " + convertTimeMsToTimeElapsedString(this.timeWorked) + "<br><br>" +
|
||||
"The program is " + (this.timeWorked / timeToComplete).toFixed(2) "% complete. <br>" +
|
||||
"The program is " + (this.timeWorked / timeToComplete).toFixed(2) + "% complete. <br>" +
|
||||
"If you cancel, you will lose all of your progress.";
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ purchaseServer = function(ram, cost) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var newServ = new Server();
|
||||
var hostname = document.getElementById("purchase-server-box-input").value;
|
||||
if (hostname == "") {
|
||||
|
@ -68,7 +68,7 @@ function Script() {
|
||||
this.code = "";
|
||||
this.ramUsage = 0;
|
||||
this.server = ""; //IP of server this script is on
|
||||
this.log = []; //Script logging. Array of strings, with each element being a log entry
|
||||
this.logs = []; //Script logging. Array of strings, with each element being a log entry
|
||||
|
||||
/* Properties to calculate offline progress. Only applies for infinitely looping scripts */
|
||||
|
||||
@ -127,18 +127,18 @@ Script.prototype.updateRamUsage = function() {
|
||||
}
|
||||
|
||||
Script.prototype.log = function(txt) {
|
||||
if (this.log.length > CONSTANTS.MaxLogCapacity) {
|
||||
if (this.logs.length > CONSTANTS.MaxLogCapacity) {
|
||||
//Delete first element and add new log entry to the end.
|
||||
//TODO Eventually it might be better to replace this with circular array
|
||||
//to improve performance
|
||||
this.log.shift();
|
||||
this.logs.shift();
|
||||
}
|
||||
this.log.push(txt);
|
||||
this.logs.push(txt);
|
||||
}
|
||||
|
||||
Script.prototype.displayLog = function() {
|
||||
for (var i = 0; i < this.log.length; ++i) {
|
||||
post(this.log[i]);
|
||||
for (var i = 0; i < this.logs.length; ++i) {
|
||||
post(this.logs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,8 +140,8 @@ var Terminal = {
|
||||
post("Estimated chance to hack: " + Math.round(Player.calculateHackingChance() * 100) + "%");
|
||||
post("Estimated time to hack: " + Math.round(Player.calculateHackingTime()) + " seconds");
|
||||
post("Estimed total money available on server: $" + Player.getCurrentServer().moneyAvailable);
|
||||
post("Required number of open ports for NUKE: " +Player.getCurrentServer().numOpenPortsRequired);
|
||||
if (Player.getCurrentServer().sshPortOpen) {
|
||||
post("Required number of open ports for NUKE: " + Player.getCurrentServer().numOpenPortsRequired);
|
||||
if (Player.getCurrentServer().sshPortOpen) {
|
||||
post("SSH port: Open")
|
||||
} else {
|
||||
post("SSH port: Closed")
|
||||
@ -425,10 +425,10 @@ var Terminal = {
|
||||
//TODO
|
||||
break;
|
||||
case "tail":
|
||||
if (commandArray.length != 1) {
|
||||
if (commandArray.length != 2) {
|
||||
post("Incorrect number of arguments. Usage: tail [script]");
|
||||
} else {
|
||||
var scriptName == commandArray[1];
|
||||
var scriptName = commandArray[1];
|
||||
|
||||
//Can only tail script files
|
||||
if (scriptName.endsWith(".script") == false) {
|
||||
@ -438,8 +438,9 @@ var Terminal = {
|
||||
//Check that the script exists on this machine
|
||||
var currScripts = Player.getCurrentServer().scripts;
|
||||
for (var i = 0; i < currScripts.length; ++i) {
|
||||
if (scriptName == currScripts[i]) {
|
||||
if (scriptName == currScripts[i].filename) {
|
||||
currScripts[i].displayLog();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -424,7 +424,7 @@ var Engine = {
|
||||
|
||||
//Online
|
||||
var onlineTotalMoneyMade = "Total online production: $" + workerscript.scriptRef.onlineMoneyMade.toFixed(2);
|
||||
var onlineTotalExpEarned = (Array(26).join(" ") + workerScript.scriptRef.onlineExpGained.toFixed(2) + " exp").replace( / /g, " ");
|
||||
var onlineTotalExpEarned = (Array(26).join(" ") + workerscript.scriptRef.onlineExpGained.toFixed(2) + " exp").replace( / /g, " ");
|
||||
|
||||
var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime;
|
||||
var onlineMpsText = "Online production rate: $" + onlineMps.toFixed(2) + "/second";
|
||||
@ -432,8 +432,8 @@ var Engine = {
|
||||
var onlineEpsText = (Array(25).join(" ") + onlineEps.toFixed(4) + " exp/second").replace( / /g, " ");
|
||||
|
||||
//Offline
|
||||
var offlineTotalMoneyMade = "Total offline production: $" + workerScript.scriptRef.offlineMoneyMade.toFixed(2);
|
||||
var offlineTotalExpEarned = (Array(27).join(" ") + workerScript.scriptRef.offlineExpGained.toFixed(2) + " exp").replace( / /g, " ");
|
||||
var offlineTotalMoneyMade = "Total offline production: $" + workerscript.scriptRef.offlineMoneyMade.toFixed(2);
|
||||
var offlineTotalExpEarned = (Array(27).join(" ") + workerscript.scriptRef.offlineExpGained.toFixed(2) + " exp").replace( / /g, " ");
|
||||
|
||||
var offlineMps = workerscript.scriptRef.offlineMoneyMade / workerscript.scriptRef.offlineRunningTime;
|
||||
var offlineMpsText = "Offline production rate: $" + offlineMps.toFixed(2) + "/second";
|
||||
@ -503,7 +503,7 @@ var Engine = {
|
||||
Engine.Clickables.tutorialFactionsButton.style.display = "block";
|
||||
Engine.Clickables.tutorialAugmentationsButton.style.display = "block";
|
||||
|
||||
Engine.CLickables.tutorialBackButton.style.display = "none";
|
||||
Engine.Clickables.tutorialBackButton.style.display = "none";
|
||||
document.getElementById("tutorial-text").style.display = "none";
|
||||
},
|
||||
|
||||
@ -518,7 +518,7 @@ var Engine = {
|
||||
Engine.Clickables.tutorialFactionsButton.style.display = "none";
|
||||
Engine.Clickables.tutorialAugmentationsButton.style.display = "none";
|
||||
|
||||
Engine.Clickables.tutorialBackButton.style.display = "block";
|
||||
Engine.Clickables.tutorialBackButton.style.display = "inline-block";
|
||||
document.getElementById("tutorial-text").style.display = "block";
|
||||
document.getElementById("tutorial-text").innerHTML = text;
|
||||
},
|
||||
@ -577,7 +577,7 @@ var Engine = {
|
||||
Counters: {
|
||||
autoSaveCounter: 300, //Autosave every minute
|
||||
updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance
|
||||
updateDisplays: 10, //Update displays such as Active Scripts display and character display
|
||||
updateDisplays: 5, //Update displays such as Active Scripts display and character display
|
||||
serverGrowth: 450, //Process server growth every minute and a half
|
||||
checkFactionInvitations: 1500, //Check whether you qualify for any faction invitations every 5 minutes
|
||||
},
|
||||
@ -610,7 +610,7 @@ var Engine = {
|
||||
Engine.displayCharacterInfo();
|
||||
}
|
||||
|
||||
Engine.Counters.updateDisplays = 10;
|
||||
Engine.Counters.updateDisplays = 5;
|
||||
}
|
||||
|
||||
if (Engine.Counters.serverGrowth <= 0) {
|
||||
|
46
utils/TravelBox.js
Normal file
46
utils/TravelBox.js
Normal file
@ -0,0 +1,46 @@
|
||||
/* Pop up Purchase Server Box */
|
||||
function travelBoxInit() {
|
||||
if (Engine.Debug) {
|
||||
console.log("Travel box Initialized");
|
||||
}
|
||||
var cancelButton = document.getElementById("travel-box-cancel");
|
||||
|
||||
//Close Dialog box
|
||||
cancelButton.addEventListener("click", function() {
|
||||
travelBoxClose();
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", travelBoxInit, false);
|
||||
|
||||
travelBoxClose = function() {
|
||||
var travelBox = document.getElementById("travel-box-container");
|
||||
travelBox.style.display = "none";
|
||||
}
|
||||
|
||||
travelBoxOpen = function() {
|
||||
var travelBox = document.getElementById("travel-box-container");
|
||||
travelBox.style.display = "block";
|
||||
}
|
||||
|
||||
travelBoxSetText = function(txt) {
|
||||
var travelBoxText = document.getElementById("travel-box-text");
|
||||
travelBoxText.innerHTML = txt;
|
||||
}
|
||||
|
||||
travelBoxCreate = function(destCityName, cost) {
|
||||
travelBoxSetText("Would you like to travel to " + destCityName + "? The trip will cost $" + cost + ".");
|
||||
|
||||
//Clear old event listeners from Confirm button
|
||||
var confirmButton = document.getElementById("travel-box-confirm");
|
||||
var newConfirmButton = confirmButton.cloneNode(true);
|
||||
confirmButton.parentNode.replaceChild(newConfirmButton, confirmButton);
|
||||
newConfirmButton.addEventListener("click", function() {
|
||||
travelBoxClose();
|
||||
travelToCity(destCityName, cost);
|
||||
return false;
|
||||
});
|
||||
|
||||
travelBoxOpen();
|
||||
}
|
Loading…
Reference in New Issue
Block a user