mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 13:43:49 +01:00
Refactored Dialog boxes so that an infinite amount can be opened
This commit is contained in:
parent
70e52553dd
commit
b53abeb280
@ -12,20 +12,43 @@
|
||||
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
||||
}
|
||||
|
||||
#dialog-box-content {
|
||||
z-index: 1;
|
||||
/*
|
||||
.dialog-box-container {
|
||||
display: block;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
margin: auto;
|
||||
width: 50%;
|
||||
height: 100%;
|
||||
vertical-align: middle;
|
||||
overflow: auto;
|
||||
background-color: black;
|
||||
background-color: rgba(0,0,0,0.4);
|
||||
}
|
||||
*/
|
||||
.dialog-box-container {
|
||||
display: block;
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
/*margin: auto;*/
|
||||
width: 50%;
|
||||
height: auto;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
margin: -10% 0 0 -25%;
|
||||
overflow: auto;
|
||||
background-color: black;
|
||||
background-color: rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.dialog-box-content {
|
||||
z-index: 2;
|
||||
background-color: black;
|
||||
margin: 20% auto; /* 20% from the top and centered */
|
||||
padding: 10px;
|
||||
border: 5px solid #FFFFFF;
|
||||
width: 40%; /* Could be more or less, depending on screen size */
|
||||
}
|
||||
|
||||
.dialog-box-text {
|
||||
color: #66ff33;
|
||||
}
|
||||
|
||||
#dialog-box-close-button {
|
||||
.dialog-box-close-button {
|
||||
color: #aaa;
|
||||
float: right;
|
||||
font-size: 20px;
|
||||
@ -38,8 +61,8 @@
|
||||
box-shadow: 1px 1px 3px #000;
|
||||
}
|
||||
|
||||
#dialog-box-close-button:hover,
|
||||
#dialog-box-close-button:focus {
|
||||
.dialog-box-close-button:hover,
|
||||
.dialog-box-close-button:focus {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
|
16
index.html
16
index.html
@ -642,21 +642,7 @@
|
||||
<a id="location-slums-assassinate" class="a-link-button tooltip"> Assassinate </a>
|
||||
<a id="location-slums-heist" class="a-link-button tooltip"> Heist </a>
|
||||
</div>
|
||||
|
||||
<!-- Dialog Box, displays status text only -->
|
||||
<div id="dialog-box-container" class="popup-box-container">
|
||||
<div id="dialog-box-content" class="dialog-box">
|
||||
<span id="dialog-box-close-button">×</span>
|
||||
<p id="dialog-box-text-1" class="dialog-box-text"> </p>
|
||||
<br>
|
||||
<p id="dialog-box-text-2" class="dialog-box-text"> </p>
|
||||
<br>
|
||||
<p id="dialog-box-text-3" class="dialog-box-text"> </p>
|
||||
<br>
|
||||
<p id="dialog-box-text-4" class="dialog-box-text"> </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Purchase Server Pop-up Box -->
|
||||
<div id="purchase-server-box-container" class="popup-box-container">
|
||||
<div id="purchase-server-box-content">
|
||||
|
@ -17,7 +17,7 @@ PlayerObject.prototype.applyForJob = function(entryPosType) {
|
||||
|
||||
if (!this.isQualified(company, pos)) {
|
||||
var reqText = getJobRequirementText(company, pos);
|
||||
dialogBoxCreate("Unforunately, you do not qualify for this position", reqText);
|
||||
dialogBoxCreate("Unforunately, you do not qualify for this position<br>" + reqText);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ PlayerObject.prototype.applyForJob = function(entryPosType) {
|
||||
pos.positionName == currPositionName) {
|
||||
var nextPos = getNextCompanyPosition(pos);
|
||||
var reqText = getJobRequirementText(company, nextPos);
|
||||
dialogBoxCreate("Unfortunately, you do not qualify for a promotion", reqText);
|
||||
dialogBoxCreate("Unfortunately, you do not qualify for a promotion<br>" + reqText);
|
||||
|
||||
return; //Same job, do nothing
|
||||
}
|
||||
@ -77,7 +77,8 @@ PlayerObject.prototype.applyForJob = function(entryPosType) {
|
||||
this.companyPosition = pos;
|
||||
|
||||
if (leaveCompany) {
|
||||
dialogBoxCreate("Congratulations! You were offered a new job at " + this.companyName + " as a " + pos.positionName + "!",
|
||||
dialogBoxCreate("Congratulations! You were offered a new job at " + this.companyName + " as a " +
|
||||
pos.positionName + "!<br>" +
|
||||
"You lost 1000 reputatation at your old company " + oldCompanyName + " because you left.");
|
||||
} else {
|
||||
dialogBoxCreate("Congratulations! You were offered a new job at " + this.companyName + " as a " + pos.positionName + "!");
|
||||
@ -126,7 +127,7 @@ PlayerObject.prototype.applyForSecurityEngineerJob = function() {
|
||||
if (this.isQualified(company, CompanyPositions.SecurityEngineer)) {
|
||||
this.companyName = company.companyName;
|
||||
this.companyPosition = CompanyPositions.SecurityEngineer;
|
||||
dialogBoxCreate("Congratulations, you were offered a position at ", this.companyName, " as a Security Engineer!" , "");
|
||||
dialogBoxCreate("Congratulations, you were offered a position at ", this.companyName, " as a Security Engineer!");
|
||||
Engine.loadLocationContent();
|
||||
} else {
|
||||
dialogBoxCreate("Unforunately, you do not qualify for this position");
|
||||
|
@ -1,5 +1,5 @@
|
||||
CONSTANTS = {
|
||||
Version: "0.18.1",
|
||||
Version: "0.18.2",
|
||||
|
||||
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
|
||||
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
|
||||
|
@ -1617,7 +1617,7 @@ purchaseTorRouter = function() {
|
||||
|
||||
Player.getHomeComputer().serversOnNetwork.push(darkweb.ip);
|
||||
darkweb.serversOnNetwork.push(Player.getHomeComputer().ip);
|
||||
dialogBoxCreate("You have purchased a Tor router!", "You now have access to the dark web from your home computer", "Use the scan/netstat commands to search for the dark web connection.");
|
||||
dialogBoxCreate("You have purchased a Tor router!<br>You now have access to the dark web from your home computer<br>Use the scan/netstat commands to search for the dark web connection.");
|
||||
}
|
||||
|
||||
displayUniversityLocationContent = function(costMult) {
|
||||
|
@ -63,7 +63,7 @@ function runScriptsLoop() {
|
||||
var scriptName = errorTextArray[2];
|
||||
var errorMsg = errorTextArray[3];
|
||||
|
||||
dialogBoxCreate("Script runtime error: ", "Server Ip: " + serverIp, "Script name: " + scriptName, errorMsg);
|
||||
dialogBoxCreate("Script runtime error:<br>Server Ip: " + serverIp + "<br>Script name: " + scriptName + "<br>" + errorMsg);
|
||||
|
||||
//Find the corresponding workerscript and set its flags to kill it
|
||||
for (var i = 0; i < workerScripts.length; ++i) {
|
||||
@ -85,7 +85,7 @@ function runScriptsLoop() {
|
||||
var scriptName = errorTextArray[2];
|
||||
var errorMsg = errorTextArray[3];
|
||||
|
||||
dialogBoxCreate("Script runtime error: ", "Server Ip: " + serverIp, "Script name: " + scriptName, errorMsg);
|
||||
dialogBoxCreate("Script runtime error: <br>Server Ip: " + serverIp + "<br>Script name: " + scriptName + "<br>" + errorMsg);
|
||||
}
|
||||
w.running = false;
|
||||
w.env.stopFlag = true;
|
||||
@ -100,7 +100,7 @@ function runScriptsLoop() {
|
||||
var scriptName = errorTextArray[2];
|
||||
var errorMsg = errorTextArray[3];
|
||||
|
||||
dialogBoxCreate("Script runtime error: ", "Server Ip: " + serverIp, "Script name: " + scriptName, errorMsg);
|
||||
dialogBoxCreate("Script runtime error: <br>Server Ip: " + serverIp + "<br>Script name: " + scriptName + "<br>" + errorMsg);
|
||||
|
||||
//Find the corresponding workerscript and set its flags to kill it
|
||||
for (var i = 0; i < workerScripts.length; ++i) {
|
||||
|
@ -159,10 +159,46 @@ Script.prototype.reset = function() {
|
||||
this.onlineExpGained = 0;
|
||||
this.logs = [];
|
||||
|
||||
this.moneyStolenMap.reset();
|
||||
this.numTimesHackMap.reset();
|
||||
this.numTimesGrowMap.reset();
|
||||
this.numTimesWeakenMap.reset();
|
||||
if (this.moneyStolenMap != null) {
|
||||
try {
|
||||
this.moneyStolenMap.reset();
|
||||
} catch(e) {
|
||||
this.moneyStolenMap = null;
|
||||
}
|
||||
} else {
|
||||
this.moneyStolenMap = new AllServersMap();
|
||||
}
|
||||
|
||||
if (this.numTimesHackMap != null) {
|
||||
try {
|
||||
this.numTimesHackMap.reset();
|
||||
} catch(e) {
|
||||
this.numTimesHackMap = null;
|
||||
}
|
||||
} else {
|
||||
this.numTimesHackMap = new AllServersMap();
|
||||
}
|
||||
|
||||
if (this.numTimesGrowMap != null) {
|
||||
try {
|
||||
this.numTimesGrowMap.reset();
|
||||
} catch(e) {
|
||||
this.numTimesGrowMap = null;
|
||||
}
|
||||
} else {
|
||||
this.numTimesGrowMap = new AllServersMap();
|
||||
}
|
||||
|
||||
if (this.numTimesWeakenMap != null) {
|
||||
try {
|
||||
this.numTimesWeakenMap.reset();
|
||||
} catch(e) {
|
||||
this.numTimesWeakenMap = null;
|
||||
}
|
||||
} else {
|
||||
this.numTimesWeakenMap = new AllServersMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Updates how much RAM the script uses when it is running.
|
||||
@ -434,4 +470,15 @@ AllServersMap.prototype.printConsole = function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AllServersMap.prototype.toJSON = function() {
|
||||
return Generic_toJSON("AllServersMap", this);
|
||||
}
|
||||
|
||||
|
||||
AllServersMap.fromJSON = function(value) {
|
||||
return Generic_fromJSON(AllServersMap, value.data);
|
||||
}
|
||||
|
||||
Reviver.constructors.AllServersMap = AllServersMap;
|
@ -2,53 +2,55 @@
|
||||
|
||||
//Close dialog box when clicking outside
|
||||
$(document).click(function(event) {
|
||||
if (dialogBoxOpened) {
|
||||
if ( $(event.target).closest(".dialog-box").get(0) == null ) {
|
||||
dialogBoxClose();
|
||||
if (dialogBoxOpened) {
|
||||
if (!$(event.target).closest('.dialog-box-container').length){
|
||||
--dialogBoxCount;
|
||||
$(".dialog-box-container").remove();
|
||||
if (dialogBoxCount == 0) {
|
||||
dialogBoxOpened = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Dialog box close buttons
|
||||
$(document).on('click', '.dialog-box-close-button', function( event ) {
|
||||
console.log("clicked close button");
|
||||
if (dialogBoxOpened) {
|
||||
$(this).closest('.dialog-box-container').remove();
|
||||
--dialogBoxCount;
|
||||
if (dialogBoxCount == 0) {
|
||||
dialogBoxOpened = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var dialogBoxOpened = false;
|
||||
function dialogBoxInit() {
|
||||
var closeButton = document.getElementById("dialog-box-close-button");
|
||||
var dialogBoxCount = 0;
|
||||
|
||||
dialogBoxCreate = function(txt) {
|
||||
console.log("created");
|
||||
var container = document.createElement("div");
|
||||
container.setAttribute("class", "dialog-box-container");
|
||||
|
||||
var content = document.createElement("div");
|
||||
content.setAttribute("class", "dialog-box-content");
|
||||
|
||||
var closeButton = document.createElement("span");
|
||||
closeButton.setAttribute("class", "dialog-box-close-button");
|
||||
closeButton.innerHTML = "×"
|
||||
|
||||
var textE = document.createElement("p");
|
||||
textE.innerHTML = txt;
|
||||
|
||||
content.appendChild(closeButton);
|
||||
content.appendChild(textE);
|
||||
container.appendChild(content);
|
||||
|
||||
document.body.appendChild(container);
|
||||
|
||||
//Close Dialog box
|
||||
closeButton.addEventListener("click", function() {
|
||||
dialogBoxClose();
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", dialogBoxInit, false);
|
||||
|
||||
dialogBoxClose = function() {
|
||||
dialogBoxOpened = false;
|
||||
var dialogBox = document.getElementById("dialog-box-container");
|
||||
dialogBox.style.display = "none";
|
||||
}
|
||||
|
||||
dialogBoxOpen = function() {
|
||||
var dialogBox = document.getElementById("dialog-box-container");
|
||||
dialogBox.style.display = "block";
|
||||
setTimeout(function() {
|
||||
dialogBoxOpened = true;
|
||||
++dialogBoxCount;
|
||||
}, 500);
|
||||
|
||||
}
|
||||
|
||||
dialogBoxSetText = function(txt1, txt2="", txt3="", txt4="") {
|
||||
var dialogBoxText1 = document.getElementById("dialog-box-text-1");
|
||||
var dialogBoxText2 = document.getElementById("dialog-box-text-2");
|
||||
var dialogBoxText3 = document.getElementById("dialog-box-text-3");
|
||||
var dialogBoxText4 = document.getElementById("dialog-box-text-4");
|
||||
dialogBoxText1.innerHTML = txt1;
|
||||
dialogBoxText2.innerHTML = txt2;
|
||||
dialogBoxText3.innerHTML = txt3;
|
||||
dialogBoxText4.innerHTML = txt4;
|
||||
}
|
||||
|
||||
dialogBoxCreate = function(txt1, txt2="", txt3="", txt4="") {
|
||||
dialogBoxSetText(txt1, txt2, txt3, txt4);
|
||||
dialogBoxOpen();
|
||||
}
|
Loading…
Reference in New Issue
Block a user