File size: 8,810 Bytes
f86061f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4d8766c
f86061f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Custom Timer</title>
<style>
:root {
--countdown-color: #ff4b1f; /* Red */
--timer-color: #32cd32; /* Green */
--pause-color: #ffcc00; /* Yellow */
--stop-color: #ffffff; /* White */
}

body, html {
margin: 0;
padding: 0;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-family: Arial, sans-serif;
transition: background 0.5s, color 0.5s;
box-sizing: border-box;
}

.container {
text-align: center;
background: #ffffff;
padding: 15px;
border-radius: 10px;
width: 100%;
max-width: 422px; /* 宽度设为422px */
height: auto; /* 自适应高度 */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
justify-content: space-between;
}

.input-row, .button-row, .iframe-row {
display: flex;
justify-content: space-between;
align-items: center;
margin: 5px 0;
}

.input-row input, .button-row button, .iframe-row iframe {
flex: 1;
margin: 3px;
color: black;
border-radius: 5px;
border: 1px solid #ccc;
}

input {
padding: 10px;
border: none;
border-radius: 5px;
text-align: center;
font-size: 1em;
}

#timeDisplay {
font-size: 2.5em; /* 调整字号以适应较小宽度 */
color: #32cd32; /* Default lime green color */
width: 100%;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Courier New', Courier, monospace;
letter-spacing: 2px;
background: #f4f4f4;
border-radius: 5px;
margin: 10px 0;
transition: color 0.5s;
}

button {
padding: 8px;
border: none;
border-radius: 5px;
color: white;
cursor: pointer;
font-size: 0.9em;
transition: background-color 0.3s;
}

.button-row button:disabled {
background-color: grey;
cursor: not-allowed;
}

#startCountdownButton {
background-color: var(--countdown-color);
}

#startTimerButton {
background-color: var(--timer-color);
}

#pauseButton {
background-color: var(--pause-color);
}

#stopButton {
background-color: var(--stop-color);
color: black;
}

.iframe-row iframe {
width: 100%;
height: 110px;
border: none;
}
</style>
</head>
<body>
<audio id="alertSound">
<source src="ear0.wav" type="audio/mpeg">
</audio>
<div class="container">
<div class="iframe-row">
<a  href="https://feeday.cn"><img class="img" src="https://tool.lu/netcard/" width="320"  height="120"  alt=""/></a>
</div>
<div class="input-row">
<input type="number" id="hours" placeholder="HH" min="0" max="23">
<input type="number" id="minutes" placeholder="MM" min="0" max="59" value="15">
<input type="number" id="seconds" placeholder="SS" min="0" max="59">
</div>
<div class="button-row">
<button id="startCountdownButton" onclick="startCountdown()">倒计时</button>
<button id="startTimerButton" onclick="startTimer()">计时器</button>
<button id="pauseButton" onclick="pauseTimer()" disabled>暂停</button>
<button id="stopButton" onclick="stopTimer()" disabled>停止</button>

</div>
<div id="timeDisplay">00:00:00:00</div>


<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=320 height=110 src="//music.163.com/outchain/player?type=0&id=12658009656&auto=1&height=90"></iframe>

<!--
<iframe id="iframe" src="/page/page/xztpc.html" frameborder="0" scrolling="no" style="width: 318px; height: 200px; margin-left: -10px; margin-top: -98px;"></iframe>
<div style="width: 300px; height: 95px; overflow: hidden; white-space: nowrap;">
<div style="display: inline-block; width: 300px; height: 100%; background-color: lightblue;">

<iframe id="iframe" scrolling="no" src="/page/xztpc.html" frameborder="0" style="margin-top: -98px;"></iframe>
</div></div>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1964437526797765"
crossorigin="anonymous"></script>

<ins class="adsbygoogle"
style="display:inline-block;width:300px;height:95px"
data-ad-client="ca-pub-1964437526797765"
data-ad-slot="5255543137"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>


<a target="_blank" href="https://cloud.tencent.com/act/cps/redirect?redirect=30206&cps_key=615609c54e8bcced8b02c202a43b5570" ><img class="img" src="/img/tt1.png" width="300px"  height="95px" title="腾讯云轻量服务器" alt=""/></a>
</div>





<div style="display: inline-block; width: 300px; height: 100%; background-color: lightgreen;">
<a target="_blank" href="https://www.v5kf.com/public/wx_wall/index.html?mine=1&sid=95495&uid=o0rT0s6owNw-7rNp44JEbQI2WjhY" ><img class="img" src="/page/img/wx2.png" width="100%"  height="95" title="关注吐槽墙:上墙+留言" alt=""/></a>

</div>


-->



<script>
let timer;
let endTime;
let startTime;
let remainingTime;
let isCountdown = false;
let isPaused = false;

const timeDisplay = document.getElementById('timeDisplay');
const alertSound = document.getElementById('alertSound');

document.addEventListener('DOMContentLoaded', () => {
startTimer();
});

function startCountdown() {
if (timer) {
clearInterval(timer);
}
const hours = parseInt(document.getElementById('hours').value) || 0;
const minutes = parseInt(document.getElementById('minutes').value) || 0;
const seconds = parseInt(document.getElementById('seconds').value) || 0;

if (hours === 0 && minutes === 0 && seconds === 0) {
alert('Please set a valid time for countdown.');
return;
}

document.body.className = 'countdown';
timeDisplay.style.color = 'var(--countdown-color)'; // Red color
const totalMilliseconds = (hours * 3600 + minutes * 60 + seconds) * 1000;

if (totalMilliseconds > 0) {
isCountdown = true;
endTime = Date.now() + totalMilliseconds;
timer = setInterval(updateTime, 10);
document.getElementById('startCountdownButton').disabled = true;
document.getElementById('startTimerButton').disabled = false;
document.getElementById('pauseButton').disabled = false;
document.getElementById('stopButton').disabled = false;
}
}

function startTimer() {
if (timer) {
clearInterval(timer);
}
document.body.className = 'timer';
timeDisplay.style.color = 'var(--timer-color)'; // Green color
startTime = Date.now();
isPaused = false;
isCountdown = false;
timer = setInterval(updateTime, 10);
document.getElementById('startCountdownButton').disabled = false;
document.getElementById('startTimerButton').disabled = true;
document.getElementById('pauseButton').disabled = false;
document.getElementById('stopButton').disabled = false;
}

function pauseTimer() {
document.body.className = 'pause';
timeDisplay.style.color = 'var(--pause-color)'; // Yellow color
clearInterval(timer);
if (isCountdown) {
remainingTime = endTime - Date.now();
} else {
remainingTime = Date.now() - startTime;
}
isPaused = true;
document.getElementById('pauseButton').innerText = "继续"; // "继续" for Resume
document.getElementById('pauseButton').onclick = resumeTimer;
}

function resumeTimer() {
document.body.className = isCountdown ? 'countdown' : 'timer';
timeDisplay.style.color = isCountdown ? 'var(--countdown-color)' : 'var(--timer-color)';
if (isCountdown) {
endTime = Date.now() + remainingTime;
} else {
startTime = Date.now() - remainingTime;
}
isPaused = false;
timer = setInterval(updateTime, 10);
document.getElementById('pauseButton').innerText = "暂停"; // "暂停" for Pause
document.getElementById('pauseButton').onclick = pauseTimer;
}


function stopTimer() {
document.body.className = 'stop';
timeDisplay.style.color = 'var(--stop-color)';
clearInterval(timer);
timeDisplay.innerHTML = '00:00:00:00';
resetButtons();
}

function updateTime() {
const currentTime = Date.now();
let remaining;
if (isCountdown) {
remaining = endTime - currentTime;
if (remaining <= 0) {
clearInterval(timer);
alertSound.play();
resetButtons();
timeDisplay.innerHTML = '00:00:00:00';
return;
}
} else {
remaining = currentTime - startTime;
}

const milliseconds = remaining % 1000;
const totalSeconds = Math.floor(remaining / 1000);
const seconds = totalSeconds % 60;
const totalMinutes = Math.floor(totalSeconds / 60);
const minutes = totalMinutes % 60;
const hours = Math.floor(totalMinutes / 60);

timeDisplay.innerHTML = `${pad(hours)}:${pad(minutes)}:${pad(seconds)}:${pad(Math.floor(milliseconds / 100), 2)}`;
}

function pad(number, length = 2) {
return number.toString().padStart(length, '0');
}



function resetButtons() {
document.getElementById('startCountdownButton').disabled = false;
document.getElementById('startTimerButton').disabled = false;
document.getElementById('pauseButton').disabled = true;
document.getElementById('stopButton').disabled = true;

// Ensure the "Pause" button stays in Chinese even after stopping the timer
document.getElementById('pauseButton').innerText = "暂停"; // "暂停" for Pause
document.getElementById('pauseButton').onclick = pauseTimer;

document.body.className = '';
isPaused = false;
remainingTime = 0;
timer = null;
}

</script>
</body>
</html>