forked from code4sabae/covid19
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokyo.html
140 lines (131 loc) · 5.04 KB
/
tokyo.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
<!DOCTYPE html><html><head><meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
<link rel="apple-touch-icon" href="tokyo.png"/>
<meta property="og:image" content="tokyo.png"/>
<meta name="format-detection" content="telephone=no"/>
<title>COVID-19 Tokyo - 東京都 新型コロナウイルスオープンデータサマリー</title>
<script src="https://fukuno.jig.jp/app/csv/lib/fukuno.js"></script>
<script>"use strict"
const url = "https://raw.githubusercontent.com/tokyo-metropolitan-gov/covid19/master/data/data.json"
async function update() {
const data = await (await fetch(url)).json()
console.log(data)
dump(data)
const calcSum = (data) => data.reduce((acc, val) => acc + parseInt(val['小計']), 0)
/*
const calcSum = function(data) {
let sum = 0
for (const d of data) {
sum += d['小計']
}
return sum
}
*/
const ncontacts = calcSum(data.contacts.data)
const nquerents = calcSum(data.querents.data)
const npatients = data.patients.data.length
const npatients2 = calcSum(data.patients_summary.data) // to check
//const ndischarges = data.discharges.data.length
//const ndischarges2 = calcSum(data.discharges_summary.data) // to check
const ninspections = data.main_summary.value // new!
const ndeath = data.main_summary.children[0].children[2].value
const nlight = data.main_summary.children[0].children[0].children[0].value
const nheavy = data.main_summary.children[0].children[0].children[1].value
const nexit = data.main_summary.children[0].children[1].value // == ndischarges + ndeath
main.innerHTML = `
<table>
<tr><td>現在患者数(入院中)</td><td>${addComma(nheavy + nlight)}人</td></tr>
<tr><td>陽性患者数</td><td>${addComma(npatients)}人</td></tr>
<tr><td>検査実施人数</td><td>${addComma(ninspections)}人</td></tr>
<tr><td>陽性率(陽性患者数/検査実施人数)</td><td>${fixfloat(npatients * 100 / ninspections, 2)}%</td></tr>
<tr><td>死亡数(死亡数/陽性患者数)</td><td>${addComma(ndeath)}人(${fixfloat(ndeath * 100 / npatients, 2)}%)</td></tr>
<tr><td>重症(入院中)(死亡数/陽性患者数)</td><td>${addComma(nheavy)}人(${fixfloat(nheavy * 100 / npatients, 2)}%)</td></tr>
<tr><td>軽症・中等症(入院中)(軽症・中等症数/陽性患者数)</td><td>${addComma(nlight)}人(${fixfloat(nlight * 100 / npatients, 2)}%)</td></tr>
<tr><td>退院数(退院数/陽性患者数)</td><td>${addComma(nexit)}人(${fixfloat(nexit * 100 / npatients, 2)}%)</td></tr>
<tr><td>新型コロナコールセンター相談件数</td><td>${addComma(ncontacts)}件</td></tr>
<tr><td>帰国者・接触者電話相談センター相談件数</td><td>${addComma(nquerents)}件</td></tr>
<tr><td>最終更新日時</td><td>${data.lastUpdate}</td></tr>
</table>
`
//console.log(ncontacts, nquerents, npatients, npatients2, ndischarges, ndischarges2)
console.log(ncontacts, nquerents, npatients, npatients2)
}
window.onload = update();
setInterval(update, 600000)
</script>
<style>
body {
font-family: sans-serif;
margin: 0;
word-wrap: break-word;
--main-color: #34b38b;
}
h1 {
margin: 0;
padding: .3em;
background-color: var(--main-color);
color: white;
font-size: 8vw;
text-align: center;
}
.subtitle {
text-align: center;
margin: 0;
padding: .3em;
background-color: var(--main-color);
color: white;
font-size: 3vw;
}
#main, #link {
text-align: center;
}
table {
margin: .5em;
display: inline-block;
border-collapse: collapse;
}
td {
border: 4px solid var(--main-color);
padding: .2em .5em;
}
td:first-child {
text-align: left;
}
td:nth-child(2) {
text-align: right;
}
#debug {
border: 1px solid black;
margin: 1em;
padding: 0.5em;
font-size: 70%;
}
#src {
margin: .5em;
}
a {
color: gray !important;
}
.buttons{
text-align: center;
}
</style>
</head>
<body>
<h1 id=title>COVID-19 Tokyo</h1><div class=subtitle>東京都 新型コロナウイルスオープンデータサマリー</div>
<div id="main"></div>
<div class="buttons">
<button type="button" onclick="update()">更新</button>
</div>
<div id="link">
<!--
→詳細「<a href=https://stopcovid19.metro.tokyo.lg.jp/>都内の最新感染動向 | 東京都 新型コロナウイルス対策サイト</a>」</div>-->
<!--<div id="debug"></div>-->
<div id="src">
DATA: CC BY <a href=https://raw.githubusercontent.com/tokyo-metropolitan-gov/covid19/master/data/data.json>data.json</a> - <a href=https://stopcovid19.metro.tokyo.lg.jp/>東京都公式 新型コロナウイルス対策サイト</a> <a href=https://github.com/tokyo-metropolitan-gov/covid19>src on GitHub</a> より<br>
APP:CC BY <a href='https://fukuno.jig.jp/2780'>fukuno.jig.jp</a> <a href=https://github.com/code4sabae/covid19>src on GitHub</a><br>
</div>
<img id=qrcode><script>addEventListener("load", () => qrcode.src = "https://chart.apis.google.com/chart?chs=140x140&cht=qr&chl=" + encodeURIComponent(document.location))</script><br>
</div>
</body>
</html>