mustard: notifs: Aggiunto timestamp alle notifiche.
* web/mustard/js/notifs.js.php: Aggiunte funzioni per determinare le notifiche "vive" (non cancellate). * web/mustard/notifs.php: Aggiunto timestamp alle notifiche e ora le funzioni che operavano sulle notifiche in massa lo fanno solo su quelle "vive".
This commit is contained in:
parent
14200ea5fd
commit
1ecf67acf8
2 changed files with 20 additions and 6 deletions
|
@ -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() {
|
function readSelected() {
|
||||||
let selected = getSelectedNotifs()
|
let selected = getSelectedNotifs()
|
||||||
let request = {
|
let request = {
|
||||||
|
@ -107,7 +117,7 @@ function deleteSelected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedNotifs() {
|
function getSelectedNotifs() {
|
||||||
let notifs = Array.from(document.querySelectorAll("div.notif"));
|
let notifs = getAliveNotifs();
|
||||||
return notifs.filter(notif => notif.querySelector("input.seen-checkbox").checked)
|
return notifs.filter(notif => notif.querySelector("input.seen-checkbox").checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ if ($filtordon) {
|
||||||
<?php if ($account['Level'] != 'guest') require('js/notifs.js.php'); ?>
|
<?php if ($account['Level'] != 'guest') require('js/notifs.js.php'); ?>
|
||||||
|
|
||||||
function reverseSelection() {
|
function reverseSelection() {
|
||||||
let checkboxes = Array.from(document.querySelectorAll("div.notif > input.seen-checkbox"));
|
let checkboxes = getAliveCheckboxes()
|
||||||
checkboxes.forEach(function (box) {
|
checkboxes.forEach(function (box) {
|
||||||
box.checked = !box.checked;
|
box.checked = !box.checked;
|
||||||
})
|
})
|
||||||
|
@ -137,14 +137,14 @@ if ($filtordon) {
|
||||||
} else {
|
} else {
|
||||||
setBtnsVisibility("hidden")
|
setBtnsVisibility("hidden")
|
||||||
}
|
}
|
||||||
let checkboxes = document.querySelectorAll("div.notif > input.seen-checkbox");
|
let checkboxes = getAliveCheckboxes()
|
||||||
checkboxes.forEach(function (box) {
|
checkboxes.forEach(function (box) {
|
||||||
box.checked = check.checked;
|
box.checked = check.checked;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function notifSelect(check) {
|
function notifSelect(check) {
|
||||||
let checkboxes = Array.from(document.querySelectorAll("div.notif > input.seen-checkbox"));
|
let checkboxes = getAliveCheckboxes()
|
||||||
if (check.checked) {
|
if (check.checked) {
|
||||||
setBtnsVisibility("visible");
|
setBtnsVisibility("visible");
|
||||||
} else if (checkboxes.every(box => !box.checked)) {
|
} else if (checkboxes.every(box => !box.checked)) {
|
||||||
|
@ -188,12 +188,16 @@ if ($filtordon) {
|
||||||
0 => "unseen",
|
0 => "unseen",
|
||||||
1 => "seen"
|
1 => "seen"
|
||||||
);
|
);
|
||||||
|
$deleted = array(
|
||||||
|
0 => "",
|
||||||
|
1 => "deleted"
|
||||||
|
);
|
||||||
foreach ($notifs['notifs'] as $n) {
|
foreach ($notifs['notifs'] as $n) {
|
||||||
echo("<div id=\"notif-" . $n["ID"] . "\" class=\"" . "notif " . $sev_classes[$n["Severity"]] . " " . $seen_class[$n["Seen"]] . "\">" .
|
echo("<div id=\"notif-" . $n["ID"] . "\" class=\"" . "notif " . $deleted[$n["Deleted"]] . " " . $sev_classes[$n["Severity"]] . " " . $seen_class[$n["Seen"]] . "\">" .
|
||||||
"<input type=\"checkbox\" class=\"seen-checkbox\" onclick='notifSelect(this)'>" .
|
"<input type=\"checkbox\" class=\"seen-checkbox\" onclick='notifSelect(this)'>" .
|
||||||
"<button type='button' onclick='markread(this.parentElement)'><i class=\"fa fa-envelope-open-o\" aria-hidden=\"true\"></i></button>" .
|
"<button type='button' onclick='markread(this.parentElement)'><i class=\"fa fa-envelope-open-o\" aria-hidden=\"true\"></i></button>" .
|
||||||
"<button type='button' onclick='markdeleted(this.parentElement)'><i class=\"fa fa-trash-o\" aria-hidden=\"true\"></i></button>" .
|
"<button type='button' onclick='markdeleted(this.parentElement)'><i class=\"fa fa-trash-o\" aria-hidden=\"true\"></i></button>" .
|
||||||
"<p>" . $n["Notification"] . "</p>" .
|
"<p id='notif-text'>" . strftime('%d/%m/%y %T', $n['Microtime']) . ": " . $n["Notification"] . "</p>" .
|
||||||
"</div>\n");
|
"</div>\n");
|
||||||
}
|
}
|
||||||
} ?>
|
} ?>
|
||||||
|
|
Loading…
Reference in a new issue