mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 12:27:07 +02:00
all the lints
This commit is contained in:
@@ -17,8 +17,8 @@ export const MainMenuHeaders: IMainMenuHeaders = {
|
||||
}
|
||||
|
||||
// Implements collapsible toggle feature when a header is clicked
|
||||
function toggleHeader(open: boolean, elems: HTMLElement[], links: HTMLElement[]) {
|
||||
for (var i = 0; i < elems.length; ++i) {
|
||||
function toggleHeader(open: boolean, elems: HTMLElement[], links: HTMLElement[]): void {
|
||||
for (let i = 0; i < elems.length; ++i) {
|
||||
if (open) {
|
||||
elems[i].style.opacity = "1";
|
||||
elems[i].style.maxHeight = elems[i].scrollHeight + "px";
|
||||
@@ -28,7 +28,7 @@ function toggleHeader(open: boolean, elems: HTMLElement[], links: HTMLElement[])
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < links.length; ++i) {
|
||||
for (let i = 0; i < links.length; ++i) {
|
||||
if (open) {
|
||||
links[i].style.opacity = "1";
|
||||
links[i].style.maxHeight = links[i].scrollHeight + "px";
|
||||
@@ -48,7 +48,7 @@ export function initializeMainMenuHeaders(p: IPlayer, dev = false): boolean {
|
||||
throw new Error(`Failed to find element with id ${id} in initializeMainMenuHeaders()`);
|
||||
}
|
||||
|
||||
return elem!;
|
||||
return elem;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -71,7 +71,7 @@ export function initializeMainMenuHeaders(p: IPlayer, dev = false): boolean {
|
||||
(this as any).classList.toggle("opened");
|
||||
|
||||
const elems: HTMLElement[] = [terminal, createScript, activeScripts, createProgram];
|
||||
const links: HTMLElement[] = [MainMenuLinks.Terminal!, MainMenuLinks.ScriptEditor!, MainMenuLinks.ActiveScripts!, MainMenuLinks.CreateProgram!];
|
||||
const links: HTMLElement[] = [MainMenuLinks.Terminal, MainMenuLinks.ScriptEditor, MainMenuLinks.ActiveScripts, MainMenuLinks.CreateProgram];
|
||||
if (terminal.style.maxHeight) {
|
||||
toggleHeader(false, elems, links);
|
||||
createProgramNot.style.display = "none";
|
||||
@@ -93,7 +93,7 @@ export function initializeMainMenuHeaders(p: IPlayer, dev = false): boolean {
|
||||
(this as any).classList.toggle("opened");
|
||||
|
||||
const elems: HTMLElement[] = [stats, factions, augmentations, hacknetnodes, sleeves];
|
||||
const links: HTMLElement[] = [MainMenuLinks.Stats!, MainMenuLinks.Factions!, MainMenuLinks.Augmentations!, MainMenuLinks.HacknetNodes!, MainMenuLinks.Sleeves!];
|
||||
const links: HTMLElement[] = [MainMenuLinks.Stats, MainMenuLinks.Factions, MainMenuLinks.Augmentations, MainMenuLinks.HacknetNodes, MainMenuLinks.Sleeves];
|
||||
if (stats.style.maxHeight) {
|
||||
toggleHeader(false, elems, links);
|
||||
} else {
|
||||
@@ -120,7 +120,7 @@ export function initializeMainMenuHeaders(p: IPlayer, dev = false): boolean {
|
||||
(this as any).classList.toggle("opened");
|
||||
|
||||
const elems: HTMLElement[] = [city, travel, job, stockmarket, bladeburner, corporation, gang];
|
||||
const links: HTMLElement[] = [MainMenuLinks.City!, MainMenuLinks.Travel!, MainMenuLinks.Job!, MainMenuLinks.StockMarket!, MainMenuLinks.Bladeburner!, MainMenuLinks.Corporation!, MainMenuLinks.Gang!];
|
||||
const links: HTMLElement[] = [MainMenuLinks.City, MainMenuLinks.Travel, MainMenuLinks.Job, MainMenuLinks.StockMarket, MainMenuLinks.Bladeburner, MainMenuLinks.Corporation, MainMenuLinks.Gang];
|
||||
if (city.style.maxHeight) {
|
||||
toggleHeader(false, elems, links);
|
||||
} else {
|
||||
@@ -136,7 +136,7 @@ export function initializeMainMenuHeaders(p: IPlayer, dev = false): boolean {
|
||||
(this as any).classList.toggle("opened");
|
||||
|
||||
const elems: HTMLElement[] = [milestones, tutorial, options];
|
||||
const links: HTMLElement[] = [MainMenuLinks.Milestones!, MainMenuLinks.Tutorial!, MainMenuLinks.Options!];
|
||||
const links: HTMLElement[] = [MainMenuLinks.Milestones, MainMenuLinks.Tutorial, MainMenuLinks.Options];
|
||||
|
||||
if (dev) {
|
||||
elems.push(safeGetElement("dev-tab"));
|
||||
|
||||
+49
-41
@@ -3,49 +3,55 @@
|
||||
import { clearEventListeners } from "../../../utils/uiHelpers/clearEventListeners";
|
||||
|
||||
interface IMainMenuLinks {
|
||||
Terminal: HTMLElement | null;
|
||||
ScriptEditor: HTMLElement | null;
|
||||
ActiveScripts: HTMLElement | null;
|
||||
CreateProgram: HTMLElement | null;
|
||||
Stats: HTMLElement | null;
|
||||
Factions: HTMLElement | null;
|
||||
Augmentations: HTMLElement | null;
|
||||
HacknetNodes: HTMLElement | null;
|
||||
Sleeves: HTMLElement | null;
|
||||
City: HTMLElement | null;
|
||||
Travel: HTMLElement | null;
|
||||
Job: HTMLElement | null;
|
||||
StockMarket: HTMLElement | null;
|
||||
Bladeburner: HTMLElement | null;
|
||||
Corporation: HTMLElement | null;
|
||||
Gang: HTMLElement | null;
|
||||
Milestones: HTMLElement | null;
|
||||
Tutorial: HTMLElement | null;
|
||||
Options: HTMLElement | null;
|
||||
DevMenu: HTMLElement | null;
|
||||
Terminal: HTMLElement;
|
||||
ScriptEditor: HTMLElement;
|
||||
ActiveScripts: HTMLElement;
|
||||
CreateProgram: HTMLElement;
|
||||
Stats: HTMLElement;
|
||||
Factions: HTMLElement;
|
||||
Augmentations: HTMLElement;
|
||||
HacknetNodes: HTMLElement;
|
||||
Sleeves: HTMLElement;
|
||||
City: HTMLElement;
|
||||
Travel: HTMLElement;
|
||||
Job: HTMLElement;
|
||||
StockMarket: HTMLElement;
|
||||
Bladeburner: HTMLElement;
|
||||
Corporation: HTMLElement;
|
||||
Gang: HTMLElement;
|
||||
Milestones: HTMLElement;
|
||||
Tutorial: HTMLElement;
|
||||
Options: HTMLElement;
|
||||
DevMenu: HTMLElement;
|
||||
}
|
||||
|
||||
const emptyElement: HTMLElement = ((): HTMLElement => {
|
||||
const elem = document.createElement('div');
|
||||
if(elem === null) throw new Error("unable to create empty div element");
|
||||
return elem;
|
||||
})();
|
||||
|
||||
export const MainMenuLinks: IMainMenuLinks = {
|
||||
Terminal: null,
|
||||
ScriptEditor: null,
|
||||
ActiveScripts: null,
|
||||
CreateProgram: null,
|
||||
Stats: null,
|
||||
Factions: null,
|
||||
Augmentations: null,
|
||||
HacknetNodes: null,
|
||||
Sleeves: null,
|
||||
City: null,
|
||||
Travel: null,
|
||||
Job: null,
|
||||
StockMarket: null,
|
||||
Bladeburner: null,
|
||||
Corporation: null,
|
||||
Gang: null,
|
||||
Milestones: null,
|
||||
Tutorial: null,
|
||||
Options: null,
|
||||
DevMenu: null,
|
||||
Terminal: emptyElement,
|
||||
ScriptEditor: emptyElement,
|
||||
ActiveScripts: emptyElement,
|
||||
CreateProgram: emptyElement,
|
||||
Stats: emptyElement,
|
||||
Factions: emptyElement,
|
||||
Augmentations: emptyElement,
|
||||
HacknetNodes: emptyElement,
|
||||
Sleeves: emptyElement,
|
||||
City: emptyElement,
|
||||
Travel: emptyElement,
|
||||
Job: emptyElement,
|
||||
StockMarket: emptyElement,
|
||||
Bladeburner: emptyElement,
|
||||
Corporation: emptyElement,
|
||||
Gang: emptyElement,
|
||||
Milestones: emptyElement,
|
||||
Tutorial: emptyElement,
|
||||
Options: emptyElement,
|
||||
DevMenu: emptyElement,
|
||||
}
|
||||
|
||||
export function initializeMainMenuLinks(): boolean {
|
||||
@@ -77,7 +83,9 @@ export function initializeMainMenuLinks(): boolean {
|
||||
MainMenuLinks.Gang = safeGetLink("gang-menu-link");
|
||||
MainMenuLinks.Milestones = safeGetLink("milestones-menu-link");
|
||||
MainMenuLinks.Tutorial = safeGetLink("tutorial-menu-link");
|
||||
MainMenuLinks.Options = document.getElementById("options-menu-link"); // This click listener is already set, so don't clear it
|
||||
const op: HTMLElement | null = document.getElementById("options-menu-link");
|
||||
if(op === null) throw new Error(`Could not find element with id: "options-menu-link"`);
|
||||
MainMenuLinks.Options = op; // This click listener is already set, so don't clear it
|
||||
MainMenuLinks.DevMenu = safeGetLink("dev-menu-link");
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user