-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhamzClock.html
More file actions
452 lines (368 loc) · 17.3 KB
/
Copy pathhamzClock.html
File metadata and controls
452 lines (368 loc) · 17.3 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
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
<html style="background-color:black;">
<head>
<title>hamzClock</title>
<meta name="description" content="Dual UTC/Local clock for ham radio">
<meta name="keywords" content="digital clock, UTC, ham radio, android APK, HTML">
<meta name="author" content="Russ Williams AD9FK, rlw1138 {AT} hot mail {dot} com 2025FEB">
<!-- solar data image by Paul L Herrman N0NBH https://www.hamqsl.com-->
<!-- made with DroidScript on a Google Pixel 3A running LineageOS 22 -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
let DeBuG = false;
if (DeBuG) {console.log('debugging is ON"');}
</script>
<style>
/* BASE SIZES for vertical phone */
body { font-size: 12px; font-family: Arial, Helvetica, sans-serif;}
.upperClock { font-size: 146px; line-height: 0.88em; }
.lowerClock { font-size: 90px; line-height: 0.9em; }
.labelUTC { font-size: 12px; line-height: 0.5em; }
.labelLocal { font-size: 12px; line-height: 0.5em; }
/* Media query for wider screens (rotated phone) */
@media screen and (min-width: 600px) {
body { font-size: 14px; }
.upperClock { font-size: 200px; line-height: 0.8em; }
.lowerClock { font-size: 126px; line-height: 0.82em; }
.labelUTC { font-size: 14px; line-height: 0.5em; }
.labelLocal { font-size: 14px; line-height: 0.5em; }
}
/* Media query for wider screens (laptop/desktop) */
@media screen and (min-width: 900px) {
body { font-size: 18px; }
.upperClock { font-size: 300px; font-weight: bold; line-height: 0.8em; }
.lowerClock { font-size: 190px; font-weight: bold; line-height: 0.82em; }
.labelUTC { font-size: 18px; line-height: 0.5em; }
.labelLocal { font-size: 18px; line-height: 0.5em; }
}
/* Media queries for Light / Dark color mode */
@media (prefers-color-scheme: dark) {
body { background-color: black; color: white; }
p { color: white; }
.colorUTC { color: red ; }
.colorLocal { color: green; }
.colorGood {color:limegreen;}
.colorMeh {color:yellow;}
.colorBad {color:red;}
.line { border-bottom:2px solid white;}
}
@media (prefers-color-scheme: light) {
body { background-color: white; color: black; }
p { color: black; }
.colorUTC { color: blue; }
.colorLocal { color: orange; }
.colorGood {color:green;}
.colorMeh {color:orange;}
.colorBad {color:red;}
.line { border-bottom:2px solid black;}
}
.vspace {
margin-bottom:20px;
}
/* the Timer and Brite/Dim button */
.button {
background-color: #5c2514;
border: 2px #5c2514;
border-radius: 5px;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 11px;
margin: 4px 0; /* L/R & top/bottom */
height: 20px;
cursor: pointer;
}
/* put the button on the same baseline as the Date */
.d-table { display:table; }
.d-table-cell { display:table-cell; }
.w-100 { width: 100%; }
.tar { text-align: right; }
/* HR with button to the right (Swap button) */
.line { position:relative; height:3px; }
.line span { display:inline-block; position:relative; bottom:0.7em; height:100%; }
.line .flip { position:absolute; right:0; }
</style>
</head>
<body>
<a id="scrollTOP"></a>
<div id="upperArea">
<div class="d-table w-100">
<div id="upperLabel">
<p id="idUTC" class="labelUTC d-table-cell"><br />UTC -- coordinated universal time</p>
</div>
<div class="d-table-cell tar">
<!-- down below, this div has buttons -->
</div>
</div>
<div id="upperContainer" class="upperClock">
<div id="clockUTC" class="colorUTC"></div>
</div>
</div><!-- upperArea -->
<div class="line">
<span class="flip"><button class="button" onclick="swapClocks()">Swap</button></span>
</div>
<div id="lowerArea">
<div id="lowerContainer" class="lowerClock">
<div id="clockLocal" class="colorLocal"></div>
</div>
<a id="scrollTo"></a>
<div class="d-table w-100">
<div id="lowerLabel">
<p id="idLocal" class="labelLocal d-table-cell">Local time -- <span id="dayndate"></span></p>
</div>
<div class="d-table-cell tar">
<button class="button" id="counter" style="width:40px;text-align:"center";" title="Ten Minute timer" onclick="countDown(600)">Timer</button>
<button class="button" id="briteDim" onclick="imgBriteDim()">Brite/Dim</button>
</div>
</div>
</div><!-- lowerArea -->
<div id="vSpace" class='vspace'></div>
<div id="N0NBHimageV"><center>
<a href="https://www.hamqsl.com/solar.html" title="Click to add Solar-Terrestrial Data to your website!"><img src="https://www.hamqsl.com/solarn0nbh.php" width=90%></a>
</center></div>
<div id="N0NBHimageH"><center>
<a href="https://www.hamqsl.com/solar.html" title="Click to add Solar-Terrestrial Data to your website!"><img src="https://www.hamqsl.com/solar101vhfpic.php" width=90%></a>
</center></div>
<p><span class="colorGood">Good</span> <span class="colorMeh">meh</span> <span class="colorBad">Bad</span></p>
<div align="left"><p><pre><code>
SFI - Sum of the Sun's Radiation Output<br />
70 -- Too low<br />
80 -- Good<br />
90 -- Better<br />
100+ -- Best<br />
<br />
A-Index - Daily Average of Geo-Magnetic Activity<br />
A = 0 - 7 Quiet<br />
A = 8 - 15 Unsettled<br />
A = 16 - 29 Active<br />
A = 30 - 49 Minor Storm<br />
A = 50 - 99 Major Storm<br />
A = 100 - 400 Severe Storm<br />
<br />
K-Index - updated every 3 Hours<br />
K = 0 Inactive<br />
K = 1 Very quiet<br />
K = 2 Quiet<br />
K = 3 Unsettled<br />
K = 4 Active<br />
K = 5 Minor storm<br />
K = 6 Major storm<br />
K = 7 Severe storm<br />
K = 8 Very severe storm<br />
K = 9 Extremely severe storm<br />
</code></pre></p></div>
<button onclick="showAbout()">About hamzClock</button>
<script type="text/javascript">
/* don't change the order of most of these */
function showAbout() {
const aboutText = "hamzClock -- UTC / Local clock\n(c) 2025 Russ Williams, AD9FK\nrlw1138 {at} hotMail {dot} com\n"
alert(aboutText);
}
function swapClocks() {
id = document.getElementById("clockUTC").parentNode.id;
const ClockUTC = document.getElementById('clockUTC');
const ClockLocal = document.getElementById('clockLocal');
ClockUTC.innerText = "";
ClockLocal.innerText = "";
const UpperContainer = document.getElementById('upperContainer');
const LowerContainer = document.getElementById('lowerContainer');
const UpperLabel = document.getElementById('upperLabel');
const LowerLabel = document.getElementById('lowerLabel');
const IdUTC = document.getElementById('idUTC');
const IdLocal = document.getElementById('idLocal');
if ( id == "upperContainer") {
UpperLabel.appendChild(IdLocal);
UpperContainer.appendChild(ClockLocal);
LowerContainer.appendChild(ClockUTC);
LowerLabel.appendChild(IdUTC);
} else {
UpperLabel.appendChild(IdUTC);
UpperContainer.appendChild(ClockUTC);
LowerContainer.appendChild(ClockLocal);
LowerLabel.appendChild(IdLocal);
}
showTimes();
}
function countDown(duration) {
var count = duration;
var timer;
var killFlag;
let isColor1 = true;
const timerButton = document.getElementById("counter")
const originalOnClick = timerButton.onclick;
// Change onclick to a new function, to be ready for 'second click'
timerButton.onclick = function() {
if (DeBuG) {console.log('New onclick function executed!');}
// Add your desired functionality here
killFlag = 1;
// revert the button style back
timerButton.style.height = "20px";
timerButton.style.background = "#5c2514";
timerButton.style.color = "white";
timerButton.innerText = "Timer";
timerButton.onclick = originalOnClick; //revert after second click
//countDown(duration);
return;
};
timer = setTimeout(update, 1000);
//this allows for 'clearTimeout' if needed
function update() {
if (killFlag) {
killFlag = 0;
return;
}
if (count >= 1) {
count--;
seconds = count % 60;
minutes = (count - seconds) /60;
seconds = (seconds < 10) ? "0" + seconds : seconds;
time = minutes + ":" + seconds;
timerButton.innerText = time;
if (DeBuG) {console.log('#', count, ' min:', minutes, ' sec:', seconds);}
timer = setTimeout(update, 1000);
} else {
//alert("Done!!!");
// change button styling to yellow square
timerButton.style.height = "40px";
timerButton.style.background = "yellow";
timerButton.style.color = "black";
timerButton.style.border = "solid #000000 1px";
timerButton.style.borderRadius = "6px";
timerButton.innerText = "Call\nSign";
beep(440, 2500);
var element_to_scroll_to = document.getElementById('scrollTOP');
element_to_scroll_to.scrollIntoView();
//console.log('ping');
timer = setTimeout(update, 1000);
}
}
}
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
function beep(frequency, duration) {
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.type = 'triangle'; // You can change the waveform: sine, square, triangle, sawtooth
oscillator.frequency.value = frequency;
// Reduce gain to avoid clipping and abrupt starts/stops
gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);
gainNode.gain.exponentialRampToValueAtTime(0.0001, audioContext.currentTime + duration / 1000);
oscillator.start(audioContext.currentTime);
oscillator.stop(audioContext.currentTime + duration / 1000);
}
/* // Example usage: Beep at 440 Hz for 500 milliseconds
//beep(440, 500);
// Beep at 880 Hz for 250 milliseconds
setTimeout(() => {
beep(880, 250);
}, 750);
*/
// explicitly set a value, so "function imgBriteDim()" below works correctly
document.getElementById("N0NBHimageH").style.opacity = "1";
document.getElementById("N0NBHimageV").style.opacity = "1";
function getOrientation() {
return window.innerWidth > window.innerHeight ? "landscape" : "portrait";
}
function handleOrientationChange() {
const orientation = getOrientation();
if (DeBuG) {console.log("Current orientation:", orientation);}
// hide / display Vertical & Horiz radio info graphic
if (screen.orientation.type.startsWith('portrait')) {
document.getElementById('N0NBHimageH').style.display = 'none';
document.getElementById('N0NBHimageV').style.display = 'inline';
} else {
document.getElementById('N0NBHimageH').style.display = 'inline';
document.getElementById('N0NBHimageV').style.display = 'none';
}
}
handleOrientationChange(); // Initial check
// Listen for orientation changes (resize event)
window.addEventListener("resize", handleOrientationChange);
function imgBriteDim() {
const element = document.getElementById("N0NBHimageH");
const element2 = document.getElementById("N0NBHimageV");
if (element.style.opacity === "1") {
element.style.opacity = "0.5";
element2.style.opacity = "0.5";
} else {
element.style.opacity = "1";
element2.style.opacity = "1";
}
var element_to_scroll_to = document.getElementById('scrollTo');
element_to_scroll_to.scrollIntoView();
}
function showTimes() {
const now = new Date();
const dayOfWeek = now.toLocaleDateString('en-US', { weekday: 'long' });
const date = now.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' });
let TZ = now.getTimezoneOffset() / 60; //offset in minutes, so div by 60
let hours = now.getHours();
let minutes = now.getMinutes();
let seconds = now.getSeconds();
let hoursUTC = now.getUTCHours();
let minutesUTC = now.getUTCMinutes();
if (hours > 23) { hours = hours - 24; }
if (hoursUTC > 23) { hoursUTC = hoursUTC - 24; }
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;
hoursUTC = (hoursUTC < 10) ? "0" + hoursUTC : hoursUTC;
var timeUTC = hoursUTC + ":" + minutes;
var timeLocal = hours + ":" + minutes;
const child = document.getElementById("clockUTC");
const parent = document.getElementById(child.parentNode.id);
const grandparent = document.getElementById(parent.parentNode.id);
if (DeBuG) {console.log("parent=", parent.id, "= Gparent=", grandparent.id,"=");}
if ( grandparent.id == "upperArea") {
timeLocal = timeLocal + ":" + seconds;
} else {
timeUTC = timeUTC + ":" + seconds;
}
document.getElementById("clockUTC").innerText = timeUTC;
document.getElementById("clockLocal").innerText = timeLocal;
document.getElementById("dayndate").innerText = dayOfWeek +", "+ date;
setTimeout(showTimes, 1000); //update every second
}
showTimes(); // initial execution of function
function isMobile() {
var check = false;
(function(a){
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))
check = true;
})(navigator.userAgent||navigator.vendor||window.opera);
return check;
};
if (isMobile()) {
if (DeBuG) {console.log("This is mobile device");}
} else {
if (DeBuG) {console.log("This is NOT mobile device");}
}
function isMobileTablet(){
var check = false;
(function(a){
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))
check = true;
})(navigator.userAgent||navigator.vendor||window.opera);
return check;
}
if (isMobileTablet()) {
if (DeBuG) {console.log("This is touchscreen device");}
} else {
if (DeBuG) {console.log("This is NOT touchscreen device");}
}
// console.log("width: ", window.innerWidth, " height: ", window.innerHeight, " pixels")
function updateDimensions() {
let screenWidth = window.innerWidth;
let screenHeight = window.innerHeight;
if (DeBuG) {console.log("Screen Width: ", screenWidth, " Screen Height: ", screenHeight);}
// Perform actions based on orientation, e.g., adjust layout
}
updateDimensions(); // Initial check
// Un-Comment to Listen for orientation changes (resize event)
//window.addEventListener("resize", updateDimensions);
</script>
<br /><br /><br /><br />
</body>
</html>