mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 02:21:24 +01:00
refactor(es modules): dissolve general.js
This commit is contained in:
parent
9206f46c42
commit
2e4d142cf7
90 changed files with 802 additions and 749 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue