summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-03-08 14:05:17 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-03-08 14:05:17 +0100
commit6ba6600f5ad2a96fdeed9c597a2763a280cdbb3f (patch)
treef3200ad02d6d6cee0f4f05455b19a89555ac728f
parent34e37fe4ecedefa254d1029ecc2f62718f3bee43 (diff)
downloadwebmusic-nginx-6ba6600f5ad2a96fdeed9c597a2763a280cdbb3f.tar.gz
webmusic-nginx-6ba6600f5ad2a96fdeed9c597a2763a280cdbb3f.tar.bz2
webmusic-nginx-6ba6600f5ad2a96fdeed9c597a2763a280cdbb3f.zip
webmusic.js: check for playable content
-rw-r--r--webmusic.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/webmusic.js b/webmusic.js
index eeea892..cf5ac73 100644
--- a/webmusic.js
+++ b/webmusic.js
@@ -7,12 +7,14 @@ let playerState = 'idle';
let continuous = true;
let repeat = false;
let total = 0;
+let onlyDirs = true;
const handleKeyEvent = (event) => {
if (event.ctrlKey === true || event.altKey === true) return;
switch (event.key) {
case ' ':
case 'p':
+ if (onlyDirs !== false) return;
if (playerState == 'idle' && total !== 0) {
if (document.getElementById(playingItem).classList.contains('dir')) {
return nextTrack();
@@ -72,7 +74,6 @@ const handleKeyEvent = (event) => {
case '9':
audioPlayer.currentTime = audioPlayer.duration / 100 * (event.key * 10);
break;
-
}
};
@@ -116,6 +117,7 @@ const initState = () => {
fileElements.forEach((element) => {
element.id = id++;
+ onlyDirs = false;
element.addEventListener('click', (event) => {
event.preventDefault();