forked from server/soundboard
reset search on sounds nav button
reset search on escape key
This commit is contained in:
parent
4c34d4ac0e
commit
6758be0396
@ -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,17 +47,33 @@ ready(function() {
|
||||
});
|
||||
|
||||
var reset = document.querySelector("#reset");
|
||||
var sounds_nav = document.querySelector("#sounds-nav");
|
||||
|
||||
reset.addEventListener("click", function() {
|
||||
reset.addEventListener("click", resetSearch, false);
|
||||
sounds_nav.addEventListener("click", resetSearch, false);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<a href="#sounds" id="reset">Sounds</a>
|
||||
<a href="#sounds" id="sounds-nav">Sounds</a>
|
||||
<a href="#youtube">YouTube</a>
|
||||
<a href="#voice">Voice</a>
|
||||
</nav>
|
||||
@ -67,3 +67,4 @@
|
||||
<script src="/static/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user