refactor(es modules): dissolve general.js

This commit is contained in:
Azgaar 2022-06-30 00:17:28 +03:00
parent 9206f46c42
commit 2e4d142cf7
90 changed files with 802 additions and 749 deletions

View file

@ -5,3 +5,18 @@ export function getNextId(core: string, index = 1) {
while (byId(core + index)) index++;
return core + index;
}
export function getInputValue(id: string) {
return (byId(id) as HTMLInputElement)?.value;
}
export function getInputNumber(id: string) {
return (byId(id) as HTMLInputElement)?.valueAsNumber;
}
// apply drop-down menu option. If the value is not in options, add it
export function applyDropdownOption($select: HTMLSelectElement, value: string, name = value) {
const isExisting = Array.from($select.options).some(o => o.value === value);
if (!isExisting) $select.options.add(new Option(name, value));
$select.value = value;
}