Add eslint and prettier to frontend
And format files
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// import CSS so it gets named with a content hash that busts caches
|
||||
import "../css/styles.css";
|
||||
import '../css/styles.css';
|
||||
|
||||
import "./localTimeController";
|
||||
import './localTimeController';
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
function convertTimeElements() {
|
||||
function convertTimeElements(): void {
|
||||
const timeElements = document.querySelectorAll('time.local-time');
|
||||
timeElements.forEach((element) => {
|
||||
const utcString = element.getAttribute("datetime");
|
||||
if (utcString) {
|
||||
const utcString = element.getAttribute('datetime');
|
||||
if (utcString !== null) {
|
||||
const utcTime = new Date(utcString);
|
||||
element.textContent = utcTime.toLocaleDateString(window.navigator.language, {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
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);
|
||||
console.error(
|
||||
'Missing datetime attribute on time.local-time element',
|
||||
element
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
convertTimeElements();
|
||||
});
|
||||
|
||||
document.body.addEventListener('htmx:afterSwap', function() {
|
||||
document.body.addEventListener('htmx:afterSwap', function () {
|
||||
convertTimeElements();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user