/* * Query handling. */ const params = new Proxy(new URLSearchParams(window.location.search), { get: (searchParams, prop) => searchParams.get(prop), }); const qstring = params.q; if (qstring != undefined) { (async () => { // Re-fill query string in form field. const search_field = document.getElementById("qry_f"); search_field.value = qstring; const fuse = await fuse_init(); const results = fuse.search(qstring); console.log(results); const res_el = document.getElementById('result_list'); results.forEach(sres => { const rsrc = sres.item; const res_tn = document.createElement("img"); res_tn.setAttribute("src", window.webroot + rsrc.tn); res_tn.setAttribute("alt", rsrc.Title); res_txt = document.createTextNode(rsrc.Title); const res_link = document.createElement("a"); res_link.setAttribute("href", window.webroot + rsrc.href); res_link.appendChild(res_tn); res_link.appendChild(res_txt); const res_li = document.createElement("li"); res_li.setAttribute("id", "sres-" + rsrc.id); res_li.appendChild(res_link); res_el.appendChild(res_li); }); // Reveal section after populating. const res_sec = document.getElementById('search_results'); res_sec.classList.remove("hidden"); })(); }