diff --git a/htdocs/assets/_floatingbar.php b/htdocs/assets/_floatingbar.php index d2d284c..c03800f 100644 --- a/htdocs/assets/_floatingbar.php +++ b/htdocs/assets/_floatingbar.php @@ -46,7 +46,7 @@ -

QUICK SHOTCUTS

+

QUICK ACTIONS

diff --git a/htdocs/assets/js/floatingbar-config.js b/htdocs/assets/js/floatingbar-config.js index c80cdf2..d4a5d94 100644 --- a/htdocs/assets/js/floatingbar-config.js +++ b/htdocs/assets/js/floatingbar-config.js @@ -138,7 +138,7 @@ function inject_search_results (results) { results.project.forEach(function(result) { let projectDiv = document.createElement("div"); projectDiv.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"; - projectDiv.setAttribute("onclick", "location.href='" + result.link + "'"); + projectDiv.setAttribute("onclick", "window.open('" + result.link + "', '_blank')"); projectDiv.innerHTML = ` @@ -178,6 +178,48 @@ function inject_search_results (results) { searchRes.appendChild(socialDiv); }); } + + if(typeof(results.page) !== 'undefined') { + results.page.forEach(function(result) { + let pageDiv = document.createElement("div"); + pageDiv.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"; + pageDiv.setAttribute("onclick", "location.href='" + result.link + "'"); + + pageDiv.innerHTML = ` + + +

${result.name}

+
+ + ${'#' + result.tag} + + + `; + + searchRes.appendChild(pageDiv); + }); + } + + if(typeof(results.action) !== 'undefined') { + results.action.forEach(function(result) { + let actionDiv = document.createElement("div"); + actionDiv.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"; + actionDiv.setAttribute("onclick", "window.open('" + result.link + "', '_blank')"); + + actionDiv.innerHTML = ` + + +

${result.name}

+
+ + ${'#' + result.tag} + + + `; + + searchRes.appendChild(actionDiv); + }); + } } function inject_no_results(results) { diff --git a/htdocs/core/handle_search.php b/htdocs/core/handle_search.php index ce1088a..6456b2d 100644 --- a/htdocs/core/handle_search.php +++ b/htdocs/core/handle_search.php @@ -5,11 +5,15 @@ require 'query_functions.php'; if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_POST['keyword'])) { $keyword = $_POST['keyword']; - $results_projects = fetch_search_results_projects($conn, $keyword); - $results_socials = fetch_search_results_socials($conn, $keyword); + $results_array = [ + $results_projects = fetch_search_results_projects($conn, $keyword), + $results_socials = fetch_search_results_socials($conn, $keyword), + $results_pages = fetch_search_results_pages($conn, $keyword), + $results_quickactions = fetch_search_results_quickactions($conn, $keyword) + ]; $results = []; - foreach ([$results_projects, $results_socials] as $array) { + foreach ($results_array as $array) { if (!empty($array)) { $results = array_merge($results, $array); } diff --git a/htdocs/core/query_functions.php b/htdocs/core/query_functions.php index ce47972..0319828 100644 --- a/htdocs/core/query_functions.php +++ b/htdocs/core/query_functions.php @@ -83,4 +83,36 @@ function fetch_search_results_socials($conn, $keyword) { return array(); } } + +//for pages table +function fetch_search_results_pages($conn, $keyword) { + $sql = "SELECT * FROM pages WHERE name LIKE '%$keyword%'"; + $result = $conn -> query($sql); + if($result -> num_rows > 0) { + $result = mysqli_fetch_all($result, MYSQLI_ASSOC); + foreach ($result as &$element) { + $element['tag'] = 'page'; + } + return $result; + } + else { + return array(); + } +} + +//for quick_actions table +function fetch_search_results_quickactions($conn, $keyword) { + $sql = "SELECT * FROM quick_actions WHERE name LIKE '%$keyword%'"; + $result = $conn -> query($sql); + if($result -> num_rows > 0) { + $result = mysqli_fetch_all($result, MYSQLI_ASSOC); + foreach ($result as &$element) { + $element['tag'] = 'action'; + } + return $result; + } + else { + return array(); + } +} ?> \ No newline at end of file