Skip to content

Commit 11a4a88

Browse files
authored
Merge pull request #139 from codeitcodes/dev
Dev
2 parents e1e7a63 + c554810 commit 11a4a88

File tree

4 files changed

+39
-31
lines changed

4 files changed

+39
-31
lines changed

homepage/homepage.js

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const isMobile = navigator.userAgent.match('Mobile') || false;
33
const isMac = navigator.platform.indexOf('Mac') > -1;
44
const isSafari = navigator.userAgent.toLowerCase().indexOf('safari') != -1;
5-
5+
/*
66
window.addEventListener('appinstalled', logAppInstalled);
77
88
// Log the installation
@@ -19,13 +19,13 @@ function logAppInstalled(evt) {
1919
localStorage.setItem('installed', 'true');
2020
2121
if (!isMobile) {
22-
window.location.replace(window.location.origin + '/full');
22+
//window.location.replace(window.location.origin + '/full');
2323
}
2424
2525
});
2626
27-
}
28-
27+
}*/
28+
/*
2929
let deferredInstallPrompt = null;
3030
3131
window.addEventListener('beforeinstallprompt', saveBeforeInstallPromptEvent);
@@ -43,11 +43,12 @@ function saveBeforeInstallPromptEvent(evt) {
4343
4444
deferredInstallPrompt = evt;
4545
46-
}
46+
}*/
4747

4848
// Event handler for butInstall - Does the PWA installation.
4949
function installPWA(evt) {
5050

51+
/*
5152
// if codeit isn't already installed
5253
if (!localStorage.getItem('installed')) {
5354
@@ -89,13 +90,13 @@ function installPWA(evt) {
8990
}
9091
9192
} else { // open in the browser
92-
93-
window.location.replace(window.location.origin + '/full');
93+
*/
94+
window.location.href = (window.location.origin + '/full');
9495

9596
// save installation in local storage
9697
localStorage.setItem('installed', 'true');
9798

98-
}
99+
/*}*/
99100

100101
}
101102

@@ -116,11 +117,7 @@ document.querySelectorAll('.btn.install').forEach(button => {
116117

117118
button.addEventListener('click', installPWA);
118119

119-
if (isSafari) {
120-
121-
button.classList.remove('loading');
122-
123-
}
120+
button.classList.remove('loading');
124121

125122
if (!checkLocalStorage()) {
126123

@@ -143,11 +140,7 @@ document.querySelectorAll('.btn.install').forEach(button => {
143140
// Register service worker
144141
if ('serviceWorker' in navigator) {
145142

146-
window.addEventListener('load', () => {
147-
148-
navigator.serviceWorker.register('/service-worker.js');
149-
150-
});
143+
navigator.serviceWorker.register('/service-worker.js');
151144

152145
}
153146

@@ -169,14 +162,14 @@ function checkPWA() {
169162

170163
if (displayMode != 'browser tab') {
171164

172-
window.location.replace(window.location.origin + '/full');
165+
//window.location.replace(window.location.origin + '/full');
173166

174167
}
175168

176169
};
177-
170+
/*
178171
document.addEventListener('visibilitychange', () => { window.setTimeout(checkPWA, 2000) });
179-
checkPWA();
172+
checkPWA();*/
180173

181174

182175
// add scroll event listeners

manifest.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ let manifest = {
3939
"accept": ["text/*", ".js", ".json", ".html", ".css", ".htm", ".svg", ".ts", ".mjs", ".py", ".scss"]
4040
}
4141
]
42-
}
43-
},
44-
"handle_links": "preferred",
45-
"launch_handler": {
46-
"route_to": "new-client"
42+
},
43+
"handle_links": "preferred",
44+
"launch_handler": {
45+
"route_to": "new-client"
46+
},
47+
"capture_links": "new-client"
4748
}
4849
};
4950

utils.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,25 @@ function showMessage(message, duration) {
145145

146146
// device and platform queries
147147

148-
const isMobile = navigator.userAgent.match('Mobile') ?? false;
149-
const isSafari = isMobile && navigator.userAgent.toLowerCase().indexOf('safari') != -1;
148+
let isMobile = false;
150149

151-
const isMac = navigator.platform.indexOf('Mac') > -1;
152-
const isWindows = navigator.platform.indexOf('Win') > -1;
150+
if (navigator.userAgentData
151+
&& navigator.userAgentData.mobile) isMobile = true;
152+
153+
if (navigator.userAgent
154+
&& navigator.userAgent.includes('Mobile')) isMobile = true;
155+
156+
let isSafari = false;
157+
158+
if (navigator.userAgentData
159+
&& navigator.userAgentData.platform === 'iOS') isSafari = true;
160+
161+
if (navigator.userAgent
162+
&& isMobile
163+
&& navigator.userAgent.toLowerCase().includes('safari')) isSafari = true;
164+
165+
const isMac = navigator.platform.includes('Mac');
166+
const isWindows = navigator.platform.includes('Win');
153167

154168
let isLandscape = window.matchMedia('(orientation: landscape)').matches;
155169

worker/client-channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
// update worker name when updating worker
7-
const WORKER_NAME = 'codeit-worker-v497';
7+
const WORKER_NAME = 'codeit-worker-v498';
88

99

1010
// internal paths

0 commit comments

Comments
 (0)