Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
51 righe
2.0 KiB
51 righe
2.0 KiB
<?php echo $this->Html->script('jixel-primitives'); ?> |
|
<!-- Creazione dinaminca delle notifiche utente --> |
|
<?= $this->Notifications->create($user_notifications) ?> |
|
<script> |
|
var new_notifications_sound; |
|
var all_notifications_read_sound; |
|
var first_notifications_count_check = true; |
|
var notifications_count = 0; |
|
var previous_notifications_count = -1; |
|
|
|
window.addEventListener('DOMContentLoaded', function() { |
|
new_notifications_sound = new Audio('/sounds/new_notification.mp3'); |
|
all_notifications_read_sound = new Audio('/sounds/all_notification_read.mp3'); |
|
|
|
setInterval(() => { |
|
makeGetRequest(`/notifications/index`) |
|
.then((content) => { |
|
$("#user-notifications-list").html(content); |
|
if (notifications_count > previous_notifications_count) { |
|
if (!first_notifications_count_check) new_notifications_sound.play(); |
|
first_notifications_count_check = false; |
|
previous_notifications_count = notifications_count; |
|
} |
|
}) |
|
.catch((error) => { |
|
console.log("errore durante il retrieving delle notifiche utente!!!!"); |
|
if (error.status == 401) window.location = '/'; |
|
}); |
|
}, 15000); |
|
|
|
$("#user-notifications-list").delegate("a", "click", function ( event ) { |
|
if ($(this).attr('href') != undefined) { |
|
console.log("captured link:"); |
|
console.log($(this).attr('href')); |
|
if ($(this).attr('href').indexOf("/notifications/readAll") === 0) { |
|
event.preventDefault(); |
|
makeGetRequest(`/notifications/readAll`) |
|
.then((content) => { |
|
all_notifications_read_sound.play(); |
|
$("#user-notifications-list").html(content); |
|
}) |
|
.catch((error) => { |
|
console.log("errore durante la cancellazione delle notifiche utente!!!!"); |
|
}); |
|
} else { |
|
console.log("event propagation allowed!"); |
|
} |
|
} |
|
}); |
|
}); |
|
</script>
|