summaryrefslogtreecommitdiff
path: root/app/ui/listing.php
diff options
context:
space:
mode:
authorRaindropsSys <raindrops@equestria.dev>2023-10-31 17:04:34 +0100
committerRaindropsSys <raindrops@equestria.dev>2023-10-31 17:04:34 +0100
commite61e581a2b66b0444db01d884465ea913929e343 (patch)
treeb49eaedb3681c4b26637acdd375cda4c3d37b07c /app/ui/listing.php
parent41c51b8bdb9c8e9fa4a7d56f260d594739d4107e (diff)
downloadmist-e61e581a2b66b0444db01d884465ea913929e343.tar.gz
mist-e61e581a2b66b0444db01d884465ea913929e343.tar.bz2
mist-e61e581a2b66b0444db01d884465ea913929e343.zip
Updated 27 files, added 12 files and deleted 3 files (automated)
Diffstat (limited to 'app/ui/listing.php')
-rw-r--r--app/ui/listing.php56
1 files changed, 37 insertions, 19 deletions
diff --git a/app/ui/listing.php b/app/ui/listing.php
index d32525b..510fa58 100644
--- a/app/ui/listing.php
+++ b/app/ui/listing.php
@@ -87,15 +87,30 @@ if (!$presetList) {
<script>
window.parent.location.hash = "#/albums/<?= $_GET["a"] ?>";
</script>
+ <?php endif; if (isset($favoritesList)): global $userId; ?>
+ <script>
+ window.parent.location.hash = "#/favorites/<?= $userId ?>";
+ </script>
<?php endif; ?>
<div class="container">
<br>
- <?php if (isset($favoritesList) && !$hasAlbum): ?>
+ <?php if (isset($favoritesList) && !$hasAlbum): global $userId; ?>
<div id="album-info" style="display: grid; grid-template-columns: 20vw 1fr; margin-top: 10px; margin-left: 10px; grid-gap: 30px;">
<img id="album-info-art" alt="" src="/assets/favorites.svg" style="height: 20vw; width: 20vw; border-radius: .75vw;">
<div id="album-info-text" style="padding: 30px 0; display: grid; grid-template-rows: 1fr max-content;">
<div><h2>Favorites</h2>
- <h2 style="opacity: .5;"><?= $_PROFILE["name"] ?></h2>
+ <h2 style="opacity: .5;">
+ <select onchange="changeView();" id="favorites-user-select" class="form-select" style="width: max-content;font-size: inherit;margin: -0.375rem 0 -0.375rem -0.75rem;">
+ <option <?= $userId === $_PROFILE["id"] ? "selected" : "" ?> value="<?= $_PROFILE["id"] ?>"><?= $_PROFILE["name"] ?></option>
+ <?php foreach (scandir($_SERVER['DOCUMENT_ROOT'] . "/includes/users") as $user):
+ if (str_ends_with($user, "-privacy.json")):
+ $userPrivacy = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . $user), true);
+ $userProfile = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/users/" . substr($user, 0, -13) . "-profile.json"), true);
+ if ($userPrivacy["listen"] >= 1 && $userProfile["id"] !== $_PROFILE["id"]): ?>
+ <option <?= $userId === $userProfile["id"] ? "selected" : "" ?> value="<?= $userProfile["id"] ?>"><?= $userProfile["name"] ?></option>
+ <?php endif; endif; endforeach; ?>
+ </select>
+ </h2>
<div style="opacity: .5;">
Click on the heart icon near a song to add it to this list.
</div>
@@ -153,7 +168,7 @@ if (!$presetList) {
<img class="icon" src="/assets/logo-transparent.svg" style="filter: grayscale(1) invert(1); width: 96px; height: 96px;" alt="">
<h4 style="opacity: .75;">Add music to your library</h4>
<p style="max-width: 300px; margin-left: auto; margin-right: auto;">Browse millions of songs and collect your favorites here.</p>
- <div class="btn btn-primary" onclick="window.parent.openUI('explore');">Browse Mist</div>
+ <div class="btn btn-primary" onclick="window.parent.openUI('home');">Browse Mist</div>
</div>
</div>
<?php endif; ?>
@@ -183,29 +198,16 @@ if (!$presetList) {
}
<?php endif; ?>
- let items = Array.from(document.getElementsByClassName("track")).map(i => { return { title: i.getAttribute("data-item-track"), artist: i.getAttribute("data-item-artist"), id: i.id } });
-
- const fuse = new Fuse(items, {
- keys: [
- {
- name: 'title',
- weight: 1
- },
- {
- name: 'artist',
- weight: .5
- }
- ]
- });
+ let items = Array.from(document.getElementsByClassName("track")).map(i => { return { title: i.getAttribute("data-item-track").toLowerCase().replace(/[^a-z\d ]/mg, " ").replace(/ +/mg, " "), artist: i.getAttribute("data-item-artist").toLowerCase().replace(/[^a-z\d ]/mg, " ").replace(/ +/mg, " "), id: i.id } });
function updateFilter() {
- let query = document.getElementById("filter").value.trim();
+ let query = document.getElementById("filter").value.trim().toLowerCase().replace(/[^a-z\d ]/mg, " ").replace(/ +/mg, " ");
if (query !== "") {
document.getElementById("search-results").style.display = "flex";
document.getElementById("main-list").style.display = "none";
- let results = items.filter(i => i.title.toLowerCase().replace(/[^a-z\d ]/mg, " ").replace(/ +/mg, " ").includes(query.toLowerCase().replace(/[^a-z\d ]/mg, " ").replace(/ +/mg, " ")) || i.artist.toLowerCase().replace(/[^a-z\d ]/mg, " ").replace(/ +/mg, " ").includes(query.toLowerCase().replace(/[^a-z\d ]/mg, " ").replace(/ +/mg, " ")));
+ let results = items.filter(i => i.title.includes(query) || i.artist.includes(query)).slice(0, 50);
document.getElementById("search-results").innerHTML = "";
for (let result of results) {
@@ -216,8 +218,24 @@ if (!$presetList) {
document.getElementById("main-list").style.display = "flex";
}
}
+
+ function changeView() {
+ location.href = "favorites.php?u=" + document.getElementById("favorites-user-select").value;
+ }
</script>
+ <style>
+ #favorites-user-select {
+ background-color: transparent;
+ border-color: transparent;
+ }
+
+ #favorites-user-select:hover, #favorites-user-select:active, #favorites-user-select:focus {
+ background-color: var(--bs-body-bg);
+ border-color: var(--bs-border-color);
+ }
+ </style>
+
<br><br>
</body>
</html> \ No newline at end of file