-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
113 lines (87 loc) · 2.48 KB
/
script.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
document.getElementById("wetab").style.display = 'none'
function addInTable() {
let input = document.getElementById('weather')
if(input.value){
let table = document.getElementById("table-body");
let newRow = table.insertRow(0);
let col1 = newRow.insertCell(0)
let col2 = newRow.insertCell(1);
let col3 = newRow.insertCell(2);
let today = new Date();
col2.innerHTML = input.value.toUpperCase();
col3.innerHTML = today.toLocaleDateString().replace(/[/]/g,'-') + ' ' + today.toLocaleTimeString();
let rows = document.getElementsByTagName('tr')
text = 'textContent' in document ? 'textContent' : 'innerText';
for (let i = 1, len = rows.length; i < len; i++) {
rows[i].children[0][text] = i;
}
}else{
alert('Debe escribir algun estado para poder agregar')
}
input.value = ''
}
function deleteRecord() {
let table = document.getElementById("table-body");
if( table.rows.length > 0){
table.deleteRow(0);
let rows = document.getElementsByTagName('tr')
text = 'textContent' in document ? 'textContent' : 'innerText';
for (let i = 1, len = rows.length; i < len; i++) {
rows[i].children[0][text] = i;
}
}else{
alert('No hay elementos en la tabla')
}
}
function change() // no ';' here
{
var elem = document.getElementById("toogle");
if (elem.value=="Tabla") {
document.getElementById('wetab').style.display = 'flex'
document.getElementById('crono').style.display = 'none'
elem.value = "Cronometro"}
else{
document.getElementById('wetab').style.display = 'none'
document.getElementById('crono').style.display= 'flex'
elem.value = "Tabla";
}
}
var h1 = document.getElementById('cron-text');
var start = document.getElementById('iniciar');
var stop = document.getElementById('parar');
var reset = document.getElementById('reiniciar');
var sec = 0;
var min = 0;
var hrs = 0;
var t;
function tick(){
sec++;
if (sec >= 60) {
sec = 0;
min++;
if (min >= 60) {
min = 0;
hrs++;
}
}
}
function add() {
tick();
h1.textContent = (hrs > 9 ? hrs : "0" + hrs)
+ ":" + (min > 9 ? min : "0" + min)
+ ":" + (sec > 9 ? sec : "0" + sec);
timer();
}
function timer() {
t = setTimeout(add, 1000);
}
timer();
start.onclick = timer;
stop.onclick = function() {
clearTimeout(t);
}
reset.onclick = function() {
h1.textContent = "00:00:00";
sec = 0; min = 0; hrs = 0;
clearTimeout(t)
}