1
1
mirror of https://github.com/neosubhamoy/neosubhamoy-portfolio.git synced 2025-12-20 01:09:35 +05:30

(feat): added profiles to search results

This commit is contained in:
2023-11-19 20:46:14 +05:30
parent cf1a410013
commit 348a8d7ea1
3 changed files with 49 additions and 1 deletions

View File

@@ -241,6 +241,37 @@ function inject_search_results (results, keyword) {
searchRes.appendChild(actionDiv); searchRes.appendChild(actionDiv);
}); });
} }
if(typeof(results.profile) !== 'undefined') {
let profileDivTitle = document.createElement("p");
profileDivTitle.className = "text-xs text-accent_three mt-3 mb-2 mx-1";
profileDivTitle.innerHTML = "PROFILES";
searchRes.appendChild(profileDivTitle);
results.profile.forEach(function(result) {
let profileDiv = document.createElement("div");
profileDiv.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";
profileDiv.setAttribute("onclick", "window.open('" + result.link + "', '_blank')");
profileDiv.innerHTML = `
<span class="flex items-center">
<span class="wrapper mx-1 w-[35px] rounded-lg overflow-hidden">
<img src="${result.photo}" alt="${result.name.toLowerCase().replace(/\s/g, '')}">
</span>
<span class="flex flex-col">
<h6 class="mx-1">${result.name}</h6>
<p class="mx-1 text-xs text-accent_three">${result.description}</p>
</span>
</span>
<span class="flex items-center mr-1">
<span class="px-[1rem] py-[0.05rem] mx-1 text-xs bg-accent_four text-bg_secondary rounded-full group-hover:hidden">${'#' + result.tag}</span>
<i class="fa-solid fa-chevron-right text-accent_three mx-2 hidden group-hover:block"></i>
</span>
`;
searchRes.appendChild(profileDiv);
});
}
} }
function inject_no_results(results, keyword) { function inject_no_results(results, keyword) {

View File

@@ -17,7 +17,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$results_projects = fetch_search_results_projects($conn, $keyword), $results_projects = fetch_search_results_projects($conn, $keyword),
$results_socials = fetch_search_results_socials($conn, $keyword), $results_socials = fetch_search_results_socials($conn, $keyword),
$results_pages = fetch_search_results_pages($conn, $keyword), $results_pages = fetch_search_results_pages($conn, $keyword),
$results_quickactions = fetch_search_results_quickactions($conn, $keyword) $results_quickactions = fetch_search_results_quickactions($conn, $keyword),
$results_profiles = fetch_search_results_profiles($conn, $keyword)
]; ];
$results = []; $results = [];

View File

@@ -115,4 +115,20 @@ function fetch_search_results_quickactions($conn, $keyword) {
return array(); return array();
} }
} }
//for quick_actions table
function fetch_search_results_profiles($conn, $keyword) {
$sql = "SELECT * FROM profile WHERE name LIKE '%$keyword%' OR stag LIKE '%$keyword%'";
$result = $conn -> query($sql);
if($result -> num_rows > 0) {
$result = mysqli_fetch_all($result, MYSQLI_ASSOC);
foreach ($result as &$element) {
$element['tag'] = 'profile';
}
return $result;
}
else {
return array();
}
}
?> ?>