From e9e235e7c6b09a61322c1666086b78a513aa881c Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 15 Mar 2024 20:24:39 +0000 Subject: [PATCH] code fixes --- Autoloader.js | 2 +- .../Notification/Browser/BrowserNotification.js | 12 ++++++++---- Module/ModuleFactory.js | 2 +- UI/Component/Form.js | 14 ++++++++------ Utils/oLib.js | 2 +- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Autoloader.js b/Autoloader.js index 0b6ef60..1f1dbde 100755 --- a/Autoloader.js +++ b/Autoloader.js @@ -40,7 +40,7 @@ Autoloader.defineNamespace = function (namespace) paths.splice(0, 1); const length = paths.length; - let current = omsApp; + let current = window.omsApp; for (let i = 0; i < length; ++i) { if (typeof current[paths[i]] === 'undefined') { diff --git a/Message/Notification/Browser/BrowserNotification.js b/Message/Notification/Browser/BrowserNotification.js index 8f62aee..26a1e05 100755 --- a/Message/Notification/Browser/BrowserNotification.js +++ b/Message/Notification/Browser/BrowserNotification.js @@ -64,13 +64,17 @@ export class BrowserNotification send (msg) { /** global: Notification */ - if (Notification.permission === 'granted') { + if (Notification.permission !== 'granted') { + return; + } + + navigator.serviceWorker.ready.then((registration) => { registration.showNotification(msg.title, { body: msg.message, - icon: "../images/touch/chrome-touch-icon-192x192.png", + icon: '../images/touch/chrome-touch-icon-192x192.png', vibrate: [msg.vibrate ? 200 : 0], - tag: "notification", + tag: 'notification' }); - } + }); }; }; diff --git a/Module/ModuleFactory.js b/Module/ModuleFactory.js index f5796cb..8d26f60 100755 --- a/Module/ModuleFactory.js +++ b/Module/ModuleFactory.js @@ -20,6 +20,6 @@ export class ModuleFactory */ static getInstance (module, app) { - return new omsApp.Modules[module](app); + return new window.omsApp.Modules[module](app); }; }; diff --git a/UI/Component/Form.js b/UI/Component/Form.js index da041e5..dd8065c 100755 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -673,8 +673,8 @@ export class Form jsOMS.removeClass(updateElements[i], 'animated'); jsOMS.removeClass(updateElements[i], 'greenCircleFade'); - requestAnimationFrame((time) => { - requestAnimationFrame((time) => { + window.requestAnimationFrame((_) => { + window.requestAnimationFrame((_) => { jsOMS.addClass(updateElements[i], 'animated'); jsOMS.addClass(updateElements[i], 'medium-duration'); jsOMS.addClass(updateElements[i], 'greenCircleFade'); @@ -705,8 +705,8 @@ export class Form jsOMS.removeClass(updateElements[i], 'greenCircleFade'); jsOMS.removeClass(updateElements[i], 'medium-duration'); - requestAnimationFrame((_) => { - requestAnimationFrame((_) => { + window.requestAnimationFrame((_) => { + window.requestAnimationFrame((_) => { // Important: all classes need to be done in one go otherwise it doesn't work (timing issue?) jsOMS.addClass(updateElements[i], 'animated medium-duration greenCircleFade'); }); @@ -890,7 +890,7 @@ export class Form } // define remote response behavior - self.forms[externalFormId].setSuccess(function (response) { + self.forms[id].setSuccess(function (response) { if (response.get('status') !== 'undefined' && response.get('status') !== NotificationLevel.HIDDEN ) { @@ -1184,6 +1184,8 @@ export class Form window.location = headerLocation; } + let statusCode = null; + if (xhr.getResponseHeader('content-type').includes('application/octet-stream')) { const blob = new Blob([xhr.response], { type: 'application/octet-stream' }); const doc = document.createElement('a'); @@ -1225,7 +1227,7 @@ export class Form const response = new Response(o); let successInject = null; - const statusCode = parseInt(xhr.getResponseHeader('status')); + statusCode = parseInt(xhr.getResponseHeader('status')); if ((successInject = form.getSuccess()) !== null && (statusCode === 200 || statusCode === null) diff --git a/Utils/oLib.js b/Utils/oLib.js index 0816760..46f8c54 100755 --- a/Utils/oLib.js +++ b/Utils/oLib.js @@ -140,7 +140,7 @@ export class jsOMS static htmlspecialchars_encode = function (str) { let escaped = str; - const length = htmlspecialchars.length; + const length = jsOMS.htmlspecialchars.length; for (let i = 0; i < length; ++i) { escaped = escaped.replace(