You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.2 KiB
JavaScript
59 lines
1.2 KiB
JavaScript
|
|
var trilled = document.getElementById("trill")
|
|
|
|
var alarm = document.getElementById("drag-alarm");
|
|
|
|
function slideon(id) {
|
|
alarm.style.display = "block";
|
|
console.log("SLIDER DOWN")
|
|
}
|
|
|
|
function slideoff(id) {
|
|
alarm.style.display = "none";
|
|
}
|
|
|
|
function trill(id) {
|
|
var aaa = (Math.round(Math.random()))*2
|
|
trilled.style.transform = `rotate(${aaa}deg)`
|
|
}
|
|
|
|
// for the audio
|
|
let player = document.querySelector('#player')
|
|
let button = document.querySelector('#button')
|
|
let playing = false
|
|
button.onclick = function(){
|
|
console.log("hellooo")
|
|
loop_segment(player)
|
|
|
|
}
|
|
|
|
function change_segment(audio) {
|
|
if (playing == true) {
|
|
clearInterval(audio);
|
|
loop_segment(audio);
|
|
} else {
|
|
loop_segment(audio)
|
|
}
|
|
}
|
|
|
|
var audio_len = player.duration
|
|
|
|
|
|
function loop_segment(audio) {
|
|
|
|
playing = true
|
|
console.log(audio_len)
|
|
|
|
var duration = 0.3 //sec
|
|
var start_time = Math.random()* (audio_len - duration)
|
|
console.log(start_time)
|
|
audio.play()
|
|
setInterval(function(){
|
|
audio.currentTime = start_time
|
|
|
|
}, duration*1000)
|
|
//clearInterval()
|
|
//Math.random() * (max - min) + min
|
|
|
|
|
|
} |