covid19/tmpl/all.pug

43 lines
1.8 KiB
Plaintext
Raw Normal View History

2020-04-27 03:04:16 +00:00
extends ./master.pug
block main
h2 Country Rollup
div#table.table-responsive: table.table.table-sm.table-hover
thead: tr
th #
2020-04-27 15:54:26 +00:00
th(data-col="name"): +sortableLinks("name") Country
th.text-center(data-col="total"): +sortableLinks("total") Deaths
th.text-center.sorted(data-col="yesterday"): +sortableLinks("yesterday") …since yesterday
th.text-center(data-col="week"): +sortableLinks("week") …since last week
th.text-center(data-col="month"): +sortableLinks("month") …month-to-date
2020-04-27 03:04:16 +00:00
th Last 14 days
-
data.sort((a, b) => {
const yesterdayA = a.timeSeriesDaily[a.timeSeriesDaily.length - 1].delta;
const yesterdayB = b.timeSeriesDaily[b.timeSeriesDaily.length - 1].delta;
if (yesterdayA === yesterdayB) {
return a.name.localeCompare(b.name);
}
return yesterdayA < yesterdayB ? 1 : -1;
});
tbody: each item, i in data
- const yesterday = item.timeSeriesDaily[item.timeSeriesDaily.length - 1].delta || 0;
- const lastWeek = item.timeSeriesDaily[item.timeSeriesDaily.length - 1].value - item.timeSeriesDaily[item.timeSeriesDaily.length - 7].value;
- const lastMonth = item.timeSeriesMonthly[item.timeSeriesMonthly.length - 1].delta || 0;
tr(id="row-" + item.safeName data-name=item.name data-total=item.total data-yesterday=yesterday data-week=lastWeek data-month=lastMonth)
td.sort-order= i + 1
td: a(href="./countries/" + item.safeName + ".html")= item.name
td.text-right: +formatNumber(item.total)
2020-04-27 15:54:26 +00:00
td.text-right.sorted: +formatNumber(yesterday)
2020-04-27 03:04:16 +00:00
td.text-right: +formatNumber(lastWeek)
td.text-right: +formatNumber(lastMonth)
td
canvas(id="sparkline-" + i width="200" height="50")
script.
2020-04-27 15:54:26 +00:00
makeSparkline(
"sparkline-#{i}",
#{JSON.stringify(item.timeSeriesDaily.slice(-14).map(x => x.value))},
);