Minor code style improvements (mostly whitespace)

This commit is contained in:
Martin Müller 2017-09-14 18:33:01 +02:00
parent 984ff20c19
commit d0dc1a7fbd

View File

@ -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<howlerSounds.length; i++) {
for (var i = 0; i < howlerSounds.length; i++) {
howlerSounds[i].stop();
}
}