diff --git a/src/lib/calculator/Calculator.svelte b/src/lib/calculator/Calculator.svelte
index fde0830..60edd09 100644
--- a/src/lib/calculator/Calculator.svelte
+++ b/src/lib/calculator/Calculator.svelte
@@ -4,6 +4,7 @@
import words from "$lib/en-lang.json";
let total = 0;
+ let error = null;
let lang = words["calculator"];
let types = lang["types"];
@@ -25,23 +26,29 @@
const urlParams = new URLSearchParams(window.location.search);
urlParams.forEach((value, key) => {
if(key == "commissions") {
- commissions = JSON.parse(value);
- commissions.forEach(value => {
- types.forEach(element => {
- if(element["name"] == value.type) {
- value['questions'] = element["questions"];
- }
+ try {
+ commissions = JSON.parse(value);
+ commissions.forEach(value => {
+ types.forEach(element => {
+ 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 => {
- value['answers'].push({'name': question.name, 'option': question.options[0]['name']});
- });
- update_price(value);
- update_example(value);
- console.log(value.example);
- });
+ } catch(msg) {
+ 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."
+ }
}
});
- if(commissions.length == 0) base();
+ if(commissions.length == 0) {
+ base();
+ }
}
function update_example(commission: Commission) {
@@ -200,6 +207,12 @@
+ {#if error}
+
+ {/if}
+
{#each [...commissions].reverse() as commission}