From fb1442b2701279c6b5788fe09da46054c76847b8 Mon Sep 17 00:00:00 2001 From: badcold Date: Sun, 21 Apr 2024 10:22:43 +0200 Subject: [PATCH] refactor header --- index.html | 25 +------------------------ index.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/index.html b/index.html index 5b7cbab..fc5465f 100644 --- a/index.html +++ b/index.html @@ -10,30 +10,7 @@ -
- Costs: - - - - - - -
-
- Rewards: - - - - - - - -
- -
- Other: - -
+
diff --git a/index.ts b/index.ts index 93eb187..f57a72c 100644 --- a/index.ts +++ b/index.ts @@ -4,6 +4,7 @@ let costs = ["sheep", "cow", "wool", "bread", "cheese", "whisky"] let rewards = ["cotton", "tobacco", "sugarCane", "upgrade", "expansion", "gold", "hops"] function init() { + buildHeader(); fetch('contracts.json') .then(response => response.json()) .then(json => { @@ -32,6 +33,37 @@ function init() { }); } +function buildHeader() { + document.getElementById("header").innerHTML = ` +
+ Costs: + ${buildCheckBoxes(costs)} +
+
+ Rewards: + ${buildCheckBoxes(rewards)} +
+ +
+ Other: + ${buildCheckBoxes(["discarded"])} +
+ `; +} + +function buildCheckBoxes(filters: string[]) : string { + let result = ""; + for (const filter of filters) { + result += buildCheckBox(filter); + } + return result; +} + +function buildCheckBox(filterKey: string): string { + let capitalized = filterKey[0].toUpperCase() + filterKey.slice(1); + return ``; +} + function update() { let includedContracts = ""; let excludedContracts = "";