aboutsummaryrefslogtreecommitdiff
path: root/asset-sources
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2024-04-06 21:28:45 +0200
committerDaniel Schadt <kingdread@gmx.de>2024-04-06 21:28:45 +0200
commit89525eebab0d359e81a9e71e4a2ba5968a52bb1e (patch)
treeb6a0c3a3cb1e19cbefde6a36a314a21602a9d29d /asset-sources
parent8bb2d8c2cb9809b2c347b98c2ac24fa760233383 (diff)
downloadfietsboek-89525eebab0d359e81a9e71e4a2ba5968a52bb1e.tar.gz
fietsboek-89525eebab0d359e81a9e71e4a2ba5968a52bb1e.tar.bz2
fietsboek-89525eebab0d359e81a9e71e4a2ba5968a52bb1e.zip
fix eslint warnings
Diffstat (limited to 'asset-sources')
-rw-r--r--asset-sources/fietsboek.ts25
1 files changed, 18 insertions, 7 deletions
diff --git a/asset-sources/fietsboek.ts b/asset-sources/fietsboek.ts
index c34e3d4..3682f5f 100644
--- a/asset-sources/fietsboek.ts
+++ b/asset-sources/fietsboek.ts
@@ -475,30 +475,38 @@ function toggleTrackFavourite(event: MouseEvent) {
addHandler(".favourite-star", "click", toggleTrackFavourite);
/**
- * Load and plot the user's summary.
+ * Returns an array of localized month names (Jan-Dec).
*/
-function loadProfileStats() {
- let monthNames: string[] = [];
- let date = new Date(2000, 0);
+function getLocalizedMonthNames(): string[] {
+ const monthNames: string[] = [];
+ const date = new Date(2000, 0);
for (let i = 0; i < 12; i++) {
monthNames.push(date.toLocaleString(LOCALE, {month: 'long'}));
date.setMonth(i + 1);
}
+ return monthNames;
+}
+
+/**
+ * Load and plot the user's summary.
+ */
+function loadProfileStats() {
+ const monthNames = getLocalizedMonthNames();
const url = new URL("/me/summary.json", window.location.href);
fetch(url)
.then(response => response.json())
.then((response: YearSummary) => {
- let datasets = [];
+ const datasets = [];
for (const [year, months] of Object.entries(response)) {
- let data = [];
+ const data = [];
for (let i = 1; i <= 12; ++i) {
data.push((i in months) ? (months[i] / 1000) : 0);
}
datasets.push({
data: data,
label: year,
- })
+ });
}
new Chart(
@@ -514,6 +522,9 @@ function loadProfileStats() {
});
}
+/* Used via in-page scripts, so make eslint happy */
+loadProfileStats;
+
document.addEventListener('DOMContentLoaded', function() {
window.fietsboekImageIndex = 0;