mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-06 08:24:27 +01:00
webui: more typings, clean-up sensor units init
This commit is contained in:
@@ -2,12 +2,21 @@ import { randomString } from './core.mjs';
|
||||
import { setChangedElement } from './settings.mjs';
|
||||
|
||||
function randomApiKey() {
|
||||
const elem = document.forms["form-admin"].elements.apiKey;
|
||||
const form = document.forms.namedItem("form-admin");
|
||||
if (!form) {
|
||||
return;
|
||||
}
|
||||
|
||||
const elem = form.elements.namedItem("apiKey");
|
||||
if (!(elem instanceof HTMLInputElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
elem.value = randomString(16, {hex: true});
|
||||
setChangedElement(elem);
|
||||
}
|
||||
|
||||
export function init() {
|
||||
document.querySelector(".button-apikey")
|
||||
.addEventListener("click", randomApiKey);
|
||||
?.addEventListener("click", randomApiKey);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user