// John's Hopkins API Data as CSV
// See https://github.com/CSSEGISandData/COVID-19
// URLs for the CSVs on GitHub
const casesURL = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv";
const deathsURL = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv";
// Test the code on jsfiddle.net
function JSFiddleTest() {
// Add styling to the collapsible content
StyleCollapsibles();
// Run, and then update every 5 min
FetchJHData();
window.setInterval(5 * 60 * 1000, FetchJHData);
}
// Make the raw JSON collapsible
function StyleCollapsibles(className) {
var eCollapsibles = document.getElementsByClassName("collapse-button");
for (var i = 0; i < eCollapsibles.length; i++) {
eCollapsibles[i].addEventListener("click", function() {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.display === "inline-block") {
content.style.display = "none";
switch (content.id) {
case "cases-table-div":
this.innerHTML = "Show Cases Table";
break;
case "deaths-table-div":
this.innerHTML = "Show Deaths Table";
break;
case "cases-JSON-div":
this.innerHTML = "Show Cases JSON";
break;
case "deaths-JSON-div":
this.innerHTML = "Show Deaths JSON";
break;
}
} else {
content.style.display = "inline-block";
switch (content.id) {
case "cases-table-div":
this.innerHTML = "Hide Cases Table";
break;
case "deaths-table-div":
this.innerHTML = "Hide Deaths Table";
break;
case "cases-JSON-div":
this.innerHTML = "Hide Cases JSON";
break;
case...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.