diff --git a/categories/view_card.html b/categories/view_card.html index 9164311..dfcc8fb 100644 --- a/categories/view_card.html +++ b/categories/view_card.html @@ -21,9 +21,10 @@ {{end}} {{if .GivenPermissionToModify}}
  • -
    - + + { + const input = document.querySelector('.js-add-cat-name'), + datalist = document.querySelector('.js-add-cat-list') + if (!input || !datalist) return; + + const categories = await fetch('/category') + .then(resp => resp.text()) + .then(html => { + return Array + .from(new DOMParser() + .parseFromString(html, 'text/html') + .querySelectorAll('.mv-category .p-name')) + .map(a => a.innerText); + }); + + for (let cat of categories) { + let optionElement = document.createElement('option') + optionElement.value = cat + datalist.appendChild(optionElement) + } + input.setAttribute('list', 'cat-name-options') +})(); +