style: apply linter suggestions

This commit is contained in:
Edouard Vanbelle
2026-04-07 22:50:42 +02:00
parent 1ce29c101d
commit a4266a6e93
33 changed files with 444 additions and 437 deletions
+11 -13
View File
@@ -1,7 +1,5 @@
// device-verify.js — Extracted from inline <script> in device-verify.html
(function () {
'use strict';
(() => {
var API_BASE = window.location.origin;
var codeInput = document.getElementById('user-code');
var deviceInfo = document.getElementById('device-info');
@@ -20,11 +18,11 @@
}
// Auto-insert hyphen and lookup on input
codeInput.addEventListener('input', function (e) {
var val = e.target.value.toUpperCase().replace(/[^A-Z0-9\-]/g, '');
codeInput.addEventListener('input', (e) => {
var val = e.target.value.toUpperCase().replace(/[^A-Z0-9-]/g, '');
// Auto-insert hyphen after 4 chars
if (val.length === 4 && val.indexOf('-') === -1) {
val = val + '-';
val = `${val}-`;
}
e.target.value = val;
errorText.classList.add('hidden');
@@ -32,7 +30,7 @@
// Debounce lookup
clearTimeout(debounceTimer);
if (val.length >= 9) {
debounceTimer = setTimeout(function () {
debounceTimer = setTimeout(() => {
lookupCode(val);
}, 300);
} else {
@@ -42,16 +40,16 @@
});
// Wire up approve / deny buttons (replaces inline onclick)
btnApprove.addEventListener('click', function () {
btnApprove.addEventListener('click', () => {
handleAction('approve');
});
btnDeny.addEventListener('click', function () {
btnDeny.addEventListener('click', () => {
handleAction('deny');
});
async function lookupCode(code) {
try {
var resp = await fetch(API_BASE + '/api/auth/device/verify?code=' + encodeURIComponent(code), {
const resp = await fetch(`${API_BASE}/api/auth/device/verify?code=${encodeURIComponent(code)}`, {
credentials: 'same-origin'
});
if (resp.status === 401) {
@@ -59,7 +57,7 @@
return;
}
if (!resp.ok) throw new Error('Lookup failed');
var data = await resp.json();
const data = await resp.json();
if (data.valid) {
currentCode = code;
@@ -83,7 +81,7 @@
btnDeny.disabled = true;
try {
var resp = await fetch(API_BASE + '/api/auth/device/verify', {
const resp = await fetch(`${API_BASE}/api/auth/device/verify`, {
method: 'POST',
credentials: 'same-origin',
headers: Object.assign({ 'Content-Type': 'application/json' }, getCsrfHeaders()),
@@ -91,7 +89,7 @@
});
if (!resp.ok) {
var err = await resp.json().catch(function () {
const err = await resp.json().catch(() => {
return {};
});
throw new Error(err.message || 'Action failed');