|
|
@@ -29,6 +29,12 @@ function apiFetch(url, opts) { |
|
|
// String.prototype.padStart not available in iOS < 10. |
|
|
// String.prototype.padStart not available in iOS < 10. |
|
|
function pad2(n) { return n < 10 ? '0' + n : '' + n; } |
|
|
function pad2(n) { return n < 10 ? '0' + n : '' + n; } |
|
|
|
|
|
|
|
|
|
|
|
// NodeList.prototype.forEach not available in iOS < 10. |
|
|
|
|
|
// Wrap querySelectorAll results in a real Array before iterating. |
|
|
|
|
|
function qsa(selector, root) { |
|
|
|
|
|
return Array.prototype.slice.call((root || document).querySelectorAll(selector)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// ── DOM refs ────────────────────────────────────────────────────────────────── |
|
|
// ── DOM refs ────────────────────────────────────────────────────────────────── |
|
|
var $ = function(id) { return document.getElementById(id); }; |
|
|
var $ = function(id) { return document.getElementById(id); }; |
|
|
|
|
|
|
|
|
@@ -172,7 +178,7 @@ $('btn-stop').addEventListener('click', function() { send({ cmd: 'stop' }); }); |
|
|
$('btn-next').addEventListener('click', function() { send({ cmd: 'next' }); }); |
|
|
$('btn-next').addEventListener('click', function() { send({ cmd: 'next' }); }); |
|
|
$('btn-prev').addEventListener('click', function() { send({ cmd: 'prev' }); }); |
|
|
$('btn-prev').addEventListener('click', function() { send({ cmd: 'prev' }); }); |
|
|
|
|
|
|
|
|
document.querySelectorAll('.btn-seek').forEach(function(btn) { |
|
|
|
|
|
|
|
|
qsa('.btn-seek').forEach(function(btn) { |
|
|
btn.addEventListener('click', function() { |
|
|
btn.addEventListener('click', function() { |
|
|
send({ cmd: 'seek', delta: parseInt(btn.dataset.delta, 10) }); |
|
|
send({ cmd: 'seek', delta: parseInt(btn.dataset.delta, 10) }); |
|
|
}); |
|
|
}); |
|
|
@@ -224,7 +230,7 @@ function updateMuteBtn(muted) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ── Rating (stars) ──────────────────────────────────────────────────────────── |
|
|
// ── Rating (stars) ──────────────────────────────────────────────────────────── |
|
|
var starEls = document.querySelectorAll('.star'); |
|
|
|
|
|
|
|
|
var starEls = qsa('.star'); |
|
|
|
|
|
|
|
|
function fetchRating() { |
|
|
function fetchRating() { |
|
|
apiFetch('/api/rating') |
|
|
apiFetch('/api/rating') |
|
|
@@ -509,7 +515,7 @@ function openPlaylist() { |
|
|
|
|
|
|
|
|
function updatePlaylistHighlight() { |
|
|
function updatePlaylistHighlight() { |
|
|
if (playlistOverlay.classList.contains('hidden')) return; |
|
|
if (playlistOverlay.classList.contains('hidden')) return; |
|
|
playlistList.querySelectorAll('li').forEach(function(li) { |
|
|
|
|
|
|
|
|
qsa('li', playlistList).forEach(function(li) { |
|
|
var isCurrent = parseInt(li.dataset.index, 10) === currentPlaylistPos - 1; |
|
|
var isCurrent = parseInt(li.dataset.index, 10) === currentPlaylistPos - 1; |
|
|
li.classList.toggle('current', isCurrent); |
|
|
li.classList.toggle('current', isCurrent); |
|
|
}); |
|
|
}); |
|
|
|