From ea8768cdf56e3a72301227dfa5f51d14282fe7e7 Mon Sep 17 00:00:00 2001 From: Maaxxs <61059039+MaaxxsDev@users.noreply.github.com> Date: Wed, 28 Oct 2026 19:57:02 +0100 Subject: [PATCH] Musik-Seite neu gestaltet: SVG-Icons statt Emojis, Player mit grossem Abspielknopf und schlankem Lautstaerkeregler, Suchleiste in voller Breite, zwei feste Spalten (Warteschlange/Verlauf links, Sprachkanal/Playlist rechts), kompaktere Listen mit Quell-Punkt oder Vorschaubild; Kanal-IDs kommen vom Bot als Text (JavaScript rundete die 19-stelligen IDs - "Unbekannter Sprachkanal") Co-Authored-By: Claude Fable 5.1 --- assets/css/style.css | 183 ++++++++++++++++++++++++++--------------- assets/js/music.js | 83 ++++++++++++------- includes/functions.php | 9 ++ musik.php | 138 +++++++++++++++++-------------- 4 files changed, 256 insertions(+), 157 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index af3e696..97f10d2 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -10197,85 +10197,138 @@ a.hunt-review-spot-thumb { width: 64px; height: 40px; flex-shrink: 0; } /* ===== Musik (musik.php, assets/js/music.js): den Bot im Sprachkanal steuern ===== */ .music-page { display: flex; flex-direction: column; gap: 1rem; } -.music-connection { padding: 0.2rem 0.7rem; border-radius: 999px; background: rgba(255, 255, 255, 0.06); color: var(--text-muted); font-size: 0.82rem; } -.music-connection.is-online { background: rgba(76, 175, 80, 0.15); color: #8fdc93; } -.music-connection.is-offline { background: rgba(217, 83, 79, 0.15); color: #f2a19e; } -.music-now { display: flex; align-items: center; gap: 1.25rem; margin: 0.8rem 0 1rem; } -.music-art { position: relative; flex: none; width: 96px; height: 96px; } -.music-cover { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 12px; object-fit: cover; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); background: #1b1b1b; } -.music-art:has(.music-cover:not([hidden])) .music-disc { display: none; } -.music-disc { - position: relative; flex: none; width: 96px; height: 96px; border-radius: 50%; - background: repeating-radial-gradient(circle, #1b1b1b 0 2px, #262626 2px 4px); box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.35), 0 6px 18px rgba(0, 0, 0, 0.45); -} -.music-disc span { position: absolute; inset: 34px; border-radius: 50%; background: radial-gradient(circle, #1a1a1a 0 18%, var(--gold) 20% 100%); } -.is-playing .music-disc { animation: music-spin 3.2s linear infinite; } -.is-playing .music-disc { box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(201, 162, 39, 0.35); } +.music-page h2 { margin: 0; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; } +.music-page h2 span { margin-left: 0.3rem; color: var(--text-muted); font-weight: 400; letter-spacing: 0; } +.music-page .icon { flex: none; } + +/* Player */ +.music-hero { position: relative; margin: 0; padding: 1.5rem 1.75rem 1.4rem; overflow: hidden; } +.music-hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 0% 0%, rgba(201, 162, 39, 0.14), transparent 55%); pointer-events: none; } +.music-hero > * { position: relative; } +.music-hero-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 1.25rem; } +.music-hero-head h1 { margin: 0; font-size: 1.5rem; } +.music-connection { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.25rem 0.75rem 0.25rem 0.6rem; border-radius: 999px; background: rgba(255, 255, 255, 0.06); color: var(--text-muted); font-size: 0.8rem; } +.music-connection::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); } +.music-connection.is-online { background: rgba(76, 175, 80, 0.14); color: #9fe3a3; } +.music-connection.is-online::before { background: #4caf50; box-shadow: 0 0 8px rgba(76, 175, 80, 0.8); } +.music-connection.is-offline { background: rgba(217, 83, 79, 0.14); color: #f2a19e; } +.music-connection.is-offline::before { background: #d9534f; } + +.music-now { display: flex; align-items: center; gap: 1.5rem; } +.music-art { position: relative; flex: none; width: 124px; height: 124px; } +.music-disc { position: absolute; inset: 0; border-radius: 50%; background: repeating-radial-gradient(circle, #151515 0 2px, #222 2px 4px); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 10px 30px rgba(0, 0, 0, 0.5); } +.music-disc span { position: absolute; inset: 44px; border-radius: 50%; background: radial-gradient(circle, #151515 0 18%, var(--gold) 20% 100%); } +.is-playing .music-disc { animation: music-spin 3.2s linear infinite; box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.5), 0 0 28px rgba(201, 162, 39, 0.25); } @keyframes music-spin { to { transform: rotate(360deg); } } -.music-now-text { display: flex; flex: 1; flex-direction: column; gap: 0.2rem; min-width: 0; } -.music-now-label { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; } -.music-now-title { font-size: 1.15rem; line-height: 1.3; overflow-wrap: anywhere; } -.music-now-meta { display: flex; flex-wrap: wrap; gap: 0.2rem 0.8rem; color: var(--text-muted); font-size: 0.8rem; } -.music-now-link { width: max-content; font-size: 0.8rem; } -.music-next { margin-top: 0.3rem; color: var(--text-muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -.music-progress { position: relative; height: 6px; margin-top: 0.45rem; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; } -.music-progress.is-seekable { height: 8px; cursor: pointer; } -.music-progress.is-seekable:hover { background: rgba(255, 255, 255, 0.14); } -.music-progress i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: linear-gradient(90deg, #a07d1c, #e3bd6e); transition: width 0.5s linear; } -.music-times { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 0.75rem; } -.music-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; } +.music-cover { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 14px; object-fit: cover; background: #151515; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); } +.music-art:has(.music-cover:not([hidden])) .music-disc { display: none; } +.music-now-text { display: flex; flex: 1; flex-direction: column; gap: 0.25rem; min-width: 0; } +.music-now-label { color: var(--text-muted); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; } +.music-now-title { font-size: 1.35rem; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; } +.music-now-meta { display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; min-height: 1.2em; color: var(--text-muted); font-size: 0.82rem; } +.music-now-link { font-size: 0.82rem; } +.music-progress { position: relative; height: 5px; margin-top: 0.7rem; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; transition: height 0.15s; } +.music-progress i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 3px; background: linear-gradient(90deg, #a07d1c, var(--gold)); transition: width 0.5s linear; } +.music-progress.is-seekable { cursor: pointer; } +.music-progress.is-seekable:hover { height: 8px; } +.music-times { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-top: 0.3rem; color: var(--text-muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; } +.music-next { flex: 1; overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; } + +.music-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; margin-top: 1.25rem; } +.music-transport { display: flex; align-items: center; gap: 0.5rem; } .music-btn { - display: grid; place-items: center; width: 2.6rem; height: 2.6rem; padding: 0; border: 1px solid var(--border); border-radius: 50%; - background: var(--bg-panel-alt); box-shadow: none; font-size: 1.05rem; transition: border-color 0.15s, transform 0.15s, background 0.15s; + position: relative; display: grid; place-items: center; width: 2.7rem; height: 2.7rem; padding: 0; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 50%; + background: rgba(255, 255, 255, 0.04); box-shadow: none; color: var(--text); transition: border-color 0.15s, background 0.15s, transform 0.15s, color 0.15s; } -.music-btn:hover { border-color: var(--gold); background: rgba(201, 162, 39, 0.1); transform: translateY(-1px); box-shadow: none; } -.music-btn.is-big { width: 3.3rem; height: 3.3rem; font-size: 1.4rem; border-color: rgba(201, 162, 39, 0.6); } -.music-btn.is-on { border-color: var(--gold); background: rgba(201, 162, 39, 0.2); } -.music-volume { display: flex; flex: 1 1 14rem; align-items: center; gap: 0.5rem; margin: 0 0 0 0.75rem; font-weight: 400; } -.music-volume input { flex: 1; width: auto; accent-color: var(--gold); } -.music-volume span { min-width: 2.8rem; color: var(--text-muted); font-size: 0.82rem; text-align: right; } -.music-error { margin: 0.8rem 0 0; padding: 0.5rem 0.75rem; border-radius: 8px; background: rgba(240, 180, 108, 0.1); color: #f0b46c; font-size: 0.85rem; } -.music-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; } -.music-card { margin: 0; } -.music-card h2 { margin: 0 0 0.6rem; font-size: 1.05rem; } -.music-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; } -.music-card-head .armory-text-button { white-space: nowrap; } +.music-btn .icon { width: 19px; height: 19px; } +.music-btn:hover { border-color: rgba(201, 162, 39, 0.7); background: rgba(201, 162, 39, 0.12); box-shadow: none; transform: translateY(-1px); } +.music-btn.is-main { width: 3.5rem; height: 3.5rem; margin: 0 0.35rem; border-color: transparent; background: var(--gold); color: #1a1408; box-shadow: 0 6px 18px rgba(201, 162, 39, 0.35); } +.music-btn.is-main .icon { width: 24px; height: 24px; stroke-width: 2.2; } +.music-btn.is-main:hover { background: #e3bd6e; transform: translateY(-1px) scale(1.03); box-shadow: 0 8px 22px rgba(201, 162, 39, 0.45); } +.music-btn .music-ico-pause, .is-playing .music-btn .music-ico-play { display: none; } +.is-playing .music-btn .music-ico-pause { display: contents; } +.music-btn.is-on { border-color: rgba(201, 162, 39, 0.8); background: rgba(201, 162, 39, 0.16); color: var(--gold); } +.music-btn.is-on::after { content: ""; position: absolute; bottom: 4px; left: 50%; width: 4px; height: 4px; border-radius: 50%; background: var(--gold); transform: translateX(-50%); } +.music-volume { display: flex; flex: 1 1 12rem; align-items: center; gap: 0.6rem; max-width: 22rem; margin: 0; color: var(--text-muted); font-weight: 400; } +.music-volume .icon { width: 18px; height: 18px; } +.music-volume input { flex: 1; width: auto; height: 4px; margin: 0; padding: 0; border: 0; border-radius: 2px; background: linear-gradient(90deg, var(--gold) var(--v, 50%), rgba(255, 255, 255, 0.12) var(--v, 50%)); box-shadow: none; appearance: none; -webkit-appearance: none; cursor: pointer; } +.music-volume input::-webkit-slider-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); -webkit-appearance: none; } +.music-volume input::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); } +.music-volume input:focus { outline: none; } +.music-volume input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.5); } +.music-volume span { min-width: 2.6rem; font-size: 0.8rem; text-align: right; font-variant-numeric: tabular-nums; } +.music-error { margin: 1rem 0 0; padding: 0.5rem 0.75rem; border-radius: 8px; background: rgba(240, 180, 108, 0.1); color: #f0b46c; font-size: 0.85rem; } + +/* Suchleiste */ +.music-search { display: flex; flex-direction: row; align-items: center; gap: 0.6rem; margin: 0; padding: 0.4rem 0.4rem 0.4rem 1rem; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-panel); transition: border-color 0.15s, box-shadow 0.15s; } +.music-search:focus-within { border-color: rgba(201, 162, 39, 0.7); box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.12); } +.music-search .icon { color: var(--text-muted); } +.music-search input { flex: 1; min-width: 0; width: auto; margin: 0; padding: 0.55rem 0; border: 0; background: none; box-shadow: none; font-size: 0.95rem; } +.music-search input:focus { outline: none; box-shadow: none; } +.music-search .button { flex: none; border-radius: 999px; } +.music-hint { margin: -0.4rem 0 0; padding: 0 1rem; color: var(--text-muted); font-size: 0.78rem; } + +/* Spalten */ +.music-columns { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 1rem; align-items: start; } +.music-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; } +.music-card { margin: 0; padding: 1.1rem 1.25rem 1.2rem; } +.music-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; min-height: 1.6rem; margin-bottom: 0.75rem; } +.music-text-btn { padding: 0.2rem 0.6rem; border: 1px solid transparent; border-radius: 999px; background: none; box-shadow: none; color: var(--gold); font-size: 0.8rem; font-weight: 500; white-space: nowrap; } +.music-text-btn:hover { border-color: rgba(201, 162, 39, 0.5); background: rgba(201, 162, 39, 0.1); box-shadow: none; } .music-row { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.5rem; } -.music-row select, .music-row input { flex: 1 1 12rem; width: auto; min-width: 0; } -.music-list { display: flex; flex-direction: column; gap: 0.25rem; max-height: 22rem; margin: 0; padding: 0; overflow-y: auto; list-style: none; counter-reset: music; } -.music-list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.5rem; border-radius: 6px; background: rgba(255, 255, 255, 0.025); font-size: 0.88rem; } -.music-item-cover { flex: none; width: 40px; height: 24px; border-radius: 4px; object-fit: cover; background: #1b1b1b; } -.music-list li:hover { background: rgba(255, 255, 255, 0.05); } -ol.music-list li:not(.music-empty)::before { counter-increment: music; content: counter(music); min-width: 1.3rem; color: var(--text-muted); font-size: 0.75rem; text-align: right; } +.music-row select, .music-row input { flex: 1 1 10rem; width: auto; min-width: 0; margin: 0; } +.music-channel-now { display: flex; align-items: center; gap: 0.5rem; margin: 0 0 0.75rem; color: var(--text-muted); font-size: 0.88rem; } +.music-filter { width: 100%; margin: 0 0 0.6rem; } + +/* Listen */ +.music-list { display: flex; flex-direction: column; gap: 2px; max-height: 24rem; margin: 0; padding: 0; overflow-y: auto; list-style: none; counter-reset: music; scrollbar-width: thin; } +.music-list li { display: flex; align-items: center; gap: 0.6rem; min-height: 2.5rem; padding: 0.3rem 0.5rem; border-radius: 8px; font-size: 0.88rem; transition: background 0.12s; } +.music-list li:not(.music-empty):hover { background: rgba(255, 255, 255, 0.05); } +ol.music-list li:not(.music-empty)::before { counter-increment: music; content: counter(music); min-width: 1.2rem; color: var(--text-muted); font-size: 0.75rem; text-align: right; font-variant-numeric: tabular-nums; } +.music-item-art { display: grid; flex: none; place-items: center; width: 44px; height: 28px; border-radius: 5px; overflow: hidden; background: rgba(255, 255, 255, 0.05); } +.music-item-art img { width: 100%; height: 100%; object-fit: cover; } +.music-src { display: block; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); } +.music-src.is-youtube, .music-src.is-search { background: #ff4e45; } +.music-src.is-spotify { background: #1db954; } .music-item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } -.music-item-meta { color: var(--text-muted); font-size: 0.75rem; } .music-item-by { max-width: 7rem; overflow: hidden; color: var(--text-muted); font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; } -.music-item-btn { padding: 0.1rem 0.45rem; border: 1px solid transparent; background: none; box-shadow: none; color: var(--text-muted); font-size: 0.85rem; } -.music-list li .music-item-btn { opacity: 0.55; } +.music-item-meta { color: var(--text-muted); font-size: 0.75rem; font-variant-numeric: tabular-nums; } +.music-item-btn { display: grid; place-items: center; width: 1.8rem; height: 1.8rem; padding: 0; border: 0; border-radius: 50%; background: none; box-shadow: none; color: var(--text-muted); opacity: 0.45; transition: opacity 0.12s, background 0.12s, color 0.12s; } .music-list li:hover .music-item-btn, .music-list li:focus-within .music-item-btn { opacity: 1; } -.music-item-btn:hover { border-color: var(--gold); background: rgba(201, 162, 39, 0.1); color: var(--text); box-shadow: none; } -.music-item-btn.is-danger:hover { border-color: var(--danger); background: rgba(217, 83, 79, 0.12); } -.music-empty { color: var(--text-muted); font-style: italic; } -.music-filter { width: 100%; margin-bottom: 0.5rem; } -.music-upload { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px dashed var(--border); } -.music-upload input[type="text"] { flex: 1 1 10rem; width: auto; } -.music-file { position: relative; display: flex; flex: 1 1 100%; align-items: center; margin: 0; padding: 0.5rem 0.75rem; border: 1px dashed rgba(201, 162, 39, 0.5); border-radius: 8px; color: var(--text-muted); font-size: 0.85rem; font-weight: 400; cursor: pointer; } -.music-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; } -.is-busy .music-btn, .is-busy .music-item-btn { opacity: 0.6; } +.music-item-btn:hover { background: rgba(201, 162, 39, 0.15); box-shadow: none; color: var(--gold); } +.music-item-btn.is-danger:hover { background: rgba(217, 83, 79, 0.15); color: #f2a19e; } +.music-empty { justify-content: center; padding: 1.2rem 0.5rem !important; color: var(--text-muted); font-size: 0.85rem; text-align: center; } + +/* Upload (Leitung) */ +.music-upload { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid var(--border); } +.music-file { position: relative; display: flex; align-items: center; gap: 0.6rem; margin: 0; padding: 0.7rem 0.9rem; border: 1px dashed rgba(201, 162, 39, 0.45); border-radius: 10px; color: var(--text-muted); font-size: 0.82rem; font-weight: 400; cursor: pointer; transition: border-color 0.15s, background 0.15s; } +.music-file:hover { border-color: var(--gold); background: rgba(201, 162, 39, 0.06); } +.music-file input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; } +.music-file .icon { color: var(--gold); } + +.is-busy .music-btn, .is-busy .music-item-btn, .is-busy .music-text-btn { opacity: 0.6; pointer-events: none; } .music-toast { position: fixed; left: 50%; bottom: 1.5rem; z-index: 1200; max-width: min(92vw, 520px); padding: 0.6rem 1rem; border: 1px solid rgba(201, 162, 39, 0.5); border-radius: 10px; background: #1d1d1d; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); transform: translateX(-50%); font-size: 0.9rem; } .music-toast.is-error { border-color: rgba(217, 83, 79, 0.7); color: #f2a19e; } + +@media (max-width: 900px) { + .music-columns { grid-template-columns: 1fr; } +} @media (max-width: 560px) { - .music-now { gap: 0.9rem; } - .music-disc { width: 64px; height: 64px; } - .music-disc span { inset: 22px; } - .music-art { width: 64px; height: 64px; } - .music-item-by, .music-item-cover { display: none; } + .music-hero { padding: 1.2rem 1.1rem; } + .music-now { gap: 1rem; } + .music-art { width: 80px; height: 80px; } + .music-disc span { inset: 28px; } + .music-now-title { font-size: 1.1rem; } + .music-next { display: none; } + .music-controls { justify-content: center; } + .music-volume { flex-basis: 100%; max-width: none; } + .music-search { padding-left: 0.8rem; } + .music-search .button { padding-left: 0.9rem; padding-right: 0.9rem; } + .music-item-by, .music-item-art { display: none; } .music-list li { gap: 0.35rem; } - .music-item-btn { padding: 0.1rem 0.3rem; } - .music-volume { flex-basis: 100%; margin-left: 0; } } @media (prefers-reduced-motion: reduce) { .is-playing .music-disc { animation: none; } diff --git a/assets/js/music.js b/assets/js/music.js index 87bc0ed..bc70e85 100644 --- a/assets/js/music.js +++ b/assets/js/music.js @@ -14,7 +14,18 @@ var csrf = (document.querySelector('meta[name="csrf-token"]') || {}).content || ''; var canManage = root.dataset.canManage === '1'; var POLL_MS = 3000; - var SOURCE_ICONS = { file: '📁', youtube: '▶', spotify: '🟱', search: '🔎' }; + var SOURCE_NAMES = { file: 'Playlist der Legion', youtube: 'YouTube', spotify: 'Spotify', search: 'YouTube-Suche' }; + // Kleine Icons fuer die Listen (gleiche Pfade wie icon() in includes/functions.php) + var ICON_PATHS = { + play: '', + trash: '', + x: '', + up: '', + replay: '' + }; + var svg = function (name) { + return ''; + }; var state = null; var stateAt = 0; var busy = false; @@ -30,7 +41,12 @@ var s = seconds % 60; return (h ? h + ':' + String(m).padStart(2, '0') : m) + ':' + String(s).padStart(2, '0'); }; - var icon = function (item) { return (SOURCE_ICONS[item.source] || '') + ' ' + item.title; }; + var sourceDot = function (source) { + var dot = document.createElement('i'); + dot.className = 'music-src is-' + (source || 'file'); + dot.title = SOURCE_NAMES[source] || ''; + return dot; + }; var toastTimer = null; var toast = function (text, isError) { @@ -104,16 +120,21 @@ $('[data-music-bar]').style.width = duration ? Math.min(100, elapsed / duration * 100) + '%' : '0%'; }; - var listItem = function (text, meta, buttons, cover, by) { + var listItem = function (item, meta, buttons, by) { var li = document.createElement('li'); - if (cover) { + var art = document.createElement('span'); + art.className = 'music-item-art'; + if (item.thumbnail) { var img = document.createElement('img'); - img.className = 'music-item-cover'; - img.src = cover; + img.src = item.thumbnail; img.alt = ''; img.loading = 'lazy'; - li.appendChild(img); + art.appendChild(img); + } else { + art.appendChild(sourceDot(item.source)); } + li.appendChild(art); + var text = item.title; var label = document.createElement('span'); label.className = 'music-item-title'; label.textContent = text; @@ -134,7 +155,7 @@ var btn = document.createElement('button'); btn.type = 'button'; btn.className = 'music-item-btn' + (b.danger ? ' is-danger' : ''); - btn.textContent = b.label; + btn.innerHTML = svg(b.icon); btn.title = b.title; btn.addEventListener('click', b.onClick); li.appendChild(btn); @@ -164,17 +185,17 @@ list.textContent = ''; var shown = tracks.filter(function (t) { return t.title.toLowerCase().indexOf(filter) !== -1; }); if (!shown.length) { - list.appendChild(emptyItem(tracks.length ? 'Kein Treffer.' : 'Noch keine Titel' + (canManage ? ' – lade unten welche hoch.' : '.'))); + list.appendChild(emptyItem(tracks.length ? 'Kein Treffer.' : 'Noch keine eigenen Titel' + (canManage ? ' – lade unten welche hoch.' : '.'))); return; } shown.forEach(function (t) { - var buttons = [{ label: '▶', title: 'In die Warteschlange', onClick: function () { play(String(t.id)).catch(function () {}); } }]; + var buttons = [{ icon: 'play', title: 'In die Warteschlange', onClick: function () { play(String(t.id)).catch(function () {}); } }]; if (canManage) { - buttons.push({ label: '🗑', title: 'Aus der Playlist löschen', danger: true, onClick: function () { + buttons.push({ icon: 'trash', title: 'Aus der Playlist löschen', danger: true, onClick: function () { if (window.confirm('„' + t.title + '“ aus der Playlist löschen?')) act({ action: 'delete', track_id: String(t.id) }).catch(function () {}); } }); } - list.appendChild(listItem('📁 ' + t.title, fmt(t.duration), buttons)); + list.appendChild(listItem({ title: t.title, source: 'file' }, fmt(t.duration), buttons)); }); }; @@ -183,13 +204,13 @@ if (!changed('queue', [music.queue, music.queue_total])) return; var queue = $('[data-music-queue]'); queue.textContent = ''; - if (!music.queue.length) queue.appendChild(emptyItem('Leer.')); + if (!music.queue.length) queue.appendChild(emptyItem('Nichts in der Warteschlange – fĂŒg oben etwas hinzu.')); music.queue.forEach(function (item, index) { var buttons = []; - if (index > 0) buttons.push({ label: '‎', title: 'Als NĂ€chstes', onClick: function () { control('move', index); } }); - buttons.push({ label: '▶', title: 'Jetzt abspielen', onClick: function () { control('jump', index); } }); - buttons.push({ label: '✕', title: 'Aus der Warteschlange', onClick: function () { control('remove', index); } }); - queue.appendChild(listItem(icon(item), fmt(item.duration), buttons, item.thumbnail, item.added_by)); + if (index > 0) buttons.push({ icon: 'up', title: 'Als NĂ€chstes', onClick: function () { control('move', index); } }); + buttons.push({ icon: 'play', title: 'Jetzt abspielen', onClick: function () { control('jump', index); } }); + buttons.push({ icon: 'x', title: 'Aus der Warteschlange', danger: true, onClick: function () { control('remove', index); } }); + queue.appendChild(listItem(item, fmt(item.duration), buttons, item.added_by)); }); if (music.queue_total > music.queue.length) { queue.appendChild(emptyItem('
 und ' + (music.queue_total - music.queue.length) + ' weitere')); @@ -203,9 +224,9 @@ var list = $('[data-music-history]'); list.textContent = ''; history.forEach(function (item) { - list.appendChild(listItem(icon(item), fmt(item.duration), [ - { label: '↻', title: 'Noch einmal in die Warteschlange', onClick: function () { play(item.replay).catch(function () {}); } } - ], item.thumbnail, item.added_by)); + list.appendChild(listItem(item, fmt(item.duration), [ + { icon: 'replay', title: 'Noch einmal in die Warteschlange', onClick: function () { play(item.replay).catch(function () {}); } } + ], item.added_by)); }); }; @@ -213,14 +234,16 @@ state = music; stateAt = Date.now(); var connection = $('[data-music-connection]'); - connection.textContent = music.connected ? '🟱 Im Sprachkanal ' + music.channel.name : 'âšȘ Nicht im Sprachkanal'; + connection.textContent = music.connected ? 'Im Sprachkanal ' + music.channel.name : 'Nicht im Sprachkanal'; connection.className = 'music-connection' + (music.connected ? ' is-online' : ''); root.classList.toggle('is-playing', !!(music.current && !music.paused)); root.classList.toggle('is-paused', !!music.paused); var current = music.current; - $('[data-music-status]').textContent = current ? (music.paused ? '⏞ Pausiert' : 'đŸŽ¶ LĂ€uft gerade') : 'Gerade lĂ€uft nichts'; - $('[data-music-title]').textContent = current ? icon(current) : '–'; + $('[data-music-status]').textContent = current + ? (music.paused ? 'Pausiert' : 'LĂ€uft gerade') + ' · ' + (SOURCE_NAMES[current.source] || '') + : 'Gerade lĂ€uft nichts'; + $('[data-music-title]').textContent = current ? current.title : (music.connected ? 'Such dir unten etwas aus' : 'Hol den Bot in einen Sprachkanal'); var by = $('[data-music-by]'); by.hidden = !(current && current.added_by); by.textContent = current && current.added_by ? 'von ' + current.added_by : ''; @@ -243,6 +266,7 @@ var next = $('[data-music-next]'); next.hidden = !music.queue.length; next.textContent = music.queue.length ? 'Als NĂ€chstes: ' + music.queue[0].title : ''; + $('[data-music-volume]').style.setProperty('--v', music.volume + '%'); root.querySelectorAll('[data-music-control="shuffle"]').forEach(function (b) { b.classList.toggle('is-on', !!music.shuffle); }); root.querySelectorAll('[data-music-control="loop"]').forEach(function (b) { b.classList.toggle('is-on', !!music.loop); }); @@ -250,6 +274,8 @@ if (document.activeElement !== volume && !volumeTimer) { volume.value = music.volume; $('[data-music-volume-text]').textContent = music.volume + ' %'; + } else { + volume.style.setProperty('--v', volume.value + '%'); } var error = $('[data-music-error]'); error.hidden = !music.last_error; @@ -267,13 +293,13 @@ (music.voice_channels || []).forEach(function (c) { var option = document.createElement('option'); option.value = String(c.id); - option.textContent = '🔊 ' + c.name + (c.listeners ? ' (' + c.listeners + ')' : ''); + option.textContent = c.name + (c.listeners ? ' · ' + c.listeners + ' drin' : ''); select.appendChild(option); }); select.value = chosen; } - $('[data-music-channel]').textContent = music.connected - ? 'Der Bot ist in 🔊 ' + music.channel.name + ' – ' + music.channel.listeners + ' Zuhörer' + $('[data-music-channel] span').textContent = music.connected + ? 'Der Bot ist in ' + music.channel.name + ' – ' + music.channel.listeners + ' Zuhörer' : 'Der Bot ist in keinem Sprachkanal.'; $('[data-music-leave]').hidden = !music.connected; $('[data-music-join]').textContent = music.connected ? 'Umziehen' : 'Holen'; @@ -293,6 +319,7 @@ var volume = $('[data-music-volume]'); volume.addEventListener('input', function () { $('[data-music-volume-text]').textContent = volume.value + ' %'; + volume.style.setProperty('--v', volume.value + '%'); clearTimeout(volumeTimer); volumeTimer = setTimeout(function () { volumeTimer = null; @@ -339,7 +366,7 @@ if (upload) { var fileInput = upload.querySelector('input[type="file"]'); fileInput.addEventListener('change', function () { - upload.querySelector('[data-music-file-label]').textContent = fileInput.files[0] ? fileInput.files[0].name : 'Datei wĂ€hlen'; + upload.querySelector('[data-music-file-label]').textContent = fileInput.files[0] ? fileInput.files[0].name : 'Audiodatei wĂ€hlen'; }); upload.addEventListener('submit', function (event) { event.preventDefault(); @@ -350,7 +377,7 @@ button.disabled = true; button.textContent = 'LĂ€dt hoch 
'; act({ action: 'upload', title: upload.querySelector('input[name="title"]').value }, file) - .then(function () { upload.reset(); upload.querySelector('[data-music-file-label]').textContent = 'Datei wĂ€hlen'; }) + .then(function () { upload.reset(); upload.querySelector('[data-music-file-label]').textContent = 'Audiodatei wĂ€hlen'; }) .catch(function () {}) .finally(function () { button.disabled = false; button.textContent = 'Hochladen'; }); }); diff --git a/includes/functions.php b/includes/functions.php index b692693..906d3a1 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -172,6 +172,15 @@ function icon(string $name): string 'code' => '', 'sword' => '', 'music' => '', + // Musik-Seite: Steuerung des Bots + 'shuffle' => '', + 'pause' => '', + 'skip' => '', + 'stop' => '', + 'repeat' => '', + 'volume' => '', + 'headphones' => '', + 'upload' => '', 'bug' => '', 'shield-check' => '', 'hammer' => '', diff --git a/musik.php b/musik.php index 372dfb1..56c9785 100644 --- a/musik.php +++ b/musik.php @@ -13,90 +13,100 @@ $pageTitle = 'Musik'; include __DIR__ . '/includes/header.php'; ?>
-
-
+
+

Musik

Verbinde mit dem Bot 

- +
Gerade lĂ€uft nichts - – - + Such dir unten etwas aus + + + + -
0:000:00
- +
0:000:00
-
- - - - - -
+
-
-
-

Sprachkanal

-

Der Bot ist in keinem Sprachkanal.

-
- - - -
-
+ +

YouTube, YouTube Music (auch Playlists) und Spotify (Song, Playlist, Album – gespielt wird der passende Titel von YouTube). Ohne Link wird auf YouTube gesucht. Ist der Bot in keinem Kanal, kommt er in den rechts gewĂ€hlten.

-
-

HinzufĂŒgen

-
- - -
-

YouTube, YouTube Music (auch Playlists) und Spotify (Song, Playlist, Album – gespielt wird der passende Titel von YouTube). Ohne Link wird auf YouTube gesucht. Ist der Bot noch in keinem Kanal, kommt er in den oben gewĂ€hlten.

-
+
+
+
+
+

Warteschlange

+ +
+
    +
    + +
    -
    -
    -

    Warteschlange

    - -
    -
    1. Leer.
    -
    +
    +
    +

    Sprachkanal

    +

    Der Bot ist in keinem Sprachkanal.

    +
    + + + +
    +
    -
    -
    -

    Playlist der Legion

    - -
    - -
    • Noch keine Titel.
    - -
    - - - -
    - -
    - - +
    +
    +

    Playlist der Legion

    + +
    + +
      + +
      + +
      + + +
      +
      + +
      +