Replace hotwire with htmx
In the process, also improve the feedback from the import/add feed forms. I also replaced the frontend code to replace utc timestamps with local time strings with @hotwired/stimulus with vanilla js.
This commit is contained in:
24
frontend/js/localTimeController.ts
Normal file
24
frontend/js/localTimeController.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
function convertTimeElements() {
|
||||
const timeElements = document.querySelectorAll('time.local-time');
|
||||
timeElements.forEach((element) => {
|
||||
const utcString = element.getAttribute("datetime");
|
||||
if (utcString) {
|
||||
const utcTime = new Date(utcString);
|
||||
element.textContent = utcTime.toLocaleDateString(window.navigator.language, {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
} else {
|
||||
console.error("Missing datetime attribute on time.local-time element", element);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
convertTimeElements();
|
||||
});
|
||||
|
||||
document.body.addEventListener('htmx:afterSwap', function() {
|
||||
convertTimeElements();
|
||||
});
|
||||
Reference in New Issue
Block a user