diff --git a/web/mustard/js/notifs.js.php b/web/mustard/js/notifs.js.php index a08bed6..976acf6 100644 --- a/web/mustard/js/notifs.js.php +++ b/web/mustard/js/notifs.js.php @@ -57,6 +57,16 @@ function markdeleted(notif) { }; } +function getAliveNotifs(){ + let notifs = Array.from(document.querySelectorAll("div.notif")); + return notifs.filter(n => !(Array.from(n.classList).includes("deleted"))) +} + +function getAliveCheckboxes() { + let notifs = getAliveNotifs(); + return notifs.map(n => n.querySelector("input.seen-checkbox")) +} + function readSelected() { let selected = getSelectedNotifs() let request = { @@ -107,7 +117,7 @@ function deleteSelected() { } function getSelectedNotifs() { - let notifs = Array.from(document.querySelectorAll("div.notif")); + let notifs = getAliveNotifs(); return notifs.filter(notif => notif.querySelector("input.seen-checkbox").checked) } diff --git a/web/mustard/notifs.php b/web/mustard/notifs.php index 0a241da..3152e8a 100644 --- a/web/mustard/notifs.php +++ b/web/mustard/notifs.php @@ -107,7 +107,7 @@ if ($filtordon) { function reverseSelection() { - let checkboxes = Array.from(document.querySelectorAll("div.notif > input.seen-checkbox")); + let checkboxes = getAliveCheckboxes() checkboxes.forEach(function (box) { box.checked = !box.checked; }) @@ -137,14 +137,14 @@ if ($filtordon) { } else { setBtnsVisibility("hidden") } - let checkboxes = document.querySelectorAll("div.notif > input.seen-checkbox"); + let checkboxes = getAliveCheckboxes() checkboxes.forEach(function (box) { box.checked = check.checked; }); } function notifSelect(check) { - let checkboxes = Array.from(document.querySelectorAll("div.notif > input.seen-checkbox")); + let checkboxes = getAliveCheckboxes() if (check.checked) { setBtnsVisibility("visible"); } else if (checkboxes.every(box => !box.checked)) { @@ -188,12 +188,16 @@ if ($filtordon) { 0 => "unseen", 1 => "seen" ); + $deleted = array( + 0 => "", + 1 => "deleted" + ); foreach ($notifs['notifs'] as $n) { - echo("
" . + echo("
" . "" . "" . "" . - "

" . $n["Notification"] . "

" . + "

" . strftime('%d/%m/%y %T', $n['Microtime']) . ": " . $n["Notification"] . "

" . "
\n"); } } ?>