-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
142 lines (129 loc) · 4.26 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mindful Breathing Timer - Mindfulness, Meditation, Yoga, Stress Relief</title>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<meta name="google-site-verification" content="ygzAWdN8QAEoEi9lOBhAk4Qrsf6e7DGv2vyPhgW1-mo" />
<meta name="description"
content="Timer and color coded visual aid for the 4-7-8 deep breathing technique! 4-7-8 is a type of timed breathing scientifically proven to reduce stress, aid mindfulness and help panic attacks.">
<meta name="robots" content="index, follow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="apple-mobile-web-app-title" content="Breathing Timer" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, viewport-fit=cover">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<style>
body,
html,
.container {
margin: 0;
padding: 0;
overflow: hidden;
}
body {
display: flex;
align-items: center;
justify-content: center;
background: black;
}
.container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
#circle {
height: 1283px;
width: 1283px;
background: #def7ff;
border-radius: 641.5px;
flex-shrink: 0;
}
#bottom {
position: fixed;
bottom: 0;
left: 0;
}
#do-this{
font-size: 4em;
font-family: helvetica;
font-weight: 100;
color: black;
}
h1 {
position: fixed;
top: 0;
left: 0;
margin: 0;
padding: 10px;
font-family: helvetica;
font-weight: 200;
background: linear-gradient(90deg, #ac97ff, #ff97ed);
font-size: 2em;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
</style>
</head>
<body>
<h1>478 Breathing Timer</h1>
<div class=" container">
<div id="circle"></div>
</div>
<div class="container">
<div id="do-this"></div>
</div>
<div id='bottom'><a href="https://www.healthline.com/health/4-7-8-breathing#1">What is 4-7-8?</a></div>
</body>
<script>
document.title = '4-7-8 Breathing Timer'
window.run = true
if(window.navigator.standalone){
document.querySelector('#bottom').style.display = 'none'
document.addEventListener('touchmove',
function(e) {
e.preventDefault();
}, {passive:false});
}
const div = document.querySelector('#circle')
const do_this = document.querySelector('#do-this')
const count = document.querySelector('#count')
let height, width, rad
window.onresize = (e) => {
height = window.innerHeight / 2
width = window.innerWidth / 2
rad = Math.ceil((height ** 2 + width ** 2) ** .5)
div.style.width = `${rad * 2}px`
div.style.height = `${rad * 2}px`
div.style['border-radius'] = `${rad}px`
}
const [i, h, o] = [4000, 7000, 8000]
const total = i + h + o
window.onresize()
const start = Date.now()
setInterval(() => {
let elapsed = (Date.now() - start) % total
let percent_elapsed = 1
let do_this_text = 'hold'
let color = '#def7ff'
if (elapsed < i) {
percent_elapsed = elapsed / i
do_this_text = 'inhale'
color = '#f2deff'
} else if (elapsed > i + h) {
percent_elapsed = 1 - ((elapsed - i - h) / o)
do_this_text = 'exhale'
color = '#deffe4'
}
if (window.run){
div.style.transform = `scale(${percent_elapsed})`
div.style.background = color
do_this.innerText = do_this_text}
}, 10)
</script>
</html>