Skip to content

Commit 3cbbe35

Browse files
author
ed.schneider
committed
addedn toast to tables
1 parent 30b60d5 commit 3cbbe35

2 files changed

Lines changed: 32 additions & 4 deletions

File tree

src/tables/tables.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
8-
<link rel="stylesheet" href="/tables/tables.css" />
9-
<script src="/tables/tables.js" defer></script>
8+
<link rel="stylesheet" href="tables.css" />
9+
<script src="tables.js" defer></script>
1010
<title>BMI Tabellen</title>
1111
</head>
1212

@@ -53,6 +53,18 @@ <h1 class="text-center mb-4">BMI-Messungen</h1>
5353
</div>
5454
</div>
5555
</div>
56+
57+
<div class="toast-container position-fixed bottom-0 end-0 p-3">
58+
<div id="errorToast" class="toast text-bg-danger border-0" role="alert">
59+
<div class="d-flex">
60+
<div class="toast-body" id="errorToastBody">
61+
Fehler
62+
</div>
63+
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast"></button>
64+
</div>
65+
</div>
66+
</div>
67+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
5668
</body>
5769

5870
</html>

src/tables/tables.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
try {
5757
return JSON.parse(localStorage.getItem(STORAGE_KEY) || "[]");
5858
} catch {
59-
return [];
60-
}
59+
showErrorToast("Fehler beim Laden der gespeicherten Daten.");
60+
return []; }
6161
}
6262

6363
function saveToStorage() {
@@ -213,4 +213,20 @@
213213
} else {
214214
tablesInit();
215215
}
216+
217+
/* =========================================================
218+
Toast
219+
========================================================= */
220+
221+
function showErrorToast(message) {
222+
const toastEl = document.getElementById("errorToast");
223+
const toastBody = document.getElementById("errorToastBody");
224+
225+
if (!toastEl || !toastBody) return;
226+
227+
toastBody.textContent = message;
228+
229+
const toast = new bootstrap.Toast(toastEl);
230+
toast.show();
231+
}
216232
})();

0 commit comments

Comments
 (0)