synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
21
README.md
Normal file
21
README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# ♫ Musique
|
||||
|
||||
Toute ta musique au même endroit : Spotify et YouTube Music importés et fusionnés, playlists en dossiers, tes écoutes — et le bon lecteur pour chaque titre.
|
||||
|
||||
| | |
|
||||
| --- | --- |
|
||||
| id | `musique` |
|
||||
| fournit | `music` `player` `musique` `bibliotheque` |
|
||||
| bions qu'il nomme | `jOSApps` |
|
||||
| fichiers | `app.blade.php` |
|
||||
| dans le labo | `resources/views/ploxions/musique/` (dépôt `my_website2`) |
|
||||
|
||||
## Contribuer
|
||||
|
||||
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=musique — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
|
||||
- **Dans VS Code** : `xb prendre musique` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
|
||||
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
|
||||
|
||||
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
|
||||
|
||||
© 2026 chill-tekk · ne pas nuire
|
||||
188
app.blade.php
Normal file
188
app.blade.php
Normal file
@@ -0,0 +1,188 @@
|
||||
{{-- ♫ MUSIQUE — la bibliothèque CONVERGÉE (17.10.2026, phase 1 — docs/plans/musique-convergence-v0.md).
|
||||
RS-7 : « un ploxion musique avec toute la musique : connecter Spotify, YouTube Music… importer ses sons et playlists, données d'écoute,
|
||||
tout merge, des dossiers de playlist, écouter avec le lecteur spotify ou un autre ». Un titre = une ligne (fusion par ISRC, sinon titre +
|
||||
artiste + durée) avec ses sources ; le LECTEUR COMMUN jOSMusique (public/js/musique.js) joue la première source jouable selon ta
|
||||
préférence et passe à la suivante si elle refuse (Spotify sans Premium → YouTube Music). Serveur : MusiqueController (/musique/…).
|
||||
Peu de texte, des glyphes, les boutons en bas (chill-tekk au pouce). --}}
|
||||
<style>
|
||||
.mq { --a:#a597cf; --b:#79d9a2; --t:#ddd6ea; --m:#8a81a6; --s:#0f0b18; --bd:#272036; --bd2:#3a3050; min-height:100%; box-sizing:border-box; display:flex; flex-direction:column;
|
||||
background:#07050c; color:var(--t); font:14px/1.4 -apple-system,system-ui,sans-serif; padding:12px 14px 0; }
|
||||
.mq * { box-sizing:border-box; }
|
||||
.mq-corps { flex:1; }
|
||||
.mq-h { margin:6px 0 10px; font-size:16px; display:flex; align-items:baseline; gap:8px; } .mq-h small { margin-left:auto; font:600 11px ui-monospace,Menlo,monospace; color:var(--m); }
|
||||
.mq-mono { font:600 11px ui-monospace,Menlo,monospace; color:var(--m); }
|
||||
.mq-cherche { display:flex; gap:6px; margin-bottom:10px; } .mq-cherche input { flex:1; min-height:42px; padding:0 12px; border-radius:12px; border:2px solid var(--bd2); background:#0a0712; color:var(--t); font:15px -apple-system,system-ui,sans-serif; }
|
||||
.mq button { font:700 13px -apple-system,system-ui,sans-serif; color:var(--t); cursor:pointer; }
|
||||
.mq-bt { min-height:42px; padding:0 12px; border-radius:12px; border:2px solid var(--bd2); background:#0a0712; }
|
||||
.mq-bt.on, .mq-bt.act { border-color:var(--a); background:var(--a); color:#0d0a16; }
|
||||
.mq-ligne { display:flex; align-items:center; gap:10px; width:100%; text-align:left; padding:7px 8px; margin-bottom:4px; border-radius:12px; border:1.5px solid transparent; background:none; }
|
||||
.mq-ligne:hover { border-color:var(--bd); background:var(--s); } .mq-ligne.cur { border-color:var(--b); background:#10201a; }
|
||||
.mq-poch { width:42px; height:42px; flex:0 0 42px; border-radius:8px; object-fit:cover; background:#151021; display:flex; align-items:center; justify-content:center; color:var(--m); }
|
||||
.mq-ligne div { flex:1; min-width:0; } .mq-ligne b { display:block; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-weight:600; }
|
||||
.mq-ligne small { display:block; color:var(--m); font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
||||
.mq-src { font:700 10px ui-monospace,Menlo,monospace; display:flex; gap:3px; } .mq-src i { font-style:normal; padding:2px 5px; border-radius:6px; border:1px solid var(--bd2); }
|
||||
.mq-src i.spotify { color:#79d9a2; border-color:#2c5a42; } .mq-src i.ytmusic { color:#ef6f8e; border-color:#5a2a36; } .mq-src i.fus { color:#f0d36c; border-color:#6b5a1f; }
|
||||
.mq-carte { padding:12px 13px; margin-bottom:9px; border-radius:15px; border:2px solid var(--bd); background:var(--s); }
|
||||
.mq-carte p { margin:6px 0 0; } .mq-barre { display:block; height:6px; border-radius:3px; background:#1a1426; margin:9px 0 4px; overflow:hidden; } .mq-barre i { display:block; height:100%; background:var(--b); }
|
||||
.mq-dossier > summary { list-style:none; cursor:pointer; padding:8px 6px; font-weight:700; display:flex; gap:8px; align-items:center; } .mq-dossier > summary::-webkit-details-marker { display:none; }
|
||||
.mq-dossier .mq-in { padding-left:14px; border-left:2px solid var(--bd); margin-left:10px; }
|
||||
.mq-pl { display:flex; align-items:center; gap:8px; } .mq-pl .mq-ligne { flex:1; margin:0; } .mq-pl select { min-height:34px; border-radius:10px; border:1.5px solid var(--bd2); background:#0a0712; color:var(--m); max-width:110px; }
|
||||
.mq-pl input[type=checkbox] { width:20px; height:20px; accent-color:var(--a); }
|
||||
.mq-actions { display:flex; flex-wrap:wrap; gap:6px; margin:8px 0 12px; }
|
||||
.mq-nav { position:sticky; bottom:calc(env(safe-area-inset-bottom,0px) + 8px); margin-top:12px; display:flex; gap:5px; padding:6px; border-radius:20px; border:2px solid var(--bd2); background:#0a0712; }
|
||||
.mq-nav button { flex:1; min-height:52px; border:0; border-radius:14px; background:none; color:var(--m); font:700 9px ui-monospace,Menlo,monospace; letter-spacing:.05em; text-transform:uppercase; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; }
|
||||
.mq-nav button i { font-style:normal; font-size:17px; } .mq-nav button.on { background:#151021; color:var(--t); box-shadow:inset 0 0 0 1.5px var(--b); }
|
||||
.mq-joue { display:flex; align-items:center; gap:8px; padding:8px 10px; margin-bottom:10px; border-radius:14px; border:1.5px solid var(--b); background:#10201a; }
|
||||
.mq-joue div { flex:1; min-width:0; } .mq-joue b { display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } .mq-joue button { min-width:42px; min-height:42px; border-radius:12px; border:1.5px solid var(--bd2); background:#0a0712; }
|
||||
.mq-vide { padding:22px 8px; text-align:center; color:var(--m); }
|
||||
</style>
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
var ID = 'musique', JS = "/js/musique.js?v={{ is_file(public_path('js/musique.js')) ? filemtime(public_path('js/musique.js')) : 1 }}";
|
||||
var VITRE = "{{ config('ytmusic.vitre', 'https://www.youtube-nocookie.com/embed/') }}";
|
||||
var SRC = { spotify: '●', ytmusic: '▶' }, NOMS = { spotify: 'Spotify', ytmusic: 'YouTube Music' };
|
||||
function esc(s) { return window.jOSb.esc(s); }
|
||||
function ls(k) { try { return localStorage.getItem(k); } catch (e) { return null; } }
|
||||
function lsSet(k, v) { try { localStorage.setItem(k, v); } catch (e) {} }
|
||||
function toast(m) { try { var T = (window.jOSb && jOSb.toast) || (window.jOS && jOS.toast); if (T) T(m); } catch (e) {} }
|
||||
function csrf() { var m = document.querySelector('meta[name="csrf-token"]'); return m ? m.content : ''; }
|
||||
function api(url, methode, corps) {
|
||||
return fetch(url, { method: methode || 'GET', credentials: 'same-origin', headers: { Accept: 'application/json', 'Content-Type': 'application/json', 'X-CSRF-TOKEN': csrf(), 'X-Requested-With': 'XMLHttpRequest' }, body: corps ? JSON.stringify(corps) : undefined })
|
||||
.then(function (r) { return r.json().catch(function () { return {}; }).then(function (d) { if (!r.ok || d.ok === false) { throw new Error(d.message || ('erreur ' + r.status)); } return d; }); });
|
||||
}
|
||||
function charger() {
|
||||
if (window.jOSMusique && window.jOSMusique.version) return Promise.resolve(window.jOSMusique);
|
||||
if (typeof window.jOSMusiqueCharger === 'function') return window.jOSMusiqueCharger();
|
||||
return new Promise(function (ok, ko) {
|
||||
var s = document.querySelector('script[data-musique]'), fin = function () { if (window.jOSMusique) ok(window.jOSMusique); else ko(new Error('lecteur')); };
|
||||
if (s) { s.addEventListener('load', fin); return; }
|
||||
s = document.createElement('script'); s.src = JS; s.async = true; s.setAttribute('data-musique', '1'); s.setAttribute('data-vitre', VITRE); s.onload = fin; s.onerror = function () { ko(new Error('lecteur')); };
|
||||
(document.head || document.documentElement).appendChild(s);
|
||||
});
|
||||
}
|
||||
// la préférence de lecture : quelle source d'abord (Spotify demande Premium pour jouer ici)
|
||||
function ordre() { var o = (ls('xb:musique:ordre') || 'spotify,ytmusic').split(','); return o.filter(function (x) { return SRC[x]; }); }
|
||||
function versLecteur(t) {
|
||||
var src = (t.sources || []).filter(function (s) { return s.jouable && SRC[s.service]; }), o = ordre();
|
||||
src.sort(function (a, b) { return o.indexOf(a.service) - o.indexOf(b.service); });
|
||||
if (!src.length) return null;
|
||||
return { source: src[0].service, id: src[0].id, titre: t.titre, artistes: (t.artistes || []).map(function (a) { return { nom: a }; }), album: t.album ? { nom: t.album } : null,
|
||||
secondes: t.duree_ms ? Math.round(t.duree_ms / 1000) : null, vignette: t.pochette, biblio: t.id, alternatives: src.slice(1).map(function (s) { return { source: s.service, id: s.id }; }) };
|
||||
}
|
||||
function pochette(u) { return u ? '<img class="mq-poch" src="' + esc(u) + '" alt="" loading="lazy" referrerpolicy="no-referrer">' : '<span class="mq-poch">♪</span>'; }
|
||||
function badges(t) { var s = {}; (t.sources || []).forEach(function (x) { s[x.service] = 1; }); var k = Object.keys(s);
|
||||
return '<span class="mq-src">' + (k.length > 1 ? '<i class="fus" title="fusionné">⧉</i>' : '') + k.map(function (x) { return '<i class="' + x + '" title="' + (NOMS[x] || x) + '">' + (SRC[x] || x) + '</i>'; }).join('') + '</span>'; }
|
||||
|
||||
function mount(c) {
|
||||
var vivant = true, tab = 'biblio', q = '', aimes = false, titres = [], total = 0, pls = null, plOuverte = null, etat = null, ecoutes = null, choix = {}, imp = null, M = null, enCours = null, offs = [];
|
||||
function charge() {
|
||||
if (tab === 'biblio') return api('/musique/biblio?' + (aimes ? 'aimes=1&' : '') + 'q=' + encodeURIComponent(q)).then(function (d) { titres = d.titres; total = d.total; dessiner(); });
|
||||
if (tab === 'playlists') return (plOuverte ? api('/musique/playlist/' + plOuverte.id).then(function (d) { plOuverte = d.playlist; titres = d.titres; }) : api('/musique/playlists').then(function (d) { pls = d; })).then(dessiner);
|
||||
if (tab === 'ecoutes') return api('/musique/ecoutes').then(function (d) { ecoutes = d; dessiner(); });
|
||||
return api('/musique/etat').then(function (d) { etat = d; dessiner(); });
|
||||
}
|
||||
function ligne(t, i, liste) {
|
||||
var cur = enCours && enCours.biblio === t.id;
|
||||
return '<button class="mq-ligne' + (cur ? ' cur' : '') + '" data-jouer="' + i + '" data-liste="' + liste + '">' + pochette(t.pochette) + '<div><b>' + (t.aime ? '♥ ' : '') + esc(t.titre) + '</b><small>' + esc((t.artistes || []).join(', ')) + (t.album ? ' · ' + esc(t.album) : '') + '</small></div>' + badges(t) + '</button>';
|
||||
}
|
||||
function vueBiblio() {
|
||||
return '<div class="mq-cherche"><input data-q placeholder="chercher dans ta musique" value="' + esc(q) + '" enterkeyhint="search"><button class="mq-bt' + (aimes ? ' on' : '') + '" data-aimes>♥</button></div>'
|
||||
+ '<div class="mq-h">◉ ' + total + ' titres<small>' + (titres.length < total ? titres.length + ' affichés' : '') + '</small></div>'
|
||||
+ (titres.length ? '<div class="mq-actions"><button class="mq-bt act" data-tout="biblio">▶ tout</button><button class="mq-bt" data-tout="biblio" data-melange>⤮</button></div>' + titres.map(function (t, i) { return ligne(t, i, 'biblio'); }).join('')
|
||||
: '<div class="mq-vide">♫ rien encore<br><br><button class="mq-bt act" data-tab="sources">⇅ importer</button></div>');
|
||||
}
|
||||
function vuePlaylists() {
|
||||
if (plOuverte) return '<button class="mq-bt" data-retour>←</button><div class="mq-h">▤ ' + esc(plOuverte.nom) + '<small>' + (plOuverte.service ? (SRC[plOuverte.service] || '') + ' ' + (NOMS[plOuverte.service] || '') : '⧉ à toi') + ' · ' + titres.length + '</small></div>'
|
||||
+ '<div class="mq-actions"><button class="mq-bt act" data-tout="pl">▶ tout</button><button class="mq-bt" data-tout="pl" data-melange>⤮</button>' + (!plOuverte.service ? '<button class="mq-bt" data-suppr-pl="' + plOuverte.id + '">✕</button>' : '') + '</div>'
|
||||
+ titres.map(function (t, i) { return ligne(t, i, 'pl'); }).join('');
|
||||
if (!pls) return '<div class="mq-vide">…</div>';
|
||||
var D = pls.dossiers, P = pls.playlists, n = Object.keys(choix).filter(function (k) { return choix[k]; }).length;
|
||||
var opts = function (p) { return '<select data-ranger="' + p.id + '"><option value="">↥ racine</option>' + D.map(function (d) { return '<option value="' + d.id + '"' + (p.dossier_id === d.id ? ' selected' : '') + '>▣ ' + esc(d.nom) + '</option>'; }).join('') + '</select>'; };
|
||||
var plHtml = function (p) { return '<div class="mq-pl"><input type="checkbox" data-choix="' + p.id + '"' + (choix[p.id] ? ' checked' : '') + ' aria-label="choisir"><button class="mq-ligne" data-ouvrir="' + p.id + '">' + pochette(p.pochette) + '<div><b>' + esc(p.nom) + '</b><small>' + (p.service ? (SRC[p.service] || '') + ' ' : '⧉ ') + p.nb + '</small></div></button>' + opts(p) + '</div>'; };
|
||||
var dossier = function (d) { var enf = D.filter(function (x) { return x.parent_id === d.id; }), mes = P.filter(function (p) { return p.dossier_id === d.id; });
|
||||
return '<details class="mq-dossier" open><summary>▣ ' + esc(d.nom) + ' <span class="mq-mono">' + mes.length + '</span><button class="mq-bt" data-suppr-dossier="' + d.id + '" style="margin-left:auto;min-height:30px">✕</button></summary><div class="mq-in">' + enf.map(dossier).join('') + mes.map(plHtml).join('') + '</div></details>'; };
|
||||
return '<div class="mq-h">▤ ' + P.length + ' playlists<small>' + D.length + ' dossiers</small></div>'
|
||||
+ '<div class="mq-actions"><button class="mq-bt" data-nouveau-dossier>+ ▣ dossier</button><button class="mq-bt" data-nouvelle-pl>+ ▤ playlist</button>' + (n >= 2 ? '<button class="mq-bt act" data-fusionner>⧉ fusionner ' + n + '</button>' : '') + '</div>'
|
||||
+ D.filter(function (d) { return !d.parent_id; }).map(dossier).join('') + P.filter(function (p) { return !p.dossier_id; }).map(plHtml).join('')
|
||||
+ (P.length ? '' : '<div class="mq-vide">▤ aucune playlist<br><br><button class="mq-bt act" data-tab="sources">⇅ importer</button></div>');
|
||||
}
|
||||
function vueEcoutes() {
|
||||
if (!ecoutes) return '<div class="mq-vide">…</div>';
|
||||
titres = ecoutes.recentes.map(function (e) { return e.titre; });
|
||||
return '<div class="mq-h">◷ récentes<small>' + ecoutes.recentes.length + '</small></div>' + ecoutes.recentes.map(function (e, i) { return ligne(e.titre, i, 'ecoutes').replace('</small>', ' · ' + esc(String(e.le).slice(5, 16).replace('T', ' ')) + '</small>'); }).join('')
|
||||
+ (ecoutes.top.length ? '<div class="mq-h">▲ les plus écoutés</div>' + ecoutes.top.map(function (e) { return '<div class="mq-ligne">' + pochette(e.titre.pochette) + '<div><b>' + esc(e.titre.titre) + '</b><small>' + esc((e.titre.artistes || []).join(', ')) + '</small></div><span class="mq-mono">×' + e.n + '</span></div>'; }).join('') : '')
|
||||
+ (ecoutes.recentes.length ? '' : '<div class="mq-vide">◷ pas encore d\'écoutes</div>');
|
||||
}
|
||||
function vueSources() {
|
||||
if (!etat) return '<div class="mq-vide">…</div>';
|
||||
var S = etat.services, k = etat.compte, o = ordre();
|
||||
return '<div class="mq-h">⇅ sources<small>' + k.titres + ' titres · ' + k.fusionnes + ' ⧉ fusionnés</small></div>'
|
||||
+ '<div class="mq-carte"><div class="mq-h" style="margin:0">● Spotify<small>' + (S.spotify.connecte ? '✓ relié' : (S.spotify.configure ? 'pas relié' : 'non configuré')) + '</small></div>'
|
||||
+ (S.spotify.connecte ? (imp ? '<span class="mq-barre"><i style="width:' + imp.pc + '%"></i></span><div class="mq-mono">' + esc(imp.txt) + '</div>' : '<p><button class="mq-bt act" data-importer>⇣ importer likés, playlists, écoutes</button></p>')
|
||||
: (S.spotify.configure ? '<p><a class="mq-bt act" style="display:inline-flex;align-items:center;text-decoration:none" href="' + esc(S.spotify.connecter) + '">relier Spotify</a></p>' : '')) + '</div>'
|
||||
+ '<div class="mq-carte"><div class="mq-h" style="margin:0">▶ YouTube Music<small>✓ dans le lecteur</small></div><p class="mq-mono">tes écoutes YouTube Music rejoignent la bibliothèque et fusionnent avec Spotify</p><p><button class="mq-bt" data-ouvrir-px="youtube-music">↗ chercher sur YouTube Music</button></p></div>'
|
||||
+ '<div class="mq-carte"><div class="mq-h" style="margin:0">⇄ jouer d\'abord</div><p>' + o.map(function (x, i) { return '<span class="mq-bt on" style="display:inline-flex;align-items:center;margin-right:6px">' + (i + 1) + ' · ' + SRC[x] + ' ' + NOMS[x] + '</span>'; }).join('') + '<button class="mq-bt" data-inverser>⇄</button></p><p class="mq-mono">si la première refuse (Spotify sans Premium), la suivante prend le relais</p></div>'
|
||||
+ '<div class="mq-carte mq-mono">bientôt : SoundCloud · Bandcamp · Last.fm · Apple Music · Deezer · Shazam (ploxi0n)</div>';
|
||||
}
|
||||
function joue() {
|
||||
if (!enCours) return '';
|
||||
return '<div class="mq-joue">' + pochette(enCours.vignette) + '<div><b>' + esc(enCours.titre) + '</b><small class="mq-mono">' + (SRC[enCours.source] || '') + ' ' + esc(NOMS[enCours.source] || '') + '</small></div><button data-cmd="precedent">⏮</button><button data-cmd="basculer">⏯</button><button data-cmd="suivant">⏭</button></div>';
|
||||
}
|
||||
function dessiner() {
|
||||
if (!vivant) return;
|
||||
c.innerHTML = '<div class="mq"><div class="mq-corps">' + joue() + (tab === 'biblio' ? vueBiblio() : tab === 'playlists' ? vuePlaylists() : tab === 'ecoutes' ? vueEcoutes() : vueSources()) + '</div>'
|
||||
+ '<nav class="mq-nav">' + [['biblio', '◉', 'biblio'], ['playlists', '▤', 'playlists'], ['ecoutes', '◷', 'écoutes'], ['sources', '⇅', 'sources']].map(function (t) { return '<button data-tab="' + t[0] + '" class="' + (tab === t[0] ? 'on' : '') + '"><i>' + t[1] + '</i>' + t[2] + '</button>'; }).join('') + '</nav></div>';
|
||||
}
|
||||
function jouerListe(i, melange) {
|
||||
var items = titres.map(versLecteur).filter(Boolean); if (!items.length) { toast('♫ aucune source jouable'); return; }
|
||||
var cible = titres[i] ? versLecteur(titres[i]) : null, idx = cible ? Math.max(0, items.findIndex(function (x) { return x.biblio === cible.biblio; })) : 0;
|
||||
charger().then(function (m) { M = m; m.jouer(items, melange ? { aleatoire: true } : { index: idx }); });
|
||||
}
|
||||
// l'import Spotify : une étape après l'autre, avec la barre
|
||||
function importer() {
|
||||
var n = 0, tours = 0;
|
||||
function pas(e) {
|
||||
if (!vivant || !e || tours++ > 2000) { imp = null; toast('⇣ import terminé · ' + n); charge(); return; }
|
||||
imp = { pc: Math.min(99, tours), txt: (e.etape === 'likes' ? '♥ likés ' : e.etape === 'playlists' ? '▤ playlists ' : e.etape === 'playlist' ? '▤ ' : '◷ écoutes ') + (e.offset || 0) + (n ? ' · ' + n : '') }; dessiner();
|
||||
api('/musique/import/spotify', 'POST', e).then(function (d) { n += d.n || 0; if (d.total) imp.pc = Math.min(99, Math.round(((e.offset || 0) + 50) / d.total * 100)); pas(d.suite); }, function (er) { imp = null; toast('⇣ ' + er.message); charge(); });
|
||||
}
|
||||
pas({ etape: 'likes', offset: 0 });
|
||||
}
|
||||
c.addEventListener('click', function (ev) {
|
||||
var b = ev.target.closest('button,[data-ouvrir]'); if (!b || !vivant) return;
|
||||
var d = b.dataset;
|
||||
if (d.tab) { tab = d.tab; plOuverte = null; choix = {}; return charge(); }
|
||||
if (d.aimes != null) { aimes = !aimes; return charge(); }
|
||||
if (d.jouer != null) return jouerListe(+d.jouer, false);
|
||||
if (d.tout) return jouerListe(0, d.melange != null);
|
||||
if (d.ouvrir) { plOuverte = { id: +d.ouvrir }; return charge(); }
|
||||
if (d.retour != null) { plOuverte = null; return charge(); }
|
||||
if (d.importer != null) return importer();
|
||||
if (d.inverser != null) { lsSet('xb:musique:ordre', ordre().reverse().join(',')); return dessiner(); }
|
||||
if (d.cmd) { charger().then(function (m) { if (m[d.cmd]) m[d.cmd](); }); return; }
|
||||
if (d.ouvrirPx) { try { if (window.jOS && jOS.openPloxion) return jOS.openPloxion(d.ouvrirPx); } catch (e) {} location.href = '/px/' + d.ouvrirPx; return; }
|
||||
if (d.nouveauDossier != null) { var nd = window.prompt ? prompt('nom du dossier') : null; if (nd) api('/musique/dossiers', 'POST', { nom: nd }).then(charge); return; }
|
||||
if (d.nouvellePl != null) { var np = window.prompt ? prompt('nom de la playlist') : null; if (np) api('/musique/playlists', 'POST', { nom: np }).then(charge); return; }
|
||||
if (d.supprDossier) { ev.preventDefault(); api('/musique/dossiers/' + d.supprDossier, 'DELETE').then(charge); return; }
|
||||
if (d.supprPl) { api('/musique/playlist/' + d.supprPl, 'DELETE').then(function () { plOuverte = null; charge(); }); return; }
|
||||
if (d.fusionner != null) { var ids = Object.keys(choix).filter(function (k) { return choix[k]; }).map(Number), nom = window.prompt ? prompt('nom de la playlist fusionnée', 'tout') : 'tout';
|
||||
if (nom) api('/musique/fusionner', 'POST', { playlists: ids, nom: nom }).then(function (r) { toast('⧉ ' + r.n + ' titres'); choix = {}; charge(); }); return; }
|
||||
});
|
||||
c.addEventListener('change', function (ev) {
|
||||
var t = ev.target;
|
||||
if (t.dataset.ranger) { api('/musique/playlist/' + t.dataset.ranger + '/dossier', 'POST', { dossier_id: t.value ? +t.value : null }).then(charge); }
|
||||
if (t.dataset.choix) { choix[t.dataset.choix] = t.checked; dessiner(); }
|
||||
});
|
||||
var tq = 0;
|
||||
c.addEventListener('input', function (ev) { if (ev.target.dataset.q != null) { q = ev.target.value; clearTimeout(tq); tq = setTimeout(function () { charge().then(function () { var i = c.querySelector('[data-q]'); if (i) { i.focus(); i.setSelectionRange(q.length, q.length); } }); }, 300); } });
|
||||
// ce qui joue (le lecteur commun, s'il est déjà là ; sinon à la première lecture)
|
||||
function suivre(m) { offs.push(m.on('titre', function (t) { enCours = t; dessiner(); })); try { var f = m.file(); enCours = f.items[f.index] || null; } catch (e) {} }
|
||||
if (window.jOSMusique && window.jOSMusique.version) suivre(window.jOSMusique); else charger().then(function (m) { if (vivant) { suivre(m); dessiner(); } }).catch(function () {});
|
||||
dessiner(); charge().catch(function (e) { c.innerHTML = '<div class="mq"><div class="mq-vide">♫ ' + esc(e.message) + '</div></div>'; });
|
||||
return { unmount: function () { vivant = false; offs.forEach(function (f) { try { f(); } catch (e) {} }); c.innerHTML = ''; } };
|
||||
}
|
||||
window.jOSApps = window.jOSApps || {};
|
||||
window.jOSApps[ID] = { manifest: { id: ID, name: 'Musique', icon: '♫' }, mount: mount };
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user