convert to ts

This commit is contained in:
badcold
2024-04-21 10:22:43 +02:00
parent ba5973bd96
commit 3d14936a99
2 changed files with 13 additions and 12 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
.idea
index.js

View File

@@ -8,20 +8,20 @@ function init() {
.then(response => response.json())
.then(json => {
contracts = json;
for (contract of contracts) {
for (const contract of contracts) {
contract.discarded = false;
}
update();
})
.catch(error => console.error('Error:', error));
for (cost of costs) {
checkBox = document.getElementById(cost);
for (const cost of costs) {
let checkBox = document.getElementById(cost);
checkBox.addEventListener('change', function () {
update();
});
}
for (reward of rewards) {
checkBox = document.getElementById(reward);
for (const reward of rewards) {
let checkBox = document.getElementById(reward);
checkBox.addEventListener('change', function () {
update();
});
@@ -31,7 +31,7 @@ function init() {
function update() {
let includedContracts = "";
let excludedContracts = "";
for (contract of contracts) {
for (const contract of contracts) {
if (isIncluded(contract)) {
includedContracts += generateContractHtml(contract);
} else {
@@ -44,14 +44,14 @@ function update() {
function isIncluded(contract) {
let included = true;
for (cost of costs) {
checkBox = document.getElementById(cost);
for (const cost of costs) {
let checkBox = document.getElementById(cost) as HTMLInputElement;
if (!checkBox.checked && (contract.costs[cost] > 0)) {
included = false;
}
}
for (reward of rewards) {
checkBox = document.getElementById(reward);
for (const reward of rewards) {
let checkBox = document.getElementById(reward) as HTMLInputElement;
if (!checkBox.checked && (contract.rewards[reward] > 0)) {
included = false;
}
@@ -69,7 +69,7 @@ function generateContractHtml(contract) {
}
function toggleDiscard(id) {
for (contract of contracts) {
for (const contract of contracts) {
if (contract.id === id) {
contract.discarded = !contract.discarded;
}