Cleanup work

This commit is contained in:
jokob-sk
2024-08-11 21:13:12 +10:00
parent 3cde177e01
commit fff1f36b61
10 changed files with 43 additions and 309 deletions

View File

@@ -666,7 +666,7 @@ function openUrl(urls) {
// -----------------------------------------------------------------------------
function navigateToDeviceWithIp (ip) {
$.get('api/table_devices.json', function(res) {
$.get('api/table_devices.json?nocache=' + Date.now(), function(res) {
devices = res["data"];
@@ -876,9 +876,9 @@ function cacheDevices()
return new Promise((resolve, reject) => {
if(!getCache('completedCalls').includes('cacheDevices'))
{
$.get('api/table_devices.json', function(data) {
// if(!getCache('completedCalls').includes('cacheDevices'))
// {
$.get('api/table_devices.json?nocache=' + Date.now(), function(data) {
// console.log(data)
@@ -901,7 +901,8 @@ function cacheDevices()
// console.log(getCache('devicesListAll_JSON'))
}).then(() => handleSuccess('cacheDevices', resolve())).catch(() => handleFailure('cacheDevices', reject("cacheDevices already completed"))); // handle AJAX synchronization
}
});
// }
);
}
var devicesListAll_JSON = []; // this will contain a list off all devices
@@ -1281,7 +1282,7 @@ const areAllStringsInitialized = () => {
// Call the function to execute the code
executeOnce();
// Set timer for regular checks
// Set timer for regular UI refresh if enabled
setTimeout(() => {
// page refresh if configured

View File

@@ -242,6 +242,18 @@ $(document).ready(function () {
});
// -----------------------------------------------------------------------------
// Escape text
function safeDecodeURIComponent(content) {
try {
return decodeURIComponent(content);
} catch (error) {
console.warn('Failed to decode URI component:', error);
return content; // Return the original content if decoding fails
}
}
// -----------------------------------------------------------------------------
// Backend notification Polling
// -----------------------------------------------------------------------------
@@ -266,7 +278,9 @@ function checkNotification() {
if (oldestInterruptNotification) {
// Show modal dialog with the oldest unread notification
const decodedContent = decodeURIComponent(oldestInterruptNotification.content);
console.log(oldestInterruptNotification.content);
const decodedContent = safeDecodeURIComponent(oldestInterruptNotification.content);
showModalOK("Notification", decodedContent, function() {
// Mark the notification as read