convert to ts
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.idea
|
.idea
|
||||||
|
index.js
|
||||||
@@ -8,20 +8,20 @@ function init() {
|
|||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(json => {
|
.then(json => {
|
||||||
contracts = json;
|
contracts = json;
|
||||||
for (contract of contracts) {
|
for (const contract of contracts) {
|
||||||
contract.discarded = false;
|
contract.discarded = false;
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
})
|
})
|
||||||
.catch(error => console.error('Error:', error));
|
.catch(error => console.error('Error:', error));
|
||||||
for (cost of costs) {
|
for (const cost of costs) {
|
||||||
checkBox = document.getElementById(cost);
|
let checkBox = document.getElementById(cost);
|
||||||
checkBox.addEventListener('change', function () {
|
checkBox.addEventListener('change', function () {
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for (reward of rewards) {
|
for (const reward of rewards) {
|
||||||
checkBox = document.getElementById(reward);
|
let checkBox = document.getElementById(reward);
|
||||||
checkBox.addEventListener('change', function () {
|
checkBox.addEventListener('change', function () {
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
@@ -31,7 +31,7 @@ function init() {
|
|||||||
function update() {
|
function update() {
|
||||||
let includedContracts = "";
|
let includedContracts = "";
|
||||||
let excludedContracts = "";
|
let excludedContracts = "";
|
||||||
for (contract of contracts) {
|
for (const contract of contracts) {
|
||||||
if (isIncluded(contract)) {
|
if (isIncluded(contract)) {
|
||||||
includedContracts += generateContractHtml(contract);
|
includedContracts += generateContractHtml(contract);
|
||||||
} else {
|
} else {
|
||||||
@@ -44,14 +44,14 @@ function update() {
|
|||||||
|
|
||||||
function isIncluded(contract) {
|
function isIncluded(contract) {
|
||||||
let included = true;
|
let included = true;
|
||||||
for (cost of costs) {
|
for (const cost of costs) {
|
||||||
checkBox = document.getElementById(cost);
|
let checkBox = document.getElementById(cost) as HTMLInputElement;
|
||||||
if (!checkBox.checked && (contract.costs[cost] > 0)) {
|
if (!checkBox.checked && (contract.costs[cost] > 0)) {
|
||||||
included = false;
|
included = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (reward of rewards) {
|
for (const reward of rewards) {
|
||||||
checkBox = document.getElementById(reward);
|
let checkBox = document.getElementById(reward) as HTMLInputElement;
|
||||||
if (!checkBox.checked && (contract.rewards[reward] > 0)) {
|
if (!checkBox.checked && (contract.rewards[reward] > 0)) {
|
||||||
included = false;
|
included = false;
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@ function generateContractHtml(contract) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggleDiscard(id) {
|
function toggleDiscard(id) {
|
||||||
for (contract of contracts) {
|
for (const contract of contracts) {
|
||||||
if (contract.id === id) {
|
if (contract.id === id) {
|
||||||
contract.discarded = !contract.discarded;
|
contract.discarded = !contract.discarded;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user