-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstartCounterHandler.js
72 lines (59 loc) · 1.66 KB
/
startCounterHandler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'use strict';
import {
CountDown
} from '../classes/CountDown.js';
import '../../lib/soundmanager2-jsmin.js';
import { logger } from "../../lib/logger.js";
var startSwitch = true;
/**
* start/stop button toggle
*/
export function start() {
console.log('start counter HANDLER - START function');
startSwitch = !startSwitch;
const timeBtn = document.querySelector('#start');
var timeDom = document.querySelector('#hour').innerHTML;
window.restart = false;
window.pause = false;
if (startSwitch) {
timeBtn.innerHTML = 'START';
console.log("start counter HANDLER - STOPPED");
if (window.playing) {
console.log('start counter HANDLER - GOT PLAYING');
window.pause = true;
window.restart = true;
}
loadMp3();
//clicked btn up
timeBtn.classList.remove("noshadow");
} else {
timeBtn.innerHTML = 'STOP';
console.log("start counter HANDLER - STARTED");
window.reset = false;
var timer;
var toSec = timeDom.split(':');
var minToSec = parseInt(toSec[0]) * 60;
var sec = parseInt(toSec[1]);
var secLeft = minToSec + sec;
timer = new CountDown(secLeft);
timer.render();
window.playing = true;
loadMp3();
//clicked btn down
timeBtn.classList.add("noshadow");
}
}
/**
* loads an audio file
*/
//play sound
function loadMp3() {
var mySound = soundManager.createSound({
url: 'https://ghcdn.rawgit.org/bermarte/pomofocus/main/public/button-press.mp3'
});
mySound.play();
}
logger.add({
handler: 'start',
function: 'loadMp3'
});