forked from shivendrasaurav/corona-rakshak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
homescreen.html
183 lines (162 loc) · 5.72 KB
/
homescreen.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html lang="en">
<head>
<link rel='manifest' href='./manifest.webmanifest'>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="./icons/icon.ico"/>
<link rel="apple-touch-icon" href="./icons/icon.png"/>
<meta name="theme-color" content="#8CBCFC">
<link href="https://fluentdesignforweb.github.io/normalize.css" type="text/css" rel="stylesheet">
<link href="https://fluentdesignforweb.github.io/fluent.css" type="text/css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Barlow&display=swap" rel="stylesheet">
<title>Corona Rakshak - Installer</title>
<style>
body{
background: #0e1e1e;
}
.carousel{
width: auto;
position: relative;
}
.carousel-inner{
display: flex;
overflow-x: scroll;
}
.item{
position: relative;
width: 100%;
height: 82vh;
display: inline;
}
.carousel-inner > .item > img{
width: auto;
height: 99%;
box-shadow: 4px 3px 6px rgba(0,0,0,0.2);
margin: 5px;
}
.installer{
width: 100vw;
padding: 10px 20px;
}
.installer-name span{
font-size: 2.4em;
color: #ffffff;
font-family: "Barlow";
}
.ins-btn{
display: inline-block;
margin: 8px 0;
background: #55e5ff;
min-width: 200px;
height: 50px;
font: 1.2em 'Barlow';
}
</style>
</head>
<body onload="checkinstall();">
<div id="wrapper">
<div id="carousel" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
<img src="./ss/1.png" alt="">
</div>
<div class="item">
<img src="./ss/2.png" alt="">
</div>
<div class="item">
<img src="./ss/3.png" alt="">
</div>
<div class="item">
<img src="./ss/4.png" alt="">
</div>
<div class="item">
<img src="./ss/5.png" alt="">
</div>
<div class="item">
<img src="./ss/6.png" alt="">
</div>
<div class="item">
<img src="./ss/7.png" alt="">
</div>
</div>
</div>
</div>
<div class="installer">
<div class="installer-name">
<span>Corona Rakshak</span>
</div>
<div class="installer-buttons">
<button id="install-button" class="ins-btn" onclick="install();">Install</button>
<a id="launch" class="button ins-btn" href="./index.html" style="display: none;">Launch</a>
</div>
</div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
let deferredPrompt = null;
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent Chrome 67 and earlier from automatically showing the prompt
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
});
async function install() {
if (deferredPrompt) {
deferredPrompt.prompt();
console.log(deferredPrompt)
deferredPrompt.userChoice.then(function(choiceResult){
if (choiceResult.outcome === 'accepted') {
localStorage.setItem('isInstalled', "true");
console.log('Your PWA has been installed');
document.getElementById("launch").style.display = "inline-block";
document.getElementById("install-button").style.display = "none";
} else {
console.log('User chose to not install your PWA');
}
deferredPrompt = null;
});
}
}
function showinstaller(){
document.getElementById("install-button").style.display="Block";
}
function closeinstaller(){
window.location.replace("./index.html");
}
</script>
<script>
function checkinstall(){
if (window.matchMedia('(display-mode: standalone)').matches) {
closeinstaller();
console.log('display-mode is standalone');
}
else if(localStorage.getItem('isInstalled') == "true"){
document.getElementById("launch").style.display = "inline-block";
document.getElementById("install-button").style.display = "none";
}
else
showinstaller();
}
</script>
<script>
// This is the "Offline copy of pages" service worker
// Add this below content to your HTML page, or add the js file to your page at the very top to register service worker
// Check compatibility for the browser we're running this in
if ("serviceWorker" in navigator) {
if (navigator.serviceWorker.controller) {
console.log("Active service worker found, no need to register");
} else {
// Register the service worker
navigator.serviceWorker
.register("pwabuilder-sw.js", {
scope: "./"
})
.then(function (reg) {
console.log("Service worker has been registered for scope: " + reg.scope);
});
}
}
</script>
</html>