-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbreathe.html
101 lines (93 loc) · 2.11 KB
/
breathe.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
<!DOCTYPE html>
<html>
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-W02LCCLH10"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-W02LCCLH10');
</script>
<title>Calm</title>
<meta name="description" content="A guided breathing app.">
<link rel="manifest" href="manifest.json">
<link rel="icon" href="images/icon-192x192.png" type="image/png"/>
<style>
body {
text-align: center;
font-size: 50px;
user-select: none;
-webkit-user-select: none;
color: grey;
font-family: futura;
overflow: hidden
}
#circle {
position: fixed;
top: 50%;
left: 50%;
width: 400px;
height: 400px;
margin: -200px -200px;
background: grey;
border-radius: 50%;
text-align: center;
}
#circle div {
animation: pulse 10s infinite;
position: absolute;
width: 70%;
height: 70%;
background: rgb(0, 0, 0, 0.5);
border-radius: 50%;
margin: 25% 25%;
}
@keyframes pulse {
0% {width: 50%; height: 50%;}
50% {width: 100%; height: 100%; margin: 0%;}
100% { width: 50%; height: 50%; margin: 25% 25%;}
}
</style>
</head>
<body>
<p>Inhale and exhale.</p>
<div id="circle" onclick="show()">
<div></div>
</div>
<script>
if (window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.body.style.background = "rgb(32, 33, 36)";
}
var circle = document.getElementById("circle");
var r = Math.floor(Math.random() * 256);
var g = Math.floor(Math.random() * 256);
var b = Math.floor(Math.random() * 256);
var col = r + ", " + g + ", " + b;
circle.style.background = "rgb(" + col + ")";
var i = 0;
setInterval(function(){i++;}, 10000);
function show() {
alert("You have reached " + i + " breaths.");
}
//pwa script
window.addEventListener('load', () => {
registerSW();
});
// Register the Service Worker
async function registerSW() {
if ('serviceWorker' in navigator) {
try {
await navigator
.serviceWorker
.register('serviceworker.js');
}
catch (e) {
console.log('SW registration failed');
}
}
}
</script>
</body>
</html>