diff options
Diffstat (limited to 'app/ui/info.php')
-rw-r--r-- | app/ui/info.php | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/app/ui/info.php b/app/ui/info.php index fd4fad5..d21e431 100644 --- a/app/ui/info.php +++ b/app/ui/info.php @@ -1,4 +1,4 @@ -<?php header("X-Frame-Options: SAMEORIGIN"); require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $songs; +<?php header("X-Frame-Options: SAMEORIGIN"); require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/session.php"; global $songs; global $favorites; if (!isset($_GET["i"]) || !isset($songs[$_GET["i"]])) { die(); @@ -158,7 +158,22 @@ function getChannelConfiguration($c) { </tr> <tr> <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">Mist Stella</td> - <td>No</td> + <td> + <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/content/" . $_GET["i"] . ".stella")): ?> + <?php + + $handle = fopen($_SERVER['DOCUMENT_ROOT'] . "/assets/content/" . $_GET["i"] . ".stella", "r"); + fseek($handle, 8); + $contents = fread($handle, 512 - 8); + fclose($handle); + $metadata = json_decode(trim(zlib_decode($contents)), true); + + ?> + Yes (<?php if (isset($metadata["id"])): ?>#<?= $metadata["id"] ?>, <?php endif; ?>Version <?= $metadata["version"] ?>) + <?php else: ?> + No + <?php endif; ?> + </td> </tr> <tr> <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">Copyright</td> @@ -172,7 +187,20 @@ function getChannelConfiguration($c) { <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">File size (AAC-LC)</td> <td><?= getSize(filesize($_SERVER['DOCUMENT_ROOT'] . "/assets/content/" . $_GET["i"] . ".m4a")) ?></td> </tr> + <tr> + <td style="width: calc(100% / 3); text-align: right; padding-right: 10px; opacity: .5;">File size (Stella)</td> + <td> + <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/content/" . $_GET["i"] . ".stella")): ?> + <?= getSize(filesize($_SERVER['DOCUMENT_ROOT'] . "/assets/content/" . $_GET["i"] . ".stella")) ?> + <?php else: ?> + - + <?php endif; ?> + </td> + </tr> </table> + + <hr><?php $id = $_GET["i"]; ?> + <a class="btn btn-primary" onclick="<?= in_array($id, $favorites) ? "un" : "" ?>favoriteSong('<?= $id ?>');" id="btn-favorite-<?= $id ?>"><img id="btn-favorite-<?= $id ?>-icon" alt="" src="/assets/icons/favorite-<?= in_array($id, $favorites) ? "on" : "off" ?>.svg" style="pointer-events: none; filter: invert(1); width: 24px; height: 24px; margin-right: 5px;"><span id="btn-favorite-<?= $id ?>-text"><?= in_array($id, $favorites) ? "Remove from favorites" : "Add to favorites" ?></span></a> </div> <script> @@ -182,6 +210,32 @@ function getChannelConfiguration($c) { window.parent.document.getElementById("modal-frame").style.height = document.body.clientHeight + "px"; } }); + + async function favoriteSong(id) { + document.getElementById("btn-favorite-" + id + "-icon").src = "/assets/icons/favorite-on.svg"; + document.getElementById("btn-favorite-" + id + "-text").innerText = "Remove from favorites"; + document.getElementById("btn-favorite-" + id).onclick = () => { + unfavoriteSong(id); + } + await fetch("/api/addFavorite.php?i=" + id); + + window.parent.redownloadFavorites(); + } + + async function unfavoriteSong(id) { + document.getElementById("btn-favorite-" + id + "-icon").src = "/assets/icons/favorite-off.svg"; + document.getElementById("btn-favorite-" + id + "-text").innerText = "Add to favorites"; + document.getElementById("btn-favorite-" + id).onclick = () => { + favoriteSong(id); + } + await fetch("/api/removeFavorite.php?i=" + id); + + <?php if (isset($favoritesList)): ?> + location.reload(); + <?php endif; ?> + + window.parent.redownloadFavorites(); + } </script> </body> </html>
\ No newline at end of file |