From 892b667f869f5ea1a0af357a83f4e89d095616d1 Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sat, 15 Apr 2023 09:57:26 +0100 Subject: [PATCH] Fixed console errors seen in certain cases. --- src/main/resources/q-apps/q-apps.js | 57 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/main/resources/q-apps/q-apps.js b/src/main/resources/q-apps/q-apps.js index 28b81692..f72d8794 100644 --- a/src/main/resources/q-apps/q-apps.js +++ b/src/main/resources/q-apps/q-apps.js @@ -355,33 +355,7 @@ else if (document.attachEvent) { document.attachEvent('onclick', interceptClickEvent); } -/** - * Send current page details to UI - */ -document.addEventListener('DOMContentLoaded', () => { - qortalRequest({ - action: "QDN_RESOURCE_DISPLAYED", - service: _qdnService, - name: _qdnName, - identifier: _qdnIdentifier, - path: _qdnPath - }); -}); -/** - * Handle app navigation - */ -navigation.addEventListener('navigate', (event) => { - const url = new URL(event.destination.url); - let fullpath = url.pathname + url.hash; - qortalRequest({ - action: "QDN_RESOURCE_DISPLAYED", - service: _qdnService, - name: _qdnName, - identifier: _qdnIdentifier, - path: (fullpath.startsWith(_qdnBase)) ? fullpath.slice(_qdnBase.length) : fullpath - }); -}); /** * Intercept image loads from the DOM @@ -490,4 +464,33 @@ const qortalRequest = (request) => * Make a Qortal (Q-Apps) request with a custom timeout, specified in milliseconds */ const qortalRequestWithTimeout = (request, timeout) => - Promise.race([qortalRequestWithNoTimeout(request), awaitTimeout(timeout, "The request timed out")]); \ No newline at end of file + Promise.race([qortalRequestWithNoTimeout(request), awaitTimeout(timeout, "The request timed out")]); + + +/** + * Send current page details to UI + */ +document.addEventListener('DOMContentLoaded', () => { + qortalRequest({ + action: "QDN_RESOURCE_DISPLAYED", + service: _qdnService, + name: _qdnName, + identifier: _qdnIdentifier, + path: _qdnPath + }); +}); + +/** + * Handle app navigation + */ +navigation.addEventListener('navigate', (event) => { + const url = new URL(event.destination.url); + let fullpath = url.pathname + url.hash; + qortalRequest({ + action: "QDN_RESOURCE_DISPLAYED", + service: _qdnService, + name: _qdnName, + identifier: _qdnIdentifier, + path: (fullpath.startsWith(_qdnBase)) ? fullpath.slice(_qdnBase.length) : fullpath + }); +});