-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
57 lines (48 loc) · 1.57 KB
/
app.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
console.log('Hello World!');
var rec = 0;
var hours = 0;
var minutes = 0;
var count = 0;
var len = count.length;
const recBtn = document.querySelector(".record-btn");
const recTime = document.querySelector("#rec-time");
const recDot = document.querySelector(".dot");
const camMode = document.getElementsByClassName(".cam-p")
recBtn.classList.add("active");
setInterval(logger, 1000)
function logger () {
console.log("Hello World!");
count++;
console.log(count);
if (rec === 0) {
recTime.innerText="Nothing to see here...";
recDot.classList.remove("active");
} else {
recTime.innerText = "recording..."+ hours +":"+ minutes +":"+ count;
recDot.classList.toggle("active");
}
if (count > 59) {count = 0; minutes++;}
if (minutes > 59) {minutes = 0; hours++;}
}
recBtn.addEventListener("click", () =>{
recBtn.classList.toggle("active")
hours = 0; minutes = 0; count = 0;
if (rec === 0) {
recTime.innerText = "Nothing to see here...";
rec = 1;
} else {
recTime.innerText = "recording..."+ count;
rec = 0;
}
})
/* buggy code from https://www.w3schools.com/howto/howto_js_active_element.asp
var header = document.getElementById("camera-modes");
var btns = header.getElementsByClassName("cam-p");
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener("click", function() {
var current = document.getElementsByClassName("active");
current[0].classList.remove("active");
this.classList.add("active");
});
}
*/