From 984ff20c19f3be40f05b6cd6a97779f40ec7d3d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Thu, 14 Sep 2017 18:27:36 +0200 Subject: [PATCH] Fix whitespace issues (trailing, indentation, etc) --- static/main.js | 117 ++++++++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 60 deletions(-) diff --git a/static/main.js b/static/main.js index e893bcc..d020e9d 100644 --- a/static/main.js +++ b/static/main.js @@ -1,7 +1,6 @@ - var localModeEnabled = false; -// References to howler objects +// References to howler objects var howlerSounds = []; function ready(fn) { @@ -39,7 +38,6 @@ ready(function() { searchfield.focus(); searchfield.addEventListener("keyup", function() { - var buttons = document.querySelectorAll(".sound"); buttons.forEach(function(item) { @@ -48,7 +46,7 @@ ready(function() { buttons.forEach(function(item) { var name = item.firstChild.innerHTML; - + if (name.toLowerCase().indexOf(searchfield.value.toLowerCase()) === -1) { item.style.display = "none"; } @@ -68,42 +66,42 @@ ready(function() { * Adds all necessary KeyListeners to document */ function addKeyListeners() { - // keyboard listener for global key strokes/inputs - document.onkeydown = function(evt) { - evt = evt || window.event; - if (evt.keyCode == 27) { - // esc key - resetSearch(); - } else if ((evt.keyCode == 75 || evt.keyCode == 67) && evt.ctrlKey) { - // ctrl+k and ctrl+c key binding - killAllAudio(); - } else if (evt.keyCode == 88 && evt.ctrlKey){ - // ctrl+x key binding - toggleLocalMode(); - } - }; + // keyboard listener for global key strokes/inputs + document.onkeydown = function(evt) { + evt = evt || window.event; + if (evt.keyCode == 27) { + // esc key + resetSearch(); + } else if ((evt.keyCode == 75 || evt.keyCode == 67) && evt.ctrlKey) { + // ctrl+k and ctrl+c key binding + killAllAudio(); + } else if (evt.keyCode == 88 && evt.ctrlKey){ + // ctrl+x key binding + toggleLocalMode(); + } + }; - // keyboard listener for playing sounds using enter key + // keyboard listener for playing sounds using enter key var buttons = document.querySelectorAll(".sound"); buttons.forEach(function(item) { - item.firstChild.addEventListener('keypress', async function (e) { - var key = e.keyCode; - 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){ - killAllAudio(); - await sleep(100); - } - source.classList.add("sound-pressed"); - source.onclick(); - await sleep(300); - source.classList.remove("sound-pressed"); - } - }); - }); + item.firstChild.addEventListener('keypress', async function (e) { + var key = e.keyCode; + 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){ + killAllAudio(); + await sleep(100); + } + source.classList.add("sound-pressed"); + source.onclick(); + await sleep(300); + source.classList.remove("sound-pressed"); + } + }); + }); } @@ -111,11 +109,11 @@ function resetSearch() { var searchfield = document.querySelector("#search"); var buttons = document.querySelectorAll(".sound"); - buttons.forEach(function(item) { - item.style.display = "inline-block"; - }); + buttons.forEach(function(item) { + item.style.display = "inline-block"; + }); - searchfield.value = ""; + searchfield.value = ""; searchfield.focus(); } @@ -124,7 +122,7 @@ function resetSearch() { */ function playStream() { var streamUrl = document.querySelector("#streaming-url").value; - ajaxRequest("/?video="+encodeURI(streamUrl)); + ajaxRequest("/?video="+encodeURI(streamUrl)); } function hideSections() { @@ -136,15 +134,15 @@ function hideSections() { } function ajaxRequest(url) { - var ajaxRequest; - try{ - ajaxRequest = new XMLHttpRequest(); - ajaxRequest.open("GET", url, true); - ajaxRequest.send(null); - }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; - } + var ajaxRequest; + try{ + ajaxRequest = new XMLHttpRequest(); + ajaxRequest.open("GET", url, true); + ajaxRequest.send(null); + }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; + } } /* @@ -161,9 +159,9 @@ function toggleLocalMode() { }else{ localModeEnabled = true; toggleButton.classList.add("local"); - toggleButton.innerHTML = "[L]"; - toggleButton.title = "play sounds locally"; - } + toggleButton.innerHTML = "[L]"; + toggleButton.title = "play sounds locally"; + } } /* @@ -173,7 +171,7 @@ function playSound(filename) { if(localModeEnabled){ // play local audio using howler.js var sound = new Howl({ - src: ['/sounds/'+filename] + src: ['/sounds/'+filename] }); sound.play(); howlerSounds.push(sound); @@ -184,8 +182,8 @@ function playSound(filename) { function killAllHowlerAudio() { for(i=0; i