-
Notifications
You must be signed in to change notification settings - Fork 2
/
data.html
211 lines (177 loc) · 7.93 KB
/
data.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
201
202
203
204
205
206
207
208
209
210
211
<html>
<head>
<title id='title'>U.S. Coronavirus Statistics</title>
<META name="description" content="Daily United States statitistics for the Coronavirus.">
<META name="keywords" content="Coronavirus, COVID-19, Flatten The Curve, Simulator">
<META name="copyright" content="(c) 2020 Jason Baker">
<META name="Author" content="Jason Baker">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="inc/bootstrap-4.4.1/bootstrap.min.css">
<script src="lib.js"></script>
<script src="stats.js"></script>
<script src="tablecreator.js"></script>
<style>
/** { font-size:3vmin; }*/
div.scrollExample { display:block; }
@media screen and (min-width: 1000px) {
/** { font-size:18px; }*/
div.scrollExample { display:none; }
}
.jumbotron, .content { min-height:100%; max-width:1200px; margin-left:auto;
margin-right:auto; padding-bottom:0; margin-bottom:0; }
.jumbotron { padding-bottom:0.5rem; }
H5 { font-weight:700; }
P { text-align:justify; }
A { color:#3498DB!important; }
IMG { max-width:100%; }
.section { margin-bottom:1rem; border-top:1px solid rgba(0,0,0,0.15); padding-top:1rem; }
.form-group { margin-top:1rem; margin-bottom:3rem; }
.simulationOutput .form-group { margin:0; margin-bottom:0.5rem; }
.simulationOutput .form-group LABEL { margin-bottom:0; }
LABEL.form-label { font-weight:700; }
LABEL.detail { display:block; font-style:italic; }
.testResult { padding:0.50rem 1rem; border-left:1px solid rgba(0,0,0,0.15); border-top:1px solid rgba(0,0,0,0.15); margin-bottom:2rem; }
.spinnerHolder { width:100%; text-align:center; margin-top:3rem; }
.table TD .stats { font-size:x-small; color:gray; display:block; padding-top:0.25rem; }
.table TD { min-width:130px; }
TH:hover { cursor:s-resize; }
TH { font-weight:400;}
div.scrollExample {
position:absolute;
top:7rem;
left:4rem;
background-color:#3498DB!important;
padding:1rem;
color:white;
border-radius:0.25rem;
animation-name: scrollExampleAnimation;
animation-duration: 0.5s;
animation-delay: 1s;
animation-iteration-count: 7;
animation-direction:alternate-reverse;
animation-timing-function:linear;
opacity:0.85;
}
@keyframes scrollExampleAnimation {
from { left:3rem;}
to { left:4rem; }
}
</style>
<script>
var dataManager = null;
var statTableCreator = null;
document.addEventListener('DOMContentLoaded', function() {
debug("Document loaded, loading data.");
hideElement("countyFormGroup");
hideElement("scrollExample");
statTableCreator = new TableCreator("statsTableCreator", el("dataTable"));
var handler = function(dataManager) {
debug("Remote data loaded. Creating table.");
var selectedState = getQueryParameterFromURL("region");
var selectedCounty = getQueryParameterFromURL("county");
var selectedMode = getQueryParameterFromURL("mode");
if (selectedState == "United States (All)") { //old user, we changed this to be "All States"
selectedState = "All States";
}
changeSelectSelectedValue("stateSelector", selectedState);
updateViewFromSelectedState();
changeSelectSelectedValue("countySelector", selectedCounty);
changeSelectSelectedValue("modeSelector", selectedMode);
updateViewFromSelectedMode();
changeTableForSelectedState();
var hospitalStates = dataManager.statesWithHospitalizationInfo;
el("hospitalInfo").innerHTML = "" + hospitalStates.length + " states";
debug("Finished creating table.");
setTimeout(function() {
el("scrollExample").className = "scrollExample";
showElement("scrollExample");
}, 3000);
setTimeout(function() { hideElement("scrollExample"); }, 10000);
};
dataManager = new CovidDataManager(handler);
//load up our selector
var selectValues = ["All States"];
for (var stateName of dataManager.getStateNames()) {
selectValues.push(stateName);
}
setSelectOptions("stateSelector", selectValues);
}, false);
function updateViewFromSelectedState() {
var selectedState = el("stateSelector").value;
var countiesForState = ["All Counties"];
for (var county of dataManager.getCountiesForState(selectedState)) {
countiesForState.push(county);
}
setSelectOptions("countySelector", countiesForState);
}
function updateViewFromSelectedMode() {
var selectedMode = el("modeSelector").value;
if (selectedMode == "Current") {
hideElement("countyFormGroup");
} else {
showElement("countyFormGroup");
}
}
function changeTableForSelectedState() {
updateUrl();
var selectedState = el("stateSelector").value;
var selectedCounty = el("countySelector").value;
var selectedMode = el("modeSelector").value;
debug("Showing data for: " + selectedState + " - " + selectedCounty + " (" + selectedMode + ")");
var tableMaker = new CovidTableMaker(dataManager, selectedState, selectedCounty, selectedMode, statTableCreator);
tableMaker.createTable();
}
function updateUrl() {
var selectedState = el("stateSelector").value;
var selectedCounty = el("countySelector").value;
var selectedMode = el("modeSelector").value;
var title = "U.S. Coronavirus Statistics - " + selectedState + " - " + selectedCounty;
var url = "data.html?region=" + selectedState + "&county=" + selectedCounty + "&mode=" + selectedMode;
debug("Updating Title/URL.", { title:title, url:url });
window.history.replaceState("state", title, url);
el("title").innerHTML = title;
}
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-33284553-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-33284553-1');
</script>
</head>
<body>
<div class="container">
<h1>U.S. Coronavirus Statistics</h1>
<div class='section'>
<p>Country and state-level stats are from the <a href="https://covidtracking.com/data/">Covid Tracking Project</a>. County-level statistics are from the <a href="https://github.com/nytimes/covid-19-data">New York Times covid-19-data</a> data set.</p>
<p><strong>Note:</strong> Hospitalization data should be considered the lower bound for total hospitalizations. State-level hospitalization data from the Covid Tracking Project is currently only available for <span id='hospitalInfo'>0 states</span>. <a href="https://covid19.healthdata.org/projections">IHME's Hospital Projections</a> appear to be more accurate.
<p><strong>Note:</strong> This is a beta version. All of the code is on <a href="https://github.com/codercowboy/coronasim">github</a>. Code review me, PLEASE! If you find a bug, please <a href="mailto:jason@onejasonforsale.com">email me</a>!</p>
</div>
<div class='form-row'>
<div class='form-group col-md-3'>
<label class='form-label'>State</label>
<select class='form-control' id='stateSelector' onChange='updateViewFromSelectedState(); changeTableForSelectedState();'></select>
</div>
<div class='form-group col-md-2'>
<label class='form-label'>Show</label>
<select class='form-control' id='modeSelector' onChange='updateViewFromSelectedMode(); changeTableForSelectedState();'>
<option>Current</option>
<option>History</option>
</select>
</div>
<div class='form-group col-md-3' id='countyFormGroup'>
<label class='form-label'>County</label>
<select class='form-control' id='countySelector' onChange='changeTableForSelectedState()'></select>
</div>
</div>
<div style="overflow-x:auto; position:relative;">
<div id='scrollExample' onclick='hideElement("scrollExample")'>← Table Moves Left And Right →</div>
<div class='simulationOutput pt-3' id='dataTable' onscroll='hideElement("scrollExample")'>
<div class='spinnerHolder'><div class="spinner-border text-primary" role="status"></div></div>
</div>
</div>
</div>
</body>
</html>