From 4214fbbd450410a957a5aa12302f098eb6868c5a Mon Sep 17 00:00:00 2001 From: Dan Cojocaru Date: Sun, 3 Sep 2023 05:56:40 +0300 Subject: [PATCH] Add today indicator to route date chooser --- route.js | 8 ++++++++ sw.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/route.js b/route.js index 07dcc2c..6c796f3 100644 --- a/route.js +++ b/route.js @@ -421,6 +421,14 @@ window.addEventListener('load', function (e) { var innerPre = document.createElement('pre') innerP.appendChild(innerPre) innerPre.textContent = `${departureOption.getDate().toString().padStart(2, '0')}.${(departureOption.getMonth() + 1).toString().padStart(2, '0')}.${departureOption.getFullYear().toString().padStart(4, '0')}` + var departureOptionMidday = new Date(departureOption.getTime()) + departureOptionMidday.setHours(12, 0, 0, 0) + var todayMidday = new Date() + todayMidday.setHours(12, 0, 0, 0) + if (departureOptionMidday.getTime() == todayMidday.getTime()) { + innerPre.textContent += ' (today)' + suggestionLi.focus() + } } document.querySelector('.csk').textContent = 'Select' diff --git a/sw.js b/sw.js index f451c40..8d11d92 100755 --- a/sw.js +++ b/sw.js @@ -1,4 +1,4 @@ -const VERSION = 'v35' +const VERSION = 'v36' const API_ORIGIN = 'https://scraper.infotren.dcdev.ro/' const API_TRAINS = `${API_ORIGIN}v3/trains` const API_STATIONS = `${API_ORIGIN}v3/stations`