-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.html
More file actions
127 lines (105 loc) · 2.86 KB
/
timer.html
File metadata and controls
127 lines (105 loc) · 2.86 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Timer</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background-color: #2c3e50;
color: #ecf0f1;
}
#timer {
text-align: center;
}
button {
background-color: #e74c3c;
color: #fff;
padding: 15px 30px;
font-size: 16px;
border: none;
border-radius: 10px;
margin: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #c0392b;
}
#display {
font-size: 2em;
margin: 10px 0;
}
#log {
margin-left: 20px;
border-left: 1px solid #ccc;
padding-left: 20px;
}
#log h3 {
color: #3498db;
}
#logList {
list-style-type: none;
padding: 0;
margin: 0;
}
#logList li {
margin-bottom: 5px;
}
</style>
</head>
<body>
<div id="timer">
<button onclick="startTimer()">Start</button>
<button onclick="pauseTimer()">Pause</button>
<button onclick="stopTimer()">Stop</button>
<p id="display">00:00:00</p>
</div>
<div id="log">
<h3>Log do Dia</h3>
<ul id="logList"></ul>
</div>
<script>
let timer;
let isTimerRunning = false;
let seconds = 0;
function startTimer() {
if (!isTimerRunning) {
timer = setInterval(updateTimer, 1000);
isTimerRunning = true;
}
}
function updateTimer() {
seconds++;
displayTime();
}
function displayTime() {
const hours = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const remainingSeconds = seconds % 60;
const formattedTime = `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(remainingSeconds).padStart(2, '0')}`;
document.getElementById('display').innerText = formattedTime;
}
function pauseTimer() {
clearInterval(timer);
isTimerRunning = false;
}
function stopTimer() {
pauseTimer();
const logList = document.getElementById('logList');
const logItem = document.createElement('li');
const formattedDate = new Date().toLocaleString('pt-BR', { hour: 'numeric', minute: 'numeric', hour12: true, day: 'numeric', month: 'numeric', year: 'numeric' });
logItem.innerText = `Contagem: ${document.getElementById('display').innerText}, Data: ${formattedDate}`;
logList.appendChild(logItem);
seconds = 0;
displayTime();
}
</script>
</body>
</html>