From c2a0a93e449476ea690dc2ea0d0ee1809c234e75 Mon Sep 17 00:00:00 2001
From: Kuba Orlik
Date: Sun, 10 Dec 2023 16:23:20 +0100
Subject: [PATCH] Add support prompt
---
public/index.html | 12 ++++++++++++
src/browser.ts | 28 +++++++++++++++++-----------
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/public/index.html b/public/index.html
index 177a42c..1b5f2c5 100644
--- a/public/index.html
+++ b/public/index.html
@@ -13,6 +13,10 @@
height: 40px;
font-size: 20px;
}
+
+ .hidden {
+ display: none;
+ }
mBank mt940 konwerter
@@ -27,6 +31,14 @@
Konwertuj
+
+ Rozpoczęto pobieranie wygenerowanego raportu mt940. Cieszymy się, że
+ mogliśmy Ci oszczędzić trochę wydatków. Jeżeli chcesz się nam
+ odwdzięczyć, zachęcamy do
+
wspierania naszej fundacji
+
Aplikacja została wykonana przez
diff --git a/src/browser.ts b/src/browser.ts
index 582e19d..9cccbf4 100644
--- a/src/browser.ts
+++ b/src/browser.ts
@@ -27,17 +27,23 @@ async function handle() {
throw new Error("no files in the input");
}
const buffer = await files[0].arrayBuffer();
- const string = new TextDecoder("windows-1250").decode(buffer);
- const result = convert(string);
- download(
- result.output,
- `raport-${result.range.date_start.getFullYear()}-${(
- result.range.date_start.getMonth() + 1
- )
- .toString()
- .padStart(2, "0")}.mt940`,
- "text"
- );
+ try {
+ const string = new TextDecoder("windows-1250").decode(buffer);
+ const result = convert(string);
+ download(
+ result.output,
+ `raport-${result.range.date_start.getFullYear()}-${(
+ result.range.date_start.getMonth() + 1
+ )
+ .toString()
+ .padStart(2, "0")}.mt940`,
+ "text"
+ );
+ document.querySelector(".success")?.classList.remove("hidden");
+ } catch (e) {
+ console.error(e);
+ alert("Wystąpił błąd: " + e.message);
+ }
}
document.querySelector("#submit")?.addEventListener("click", handle);