diff --git a/homepage/homepage.js b/homepage/homepage.js index 5bdbce021e..04f71dda57 100644 --- a/homepage/homepage.js +++ b/homepage/homepage.js @@ -2,7 +2,7 @@ const isMobile = navigator.userAgent.match('Mobile') || false; const isMac = navigator.platform.indexOf('Mac') > -1; const isSafari = navigator.userAgent.toLowerCase().indexOf('safari') != -1; - +/* window.addEventListener('appinstalled', logAppInstalled); // Log the installation @@ -19,13 +19,13 @@ function logAppInstalled(evt) { localStorage.setItem('installed', 'true'); if (!isMobile) { - window.location.replace(window.location.origin + '/full'); + //window.location.replace(window.location.origin + '/full'); } }); -} - +}*/ +/* let deferredInstallPrompt = null; window.addEventListener('beforeinstallprompt', saveBeforeInstallPromptEvent); @@ -43,11 +43,12 @@ function saveBeforeInstallPromptEvent(evt) { deferredInstallPrompt = evt; -} +}*/ // Event handler for butInstall - Does the PWA installation. function installPWA(evt) { + /* // if codeit isn't already installed if (!localStorage.getItem('installed')) { @@ -89,13 +90,13 @@ function installPWA(evt) { } } else { // open in the browser - - window.location.replace(window.location.origin + '/full'); + */ + window.location.href = (window.location.origin + '/full'); // save installation in local storage localStorage.setItem('installed', 'true'); - } + /*}*/ } @@ -116,11 +117,7 @@ document.querySelectorAll('.btn.install').forEach(button => { button.addEventListener('click', installPWA); - if (isSafari) { - - button.classList.remove('loading'); - - } + button.classList.remove('loading'); if (!checkLocalStorage()) { @@ -143,11 +140,7 @@ document.querySelectorAll('.btn.install').forEach(button => { // Register service worker if ('serviceWorker' in navigator) { - window.addEventListener('load', () => { - - navigator.serviceWorker.register('/service-worker.js'); - - }); + navigator.serviceWorker.register('/service-worker.js'); } @@ -169,14 +162,14 @@ function checkPWA() { if (displayMode != 'browser tab') { - window.location.replace(window.location.origin + '/full'); + //window.location.replace(window.location.origin + '/full'); } }; - +/* document.addEventListener('visibilitychange', () => { window.setTimeout(checkPWA, 2000) }); -checkPWA(); +checkPWA();*/ // add scroll event listeners diff --git a/manifest.js b/manifest.js index aea661574a..e61902b987 100644 --- a/manifest.js +++ b/manifest.js @@ -39,11 +39,12 @@ let manifest = { "accept": ["text/*", ".js", ".json", ".html", ".css", ".htm", ".svg", ".ts", ".mjs", ".py", ".scss"] } ] - } - }, - "handle_links": "preferred", - "launch_handler": { - "route_to": "new-client" + }, + "handle_links": "preferred", + "launch_handler": { + "route_to": "new-client" + }, + "capture_links": "new-client" } }; diff --git a/utils.js b/utils.js index 3347066880..ca3c184b67 100644 --- a/utils.js +++ b/utils.js @@ -145,11 +145,25 @@ function showMessage(message, duration) { // device and platform queries -const isMobile = navigator.userAgent.match('Mobile') ?? false; -const isSafari = isMobile && navigator.userAgent.toLowerCase().indexOf('safari') != -1; +let isMobile = false; -const isMac = navigator.platform.indexOf('Mac') > -1; -const isWindows = navigator.platform.indexOf('Win') > -1; +if (navigator.userAgentData + && navigator.userAgentData.mobile) isMobile = true; + +if (navigator.userAgent + && navigator.userAgent.includes('Mobile')) isMobile = true; + +let isSafari = false; + +if (navigator.userAgentData + && navigator.userAgentData.platform === 'iOS') isSafari = true; + +if (navigator.userAgent + && isMobile + && navigator.userAgent.toLowerCase().includes('safari')) isSafari = true; + +const isMac = navigator.platform.includes('Mac'); +const isWindows = navigator.platform.includes('Win'); let isLandscape = window.matchMedia('(orientation: landscape)').matches; diff --git a/worker/client-channel.js b/worker/client-channel.js index 042de6ca9e..22b1acc135 100644 --- a/worker/client-channel.js +++ b/worker/client-channel.js @@ -4,7 +4,7 @@ // update worker name when updating worker -const WORKER_NAME = 'codeit-worker-v497'; +const WORKER_NAME = 'codeit-worker-v498'; // internal paths