mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 04:35:46 +01:00
[refactor] Moved 'createPopup' to its own TS file.
This commit is contained in:
parent
107f1de18d
commit
8c25684fe1
@ -13,12 +13,13 @@ import {createProgressBarText} from "../utils/helpers/creat
|
||||
import {dialogBoxCreate} from "../utils/DialogBox";
|
||||
import {addOffset, clearObject,
|
||||
removeChildrenFromElement,
|
||||
createPopup, appendLineBreaks,
|
||||
appendLineBreaks,
|
||||
removeElementById, removeElement} from "../utils/HelperFunctions";
|
||||
import {Reviver, Generic_toJSON,
|
||||
Generic_fromJSON} from "../utils/JSONReviver";
|
||||
import numeral from "numeral/min/numeral.min";
|
||||
import {createElement} from "../utils/uiHelpers/createElement";
|
||||
import {createPopup} from "../utils/uiHelpers/createPopup";
|
||||
import {exceptionAlert} from "../utils/helpers/exceptionAlert";
|
||||
import {formatNumber} from "../utils/StringHelperFunctions";
|
||||
import {getRandomInt} from "../utils/helpers/getRandomInt";
|
||||
|
@ -9,12 +9,13 @@ import Decimal from "decimal.js";
|
||||
import {dialogBoxCreate} from "../utils/DialogBox";
|
||||
import {removeElementById,
|
||||
createAccordionElement,
|
||||
removeChildrenFromElement, createPopup,
|
||||
removeChildrenFromElement,
|
||||
clearSelector} from "../utils/HelperFunctions";
|
||||
import {Reviver, Generic_toJSON,
|
||||
Generic_fromJSON} from "../utils/JSONReviver";
|
||||
import numeral from "numeral/min/numeral.min";
|
||||
import {createElement} from "../utils/uiHelpers/createElement";
|
||||
import {createPopup} from "../utils/uiHelpers/createPopup";
|
||||
import {formatNumber, generateRandomString} from "../utils/StringHelperFunctions";
|
||||
import {getRandomInt} from "../utils/helpers/getRandomInt";
|
||||
import {isString} from "../utils/helpers/isString";
|
||||
|
@ -7,9 +7,10 @@ import {dialogBoxCreate} from "../utils/DialogBox";
|
||||
import {Reviver, Generic_toJSON,
|
||||
Generic_fromJSON} from "../utils/JSONReviver";
|
||||
import {removeChildrenFromElement,
|
||||
createAccordionElement, createPopup,
|
||||
createAccordionElement,
|
||||
removeElementById, removeElement} from "../utils/HelperFunctions";
|
||||
import {createElement} from "../utils/uiHelpers/createElement";
|
||||
import {createPopup} from "../utils/uiHelpers/createPopup";
|
||||
import numeral from "numeral/min/numeral.min";
|
||||
import {formatNumber} from "../utils/StringHelperFunctions";
|
||||
import {getRandomInt} from "../utils/helpers/getRandomInt";
|
||||
|
@ -30,8 +30,9 @@ import {initStockMarket, initSymbolToStockMap,
|
||||
import {Terminal, postNetburnerText} from "./Terminal";
|
||||
import Decimal from "decimal.js";
|
||||
import {dialogBoxCreate} from "../utils/DialogBox";
|
||||
import {createPopup, removeElementById} from "../utils/HelperFunctions";
|
||||
import {removeElementById} from "../utils/HelperFunctions";
|
||||
import {createElement} from "../utils/uiHelpers/createElement";
|
||||
import {createPopup} from "../utils/uiHelpers/createPopup";
|
||||
import {exceptionAlert} from "../utils/helpers/exceptionAlert";
|
||||
import {yesNoBoxCreate, yesNoBoxGetYesButton,
|
||||
yesNoBoxGetNoButton, yesNoBoxClose} from "../utils/YesNoBox";
|
||||
|
@ -19,11 +19,11 @@ import {loadSpecialServerIps, SpecialServerIps} from "./SpecialServerIps";
|
||||
import {loadStockMarket, StockMarket} from "./StockMarket";
|
||||
import {dialogBoxCreate} from "../utils/DialogBox";
|
||||
import {gameOptionsBoxClose} from "../utils/GameOptions";
|
||||
import {clearEventListeners,
|
||||
createPopup, removeElementById} from "../utils/HelperFunctions";
|
||||
import {clearEventListeners, removeElementById} from "../utils/HelperFunctions";
|
||||
import {Reviver, Generic_toJSON,
|
||||
Generic_fromJSON} from "../utils/JSONReviver";
|
||||
import {createElement} from "../utils/uiHelpers/createElement";
|
||||
import {createPopup} from "../utils/uiHelpers/createPopup";
|
||||
import {formatNumber} from "../utils/StringHelperFunctions";
|
||||
|
||||
import Decimal from "decimal.js";
|
||||
|
@ -89,25 +89,6 @@ function getElementById(elementId) {
|
||||
return el;
|
||||
}
|
||||
|
||||
function createPopup(id, elems) {
|
||||
var container = createElement("div", {
|
||||
class:"popup-box-container",
|
||||
id:id,
|
||||
display:"block"
|
||||
}),
|
||||
content = createElement("div", {
|
||||
class:"popup-box-content",
|
||||
id:id + "-content",
|
||||
});
|
||||
|
||||
for (var i = 0; i < elems.length; ++i) {
|
||||
content.appendChild(elems[i]);
|
||||
}
|
||||
container.appendChild(content);
|
||||
document.getElementById("entire-game-container").appendChild(container);
|
||||
return container;
|
||||
}
|
||||
|
||||
//Creates both the header and panel element of an accordion and sets the click handler
|
||||
function createAccordionElement(params) {
|
||||
var li = document.createElement("li"),
|
||||
@ -186,6 +167,5 @@ export {sizeOfObject,
|
||||
createAccordionElement,
|
||||
appendLineBreaks,
|
||||
removeChildrenFromElement,
|
||||
createPopup,
|
||||
clearSelector,
|
||||
getElementById};
|
||||
|
32
utils/uiHelpers/createPopup.ts
Normal file
32
utils/uiHelpers/createPopup.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { createElement } from "./createElement";
|
||||
|
||||
/**
|
||||
* Creates the necessary DOM elements to present an in-game popup to the player.
|
||||
* @param id The (hopefully) unique identifier for the popup container.
|
||||
* @param elems The collection of HTML Elements to show within the popup.
|
||||
*/
|
||||
export function createPopup(id: string, elems: HTMLElement[]) {
|
||||
const container: HTMLDivElement = createElement("div", {
|
||||
class: "popup-box-container",
|
||||
display: "block",
|
||||
id,
|
||||
}) as HTMLDivElement;
|
||||
const content: HTMLElement = createElement("div", {
|
||||
class: "popup-box-content",
|
||||
id: `${id}-content`,
|
||||
});
|
||||
|
||||
for (const elem of elems) {
|
||||
content.appendChild(elem);
|
||||
}
|
||||
container.appendChild(content);
|
||||
const gameContainer: HTMLElement | null = document.getElementById("entire-game-container");
|
||||
|
||||
if (gameContainer === null) {
|
||||
throw new Error("Unable to find the game container. Something is *seriously* wrong...");
|
||||
}
|
||||
|
||||
gameContainer.appendChild(container);
|
||||
|
||||
return container;
|
||||
}
|
Loading…
Reference in New Issue
Block a user