main^2
Midnight 3 years ago
parent 306514fe1c
commit 7e18aa3003

@ -4,6 +4,7 @@
import words from "$lib/en-lang.json"; import words from "$lib/en-lang.json";
let total = 0; let total = 0;
let error = null;
let lang = words["calculator"]; let lang = words["calculator"];
let types = lang["types"]; let types = lang["types"];
@ -25,23 +26,29 @@
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
urlParams.forEach((value, key) => { urlParams.forEach((value, key) => {
if(key == "commissions") { if(key == "commissions") {
commissions = JSON.parse(value); try {
commissions.forEach(value => { commissions = JSON.parse(value);
types.forEach(element => { commissions.forEach(value => {
if(element["name"] == value.type) { types.forEach(element => {
value['questions'] = element["questions"]; if(element["name"] == value.type) {
} value['questions'] = element["questions"];
}
});
value.questions.forEach(question => {
value['answers'].push({'name': question.name, 'option': question.options[0]['name']});
});
update_price(value);
update_example(value);
console.log(value.example);
}); });
value.questions.forEach(question => { } catch(msg) {
value['answers'].push({'name': question.name, 'option': question.options[0]['name']}); error = "The selected preset link failed to load. It may be from an old version of the commission picker. It has been replaced with the default preset below."
}); }
update_price(value);
update_example(value);
console.log(value.example);
});
} }
}); });
if(commissions.length == 0) base(); if(commissions.length == 0) {
base();
}
} }
function update_example(commission: Commission) { function update_example(commission: Commission) {
@ -200,6 +207,12 @@
</div> </div>
</section> </section>
{#if error}
<section class="bg-slate-800 text-yellow-500 font-bold rounded-lg shadow-lg p-5 flex flex-col gap-5">
⚠️ {error}
</section>
{/if}
{#each [...commissions].reverse() as commission} {#each [...commissions].reverse() as commission}
<section class="flex gap-5"> <section class="flex gap-5">
<div class="w-3/5 bg-slate-800 rounded-lg shadow-lg p-5 flex flex-col gap-5"> <div class="w-3/5 bg-slate-800 rounded-lg shadow-lg p-5 flex flex-col gap-5">

Loading…
Cancel
Save