-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
81 lines (71 loc) · 1.96 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html>
<head>
<!-- Responsive -->
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width,
initial-scale=1">
<meta http-equiv="X-UA-Compatible"
content="ie=edge">
<!-- Title -->
<title>PWA for xcloud</title>
<!-- Meta Tags required for
Progressive Web App -->
<meta name=
"apple-mobile-web-app-status-bar"
content="#067D06">
<meta name="theme-color"
content="#067D06">
<!-- Manifest File link -->
<link rel="manifest"
href="manifest.json">
</head>
<body text="white" style="background-color:black;">
<div id="loadingicon" style="position:absolute; width:98%; height:92%; display: flex; align-items: center; justify-content: center;">
</div>
<script>
function isOnline(cb){
var img = new Image();
img.onerror = function() {
cb(false)
}
img.onload = function() {
cb(true)
}
img.src = "https://www.xbox.com/favicon.ico";
}
if (window.matchMedia('(display-mode: standalone)').matches) {
document.getElementById('loadingicon').innerHTML = '<img src="/xcloud-pwa/icons/loading.gif" height="12%">';
isOnline(function(res){
if (res) {
location.replace("https://www.xbox.com/play");
} else {
location.replace("offline.html");
}
});
}
else {
document.write("This is the host page for my xcloud pwa. If you don't get a prompt to add or install the page, then try using your browser's functionality to do so manually.");
}
</script>
<script>
window.addEventListener('load', () => {
registerSW();
});
// Register the Service Worker
async function registerSW() {
if ('serviceWorker' in navigator) {
try {
await navigator
.serviceWorker
.register('/xcloud-pwa/serviceworker.js', {scope: '/xcloud-pwa/'});
}
catch (e) {
console.log('SW registration failed');
}
}
}
</script>
</body>
</html>