select first element on down arrow press, cleanup
This commit is contained in:
parent
75c86b5fd8
commit
e09c2545a1
|
@ -10,7 +10,7 @@ let total = 0;
|
|||
let onlyDirs = true;
|
||||
|
||||
const handleKeyEvent = (event) => {
|
||||
if (event.ctrlKey === true || event.altKey === true || event.metaKey == true) return;
|
||||
if (event.ctrlKey === true || event.altKey === true || event.metaKey === true) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
|
@ -18,7 +18,7 @@ const handleKeyEvent = (event) => {
|
|||
case ' ':
|
||||
case 'p':
|
||||
if (onlyDirs !== false) return;
|
||||
if (playerState == 'idle' && total !== 0) {
|
||||
if (playerState === 'idle' && total !== 0) {
|
||||
if (document.getElementById(playingItem).classList.contains('dir')) {
|
||||
return nextTrack();
|
||||
}
|
||||
|
@ -239,9 +239,13 @@ const selectPreviousItem = () => {
|
|||
}
|
||||
|
||||
const selectNextItem = () => {
|
||||
if (selectedItem === 0 && document.getElementsByClassName('selected').length === 0) {
|
||||
document.getElementById(selectedItem).classList.add('selected');
|
||||
} else {
|
||||
if (++selectedItem === total) selectedItem = 0;
|
||||
updateSelectedItem();
|
||||
}
|
||||
}
|
||||
|
||||
const updateSelectedItem = () => {
|
||||
if (document.getElementsByClassName('selected').length > 0) {
|
||||
|
|
Loading…
Reference in a new issue