mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
remove some now unused files
This commit is contained in:
parent
5f8de7e426
commit
d515db0842
@ -1,12 +0,0 @@
|
||||
import { createElement } from "./createElement";
|
||||
|
||||
/**
|
||||
* Appends the specified number of breaks (as children) to the specified element
|
||||
* @param el The element to add child break elements to.
|
||||
* @param n The number of breaks to add.
|
||||
*/
|
||||
export function appendLineBreaks(el: HTMLElement, n: number): void {
|
||||
for (let i = 0; i < n; ++i) {
|
||||
el.appendChild(createElement("br"));
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
/**
|
||||
* Clears all <option> elements from a <select>.
|
||||
* @param selector The <select> element
|
||||
*/
|
||||
export function clearSelector(selector: HTMLSelectElement): void {
|
||||
for (let i: number = selector.options.length - 1; i >= 0; i--) {
|
||||
selector.remove(i);
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
import { createElement } from "./createElement";
|
||||
|
||||
/**
|
||||
* Possible configuration parameters when creating the accordion element.
|
||||
*/
|
||||
interface IAccordionConfigurationParameters {
|
||||
/**
|
||||
* The HTML to appear in the accordion header.
|
||||
*/
|
||||
hdrText?: string;
|
||||
|
||||
/**
|
||||
* A (hopefully) unique identifier for the accordion.
|
||||
*/
|
||||
id?: string;
|
||||
|
||||
/**
|
||||
* The HTML to appear in the expanded accordion.
|
||||
*/
|
||||
panelText?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates both the header and panel element of an accordion and sets the click handler
|
||||
* @param params The creation parameters.
|
||||
*/
|
||||
export function createAccordionElement(params: IAccordionConfigurationParameters): any[] {
|
||||
const liElem: HTMLLIElement = createElement("li") as HTMLLIElement;
|
||||
const header: HTMLButtonElement = createElement("button", {
|
||||
class: "accordion-header",
|
||||
clickListener() {
|
||||
this.classList.toggle("active");
|
||||
const pnl: CSSStyleDeclaration = (this.nextElementSibling as HTMLDivElement).style;
|
||||
pnl.display = pnl.display === "block" ? "none" : "block";
|
||||
},
|
||||
id: params.id !== undefined ? `${params.id}-hdr` : undefined,
|
||||
innerHTML: params.hdrText,
|
||||
}) as HTMLButtonElement;
|
||||
const panel: HTMLDivElement = createElement("div", {
|
||||
class: "accordion-panel",
|
||||
id: params.id !== undefined ? `${params.id}-panel` : undefined,
|
||||
innerHTML: params.panelText,
|
||||
}) as HTMLDivElement;
|
||||
|
||||
liElem.appendChild(header);
|
||||
liElem.appendChild(panel);
|
||||
|
||||
return [liElem, header, panel];
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
import { createElement } from "./createElement";
|
||||
|
||||
export function createOptionElement(text: string, value = ""): HTMLOptionElement {
|
||||
let sanitizedValue: string = value;
|
||||
if (sanitizedValue === "") {
|
||||
sanitizedValue = text;
|
||||
}
|
||||
|
||||
return createElement("option", {
|
||||
text: text,
|
||||
value: sanitizedValue,
|
||||
}) as HTMLOptionElement;
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/**
|
||||
* Creates a Close/Cancel button that is used for removing popups
|
||||
*/
|
||||
|
||||
import { createElement } from "./createElement";
|
||||
import { removeElement } from "./removeElement";
|
||||
|
||||
interface ICreatePopupCloseButtonOptions {
|
||||
class?: string;
|
||||
display?: string;
|
||||
innerText?: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export function createPopupCloseButton(
|
||||
popup: Element | string,
|
||||
options: ICreatePopupCloseButtonOptions,
|
||||
): HTMLButtonElement {
|
||||
const button = createElement("button", {
|
||||
class: options.class ? options.class : "popup-box-button",
|
||||
display: options.display ? options.display : "inline-block",
|
||||
innerText: options.innerText == null ? "Cancel" : options.innerText,
|
||||
}) as HTMLButtonElement;
|
||||
|
||||
function closePopupWithEscFn(e: any): void {
|
||||
if (e.keyCode === 27) {
|
||||
button.click();
|
||||
}
|
||||
}
|
||||
|
||||
button.addEventListener("click", () => {
|
||||
if (popup instanceof Element) {
|
||||
removeElement(popup);
|
||||
} else {
|
||||
try {
|
||||
const popupEl = document.getElementById(popup);
|
||||
if (popupEl instanceof Element) {
|
||||
removeElement(popupEl);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`createPopupCloseButton() threw: ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
document.removeEventListener("keydown", closePopupWithEscFn);
|
||||
return false;
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", closePopupWithEscFn);
|
||||
|
||||
return button;
|
||||
}
|
Loading…
Reference in New Issue
Block a user