diff options
author | Minteck <contact@minteck.org> | 2022-12-10 22:27:08 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2022-12-10 22:27:08 +0100 |
commit | 30303a3ad0d0f31d93c25f42bfd10d70e8277b72 (patch) | |
tree | 622964e7895c759232aff28230394aa5cc747be9 /includes/search.inc | |
parent | f850a8a53efd719fef6c8784c5af7b89dd9a6a2f (diff) | |
download | pluralconnect-30303a3ad0d0f31d93c25f42bfd10d70e8277b72.tar.gz pluralconnect-30303a3ad0d0f31d93c25f42bfd10d70e8277b72.tar.bz2 pluralconnect-30303a3ad0d0f31d93c25f42bfd10d70e8277b72.zip |
Update
Diffstat (limited to 'includes/search.inc')
-rw-r--r-- | includes/search.inc | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/includes/search.inc b/includes/search.inc index f240363..c125556 100644 --- a/includes/search.inc +++ b/includes/search.inc @@ -1,13 +1,15 @@ +<?php global $lang; global $pages; ?> + <div id="global-search-container" style="display: none; position: fixed; z-index: 99999999;background-color: rgba(0, 0, 0, .75); inset: 0; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); align-items: center; justify-content: center;"> <div id="global-search-box" style="background: rgba(50, 50, 50, .5); color: white; backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); border-radius: 15px; width: 768px; max-width: 90vw;"> <div id="global-search-input-container" onclick="document.getElementById('global-search-input').focus();" style="cursor:text;padding: 10px 50px; font-size: 22px; border: 1px solid rgba(100, 100, 100, .5); border-top-left-radius: 15px; border-top-right-radius: 15px; width: 768px; max-width: 90vw;"> - <span onchange="globalSearchPlaceholder(); globalSearch();" onkeyup="globalSearchPlaceholder(); globalSearch();" onkeydown="globalSearchPlaceholder(); globalSearch();" type="text" id="global-search-input" style="vertical-align: middle; display:inline-block; background: transparent; color: white; border: none;" spellcheck="false" contenteditable="true"></span><span id="global-search-placeholder" style="opacity:.5;">Website Search</span><span id="global-search-autocomplete" style="vertical-align: middle; opacity:.5;"></span><span id="global-search-action" style="vertical-align: middle; opacity:.5;font-size:16px;"></span> + <span onchange="globalSearchPlaceholder(); globalSearch();" onkeyup="globalSearchPlaceholder(); globalSearch();" onkeydown="globalSearchPlaceholder(); globalSearch();" type="text" id="global-search-input" style="vertical-align: middle; display:inline-block; background: transparent; color: white; border: none;" spellcheck="false" contenteditable="true"></span><span id="global-search-placeholder" style="opacity:.5;"><?= $lang["search"]["title"] ?></span><span id="global-search-autocomplete" style="vertical-align: middle; opacity:.5;"></span><span id="global-search-action" style="vertical-align: middle; opacity:.5;font-size:16px;"></span> </div> <div id="global-search-results" style="border-bottom-left-radius: 15px; border-bottom-right-radius: 15px; border-top-style: none; border-right: 1px solid rgba(100, 100, 100, .5); border-bottom: 1px solid rgba(100, 100, 100, .5); border-left: 1px solid rgba(100, 100, 100, .5); width: 768px; max-width: 90vw; height: 400px; max-height: calc(90vh - 60px);"> <div id="global-search-intro" style="display: flex; align-items: center; justify-content: center; height: 100%; text-align: center;"> <div style="opacity: .5;"> <img src="/assets/logo/logo.png" style="width: 64px; height: 64px; margin-bottom: 10px;"> - <p>Start typing to search for something on the entire website.</p> + <p><?= $lang["search"]["placeholder"] ?></p> </div> </div> <div id="global-search-list" style="overflow: auto; display: flex; align-items: center; justify-content: center; height: 100%; text-align: center;"></div> @@ -22,9 +24,9 @@ const pages_list = JSON.parse(atob(`<?php $base = array_values(array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/pages"), function ($i) { - return !str_starts_with($i, ".") && $i !== "page.inc" && $i !== "api.inc" && $i !== "demo.inc" && $i !== "logout.inc" && $i !== "edit.inc" && $i !== "edit-private.inc" && $i !== "app.inc" && !str_ends_with($i, ".bak.php") && !str_ends_with($i, ".old.php") && !str_ends_with($i, "-dev.php") && !str_ends_with($i, ".bak.inc") && !str_ends_with($i, ".old.inc") && !str_ends_with($i, "-dev.inc"); + return !str_starts_with($i, ".") && $i !== "page.inc" && $i !== "api.inc" && $i !== "demo.inc" && $i !== "logout.inc" && $i !== "edit.inc" && $i !== "metadata.inc" && $i !== "edit-private.inc" && $i !== "app.inc" && !str_ends_with($i, ".bak.php") && !str_ends_with($i, ".old.php") && !str_ends_with($i, "-dev.php") && !str_ends_with($i, ".bak.inc") && !str_ends_with($i, ".old.inc") && !str_ends_with($i, "-dev.inc"); })); - $list = array_values(array_filter(array_map(function ($i) { + $list = array_values(array_filter(array_map(function ($i) use ($lang) { global $pages; global $isLoggedIn; @@ -32,8 +34,8 @@ return null; } else { return [ - 'name' => in_array(substr($i, 0, strlen($i) - 4), array_keys($pages)) ? $pages[substr($i, 0, strlen($i) - 4)]["name"] : substr($i, 0, strlen($i) - 4), - 'description' => in_array(substr($i, 0, strlen($i) - 4), array_keys($pages)) ? ($pages[substr($i, 0, strlen($i) - 4)]["short"] ?? $pages[substr($i, 0, strlen($i) - 4)]["name"]) : substr($i, 0, strlen($i) - 4), + 'name' => in_array(substr($i, 0, strlen($i) - 4), array_keys($pages)) ? $pages[substr($i, 0, strlen($i) - 4)]["name"][$lang["_name"]] : substr($i, 0, strlen($i) - 4), + 'description' => in_array(substr($i, 0, strlen($i) - 4), array_keys($pages)) ? ($pages[substr($i, 0, strlen($i) - 4)]["short"] ?? $pages[substr($i, 0, strlen($i) - 4)]["name"][$lang["_name"]]) : substr($i, 0, strlen($i) - 4), 'url' => "/-/" . substr($i, 0, strlen($i) - 4), 'icon' => "/assets/icons/" . (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/icons/" . substr($i, 0, strlen($i) - 4) . ".svg") ? substr($i, 0, strlen($i) - 4) : "") . ".svg", 'invert' => true @@ -279,7 +281,7 @@ if (isAutocomplete) { document.getElementById("global-search-autocomplete").innerText = firstResult.name.substring(count); - document.getElementById("global-search-action").innerText = " — View page"; + document.getElementById("global-search-action").innerText = " — <?= $lang["search"]["view"] ?>"; } else { document.getElementById("global-search-autocomplete").innerText = ""; document.getElementById("global-search-action").innerText = " — " + firstResult.name; @@ -319,7 +321,7 @@ scores = results.map((i) => { return i.score; }); let results_ponies = { category: { - name: "Ponies", + name: "<?= $lang["search"]["categories"][0] ?>", id: "ponies" }, average: scores.length > 0 ? scores.reduce((a, b) => { return a + b; }) / results.length : 1, @@ -333,7 +335,7 @@ scores = results.map((i) => { return i.score; }); let results_pages = { category: { - name: "Pages", + name: "<?= $lang["search"]["categories"][1] ?>", id: "pages" }, average: scores.length > 0 ? scores.reduce((a, b) => { return a + b; }) / results.length : 1, @@ -347,7 +349,7 @@ scores = results.map((i) => { return i.score; }); let results_actions = { category: { - name: "Actions", + name: "<?= $lang["search"]["categories"][2] ?>", id: "actions" }, average: scores.length > 0 ? scores.reduce((a, b) => { return a + b; }) / results.length : 1, @@ -361,7 +363,7 @@ scores = results.map((i) => { return i.score; }); let results_documents = { category: { - name: "Documents", + name: "<?= $lang["search"]["categories"][3] ?>", id: "docs" }, average: scores.length > 0 ? scores.reduce((a, b) => { return a + b; }) / results.length : 1, @@ -375,7 +377,7 @@ scores = results.map((i) => { return i.score; }); let results_toys = { category: { - name: "Toys", + name: "<?= $lang["search"]["categories"][4] ?>", id: "toys" }, average: scores.length > 0 ? scores.reduce((a, b) => { return a + b; }) / results.length : 1, |