Browse Source

mustard: notifs.js: Aggiunta funzione per cancellare le notifiche.

* web/mustard/js/notifs.js.php: Aggiunta funzione per la rimozione
  delle notifiche ed una funzione per applicare una funzione a tutte
  le notifiche selezionate.
paul 4 years ago
parent
commit
33e0f335a8
1 changed files with 27 additions and 0 deletions
  1. 27 0
      web/mustard/js/notifs.js.php

+ 27 - 0
web/mustard/js/notifs.js.php

@@ -39,6 +39,33 @@ function markread(notif) {
 		alert('La richiesta è fallita.');
 	};
 }
+
+function markdeleted(notif) {
+    let xhr=new XMLHttpRequest();
+    xhr.open('GET','notifsh.php?act=delete&id='+notif.id.replace(/^notif-([0-9]+)$/,'$1'));
+    xhr.responseType='json';
+    xhr.send();
+    xhr.onload=function() {
+        if (xhr.response['deleted']) {
+            notif.remove();
+        } else {
+            alert("Il server non ha potuto cancellare la notifica " + notif.text);
+        }
+    };
+    xhr.onerror=function() {
+        alert('La richiesta è fallita.');
+    };
+}
+
+function applyAllSelected(fun) {
+    let notifs = document.querySelectorAll("div#notifs-list > div");
+    notifs.forEach(function (notif) {
+        let checkbox = notif.querySelector("input.seen-checkbox");
+        if (checkbox.checked) {
+            fun(notif);
+        }});
+}
+
 lmt=<?php echo($notifs['lastmicrotime']); ?>;
 chunk=0;
 end=false;