var timerVar; var needsToPress; var transcriptionArray = new Array(); function startNoiseProcess() { //seconds until next sound needsToPress=0; var max = 15; var min = 10; var randomNum = Math.round(Math.random() * (max - min) + min)*1000; timerVar=setTimeout(playNoise,randomNum); } function playNoise() { needsToPress=1; var audio = new Audio('beep.mp3'); audio.play(); timerVar=setTimeout(didntPressFastEnough,5000); } function didntPressFastEnough() { document.getElementById("messageText").innerHTML = "Sorry, you did not press after a noise"; deleteTranscription(); } function deleteTranscription() { transcriptionArray.length = 0; var i; for(i=1; i<=34; i++) { var positionImageId="position"+i; document.getElementById(positionImageId).src = "pics/placeholder.png"; } } function pressedNoise() { if (needsToPress==1) { document.getElementById("messageText").innerHTML = "Noise reset"; clearTimeout(timerVar); startNoiseProcess(); } else { document.getElementById("messageText").innerHTML = "Sorry, pressed when there was no noise"; deleteTranscription(); } } //change width and height of breaks so fits on iphone function setBreakHeight() { var w = window.innerWidth; if (w<739) { document.getElementById("break1").style.width = '5px'; document.getElementById("break2").style.width = '10px'; document.getElementById("break3").style.width = '10px'; document.getElementById("break4").style.width = '10px'; } else { document.getElementById("bigTable").width = '70%'; } } function addLetter(letter) { document.getElementById("messageText").innerHTML = ""; if (transcriptionArray.length<35) { transcriptionArray.push(letter); var newLetterImage="pics/"+letter+".png"; var positionImageId="position"+transcriptionArray.length; document.getElementById(positionImageId).src = newLetterImage; } } function dropLetter(letter) { if (transcriptionArray.length>0) { var positionImageId="position"+transcriptionArray.length; transcriptionArray.pop(); document.getElementById(positionImageId).src = "pics/placeholder.png"; } }