-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
200 lines (171 loc) · 7.71 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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="INDEX,FOLLOW" />
<meta name="description" content="Informationseite, die die 7-Tage-Inzidenz für COVID-19 anzeigt." />
<meta name="keywords" content="Covid Corona Inzidenz RKI" />
<title>COVID19 7-Tage-Inzidenz</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css" />
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/luxon@1.25.0/build/global/luxon.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jets@0.14.1/jets.min.js"></script>
<script src="bar.js"></script>
<link rel="icon"
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🦠</text></svg>">
<style>
html {
height: 100vh;
height: calc(var(--vh, 1vh) * 100);
overflow: hidden
}
.hero.is-fullheight {
min-height: calc(var(--vh, 1vh) * 100) !important;
}
#suche {
display: flex;
}
#result {
display: flex;
}
</style>
</head>
<body>
<section id="suche" class="hero is-fullheight is-info is-bold">
<div class="hero-body" style="flex-direction:col">
<div class="container box has-text-centered">
<h1 class="title has-text-centered pb-5 has-text-dark">
🦠 7-Tage-Inzidenz COVID-19
</h1>
<h3 class="subtitle has-text-dark">
Erfahre die aktuelle Inzidenzzahl deiner Stadt/deines Kreises:
</h3>
<form class="dropdown" id="dropdown">
<div class="dropdown-trigger">
<div class="field is-expanded">
<div class="field has-addons">
<div class="control">
<input id="locality-dropdown" type="search" class="input" autocomplete="off"
onfocus="show()" onfocusout="setTimeout(hide, 300)">
</div>
<p class="control">
<button class="button is-info" id="go-button">
Los!
</button>
</p>
</div>
</div>
</div>
<div class="dropdown-menu">
<div class="dropdown-content" id="dropdown-list">
</div>
</div>
</form>
<p class="pt-5">Stay safe and wear a mask! 😷</p>
<p>Erstellt mit den Daten des <a href="https://rki.de" target="_blank" rel=“noopener noreferrer“>RKI</a>
💙</p>
</div>
</div>
</section>
<section id="result" class="hero is-fullheight is-bold">
<div class="hero-body">
<div class="container box has-text-centered">
<h1 class="subtitle has-text-dark">🦠 COVID-19 7-Tage-Inzidenz Erlangen</h1>
<br>
<h2 id="7days" class="has-text-dark title is-static"></h2><span class="text">Fälle in den letzten 7 Tagen pro 100.000 Einwohner:innen</span>
<hr />
<div class="columns is-gapless">
<p class="column">
Quelle:
<a href="https://www.rki.de/DE/Home/homepage_node.html" rel="noopener" target="_blank">RKI</a>
</p>
<p class="column">Stand: <span id="date"> </span></p>
</div>
</div>
</section>
<script>
let resultMode = window.location.href.split("/")[1];
if (resultMode) {
document.getElementById("result").style.display = "flex";
document.getElementById("suche").style.display = "none";
} else {
document.getElementById("suche").style.display = "flex";
document.getElementById("result").style.display = "none";
}
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
window.addEventListener('resize', () => {
let vh = window.innerHeight * 0.01;
document.documentElement.style.setProperty('--vh', `${vh}px`);
});
let dropdownList = document.getElementById('dropdown-list');
let goButton = document.getElementById('go-button');
const url = 'landkreise.json';
fetch(url)
.then(
function (response) {
if (response.status !== 200) {
console.warn('Looks like there was a problem. Status Code: ' + response.status);
return;
}
// Examine the text in the response
response.json().then(function (data) {
var item;
for (let i = 0; i < data.length; i++) {
item = document.createElement('a');
item.classList.add('dropdown-item');
item.classList.add('has-text-left');
item.setAttribute("href", data[i].Name.toLowerCase());
item.text = data[i].Name;
dropdownList.appendChild(item);
}
var results = [];
var jets = new Jets({
searchTag: '#locality-dropdown',
contentTag: '#dropdown-list',
didSearch: () => {
results.length > 0 && results[0].classList.remove('is-active');
results =
Array.from(dropdownList.children)
.filter((element) =>
window.getComputedStyle(element).display !== "none");
if (results.length > 0) {
results[0].classList.add('is-active');
goButton.removeAttribute('disabled');
} else {
goButton.setAttribute('disabled', '');
}
}
});
let form = document.getElementsByTagName('form')[0];
form.addEventListener('submit', (event) => {
event.preventDefault();
if (results.length >= 1) {
window.location.href = results[0].getAttribute('href');
}
});
});
}
)
.catch(function (err) {
console.error('Fetch Error -', err);
});
function show() {
document.getElementById("dropdown").classList.add("is-active");
}
function hide() {
document.getElementById("dropdown").classList.remove("is-active");
}
</script>
<style>
html {
height: 100vh;
height: calc(var(--vh, 1vh) * 100);
}
.hero.is-fullheight {
min-height: calc(var(--vh, 1vh) * 100) !important;
}
</style>
</body>
</html>