shorten urls

main^2
Midnight 2 years ago
parent 1d3a2ad456
commit 306514fe1c

@ -21,12 +21,24 @@
let number: number;
$: number = commissions.length + 1;
function setup() {
async function setup() {
const urlParams = new URLSearchParams(window.location.search);
urlParams.forEach((value, key) => {
if(key == "commissions") {
commissions = JSON.parse(value);
update_price(commissions[0]);
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);
});
}
});
if(commissions.length == 0) base();
@ -79,8 +91,19 @@
}
function save() {
let data = [];
commissions.forEach(value => {
data.push({
"type": value['type'],
"name": value["name"],
"answers": value["answers"]
})
});
console.log(data);
console.log(JSON.stringify(data));
const urlParams = new URLSearchParams(window.location.search);
urlParams.set("commissions", JSON.stringify(commissions));
urlParams.set("commissions", JSON.stringify(data));
let url = window.location.origin + window.location.pathname + "?" + urlParams.toString();
@ -100,7 +123,6 @@
});
update_price(commission);
update_example(commission);
console.log(commission.answers);
}
function update_price(commission: Commission) {

Loading…
Cancel
Save