Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michał Woźniak
covid
Commits
cf01403f
Commit
cf01403f
authored
Mar 22, 2020
by
Michał Woźniak
Browse files
infection sites now gotten from Wikipedia too
parent
3ca8a825
Pipeline
#86
passed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
covid.js
View file @
cf01403f
...
...
@@ -2,255 +2,7 @@
* yes, hard-coding. shoot me.
* if you want to go fancy, you can use the getCountries() function below instead.
*/
var
sites
=
[
"
Afghanistan
"
,
"
Albania
"
,
"
Algeria
"
,
"
Andorra
"
,
"
Angola
"
,
"
Antigua and Barbuda
"
,
"
Argentina
"
,
"
Armenia
"
,
"
Australia
"
,
"
Austria
"
,
"
Azerbaijan
"
,
"
Bahamas
"
,
"
Bahrain
"
,
"
Bangladesh
"
,
"
Barbados
"
,
"
Belarus
"
,
"
Belgium
"
,
"
Belize
"
,
"
Benin
"
,
"
Bhutan
"
,
"
Plurinational State of Bolivia
"
,
"
Bosnia and Herzegovina
"
,
"
Botswana
"
,
"
Brazil
"
,
"
Brunei Darussalam
"
,
"
Bulgaria
"
,
"
Burkina Faso
"
,
"
Burundi
"
,
"
Cabo Verde
"
,
"
Cambodia
"
,
"
Cameroon
"
,
"
Canada
"
,
"
Central African Republic
"
,
"
Chad
"
,
"
Chile
"
,
"
China
"
,
"
Colombia
"
,
"
Comoros
"
,
"
Congo
"
,
"
Costa Rica
"
,
"
Côte d'Ivoire
"
,
"
Croatia
"
,
"
Cuba
"
,
"
Cyprus
"
,
"
Czech Republic
"
,
"
Democratic People's Republic of Korea
"
,
"
Democratic Republic of the Congo
"
,
"
Denmark
"
,
"
Djibouti
"
,
"
Dominica
"
,
"
Dominican Republic
"
,
"
Ecuador
"
,
"
Egypt
"
,
"
El Salvador
"
,
"
Equatorial Guinea
"
,
"
Eritrea
"
,
"
Estonia
"
,
"
Eswatini
"
,
"
Ethiopia
"
,
"
Fiji
"
,
"
Finland
"
,
"
France
"
,
"
Gabon
"
,
"
Republic of The Gambia
"
,
"
Georgia
"
,
"
Germany
"
,
"
Ghana
"
,
"
Greece
"
,
"
Grenada
"
,
"
Guatemala
"
,
"
Guinea
"
,
"
Guinea-Bissau
"
,
"
Guyana
"
,
"
Haiti
"
,
"
Honduras
"
,
"
Hungary
"
,
"
Iceland
"
,
"
India
"
,
"
Indonesia
"
,
"
Iran
"
,
"
Iraq
"
,
"
Ireland
"
,
"
Israel
"
,
"
Italy
"
,
"
Jamaica
"
,
"
Japan
"
,
"
Jordan
"
,
"
Kazakhstan
"
,
"
Kenya
"
,
"
Kiribati
"
,
"
Kuwait
"
,
"
Kyrgyzstan
"
,
"
Lao People's Democratic Republic
"
,
"
Latvia
"
,
"
Lebanon
"
,
"
Lesotho
"
,
"
Liberia
"
,
"
Libya
"
,
"
Liechtenstein
"
,
"
Lithuania
"
,
"
Luxembourg
"
,
"
Madagascar
"
,
"
Malawi
"
,
"
Malaysia
"
,
"
Maldives
"
,
"
Mali
"
,
"
Malta
"
,
"
Marshall Islands
"
,
"
Mauritania
"
,
"
Mauritius
"
,
"
Mexico
"
,
"
Federated States of Micronesia
"
,
"
Monaco
"
,
"
Mongolia
"
,
"
Montenegro
"
,
"
Morocco
"
,
"
Mozambique
"
,
"
Myanmar
"
,
"
Namibia
"
,
"
Nauru
"
,
"
Nepal
"
,
"
Netherlands
"
,
"
New Zealand
"
,
"
Nicaragua
"
,
"
Niger
"
,
"
Nigeria
"
,
"
North Macedonia
"
,
"
Norway
"
,
"
Oman
"
,
"
Pakistan
"
,
"
Palau
"
,
"
Panama
"
,
"
Papua New Guinea
"
,
"
Paraguay
"
,
"
Peru
"
,
"
Philippines
"
,
"
Poland
"
,
"
Portugal
"
,
"
Qatar
"
,
"
South Korea
"
,
"
Moldova
"
,
"
Romania
"
,
"
Russia
"
,
"
Rwanda
"
,
"
Saint Kitts and Nevis
"
,
"
Saint Lucia
"
,
"
Saint Vincent and the Grenadines
"
,
"
Samoa
"
,
"
San Marino
"
,
"
São Tomé and Príncipe
"
,
"
Saudi Arabia
"
,
"
Senegal
"
,
"
Serbia
"
,
"
Seychelles
"
,
"
Sierra Leone
"
,
"
Singapore
"
,
"
Slovakia
"
,
"
Slovenia
"
,
"
Solomon Islands
"
,
"
Somalia
"
,
"
South Africa
"
,
"
South Sudan
"
,
"
Spain
"
,
"
Sri Lanka
"
,
"
Sudan
"
,
"
Suriname
"
,
"
Sweden
"
,
"
Switzerland
"
,
"
Syrian Arab Republic
"
,
"
Tajikistan
"
,
"
Thailand
"
,
"
Timor-Leste
"
,
"
Togo
"
,
"
Tonga
"
,
"
Trinidad and Tobago
"
,
"
Tunisia
"
,
"
Turkey
"
,
"
Turkmenistan
"
,
"
Tuvalu
"
,
"
Uganda
"
,
"
Ukraine
"
,
"
United Arab Emirates
"
,
"
United Kingdom
"
,
"
United Republic of Tanzania
"
,
"
United States
"
,
"
Uruguay
"
,
"
Uzbekistan
"
,
"
Vanuatu
"
,
"
Venezuela
"
,
"
Viet Nam
"
,
"
Yemen
"
,
"
Zambia
"
,
"
Zimbabwe
"
,
"
Hong Kong
"
]
/*
* get a list of infection outbreak sites
* from https://en.wikipedia.org/wiki/Member_states_of_the_United_Nations
*
* yes, naïve and limited, I know.
*
* also, no, we should not be using this everytime the interface is displayed
* world political situation is unstable, but not *that* unstable
*
* we probably should take the list from here instead:
* https://en.wikipedia.org/wiki/Template:2019%E2%80%9320_coronavirus_pandemic_data
*/
let
getSite
=
()
=>
{
return
wtf
.
fetch
(
'
Member states of the United Nations
'
)
.
then
((
doc
)
=>
{
return
doc
.
json
()
})
.
then
((
data
)
=>
{
return
data
.
sections
[
2
]
.
tables
[
0
]
.
map
((
row
)
=>
{
var
sane_site_name
=
row
[
"
Member state
"
].
text
.
replace
(
/
\(
.+
\)
$/
,
''
)
switch
(
sane_site_name
)
{
case
'
United Kingdom of Great Britain and Northern Ireland
'
:
return
"
United Kingdom
"
;
break
;
case
'
United States of America
'
:
return
"
United States
"
;
break
;
case
'
Islamic Republic of Iran
'
:
return
"
Iran
"
;
break
;
case
'
Bolivarian Republic of Venezuela
'
:
return
"
Venezuela
"
;
break
;
case
'
Russian Federation
'
:
return
"
Russia
"
;
break
;
case
'
Republic of Korea
'
:
return
"
South Korea
"
;
break
;
case
'
Republic of Moldova
'
:
return
"
Moldova
"
;
break
;
default
:
return
sane_site_name
;
}
})
})
}
var
sites
=
[]
/*
...
...
@@ -273,6 +25,22 @@ let getCovidData = () => {
+
`\n deaths :
${
cleaned_data
.
deaths
}
`
+
`\n recovered :
${
cleaned_data
.
recovered
}
`
+
`\n mortality :
${
cleaned_data
.
mortality
}
`
)
// hey we can get countries / locations / infection sites list from this too!
sites
=
data
.
sections
[
0
]
.
tables
[
0
]
.
filter
(
row
=>
row
.
col2
.
text
!==
""
)
.
map
((
row
)
=>
{
// snowflakes ugh
if
(
row
.
col2
.
text
===
"
China (mainland)
"
)
{
return
"
China
"
}
else
{
return
row
.
col2
.
text
}
})
.
sort
()
return
cleaned_data
})
}
...
...
@@ -404,12 +172,6 @@ document.addEventListener('DOMContentLoaded', (e)=>{
// fill out site drop-down
var
siteSelect
=
document
.
getElementById
(
"
sites
"
);
for
(
site
in
sites
.
sort
())
{
var
cOpt
=
document
.
createElement
(
"
option
"
);
cOpt
.
value
=
sites
[
site
];
cOpt
.
innerHTML
=
sites
[
site
];
siteSelect
.
appendChild
(
cOpt
);
}
// handle user interaction
var
siteSelectTimeout
=
false
...
...
@@ -465,6 +227,12 @@ document.addEventListener('DOMContentLoaded', (e)=>{
document
.
querySelector
(
'
#covid-stats > #deaths > .value
'
).
innerHTML
=
data
.
deaths
document
.
querySelector
(
'
#covid-stats > #recovered > .value
'
).
innerHTML
=
data
.
recovered
document
.
querySelector
(
'
#covid-stats > #mortality > .value
'
).
innerHTML
=
"
~
"
+
Math
.
round
(
data
.
mortality
*
10000
)
/
100
+
'
%
'
for
(
site
in
sites
.
sort
())
{
var
cOpt
=
document
.
createElement
(
"
option
"
);
cOpt
.
value
=
sites
[
site
];
cOpt
.
innerHTML
=
sites
[
site
];
siteSelect
.
appendChild
(
cOpt
);
}
})
});
...
...
index.html
View file @
cf01403f
...
...
@@ -130,6 +130,7 @@
color
:
springgreen
;
font-family
:
inherit
;
font-size
:
inherit
;
min-width
:
15em
;
}
#site-data-container
h2
{
position
:
relative
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment