Skip to content
35 changes: 14 additions & 21 deletions homepage/homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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')) {

Expand Down Expand Up @@ -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');

}
/*}*/

}

Expand All @@ -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()) {

Expand All @@ -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');

}

Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
};

Expand Down
22 changes: 18 additions & 4 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion worker/client-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


// update worker name when updating worker
const WORKER_NAME = 'codeit-worker-v497';
const WORKER_NAME = 'codeit-worker-v498';


// internal paths
Expand Down