From 5abe8cba55965f70e07e1163239bcc9d797c864a Mon Sep 17 00:00:00 2001 From: Minteck Date: Sat, 9 Jul 2022 15:22:44 +0200 Subject: Bye bye desktop app --- assets/create.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 assets/create.js (limited to 'assets/create.js') diff --git a/assets/create.js b/assets/create.js new file mode 100644 index 0000000..cd787af --- /dev/null +++ b/assets/create.js @@ -0,0 +1,28 @@ +async function createTransaction() { + document.getElementById('create-action').disabled = true; + document.getElementById('create-currency').disabled = true; + document.getElementById('create-description').disabled = true; + document.getElementById('create-amount').disabled = true; + document.getElementById('create-button-create').disabled = true; + document.getElementById('create-button-cancel').disabled = true; + + if (isNodeJS) { + await (await window.fetch("https://money-v1.equestria.dev/Application/AddTransaction/?Currency=" + document.getElementById('create-currency').value + "&Amount=" + document.getElementById('create-amount').value + "&Operation=" + document.getElementById('create-action').value + "&Description=" + Buffer.from(document.getElementById('create-description').value).toString("base64url"))).text(); + } else { + await (await window.fetch("https://money-v1.equestria.dev/Application/AddTransaction/?Currency=" + document.getElementById('create-currency').value + "&Amount=" + document.getElementById('create-amount').value + "&Operation=" + document.getElementById('create-action').value + "&Description=" + btoa(document.getElementById('create-description').value).replaceAll("+", "-").replaceAll("/", "_"))).text(); + } + + await refresh(); + + document.getElementById('create-action').disabled = false; + document.getElementById('create-currency').disabled = false; + document.getElementById('create-description').disabled = false; + document.getElementById('create-amount').disabled = false; + document.getElementById('create-button-create').disabled = false; + document.getElementById('create-button-cancel').disabled = false; + document.getElementById('create-modal').style.display = 'none'; + document.getElementById('create-action').value = '+'; + document.getElementById('create-currency').value = '£'; + document.getElementById('create-description').value = ''; + document.getElementById('create-amount').value = ''; +} \ No newline at end of file -- cgit