From fad2f33fd600cce136af58343980eda9541c66a4 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Wed, 10 Jan 2024 09:22:51 +0100 Subject: [PATCH] refactor: use event listener to listen for page load event --- src/main/resources/static/scripts.js | 4 ++-- src/main/resources/templates/index.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/static/scripts.js b/src/main/resources/static/scripts.js index 2285167..73ad71b 100644 --- a/src/main/resources/static/scripts.js +++ b/src/main/resources/static/scripts.js @@ -4,14 +4,14 @@ const dateFormat = new Intl.DateTimeFormat('de-DE', dateFormatOptions); const dateTimeFormatOptions = { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: 'numeric', second: 'numeric' }; const dateTimeFormat = new Intl.DateTimeFormat('de-DE', dateTimeFormatOptions); -window.onload = () => { +window.addEventListener('load', () => { Array.from(document.getElementsByTagName('time')).forEach((timeTag) => { let date = Date.parse(timeTag.getAttribute('datetime')); if (! isNaN(date)) { timeTag.innerText = dateTimeFormat.format(date); } }); -}; +}); function drawPieChart(url, elemId, title, data) { if (data) { diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index ec8b3c7..c2ade61 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -51,7 +51,7 @@ \ No newline at end of file