Skip to content

Commit

Permalink
added all the code for making stuff work
Browse files Browse the repository at this point in the history
  • Loading branch information
notthetup committed Nov 18, 2015
1 parent d816a9d commit e12fcc8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions midi.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ function onMIDIInit (midi){
function onMIDIConect(input){
console.log("Input id:", input.id, input);
input.onmidimessage = function(event){
var midiMessage = MIDIMessage(event);
console.log("Parsed", midiMessage);
var channel = (event.data[0]-176)+1;
console.log("Parsed", channel);
triggerPlayer(channel);
}
}

Expand All @@ -64,6 +65,7 @@ function makeMidiMsg(ch, state){
}

window.switchOnLED = function(ch){
console.log('setting led', ch);
if (window.teensy && typeof window.teensy.send === 'function'){
var channels = [0,1,2];
channels.forEach(function(thisCh){
Expand Down
6 changes: 5 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var blockBuzz = true,
questionsJson,
introClick = 1;


var onKeyPress = function(e) {
if(e.keyCode > 48 && e.keyCode < 52) {
triggerPlayer(e.keyCode - 48);
Expand All @@ -13,6 +12,7 @@ var onKeyPress = function(e) {
var onDocumentClick = function(e) {

if(introClick == 1) {
switchOnLED(null);
Array.prototype.forEach.call(document.querySelectorAll("#players input"), function(input) {
input.readOnly = true;
});
Expand Down Expand Up @@ -47,11 +47,13 @@ var onPlayerClick = function(e) {
e.currentTarget.children[1].textContent = parseInt(e.currentTarget.children[1].textContent, 10) + answerValue;
e.currentTarget.classList.remove("buzzed");
answerValue = 0;
switchOnLED(null);
}
else {
try {
document.querySelector(".buzzed").classList.remove("buzzed");
blockBuzz = false;
switchOnLED(null);
}
catch(e) {}
}
Expand All @@ -72,6 +74,7 @@ var onCardClick = function(e) {
e.currentTarget.children[2].style.transformOrigin = x + "px " + y + "px 0px";
e.currentTarget.classList.add("open");
blockBuzz = false;
switchOnLED(null);
answerValue = parseInt(e.currentTarget.children[0].textContent, 10);

try {
Expand All @@ -87,6 +90,7 @@ var triggerPlayer = function(player_number) { // player_numbers: 1, 2, 3
}

blockBuzz = true;
switchOnLED(player_number-1);
document.getElementById("player" + player_number).classList.add("buzzed");
}

Expand Down

0 comments on commit e12fcc8

Please sign in to comment.