From 87c9acfde10318d21f097d7c803d5f8d12516956 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Tue, 4 May 2021 10:40:04 +0200 Subject: [PATCH] Enable search form --- static/scripts.js | 9 +++++++++ views/index.pug | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) 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