summaryrefslogtreecommitdiff
path: root/includes/components
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-02 23:03:02 +0200
committerRaindropsSys <contact@minteck.org>2023-04-02 23:03:02 +0200
commit02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b (patch)
tree6d1dec61008998aadc6b69f7e750712794d99324 /includes/components
parentf559308a1b42a9036135d764374a8c007b7d70a9 (diff)
downloadpluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.tar.gz
pluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.tar.bz2
pluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.zip
Updated 35 files, added 11 files and deleted includes/components/search.inc (automated)
Diffstat (limited to 'includes/components')
-rw-r--r--includes/components/footer.inc13
-rw-r--r--includes/components/header.inc16
-rw-r--r--includes/components/navigation.inc148
-rw-r--r--includes/components/pane.inc5
-rw-r--r--includes/components/search.inc534
-rw-r--r--includes/components/wakeup.inc2
6 files changed, 93 insertions, 625 deletions
diff --git a/includes/components/footer.inc b/includes/components/footer.inc
index d75b480..059d956 100644
--- a/includes/components/footer.inc
+++ b/includes/components/footer.inc
@@ -1,7 +1,8 @@
<?php
-
+global $start;
+$GLOBALS["ColdHazePerformance"]["page"] = (microtime(true) - $start) * 1000;
+$start = microtime(true);
global $pageFile;
-require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
?>
@@ -16,8 +17,10 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
global $lang; global $pages;
+ $time = microtime(true) - $GLOBALS["ColdHazeStart"];
+
?>
- © <?= date("Y") ?> <a href="https://equestria.horse" target="_blank" class="text-muted"><?= $lang["footer"]["copyright"] ?></a> · build <?= $version["build"] ?>.<?= $version["revision"] ?>
+ © <?= date("Y") ?> <a href="https://equestria.horse" target="_blank" class="text-muted"><?= $lang["footer"]["copyright"] ?></a> · build <?= $version["build"] ?>.<?= $version["revision"] ?>, took <?= round($time * 1000, 2) ?> ms
<br><br><br><br><br>
</div>
</div>
@@ -35,7 +38,9 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
})
</script>
-<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/search.inc"; ?>
+<?php if (isset($_GET["performance"])): ?>
+<pre><?php $GLOBALS["ColdHazePerformance"]["footer"] = (microtime(true) - $start) * 1000; var_dump($GLOBALS["ColdHazePerformance"]); ?></pre>
+<?php endif; ?>
</body>
</html> \ No newline at end of file
diff --git a/includes/components/header.inc b/includes/components/header.inc
index 06b9bdb..0542314 100644
--- a/includes/components/header.inc
+++ b/includes/components/header.inc
@@ -1,14 +1,6 @@
-<?php global $title; global $pages;
-
+<?php global $title; global $pages; global $readOnly;
+$start = microtime(true);
$useNewUI = !isset($_GET['old']);
-$readOnly = false;
-file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test", "hello");
-
-if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test")) {
- unlink($_SERVER['DOCUMENT_ROOT'] . "/includes/data/.test");
-} else {
- $readOnly = true;
-}
$isNormallyLoggedIn = false;
@@ -69,7 +61,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
<title><?= $title && $title !== "-" ? $title . " · " : "" ?>Cold Haze</title>
<link rel="shortcut icon" href="/assets/logo/newlogo<?= $isLoggedIn || $isLowerLoggedIn ? "3" : "" ?>.png" type="image/png">
</head>
-<body<?php if ($page["rail"] && $isLoggedIn && !$useNewUI): ?> id="admin-page"<?php endif; ?>>
+<body>
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/components/navigation.inc"; global $navigation; ?>
<?php if (!$useNewUI): ?>
@@ -246,4 +238,4 @@ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/util/functions.inc";
display: none;
}
</style>
-<?php } ?>
+<?php } $GLOBALS["ColdHazePerformance"]["header"] = (microtime(true) - $start) * 1000; $start = microtime(true); ?>
diff --git a/includes/components/navigation.inc b/includes/components/navigation.inc
index bd4ea4b..29168ec 100644
--- a/includes/components/navigation.inc
+++ b/includes/components/navigation.inc
@@ -4,7 +4,78 @@ $pages = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/pa
global $navigation;
global $toplevel;
-global $lang; global $pages; global $app; global $isLowerLoggedIn;
+global $lang; global $pages; global $app; global $isLowerLoggedIn; global $isLoggedIn;
+
+$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json"), true);
+
+if (!isset($cache["raindrops"])) $cache["raindrops"] = [];
+if (!isset($cache["cloudburst"])) $cache["cloudburst"] = [];
+if (!isset($cache["other"])) $cache["other"] = [];
+
+foreach ([
+ [
+ "name" => "raindrops",
+ "id" => "gdapd"
+ ],
+ [
+ "name" => "cloudburst",
+ "id" => "ynmuc"
+ ],
+ [
+ "name" => "other",
+ "id" => $app["other"]["id"]
+ ]
+] as $cacheSystem) {
+ if (!isset($cache[$cacheSystem["name"]]["public"])) {
+ $isLoggedInOldState = $isLoggedIn;
+ $isLowerLoggedInOldState = $isLowerLoggedIn;
+
+ $isLoggedIn = false;
+ $isLowerLoggedIn = false;
+
+ $cache[$cacheSystem["name"]]["public"] = array_map(function ($member) {
+ return [
+ "name" => $member['display_name'] ?? $member['name'],
+ "icon" => getAsset($member["system"], $member["id"], "heads"),
+ "invert" => false,
+ "link" => "/$member[name]",
+ "stepped" => null,
+ "private" => false
+ ];
+ }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$cacheSystem[id]/members.json"), true), "$cacheSystem[id]"), "$cacheSystem[id]"), function ($member) {
+ return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new";
+ }));
+
+ $isLoggedIn = $isLoggedInOldState;
+ $isLowerLoggedIn = $isLowerLoggedInOldState;
+ }
+
+ if (!isset($cache[$cacheSystem["name"]]["private"])) {
+ $isLoggedInOldState = $isLoggedIn;
+ $isLowerLoggedInOldState = $isLowerLoggedIn;
+
+ $isLoggedIn = true;
+ $isLowerLoggedIn = false;
+
+ $cache[$cacheSystem["name"]]["private"] = array_map(function ($member) {
+ return [
+ "name" => $member['display_name'] ?? $member['name'],
+ "icon" => getAsset($member["system"], $member["id"], "heads"),
+ "invert" => false,
+ "link" => "/$member[name]",
+ "stepped" => null,
+ "private" => false
+ ];
+ }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$cacheSystem[id]/members.json"), true), "$cacheSystem[id]"), "$cacheSystem[id]"), function ($member) {
+ return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new";
+ }));
+
+ $isLoggedIn = $isLoggedInOldState;
+ $isLowerLoggedIn = $isLowerLoggedInOldState;
+ }
+}
+
+file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json", json_encode($cache));
$navigation_admin = [
"admin" => !$isLowerLoggedIn,
@@ -173,41 +244,7 @@ $navigation_admin = [
"private" => false
],
]
- ],
- /*"debug" => [
- "name" => $lang["navigation"]["debug"],
- "minimal" => false,
- "items" => [
- [
- "name" => $pages["debug"]["name"][$lang["_name"]],
- "icon" => "/assets/icons/debug.svg",
- "invert" => true,
- "link" => "/-/debug",
- "stepped" => null
- ],
- [
- "name" => $pages["bitset"]["name"][$lang["_name"]],
- "icon" => "/assets/icons/bitset.svg",
- "invert" => true,
- "link" => "/-/bitset",
- "stepped" => null
- ],
- [
- "name" => $pages["score"]["name"][$lang["_name"]],
- "icon" => "/assets/icons/score.svg",
- "invert" => true,
- "link" => "/-/score",
- "stepped" => null
- ],
- [
- "name" => $pages["logout"]["name"][$lang["_name"]],
- "icon" => "/assets/icons/logout.svg",
- "invert" => true,
- "link" => "/-/logout",
- "stepped" => null
- ]
- ]
- ]*/
+ ]
]
];
$navigation_global = [
@@ -287,18 +324,7 @@ $navigation_cloudburst = [
"members" => [
"name" => $lang["navigation"]["members"],
"minimal" => false,
- "items" => array_map(function ($member) {
- return [
- "name" => $member['display_name'] ?? $member['name'],
- "icon" => getAsset($member["system"], $member["id"], "heads"),
- "invert" => false,
- "link" => "/$member[name]",
- "stepped" => null,
- "private" => false
- ];
- }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/ynmuc/members.json"), true), "ynmuc"), "ynmuc"), function ($member) {
- return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new";
- }))
+ "items" => $cache["cloudburst"][$isLoggedIn || $isLowerLoggedIn ? "private" : "public"]
]
]
];
@@ -341,18 +367,7 @@ $navigation_other = [
"members" => [
"name" => $lang["navigation"]["members"],
"minimal" => false,
- "items" => array_map(function ($member) {
- return [
- "name" => $member['display_name'] ?? $member['name'],
- "icon" => getAsset($member["system"], $member["id"], "heads"),
- "invert" => false,
- "link" => "/$member[name]",
- "stepped" => null,
- "private" => false
- ];
- }, array_filter(scoreOrder(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/other/members.json"), true), $app["other"]["id"]), function ($member) {
- return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new";
- }))
+ "items" => $cache["other"][$isLoggedIn || $isLowerLoggedIn ? "private" : "public"]
]
]
];
@@ -395,18 +410,7 @@ $navigation_raindrops = [
"members" => [
"name" => $lang["navigation"]["members"],
"minimal" => false,
- "items" => array_map(function ($member) {
- return [
- "name" => $member['display_name'] ?? $member['name'],
- "icon" => getAsset($member["system"], $member["id"], "heads"),
- "invert" => false,
- "link" => "/$member[name]",
- "stepped" => null,
- "private" => false
- ];
- }, array_filter(scoreOrder(withTravelers(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/gdapd/members.json"), true), "gdapd"), "gdapd"), function ($member) {
- return $member['name'] !== "unknown" && $member['name'] !== "fusion" && $member['name'] !== "new";
- }))
+ "items" => $cache["raindrops"][$isLoggedIn || $isLowerLoggedIn ? "private" : "public"]
]
]
];
diff --git a/includes/components/pane.inc b/includes/components/pane.inc
index eb735f5..1ecbcdf 100644
--- a/includes/components/pane.inc
+++ b/includes/components/pane.inc
@@ -22,8 +22,9 @@ foreach ($list as $color) {
</div>
<?php if ($isLoggedIn || $isLowerLoggedIn): ?>
- <a onclick="toggleGlobalSearch();" id="login-link" class="login-link-clickable">
- <?= $lang["navigation"]["search"] ?>
+ <a href="/-/logout" id="login-link" class="login-link-clickable">
+ <img alt="" src="/assets/icons/logout.svg" style="filter:invert(1);width:24px;vertical-align: middle;">
+ <span style="vertical-align: middle;"><?= $pages["logout"]["name"]["en"] ?></span>
</a>
<?php else: ?>
<a href="/-/login" id="login-link" class="login-link-clickable">
diff --git a/includes/components/search.inc b/includes/components/search.inc
deleted file mode 100644
index 278ec41..0000000
--- a/includes/components/search.inc
+++ /dev/null
@@ -1,534 +0,0 @@
-<?php global $lang; global $pages; global $isLowerLoggedIn; global $isLoggedIn; ?>
-
-<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;"><?= $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/newlogo<?= $isLoggedIn || $isLowerLoggedIn ? "3" : "" ?>.png" style="width: 64px; height: 64px; margin-bottom: 10px;">
- <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>
- </div>
- </div>
-</div>
-
-<script src="/assets/editor/fuse.js"></script>
-
-<!--suppress JSUnresolvedFunction -->
-<script>
- 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 !== "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) use ($lang) {
- global $pages;
- global $isLoggedIn;
- global $isLowerLoggedIn;
-
- if (in_array(substr($i, 0, strlen($i) - 4), array_keys($pages)) && $pages[substr($i, 0, strlen($i) - 4)]["admin"] && !((!$pages[substr($i, 0, strlen($i) - 4)]["limited"] && $isLoggedIn) || ($pages[substr($i, 0, strlen($i) - 4)]["limited"] && $isLowerLoggedIn))) {
- return null;
- } else if (in_array(substr($i, 0, strlen($i) - 4), array_keys($pages))) {
- return [
- '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' => file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/icons/uncolored/" . substr($i, 0, strlen($i) - 4) . ".svg") ? ("/assets/icons/uncolored/" . (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/icons/uncolored/" . substr($i, 0, strlen($i) - 4) . ".svg") ? substr($i, 0, strlen($i) - 4) : "") . ".svg") : ("/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
- ];
- } else {
- return null;
- }
- }, $base), function ($i) {
- return isset($i);
- }));
-
- echo(base64_encode(json_encode($list)));
-
- ?>`));
- const pages = new Fuse(pages_list, {
- includeScore: true,
- keys: [
- {
- name: 'name',
- weight: 0.7
- },
- {
- name: 'description',
- weight: 0.5
- },
- {
- name: 'url',
- weight: 0.2
- }
- ]
- })
-
- const ponies_list = JSON.parse(atob(`<?php
-
- $base = array_values(scoreOrderGlobal());
- $list = array_map(function ($i) {
- return [
- 'name' => $i["display_name"] ?? $i["name"],
- 'description' => file_exists($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$i[id].html") ? strip_tags(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/content/$i[id].html")) : "",
- 'url' => '/' . $i["name"],
- 'icon' => getAsset($i["system"], $i["id"], "heads"),
- 'invert' => false
- ];
- }, $base);
-
- echo(base64_encode(json_encode($list)));
-
- ?>`));
- const ponies = new Fuse(ponies_list, {
- includeScore: true,
- keys: [
- {
- name: 'name',
- weight: 1
- },
- {
- name: 'description',
- weight: 0.7
- },
- {
- name: 'url',
- weight: 0.5
- }
- ]
- })
-
- const toys_list = JSON.parse(atob(`<?php
-
- global $isLoggedIn;
-
- if (false && $isLoggedIn) {
- $base = array_values(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/toys/toys.json"), true));
- $list = array_map(function ($i) {
- return [
- 'name' => $i["name"],
- 'description' => $i["description"],
- 'icon' => "/assets/icons/toys.svg",
- 'url' => "/-/toys/$i[id]",
- 'invert' => true
- ];
- }, $base);
-
- echo(base64_encode(json_encode($list)));
- } else {
- echo(base64_encode(json_encode([])));
- }
-
- ?>`));
- const toys = new Fuse(toys_list, {
- includeScore: true,
- keys: [
- {
- name: 'name',
- weight: 1
- },
- {
- name: 'description',
- weight: 0.7
- },
- {
- name: 'url',
- weight: 0.5
- }
- ]
- })
-
- const actions_list = JSON.parse(atob(`<?php
-
- global $isLoggedIn;
-
- if (false && $isLoggedIn) {
- $base = array_values(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/actions/actions.json"), true));
- $list = array_map(function ($i) {
- return [
- 'name' => $i["name"],
- 'description' => $i["description"],
- 'icon' => "/assets/icons/actions.svg",
- 'url' => "/-/actions/$i[id]",
- 'invert' => true
- ];
- }, $base);
-
- echo(base64_encode(json_encode($list)));
- } else {
- echo(base64_encode(json_encode([])));
- }
-
- ?>`));
- const actions = new Fuse(actions_list, {
- includeScore: true,
- keys: [
- {
- name: 'name',
- weight: 1
- },
- {
- name: 'description',
- weight: 0.7
- },
- {
- name: 'url',
- weight: 0.5
- }
- ]
- })
-
- const documents_list = JSON.parse(atob(`<?php
-
- global $isLoggedIn;
-
- if ($isLoggedIn) {
- $base = array_values(array_map(function ($i) {
- return [
- "id" => substr($i, 0, -5),
- ...(json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $i), true) ?? [])
- ];
- }, array_filter(scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs"), function ($i) {
- return !str_starts_with($i, ".") && str_ends_with($i, ".json");
- })));
- $list = array_map(function ($i) {
- return [
- 'name' => $i["name"],
- 'content' => strip_tags($i["contents"]),
- 'category' => $i["category"],
- 'icon' => "/assets/icons/docs.svg",
- 'url' => "/-/docs/$i[id]",
- 'invert' => true
- ];
- }, $base);
-
- echo(base64_encode(json_encode($list)));
- } else {
- echo(base64_encode(json_encode([])));
- }
-
- ?>`));
- const documents = new Fuse(documents_list, {
- includeScore: true,
- keys: [
- {
- name: 'name',
- weight: 1
- },
- {
- name: 'category',
- weight: 0.7
- },
- {
- name: 'content',
- weight: 0.4
- },
- {
- name: 'url',
- weight: 0.5
- }
- ]
- })
-
- window.shiftPresses = 0;
- window.searchBoxOpen = false;
- window.lastKnownSearchQuery = null;
-
- function toggleGlobalSearch() {
- window.shiftPresses = 0;
- console.log("Search!");
-
- if (document.getElementById("global-search-container").style.display === "none") {
- document.getElementById("global-search-container").style.display = "flex";
- document.getElementById("global-search-list").style.display = "none";
- document.getElementById("global-search-intro").style.display = "flex";
- document.getElementById("global-search-input").focus();
- document.getElementById("global-search-input").value = "";
- window.searchBoxOpen = true;
- } else if (document.getElementById("global-search-container").style.display === "flex") {
- document.getElementById("global-search-container").style.display = "none";
- window.searchBoxOpen = false;
- }
- }
-
- function globalSearchPlaceholder() {
- if (document.getElementById("global-search-input").innerText === "") {
- document.getElementById("global-search-placeholder").style.display = "";
- document.getElementById("global-search-autocomplete").innerText = "";
- document.getElementById("global-search-action").innerText = "";
- } else {
- document.getElementById("global-search-placeholder").style.display = "none";
- }
- }
-
- function globalSearchAutocomplete(firstResult) {
- let querySearch = document.getElementById("global-search-input").innerText.toLowerCase();
- let firstResultSearch = firstResult.name.toLowerCase();
- let isAutocomplete = true;
-
- if (firstResultSearch.length > querySearch.length) {
- let count = 0;
-
- for (let i = 0; i < querySearch.length; i++) {
- if (querySearch.substring(i, i + 1) === firstResultSearch.substring(i, i + 1)) {
- count++;
- } else {
- isAutocomplete = false;
- }
- }
-
- if (isAutocomplete) {
- document.getElementById("global-search-autocomplete").innerText = firstResult.name.substring(count);
- document.getElementById("global-search-action").innerText = " — <?= $lang["search"]["view"] ?>";
- } else {
- document.getElementById("global-search-autocomplete").innerText = "";
- document.getElementById("global-search-action").innerText = " — " + firstResult.name;
- }
- } else {
- document.getElementById("global-search-autocomplete").innerText = "";
- document.getElementById("global-search-action").innerText = "";
- }
- }
-
- function globalSearch() {
- let query = document.getElementById("global-search-input").innerText.trim();
-
- if (query !== lastKnownSearchQuery) {
- window.lastKnownSearchQuery = query;
- } else {
- return;
- }
-
- let results, scores;
- let categories = [];
- console.log("Query:", query);
-
- if (query.trim() === "") {
- document.getElementById("global-search-list").style.display = "none";
- document.getElementById("global-search-intro").style.display = "flex";
- return;
- } else {
- document.getElementById("global-search-list").style.display = "block";
- document.getElementById("global-search-intro").style.display = "none";
- }
-
- results = ponies.search(query).map((i) => {
- i.item.score = i.score;
- return i.item;
- });
- scores = results.map((i) => { return i.score; });
- let results_ponies = {
- category: {
- name: "<?= $lang["search"]["categories"][0] ?>",
- id: "ponies"
- },
- average: scores.length > 0 ? scores.reduce((a, b) => { return a + b; }) / results.length : 1,
- results
- };
-
- results = pages.search(query).map((i) => {
- i.item.score = i.score;
- return i.item;
- });
- scores = results.map((i) => { return i.score; });
- let results_pages = {
- category: {
- name: "<?= $lang["search"]["categories"][1] ?>",
- id: "pages"
- },
- average: scores.length > 0 ? scores.reduce((a, b) => { return a + b; }) / results.length : 1,
- results
- };
-
- results = actions.search(query).map((i) => {
- i.item.score = i.score;
- return i.item;
- });
- scores = results.map((i) => { return i.score; });
- let results_actions = {
- category: {
- name: "<?= $lang["search"]["categories"][2] ?>",
- id: "actions"
- },
- average: scores.length > 0 ? scores.reduce((a, b) => { return a + b; }) / results.length : 1,
- results
- };
-
- results = documents.search(query).map((i) => {
- i.item.score = i.score;
- return i.item;
- });
- scores = results.map((i) => { return i.score; });
- let results_documents = {
- category: {
- name: "<?= $lang["search"]["categories"][3] ?>",
- id: "docs"
- },
- average: scores.length > 0 ? scores.reduce((a, b) => { return a + b; }) / results.length : 1,
- results
- };
-
- results = toys.search(query).map((i) => {
- i.item.score = i.score;
- return i.item;
- });
- scores = results.map((i) => { return i.score; });
- let results_toys = {
- category: {
- name: "<?= $lang["search"]["categories"][4] ?>",
- id: "toys"
- },
- average: scores.length > 0 ? scores.reduce((a, b) => { return a + b; }) / results.length : 1,
- results
- };
-
- window.allSearchResults = [];
- categories.push(results_ponies, results_pages, results_documents, results_actions, results_toys);
- categories = categories.sort((a, b) => {
- return a.average - b.average;
- }).filter((i) => i.results.length > 0);
-
- console.log(categories);
-
- index = -1;
- document.getElementById("global-search-list").innerHTML = categories.map((i) => `
- <div class="global-search-category">
- <div class="global-search-category-header">${i.category.name}</div>
- <div class="global-search-category-items">
- ${i.results.map((j) => { index++; allSearchResults.push(j); return `
- <a href="${j.url}" class="global-search-item ${index === 0 ? 'selected' : ''}" id="global-search-item-${index}">
- <img src="${j.icon}" class="global-search-item-icon" ${j['invert'] ? 'style="filter:invert(1) brightness(5);"' : ""}>
- <span class="global-search-item-title">${j.name}</span>
- </a>
- ` }).join("")}
- </div>
- </div>
- `).join("");
-
- globalSearchAutocomplete(allSearchResults[0]);
-
- console.log("=================================");
- }
-
- document.onkeydown = (event) => {
- if (window.searchBoxOpen) {
- console.log(event);
-
- if (event.key === "Escape") {
- if (document.getElementById("global-search-input").innerText.trim() === "") {
- toggleGlobalSearch();
- } else {
- document.getElementById("global-search-input").innerText = "";
- globalSearch();
- }
- }
-
- if (event.key === "ArrowDown") {
- let id = parseInt(document.querySelector(".global-search-item.selected").id.split("-")[3]);
-
- if (document.getElementById("global-search-item-" + (id + 1)) !== null) {
- document.getElementById("global-search-item-" + id).classList.remove("selected");
- document.getElementById("global-search-item-" + (id + 1)).classList.add("selected");
- document.getElementById("global-search-item-" + (id + 1)).scrollIntoView({
- block: "center",
- inline: "center"
- });
-
- globalSearchAutocomplete(allSearchResults[id + 1]);
- }
-
- event.preventDefault();
- }
-
- if (event.key === "ArrowUp") {
- let id = parseInt(document.querySelector(".global-search-item.selected").id.split("-")[3]);
-
- if (document.getElementById("global-search-item-" + (id - 1)) !== null) {
- document.getElementById("global-search-item-" + id).classList.remove("selected");
- document.getElementById("global-search-item-" + (id - 1)).classList.add("selected");
- document.getElementById("global-search-item-" + (id - 1)).scrollIntoView({
- block: "center",
- inline: "center"
- });
-
- globalSearchAutocomplete(allSearchResults[id - 1]);
- }
-
- event.preventDefault();
- }
-
- if (event.key === "Enter") {
- document.querySelector(".global-search-item.selected").click();
-
- event.preventDefault();
- }
- }
-
- if (event.key === "Shift") {
- window.shiftPresses++;
- }
-
- if ((event.code === "Space" && event.ctrlKey) || window.shiftPresses === 2 && document.getElementsByClassName("ck-focused").length === 0) {
- toggleGlobalSearch();
- }
- }
-
- document.getElementById("global-search-container").onclick = (event) => {
- if (event.target === document.getElementById("global-search-container")) toggleGlobalSearch();
- }
-
- setInterval(() => {
- window.shiftPresses = 0;
- }, 500);
-</script>
-
-<style>
- .global-search-category {
- text-align: left;
- padding: 10px 20px;
- }
-
- .global-search-category-header {
- font-size: 12px;
- opacity: .5;
- margin-bottom: 5px;
- margin-top: 10px;
- }
-
- .global-search-item-icon {
- vertical-align: middle;
- width: 24px;
- height: 24px;
- margin-right: 5px;
- }
-
- .global-search-item-title {
- vertical-align: middle;
- }
-
- .global-search-item {
- text-decoration: none;
- display: block;
- color: white !important;
- border-radius: 10px;
- padding: 3px 5px;
- height: 32px;
- }
-
- .global-search-item:hover, .global-search-item:focus, .global-search-item.selected {
- background-color: rgba(255, 255, 255, .1);
- }
-
- .global-search-item:active {
- background-color: rgba(255, 255, 255, .2);
- }
-
- #global-search-container * {
- outline: none !important;
- }
-</style> \ No newline at end of file
diff --git a/includes/components/wakeup.inc b/includes/components/wakeup.inc
index 818378a..cc54821 100644
--- a/includes/components/wakeup.inc
+++ b/includes/components/wakeup.inc
@@ -104,7 +104,7 @@
if (window.alertIntervalCounter === 0) {
sendNotification();
} else if (window.alertIntervalCounter > -1) {
- document.getElementById("next-notification").innerText = window.alertIntervalCounter + " second" + (window.alertIntervalCounter > 1 ? "s" : "");
+ document.getElementById("next-notification").innerText = "in " + window.alertIntervalCounter + " second" + (window.alertIntervalCounter > 1 ? "s" : "");
}
}, 1000);
}