From b7e41b3003c0451ef6ddf6dbe01abbfca6144d3f Mon Sep 17 00:00:00 2001 From: Subhamoy Biswas Date: Fri, 17 Nov 2023 14:54:12 +0530 Subject: [PATCH] (feat): implemented basic dynamic search results on flotingwindow --- htdocs/assets/js/floatingbar-config.js | 28 ++++++++++++++++++- htdocs/assets/style.css | 38 ++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/htdocs/assets/js/floatingbar-config.js b/htdocs/assets/js/floatingbar-config.js index 96d174f..520bf91 100644 --- a/htdocs/assets/js/floatingbar-config.js +++ b/htdocs/assets/js/floatingbar-config.js @@ -100,7 +100,7 @@ function perform_search(searchInput, searchDef, searchRes) { dataType: 'json', data: { keyword: searchString }, success: function(response) { - console.log(response); + inject_search_results(response); }, error: function(error) { console.error('error:', error); @@ -118,6 +118,32 @@ function fallback_search(searchDef, searchRes) { searchRes.classList.add("hidden"); } +function inject_search_results (results) { + searchRes.innerHTML = `

SEARCH RESULTS

`; + + results.forEach(function(result) { + let resultDiv = document.createElement("div"); + resultDiv.className = "group resultitem w-full flex justify-between items-center my-1 p-1 cursor-pointer hover:bg-bg_third transition transform duration-200 rounded-lg"; + resultDiv.setAttribute("onclick", "location.href='" + result.link + "'"); + + resultDiv.innerHTML = ` + + ${result.name.charAt(0).toUpperCase()} + +
${result.name}
+

${result.description.slice(0, 35) + '...'}

+
+
+ + ${'#' + result.tag} + + + `; + + searchRes.appendChild(resultDiv); + }); +} + searchInput.addEventListener('input', function() { if (searchInput.value != "") { perform_search(searchInput, searchDef, searchRes); diff --git a/htdocs/assets/style.css b/htdocs/assets/style.css index 53df7cb..dd76133 100644 --- a/htdocs/assets/style.css +++ b/htdocs/assets/style.css @@ -522,8 +522,38 @@ video { --tw-backdrop-sepia: ; } -.static { - position: static; +.container { + width: 100%; +} + +@media (min-width: 640px) { + .container { + max-width: 640px; + } +} + +@media (min-width: 768px) { + .container { + max-width: 768px; + } +} + +@media (min-width: 1024px) { + .container { + max-width: 1024px; + } +} + +@media (min-width: 1280px) { + .container { + max-width: 1280px; + } +} + +@media (min-width: 1536px) { + .container { + max-width: 1536px; + } } .fixed { @@ -998,10 +1028,6 @@ video { cursor: pointer; } -.resize { - resize: both; -} - .flex-col { flex-direction: column; }