From 66a95dd2be0bb09f6659641c7904b9bca7bb338b Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Wed, 19 Jul 2017 13:27:10 +0200 Subject: [PATCH 01/30] autofocus for search field --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 40bef57..f65a124 100644 --- a/templates/index.html +++ b/templates/index.html @@ -36,7 +36,7 @@
-
+
{% for sound in sounds %} {% endfor %} From f605cdc8be5687937e3cce1e99a712f7d1aa8fe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20M=C3=BCller?= Date: Thu, 27 Jul 2017 17:18:49 +0200 Subject: [PATCH 02/30] Add shell script for development server --- devserver.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 devserver.sh diff --git a/devserver.sh b/devserver.sh new file mode 100755 index 0000000..460b9de --- /dev/null +++ b/devserver.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +basedir=$(dirname "$0") + +if [ ! -d "$basedir/py" ]; then + echo "Directory \"py\" with a Python virtual environment" + echo "does not exist. See README.rst on how to set it up." +else + export FLASK_DEBUG=1 + export FLASK_APP="$basedir/soundboard.py" + "$basedir"/py/bin/flask run +fi From 26bb3dca8589be3dbc8cb6fa875e726c87849364 Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 3 Aug 2017 17:17:51 +0200 Subject: [PATCH 03/30] implementing AJAX loading for sounds as described in issue #5 --- static/main.js | 15 +++++++++++++-- templates/index.html | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/static/main.js b/static/main.js index e2af0a3..b965ee1 100644 --- a/static/main.js +++ b/static/main.js @@ -30,8 +30,6 @@ ready(function() { var searchfield = document.querySelector("#search"); searchfield.addEventListener("keyup", function() { - console.log("Search!"); - var buttons = document.querySelectorAll(".sound"); buttons.forEach(function(item) { @@ -67,3 +65,16 @@ function hideSections() { item.style.display = "none"; }); } + +function ajaxRequest(filename){ + var ajaxRequest; + try{ + ajaxRequest = new XMLHttpRequest(); + var url = "play/" + filename; + ajaxRequest.open("GET", url, true); + ajaxRequest.send(null); + }catch (e){ + alert("Your browser broke!"); + return false; + } +} diff --git a/templates/index.html b/templates/index.html index f65a124..9166151 100644 --- a/templates/index.html +++ b/templates/index.html @@ -38,7 +38,7 @@
{% for sound in sounds %} - + {% endfor %}
From 4aa9f928484314e34e44184e3dd66aff8f4a0f1c Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 3 Aug 2017 17:27:48 +0200 Subject: [PATCH 04/30] fixed quoting in ajax call removed href since onclick seems to work fine --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 9166151..fbfad67 100644 --- a/templates/index.html +++ b/templates/index.html @@ -38,7 +38,7 @@
{% for sound in sounds %} - + {% endfor %}
From 6290c939826cbfc27317134ef6486976e6c4a233 Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 3 Aug 2017 17:40:34 +0200 Subject: [PATCH 05/30] added: sound button resets search field --- static/main.css | 4 ++-- templates/index.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/static/main.css b/static/main.css index 21195a9..90419d9 100644 --- a/static/main.css +++ b/static/main.css @@ -65,12 +65,12 @@ section { width: 100%; } -#reset { +div #reset { font-size: 2em; padding-left: 5px; } -#reset:hover { +div #reset:hover { cursor: pointer; } diff --git a/templates/index.html b/templates/index.html index fbfad67..93895b2 100644 --- a/templates/index.html +++ b/templates/index.html @@ -30,7 +30,7 @@ From 4c34d4ac0ec27e2e6e8e2154ff61124f7e3db06d Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 3 Aug 2017 19:37:58 +0200 Subject: [PATCH 06/30] pointer style cursor on hovering sound buttons --- static/main.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/static/main.css b/static/main.css index 90419d9..d792db2 100644 --- a/static/main.css +++ b/static/main.css @@ -98,4 +98,6 @@ div #reset:hover { .sound a:hover { background-color: #ff4136; box-shadow: inset 5px 5px 5px rgba(0, 0, 0, 0.6); + cursor: pointer; } + From 6758be03968a4cc563fbf665382cac7588f05814 Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 3 Aug 2017 19:39:02 +0200 Subject: [PATCH 07/30] reset search on sounds nav button reset search on escape key --- static/main.js | 34 ++++++++++++++++++++++++++-------- templates/index.html | 3 ++- 2 files changed, 28 insertions(+), 9 deletions(-) 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 @@ + From fa23ea0fbf3e77912615d22a9ee5a9a3f1cddace Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 3 Aug 2017 19:49:37 +0200 Subject: [PATCH 08/30] made button text unselectable --- static/main.css | 9 +++++++++ templates/index.html | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/static/main.css b/static/main.css index d792db2..9f2c798 100644 --- a/static/main.css +++ b/static/main.css @@ -101,3 +101,12 @@ div #reset:hover { cursor: pointer; } +.unselectable { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + diff --git a/templates/index.html b/templates/index.html index bf38b3e..02c6738 100644 --- a/templates/index.html +++ b/templates/index.html @@ -38,7 +38,7 @@
{% for sound in sounds %} - + {% endfor %}
From d4377e0f49dc8dd5787f4466c9ab7f7e7cd37ec5 Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 3 Aug 2017 20:34:22 +0200 Subject: [PATCH 09/30] keyboard controls and visuals closes #21 --- static/main.css | 13 +++++++++++-- static/main.js | 22 ++++++++++++++++++++++ templates/index.html | 3 +-- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/static/main.css b/static/main.css index 9f2c798..86106d7 100644 --- a/static/main.css +++ b/static/main.css @@ -96,11 +96,20 @@ div #reset:hover { } .sound a:hover { - background-color: #ff4136; - box-shadow: inset 5px 5px 5px rgba(0, 0, 0, 0.6); cursor: pointer; } +.sound a:active { + background-color: #ff4136; + box-shadow: inset 5px 5px 5px rgba(0, 0, 0, 0.6); + cursor: pointer; +} + +.sound-pressed { + background-color: #ff4136 !important; + box-shadow: inset 5px 5px 5px rgba(0, 0, 0, 0.6) !important; +} + .unselectable { -webkit-touch-callout: none; -webkit-user-select: none; diff --git a/static/main.js b/static/main.js index f5a682c..b33f0bd 100644 --- a/static/main.js +++ b/static/main.js @@ -6,6 +6,10 @@ function ready(fn) { } } +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + ready(function() { hideSections(); @@ -52,12 +56,29 @@ ready(function() { reset.addEventListener("click", resetSearch, false); sounds_nav.addEventListener("click", resetSearch, false); + // keyboard listener for esc button document.onkeydown = function(evt) { evt = evt || window.event; if (evt.keyCode == 27) { resetSearch(); } }; + + // keyboard listener for enter key + var all_a_s = document.getElementsByTagName("a"); + for(i=0; i
{% for sound in sounds %} - + {% endfor %}
@@ -67,4 +67,3 @@ - From 90c0887f979785d35484dbd6247a59c8d54c6e81 Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 3 Aug 2017 21:08:38 +0200 Subject: [PATCH 10/30] 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 @@ + From 730147514b24507e8ea245d264de6201a87a7e0f Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 3 Aug 2017 21:33:04 +0200 Subject: [PATCH 11/30] added new shortcut ...to kill sounds --- static/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/main.js b/static/main.js index fc6a44d..974206f 100644 --- a/static/main.js +++ b/static/main.js @@ -61,9 +61,9 @@ ready(function() { evt = evt || window.event; if (evt.keyCode == 27) { resetSearch(); - } else if (evt.keyCode == 75 && evt.ctrlKey) { + } else if ((evt.keyCode == 75 || evt.keyCode == 67) && evt.ctrlKey) { ajaxRequest("/?killvideo=yes"); - } + } }; // keyboard listener for enter key From 7f3cd26484ac70b21a4807c3958a909ee2a7ecbf Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 3 Aug 2017 21:42:58 +0200 Subject: [PATCH 12/30] fixed section content is overlapping dirty fixes #18 --- static/main.js | 2 -- templates/index.html | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/static/main.js b/static/main.js index 974206f..95bdbd0 100644 --- a/static/main.js +++ b/static/main.js @@ -11,8 +11,6 @@ function sleep(ms) { } ready(function() { - hideSections(); - var sections = document.querySelectorAll("section"); var nav = document.querySelectorAll("nav a"); diff --git a/templates/index.html b/templates/index.html index 03792ac..3d9c538 100644 --- a/templates/index.html +++ b/templates/index.html @@ -35,13 +35,13 @@ Voice -
+ -
+ -
+