forked from code4sabae/covid19
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hokkaido.html
168 lines (157 loc) · 5.93 KB
/
hokkaido.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
<!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="hokkaido.png"/>
<meta property="og:image" content="hokkaido.png"/>
<meta name="format-detection" content="telephone=no"/>
<title>COVID-19 Hokkaido - 北海道 新型コロナウイルスオープンデータサマリー</title>
<script src="https://fukuno.jig.jp/app/csv/lib/fukuno.js"></script>
<script>"use strict"
const url = 'https://raw.githubusercontent.com/codeforsapporo/covid19/master/data/data.json' // Hokkaido
async function update() {
var noft = window.document.getElementById("noftication_refreshed");
if(noft !== void 0&&noft !== null){
noft.textContent = "更新しています....";
}
//const url = "https://raw.githubusercontent.com/tokyo-metropolitan-gov/covid19/master/data/data.json" // Tokyo
const data = await (await fetch(url)).json()
console.log(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 npatiants = data.patients.data.length
const npatiants2 = calcSum(data.patients_summary.data) // to check
const ndischarges = 0 // data.discharges.data.length
const ndischarges2 = 0 // calcSum(data.discharges_summary.data) // to check
const ninspections = data.main_summary.value // new!
const ndeath = 0 // data.main_summary.children[0].children[2].value
const nlight = 0 // data.main_summary.children[0].children[0].children[0].value
const nheavy = 0 // data.main_summary.children[0].children[0].children[1].value
const nexit = 0 // data.main_summary.children[0].children[1].value // == ndischarges + ndeath
main.innerHTML = `
<table>
<tr><td>陽性患者数</td><td>${addComma(npatiants)}人</td></tr>
<!--
<tr><td>検査実施人数</td><td>${addComma(ninspections)}人</td></tr>
<tr><td>陽性率(陽性患者数/検査実施人数)</td><td>${fixfloat(npatiants * 100 / ninspections, 2)}%</td></tr>
<tr><td>死亡数(死亡数/陽性患者数)</td><td>${addComma(ndeath)}人(${fixfloat(ndeath * 100 / npatiants, 2)}%)</td></tr>
<tr><td>重症(入院中)(死亡数/陽性患者数)</td><td>${addComma(nheavy)}人(${fixfloat(nheavy * 100 / npatiants, 2)}%)</td></tr>
<tr><td>軽症・中等症(入院中)(軽症・中等症数/陽性患者数)</td><td>${addComma(nlight)}人(${fixfloat(nlight * 100 / npatiants, 2)}%)</td></tr>
<tr><td>退院数(退院数/陽性患者数)</td><td>${addComma(nexit)}人(${fixfloat(nexit * 100 / npatiants, 2)}%)</td></tr>-->
<tr><td>新型コロナコールセンター相談件数</td><td>${addComma(ncontacts)}件</td></tr>
<tr><td>帰国者・接触者電話相談センター相談件数</td><td>${addComma(nquerents)}件</td></tr>
<tr><td>最終更新日時</td><td>${data.last_update}</td></tr>
</table>
`
console.log(ncontacts, nquerents, npatiants, npatiants2, ndischarges, ndischarges2)
dump(data)
if(noft !== void 0&&noft !== null){
noft.textContent = "更新しました!";
setTimeout(function(){
noft.textContent = " ";
}
,3000)
}
}
window.onload = update()
setInterval(update,600000)
</script>
<style>
body {
font-family: sans-serif;
margin: 0;
word-wrap: break-word;
--main-color: #62A9F9;
}
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;
}
#button_of_refresh {
position: relative;
z-index: 2;
background-color: #fff;
border:4px solid var(--main-color);
font:16px sans-serif;
color: #333;
line-height: 50px;
overflow: hidden;
width:200px;
}
#noftication_refreshed{
text-align: center;
}
</style>
</head>
<body>
<h1 id=title>COVID-19 Hokkaido</h1><div class=subtitle>北海道 新型コロナウイルスオープンデータサマリー</div>
<div id="main"></div>
<div class="buttons">
<button type="button" onclick="update()" id="button_of_refresh">クリックで更新</button>
</div>
<p id="noftication_refreshed"> </p>
<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=http://www.pref.hokkaido.lg.jp/hf/kth/kak/hasseijoukyou.htm>新型コロナ:道内の発生状況 | 保健福祉部健康安全局地域保健課」</a> <a href=https://raw.githubusercontent.com/codeforsapporo/covid19/master/data/data.json>data.json</a> - <a href=https://stopcovid19.hokkaido.dev/>北海道 新型コロナウイルス対策サイト</a> <a href=https://github.com/codeforsapporo/covid19>src on GitHub</a> forked from <a href=https://github.com/tokyo-metropolitan-gov/covid19>COVID-19 Tokyo</a> より<br>
APP:CC BY <a href='https://fukuno.jig.jp/2784'>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>