diff --git a/static/main.js b/static/main.js index b965ee1..f5a682c 100644 --- a/static/main.js +++ b/static/main.js @@ -30,6 +30,7 @@ ready(function() { var searchfield = document.querySelector("#search"); searchfield.addEventListener("keyup", function() { + var buttons = document.querySelectorAll(".sound"); buttons.forEach(function(item) { @@ -46,18 +47,34 @@ ready(function() { }); var reset = document.querySelector("#reset"); + var sounds_nav = document.querySelector("#sounds-nav"); - reset.addEventListener("click", function() { - var buttons = document.querySelectorAll(".sound"); + reset.addEventListener("click", resetSearch, false); + sounds_nav.addEventListener("click", resetSearch, false); - buttons.forEach(function(item) { - item.style.display = "inline-block"; - }); - - searchfield.value = ""; - }); + document.onkeydown = function(evt) { + evt = evt || window.event; + if (evt.keyCode == 27) { + resetSearch(); + } + }; }); + +function resetSearch() { + var searchfield = document.querySelector("#search"); + var buttons = document.querySelectorAll(".sound"); + + searchfield.blur(); + + buttons.forEach(function(item) { + item.style.display = "inline-block"; + }); + + searchfield.value = ""; +} + + function hideSections() { var sections = document.querySelectorAll("section"); @@ -78,3 +95,4 @@ function ajaxRequest(filename){ return false; } } + diff --git a/templates/index.html b/templates/index.html index 93895b2..bf38b3e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -30,7 +30,7 @@ @@ -67,3 +67,4 @@ +