diff --git a/static/scripts.js b/static/scripts.js index 41a4731..b300225 100644 --- a/static/scripts.js +++ b/static/scripts.js @@ -115,6 +115,15 @@ const elFormSearch = document.body.querySelector("#search"); if (elFormSearch) { elFormSearch.onsubmit = function (evt) { evt.preventDefault(); + + const protocol = elFormSearch.querySelector("input[type='radio']:checked").value; + const identifier = elFormSearch.querySelector("input[type='search']").value; + + if (protocol == 'sig') { + window.location.href = `/${protocol}`; + } else { + window.location.href = `/${protocol}/${encodeURIComponent(identifier)}`; + } } const elSearchRadio = elFormSearch.querySelectorAll("input[type='radio']"); diff --git a/views/index.pug b/views/index.pug index 2479856..dae2443 100644 --- a/views/index.pug +++ b/views/index.pug @@ -14,7 +14,7 @@ block content #search.form-wrapper.card h2 Generate a profile form(action="post") - input(type="search" name="query" placeholder="3637202523e7c1309ab79e99ef2dc5827b445f4b, test@doip.rocks") + input(type="search" name="query" required placeholder="3637202523e7c1309ab79e99ef2dc5827b445f4b, test@doip.rocks") div.radio-wrapper input#protocol-hkp(type="radio" name="protocol" value="hkp" checked="true") label(for="protocol-hkp") HKP