show known types in form

This commit is contained in:
jomo 2022-08-05 22:05:51 +02:00
parent 8e19a1dbad
commit c763cdb23f
2 changed files with 13 additions and 0 deletions

View file

@ -30,6 +30,7 @@
<label for="type">Type</label>
<input id="type" type="text">
<p id="knowntypes"></p>
<label for="name">Name / Label</label>
<input id="name" type="text">

View file

@ -12,6 +12,7 @@ document.onreadystatechange = function() {
function fillForm() {
const item = items[id];
knownTypes();
const is_in = document.getElementById('is_in');
@ -52,6 +53,17 @@ function fillForm() {
}
}
function knownTypes() {
let map = {};
for (const i of Object.values(items)) {
if (i.type) {
map[i.type] = true;
}
}
let types = Object.keys(map).sort().join(', ')
document.getElementById('knowntypes').textContent = `Known types: ${types}.`;
}
function save() {
item = {
id: document.getElementById('id').value || null,