2020-08-04 17:42:31 +02:00
|
|
|
let __notificationCount = '';
|
|
|
|
|
2020-07-29 22:48:49 +02:00
|
|
|
runAfterLoad(() => {
|
2020-08-20 16:14:07 +02:00
|
|
|
retrieveLoginStatus();
|
2020-08-04 17:42:31 +02:00
|
|
|
__notificationCount = getNotificationCount();
|
2020-07-29 22:48:49 +02:00
|
|
|
displayNotificationsInTitle();
|
|
|
|
}, ".*");
|
|
|
|
|
2020-08-04 17:42:31 +02:00
|
|
|
runAfterPathnameChange(() => {
|
|
|
|
displayNotificationsInTitle();
|
|
|
|
}, ".*");
|
|
|
|
|
|
|
|
function getNotificationCount() {
|
2020-08-20 16:14:07 +02:00
|
|
|
if (isLoggedIn) {
|
|
|
|
let menuUserText = document.getElementById('materialize-menu-dropdown').innerText.split('\n')[4];
|
2020-08-20 17:47:00 +02:00
|
|
|
let notificationCount = menuUserText.split("")[6];
|
|
|
|
console.log(notificationCount);
|
|
|
|
// If there are no notifications
|
|
|
|
if (Number.isNaN(parseInt(notificationCount)) || typeof notificationCount === 'undefined') {
|
|
|
|
console.warn("NaN or undefined");
|
|
|
|
return ``; // Otherwise displayNotificationsInTitle() throws undefined again
|
|
|
|
}
|
|
|
|
// Notifications present
|
|
|
|
else {
|
|
|
|
return `(${notificationCount}) `;
|
|
|
|
}
|
2020-08-20 16:14:07 +02:00
|
|
|
}
|
2020-08-04 17:42:31 +02:00
|
|
|
}
|
|
|
|
|
2020-08-20 17:47:00 +02:00
|
|
|
function displayNotificationsInTitle() {
|
|
|
|
console.log(__notificationCount);
|
|
|
|
if (typeof __notificationCount === 'undefined') {
|
|
|
|
console.error("NoTiFiCaTiOnCoUnT uNdEfInEd!");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
document.title = __notificationCount + document.title;
|
|
|
|
}
|
2020-08-04 17:42:31 +02:00
|
|
|
}
|