github.com/navikt/knorten@v0.0.0-20240419132333-1333f46ed8b6/templates/charts/script.tmpl (about)

     1  {{ define "charts/script" }}
     2      function deleteRow(event) {
     3          const users = document.getElementById("allowlist");
     4          users.removeChild(event.target.parentElement.parentElement)
     5      }
     6  
     7      function addElement(host) {
     8          const target = document.getElementById("allowlist");
     9          target.insertAdjacentHTML("beforeend",
    10              `<div class="flex gap-2 mb-2">
    11                  <input 
    12                      class="navds-text-field__input navds-body-short navds-body-medium" 
    13                      type="text" 
    14                      name="allowlist[]" 
    15                      id="host" 
    16                      value="${host ? host : ''}"
    17                      placeholder="Host"
    18                  />
    19                  <button type="button" onclick="deleteRow(event)" class="navds-button navds-button--secondary">
    20                      <span class="navds-label">Slett</span>
    21                  </button>
    22              </div>` 
    23          );
    24      }
    25  {{ end }}