From 90c0887f979785d35484dbd6247a59c8d54c6e81 Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 3 Aug 2017 21:08:38 +0200 Subject: [PATCH] added keyboard shortcut for killing sounds via ajax --- static/main.js | 14 ++++++++++---- templates/index.html | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/static/main.js b/static/main.js index b33f0bd..fc6a44d 100644 --- a/static/main.js +++ b/static/main.js @@ -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){ diff --git a/templates/index.html b/templates/index.html index 8378a11..03792ac 100644 --- a/templates/index.html +++ b/templates/index.html @@ -38,7 +38,7 @@
тип
{% for sound in sounds %} - + {% endfor %}
@@ -67,3 +67,4 @@ +