ctucx.git: webmusic-nginx

nginx xslt-based index files optimized for music, inspired by https://git.ztn.sh/zotan/webmusic

commit dec620c7bc842add097201f0c904a39cc5956c9c
parent 0a9512e9f7df1a60b376fc8620ce1d2ba444ef58
Author: ctucx <c@ctu.cx>
Date: Sun, 7 Mar 2021 01:24:44 +0100

webmusic.js: set onclick-event on state element just once
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/webmusic.js b/webmusic.js
@@ -71,8 +71,9 @@ window.onkeyup = function (event) {
 function initState() {
 	const dirElements  = document.querySelectorAll(".dir");
 	const fileElements = document.querySelectorAll(".file");
+	let   id           = 0;
 
-	let id = 0;
+	document.getElementById("state").addEventListener("click", togglePlayback)
 
 	dirElements.forEach(function(element){
 		element.id = id++;

@@ -166,7 +167,6 @@ function toggleContinue() {
 }
 
 function updateState() {
-	document.getElementById("state").setAttribute('onclick', 'togglePlayback()');
 	let statestr = "[";
 	statestr += gstate;
 	if (sound.playing()) {