1
1
mirror of https://github.com/neosubhamoy/neosubhamoy-portfolio.git synced 2025-12-19 21:43:06 +05:30

(fixed): router and host_config for my local network cross device access

This commit is contained in:
2023-11-18 00:35:46 +05:30
parent 02834eb5f6
commit 771771e061
5 changed files with 28 additions and 8 deletions

View File

@@ -128,11 +128,11 @@ function inject_search_results (results) {
searchRes.innerHTML = `<p class="text-xs text-accent_three mt-3 mb-2 mx-1">SEARCH RESULTS</p>`;
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 + "'");
let projectsDiv = document.createElement("div");
projectsDiv.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";
projectsDiv.setAttribute("onclick", "location.href='" + result.link + "'");
resultDiv.innerHTML = `
projectsDiv.innerHTML = `
<span class="flex items-center">
<span class="mx-1 px-[0.65rem] py-1 rounded border-[1px] border-accent_secondary_transparent">${result.name.charAt(0).toUpperCase()}</span>
<span class="flex flex-col">
@@ -146,7 +146,7 @@ function inject_search_results (results) {
</span>
`;
searchRes.appendChild(resultDiv);
searchRes.appendChild(projectsDiv);
});
}

View File

@@ -5,7 +5,9 @@ require 'query_functions.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['keyword'])) {
$keyword = $_POST['keyword'];
$results = fetch_search_results($conn, $keyword);
$results_projects = fetch_search_results_projects($conn, $keyword);
$results_socials = fetch_search_results_socials($conn, $keyword);
$results = array_merge($results_projects, $results_socials);
echo json_encode($results);
}
}

View File

@@ -4,6 +4,9 @@ $currentHost = $_SERVER['HTTP_HOST'];
if($currentHost == "localhost") {
$basePath = "https://localhost/neosubhamoy/htdocs";
}
elseif ($currentHost == "192.168.29.177") {
$basePath = "https://192.168.29.177/neosubhamoy/htdocs";
}
else {
$basePath = "https://" . $currentHost;
}

View File

@@ -51,7 +51,7 @@ function fetch_social_icon($conn, $platform_name) {
}
}
function fetch_search_results($conn, $keyword) {
function fetch_search_results_projects($conn, $keyword) {
$sql = "SELECT * FROM projects WHERE name LIKE '%$keyword%'";
$result = $conn -> query($sql);
if($result -> num_rows > 0) {
@@ -65,4 +65,19 @@ function fetch_search_results($conn, $keyword) {
return array('results' => 'none', 'message' => ': ( &nbsp; No Results Found');
}
}
function fetch_search_results_socials($conn, $keyword) {
$sql = "SELECT * FROM socials WHERE platform LIKE '%$keyword%'";
$result = $conn -> query($sql);
if($result -> num_rows > 0) {
$result = mysqli_fetch_all($result, MYSQLI_ASSOC);
foreach ($result as &$element) {
$element['tag'] = 'social';
}
return $result;
}
else {
return array('results' => 'none', 'message' => ': ( &nbsp; No Results Found');
}
}
?>

View File

@@ -16,7 +16,7 @@ $devRoutes = [
'/neosubhamoy/htdocs/contact' => 'contact.php',
];
if ($host == "localhost") {
if ($host == "localhost" || $host == "192.168.29.177") {
$routes = $devRoutes;
}
else {