From d0dc1a7fbd3967e4602f96c5df77e7a45a80a296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Thu, 14 Sep 2017 18:33:01 +0200 Subject: [PATCH] Minor code style improvements (mostly whitespace) --- static/main.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/static/main.js b/static/main.js index d020e9d..be5b03e 100644 --- a/static/main.js +++ b/static/main.js @@ -81,7 +81,6 @@ function addKeyListeners() { } }; - // keyboard listener for playing sounds using enter key var buttons = document.querySelectorAll(".sound"); @@ -91,7 +90,7 @@ function addKeyListeners() { var source = e.target; // keylistener for enter or ctrl+enter (which is k10 on chrome) if (key === 13 || (key === 10 && e.ctrlKey)) { - if(e.ctrlKey){ + if (e.ctrlKey){ killAllAudio(); await sleep(100); } @@ -135,11 +134,11 @@ function hideSections() { function ajaxRequest(url) { var ajaxRequest; - try{ + try { ajaxRequest = new XMLHttpRequest(); ajaxRequest.open("GET", url, true); ajaxRequest.send(null); - }catch (e){ + } catch (e) { alert("Unfortunately we were unable to handle your request. Please try again later and contact the server administrator if the problem persists."); return false; } @@ -151,12 +150,12 @@ function ajaxRequest(url) { */ function toggleLocalMode() { toggleButton = document.getElementById("local-mode-button").children[0]; - if(localModeEnabled){ + if (localModeEnabled) { localModeEnabled = false; toggleButton.classList.remove("local"); toggleButton.innerHTML = "[S]"; toggleButton.title = "play sounds on server"; - }else{ + } else { localModeEnabled = true; toggleButton.classList.add("local"); toggleButton.innerHTML = "[L]"; @@ -168,20 +167,20 @@ function toggleLocalMode() { * Either plays the given sound file locally by using howler.js or forwards the request to the remote server using AJAX. */ function playSound(filename) { - if(localModeEnabled){ + if (localModeEnabled){ // play local audio using howler.js var sound = new Howl({ - src: ['/sounds/'+filename] + src: ['/sounds/' + filename] }); sound.play(); howlerSounds.push(sound); - }else{ - ajaxRequest("/play/"+filename); + } else { + ajaxRequest("/play/" + filename); } } function killAllHowlerAudio() { - for(i=0; i