Format fixes for js with biome.

This commit is contained in:
Fredrik Jonsson 2024-12-20 15:25:18 +01:00
commit 2f6becec53
10 changed files with 28 additions and 36 deletions

View file

@ -17,15 +17,19 @@
form.classList.remove('hidden'); form.classList.remove('hidden');
// Wait for a mouse to move, indicating they are human. // Wait for a mouse to move, indicating they are human.
document.body.addEventListener('mousemove', activateForm, {once: true}); document.body.addEventListener('mousemove', activateForm, { once: true });
// Wait for a touch move event, indicating that they are human. // Wait for a touch move event, indicating that they are human.
document.body.addEventListener('touchmove', activateForm, {once: true}); document.body.addEventListener('touchmove', activateForm, { once: true });
// A tab or enter key pressed can also indicate they are human. // A tab or enter key pressed can also indicate they are human.
document.body.addEventListener('keydown', function (e) { document.body.addEventListener(
if ((e.key === 'Tab') || (e.key === 'Enter')) { 'keydown',
activateForm(); function (e) {
} if (e.key === 'Tab' || e.key === 'Enter') {
}, {once: true}); activateForm();
}
},
{ once: true },
);
// Mark the form as submitted. // Mark the form as submitted.
button.addEventListener('click', () => form.classList.add('js-submitted')); button.addEventListener('click', () => form.classList.add('js-submitted'));
@ -42,5 +46,4 @@
break; break;
} }
} }
})(); })();

View file

@ -17,8 +17,7 @@
button.addEventListener('click', function () { button.addEventListener('click', function () {
if (button.getAttribute('data-consent') === 'true') { if (button.getAttribute('data-consent') === 'true') {
localStorage.setItem('cookieconsent', 'accept'); localStorage.setItem('cookieconsent', 'accept');
} } else {
else {
localStorage.setItem('cookieconsent', 'decline'); localStorage.setItem('cookieconsent', 'decline');
} }
cookiebanner.classList.remove('js-cookieconsent-open'); cookiebanner.classList.remove('js-cookieconsent-open');
@ -37,5 +36,4 @@
} }
}); });
}); });
})(); })();

View file

@ -7,13 +7,12 @@
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
renderMathInElement(document.body, { renderMathInElement(document.body, {
delimiters: [ delimiters: [
{left: '\\[', right: '\\]', display: true}, // block { left: '\\[', right: '\\]', display: true }, // block
{left: '$$', right: '$$', display: true}, // block { left: '$$', right: '$$', display: true }, // block
{left: '\\(', right: '\\)', display: false}, // inline { left: '\\(', right: '\\)', display: false }, // inline
{left: '$', right: '$', display: false} // inline { left: '$', right: '$', display: false }, // inline
], ],
throwOnError: false throwOnError: false,
}); });
}); });
})(); })();

View file

@ -9,7 +9,7 @@
const toggle = document.querySelector('.mobile-nav__toggle'); const toggle = document.querySelector('.mobile-nav__toggle');
function navopen() { function navopen() {
nav.dataset.navopen='true'; nav.dataset.navopen = 'true';
sheet.setAttribute('aria-hidden', 'false'); sheet.setAttribute('aria-hidden', 'false');
toggle.setAttribute('aria-expanded', 'true'); toggle.setAttribute('aria-expanded', 'true');
document.body.addEventListener('keydown', closeonesc); document.body.addEventListener('keydown', closeonesc);
@ -27,7 +27,7 @@
if (e.key === 'Escape') { if (e.key === 'Escape') {
navclose(); navclose();
} }
}; }
// Toggle the mobile nav sheet. // Toggle the mobile nav sheet.
const toggles = document.querySelectorAll('.mobile-nav__cover, .mobile-nav__toggle'); const toggles = document.querySelectorAll('.mobile-nav__cover, .mobile-nav__toggle');
@ -36,8 +36,7 @@
e.preventDefault(); e.preventDefault();
if (nav.dataset.navopen) { if (nav.dataset.navopen) {
navclose(); navclose();
} } else {
else {
navopen(); navopen();
} }
}); });
@ -56,5 +55,4 @@
const lastlink = [].slice.call(links).pop(); const lastlink = [].slice.call(links).pop();
lastlink.addEventListener('blur', () => toggle.focus()); lastlink.addEventListener('blur', () => toggle.focus());
} }
})(); })();

View file

@ -6,5 +6,4 @@
(function () { (function () {
// Add a js class to the html-tag when JavsScript is active. // Add a js class to the html-tag when JavsScript is active.
document.querySelector('html').classList.replace('nojs', 'js'); document.querySelector('html').classList.replace('nojs', 'js');
})(); })();

View file

@ -4,7 +4,5 @@
*/ */
(function () { (function () {
// Place your code here. // Place your code here.
})(); })();

View file

@ -10,9 +10,9 @@ import * as params from '@params';
document: { document: {
id: 'id', id: 'id',
index: ['title', 'tags', 'content', 'date'], index: ['title', 'tags', 'content', 'date'],
store: ['title', 'summary', 'date', 'permalink'] store: ['title', 'summary', 'date', 'permalink'],
}, },
tokenize: 'forward' tokenize: 'forward',
}); });
function showResults(items) { function showResults(items) {
@ -42,7 +42,7 @@ import * as params from '@params';
const results = index.search({ const results = index.search({
query: query, query: query,
enrich: true, enrich: true,
limit: params.searchLimit limit: params.searchLimit,
}); });
const items = {}; const items = {};
results.forEach(function (result) { results.forEach(function (result) {

View file

@ -14,12 +14,11 @@
const cells = row.querySelectorAll('td'); const cells = row.querySelectorAll('td');
cells.forEach(function (cell, i) { cells.forEach(function (cell, i) {
cell.setAttribute('role','cell'); cell.setAttribute('role', 'cell');
if (headers[i].innerText) { if (headers[i].innerText) {
cell.setAttribute('aria-label', headers[i].innerText); cell.setAttribute('aria-label', headers[i].innerText);
} }
}); });
}); });
}); });
})(); })();

View file

@ -3,7 +3,6 @@
* A JavaScript file for analytic tracking. * A JavaScript file for analytic tracking.
*/ */
import * as params from '@params'; import * as params from '@params';
const cookiebanner = params.cookieConsent; const cookiebanner = params.cookieConsent;
@ -13,9 +12,8 @@ const matomoTrackingApiUrl = 'https://' + params.piwikTrackerUrl + '/matomo.php'
const googleAnalytics = params.GoogleAnalytics; const googleAnalytics = params.GoogleAnalytics;
if (idSite) { if (idSite) {
// biome-ignore lint/style/useConst: Google code. // biome-ignore lint: Google code.
// biome-ignore lint/suspicious/noAssignInExpressions: Google code. let _paq = (window._paq = window._paq || []);
let _paq = window._paq = window._paq || [];
if (cookiebanner) { if (cookiebanner) {
_paq.push(['requireConsent']); _paq.push(['requireConsent']);

View file

@ -10,7 +10,6 @@
"ignoreUnknown": true, "ignoreUnknown": true,
"include": ["assets/**/*.js"], "include": ["assets/**/*.js"],
"ignore": ["**/*.min.js", "assets/libs/**/*.js"] "ignore": ["**/*.min.js", "assets/libs/**/*.js"]
}, },
"formatter": { "formatter": {
"enabled": true, "enabled": true,
@ -34,7 +33,8 @@
}, },
"javascript": { "javascript": {
"formatter": { "formatter": {
"quoteStyle": "single" "quoteStyle": "single",
"lineWidth": 100
}, },
"globals": ["define", "htmx", "jQuery", "Alpine"] "globals": ["define", "htmx", "jQuery", "Alpine"]
} }