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 @@

+

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);