forked from server/soundboard
added keyboard shortcut for killing sounds via ajax
This commit is contained in:
parent
d4377e0f49
commit
90c0887f97
@ -61,6 +61,8 @@ ready(function() {
|
||||
evt = evt || window.event;
|
||||
if (evt.keyCode == 27) {
|
||||
resetSearch();
|
||||
} else if (evt.keyCode == 75 && evt.ctrlKey) {
|
||||
ajaxRequest("/?killvideo=yes");
|
||||
}
|
||||
};
|
||||
|
||||
@ -70,8 +72,13 @@ ready(function() {
|
||||
all_a_s[i].addEventListener('keypress', async function (e) {
|
||||
var key = e.keyCode;
|
||||
var source = e.target;
|
||||
if (key === 13) {
|
||||
source.classList.add("sound-pressed")
|
||||
// keylistener for enter or ctrl+enter (which is k10 on chrome)
|
||||
if (key === 13 || (key === 10 && e.ctrlKey)) {
|
||||
if(e.ctrlKey){
|
||||
ajaxRequest("/?killvideo=yes");
|
||||
await sleep(100);
|
||||
}
|
||||
source.classList.add("sound-pressed");
|
||||
source.onclick();
|
||||
await sleep(300);
|
||||
source.classList.remove("sound-pressed");
|
||||
@ -105,11 +112,10 @@ function hideSections() {
|
||||
});
|
||||
}
|
||||
|
||||
function ajaxRequest(filename){
|
||||
function ajaxRequest(url){
|
||||
var ajaxRequest;
|
||||
try{
|
||||
ajaxRequest = new XMLHttpRequest();
|
||||
var url = "play/" + filename;
|
||||
ajaxRequest.open("GET", url, true);
|
||||
ajaxRequest.send(null);
|
||||
}catch (e){
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
<section id="sounds">
|
||||
<div><input type="text" id="search" autofocus/><span id="reset">⨯</span></div>
|
||||
{% for sound in sounds %}
|
||||
<div class="sound"><a tabindex="0" class="unselectable" onclick="ajaxRequest('{{ sound | urlencode }}');">{{ sound.split('.', 1)[0] }}</a></div>
|
||||
<div class="sound"><a tabindex="0" class="unselectable" onclick="ajaxRequest('{{ '/play/' + sound | urlencode }}');">{{ sound.split('.', 1)[0] }}</a></div>
|
||||
{% endfor %}
|
||||
</section>
|
||||
<section id="youtube">
|
||||
@ -67,3 +67,4 @@
|
||||
<script src="/static/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user