-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
807 lines (700 loc) · 37.2 KB
/
index.html
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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
<!DOCTYPE html>
<!--suppress ALL -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<title>DaySee.org Clock</title>
<script type="application/javascript">
/* Initial Configuration */
var displaySeconds = true; // display the seconds hand
var traceinfo = 0; // developers aid
</script>
<style>
#DaySee_Container { /* container for full width/height HTML Canvas */
background: black;
}
</style>
<style>
body {
font-family: "Arial", sans-serif;
margin: 0;
padding: 0;
overflow: hidden; /* disable any scroll bar */
}
#DaySee_Container { /* container for full width/height HTML Canvas */
position: relative;
width: 100vw;
height: 100vh;
top: 0;
margin: 0 auto;
display: block;
box-sizing: border-box;
}
#DaySee_Canvas {
position: absolute; /* CANVAS covers the whole parent element */
width: 100%;
height: 100%;
}
#DaySee_URL {
position: absolute;
bottom: 0;
left: .1vw;
font-size: 1vw;
color: whitesmoke;
opacity: .5;
}
#DaySee_Controls {
position: relative;
width: 100%;
height: 100%;
opacity: .8;
box-sizing: border-box;
padding: 1vh 1vw;
}
#DaySee_Languages {
border: 5px solid grey;
background: grey;
position: absolute;
width: 100%;
height: 70px;
top: 50%;
display: flex; /* HTML5 Flex-Box : spaces items horizontally */
justify-content: space-between;
box-sizing: border-box;
}
#DaySee_Languages svg {
width: 15%;
height: 100%;
opacity: .5;
cursor: pointer;
}
#DaySee_Languages svg {
transition: 200ms;
transition-timing-function: ease-in-out;
-webkit-transition: 200ms;
-webkit-transition-timing-function: ease-in-out;
}
</style>
<style id="portrait" media="all and (orientation:portrait)"></style>
<style id="landscape" media="all and (orientation:landscape)"></style>
</head>
<body>
<div id="DaySee_Container" onclick="showDaySeeControls(!showingDaySeeControls)">
<div id="programmersError"></div>
<!-- All content is drawn on the fullscreen HTML5 Canvas -->
<canvas id="DaySee_Canvas"></canvas>
<!-- DaySee configuration controls -->
<div id="DaySee_Controls">
<div onclick="event.stopPropagation();showDaySeeControls(false);">
<svg xmlns="http://www.w3.org/2000/svg" fill="whitesmoke" width="24" height="24" viewBox="0 0 24 24">
<path d="M16 16h-8v-8h8v8zm-10-7.172v-2.828h2.828l-3.414-3.414 2.586-2.586h-8v8l2.586-2.586 3.414 3.414zm2.828 9.172h-2.828v-2.828l-3.414 3.414-2.586-2.586v8h8l-2.586-2.586 3.414-3.414zm9.172-2.828v2.828h-2.828l3.414 3.414-2.586 2.586h8v-8l-2.586 2.586-3.414-3.414zm-2-15.172l2.586 2.586-3.414 3.414h2.828v2.828l3.414-3.414 2.586 2.586v-8h-8z"/>
</svg>
</div>
<div id="DaySee_TestDates">
<style>
#DaySee_TestDates {
position: relative;
color: orange;
font-size:3em;
background:grey;
width:50%;
}
</style>
Testdates:
<div onclick="setDate(event,this)">
9/22/2017 21:10
</div>
<div onclick="setDate(event,this)">
2/6/2017 11:10
</div>
</div>
<div id="DaySee_Languages">
<svg data-daysee-language="nl" viewBox="0 0 12 9"> <!-- Dutch -->
<path fill="#ae1c28" d="M0 0h12v3H0z"/>
<path fill="white" d="M0 3h12v3H0z"/>
<path fill="#21468b" d="M0 6h12v3H0z"/>
</svg>
<svg data-daysee-language="en" viewBox="0 0 640 480"> <!-- English -->
<defs>
<clipPath id="a">
<path fill-opacity=".67" d="M-85.333 0h682.67v512h-682.67z"/>
</clipPath>
</defs>
<g clip-path="url(#a)" transform="translate(80) scale(.94)">
<g stroke-width="1pt">
<path fill="#006" d="M-256 0H768.02v512H-256z"/>
<path d="M-256 0v57.244l909.535 454.768H768V454.77L-141.515 0H-256zM768 0v57.243L-141.515 512H-256v-57.243L653.535 0H768z"
fill="#fff"/>
<path d="M170.675 0v512h170.67V0h-170.67zM-256 170.67v170.67H768.02V170.67H-256z"
fill="#fff"/>
<path d="M-256 204.804v102.402H768.02V204.804H-256zM204.81 0v512h102.4V0h-102.4zM-256 512L85.34 341.34h76.324l-341.34 170.67H-256zM-256 0L85.34 170.67H9L-256 38.164V0zm606.356 170.67L691.696 0h76.324L426.68 170.67h-76.324zM768.02 512L426.68 341.34h76.324L768.02 473.848v38.162z"
fill="#c00"/>
</g>
</g>
</svg>
<svg data-daysee-language="it" viewBox="0 0 12 9"> <!-- Italian -->
<path fill="#ce2b37" d="M0 0h12v9H0z"/>
<path fill="#fff" d="M0 0h8v9H0z"/>
<path fill="#009246" d="M0 0h4v9H0z"/>
</svg>
<svg data-daysee-language="de" viewBox="0 0 12 9"> <!-- German -->
<path d="M0 0h12v3H0z"/>
<path fill="#d00" d="M0 3h12v3H0z"/>
<path fill="#ffce00" d="M0 6h12v3H0z"/>
</svg>
<svg data-daysee-language="fr" viewBox="0 0 12 9"> <!-- French -->
<path fill="#f31830" d="M0 0h12v9H0z"/>
<path fill="#fff" d="M0 0h8v9H0z"/>
<path fill="#00267f" d="M0 0h4v9H0z"/>
</svg>
<svg data-daysee-language="da" viewBox="0 0 640 480"> <!-- Danish -->
<path fill="#c60c30" d="M0 0h640.1v480H0z"/>
<path fill="#fff" d="M205.714 0h68.57v480h-68.57z"/>
<path fill="#fff" d="M0 205.714h640.1v68.57H0z"/>
</svg>
<svg data-daysee-language="es" viewBox="0 0 12 9"> <!-- Spanish -->
<path fill="#c60b1e" d="M0 0h12v9H0z"/>
<path fill="#ffc400" d="M0 2.25h12v4.5H0z"/>
</svg>
<svg data-daysee-language="pt" viewBox="0 0 12 9"> <!-- Portugese -->
<path fill="red" d="M0 0h12v9H0z"/>
<path fill="#060" d="M0 0h5v9H0z"/>
</svg>
</div>
</div>
<div id="DaySee_URL" onclick="document.location='http://daysee.org';">www.DaySee.org</div>
</div>
<script type="application/javascript">
var DaySee_Logo_Image = new Image();
DaySee_Logo_Image.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTM0A1t6AAAJu0lEQVRYR81YaUyV2Rm+s2EVHUVcMm3SZfpjpulMOmlMOrGTMRm7ZNIlaacm7SSTtnYUK+47yqbj1hoZjbihiBsGxQUVcANEQJBNZLlcvMgiyCKyb5e7vn2ez/Nd70WwM4FM5km+XL5zznfOe573fZ/3HAyjhbCwMJ/U1NR1O3bsmKaavl3Izc2Nbm9vF6PRWEhjVfM3g/nz57+2fPnyP61Zs2beokWLPlLNbsTExLzf3d3tam1tFYvFIomJiYtVlxfOnDnzypEjR2bu2rVrumoaHaSnp0fYbDZxOp1SWVkpmzdvjlJdGsBalMvlEofDIfy9d+9esepy49y5c79+AHR2dkpeXt5m1TxygLnJTU1N1t7eXuHkVqtVSktLZenSpb9VQwy1tbXl4gHY4Vq7du1E1W24cuXK3/C9o6+vT8iyyWRKVV0jx+rVq2eQmba2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F22dRRhsTUxMXIXT8MuQghTPkkjghheCcnlPvbKUmVatWhWC+7Lman0858Npez0TD5f/DJyg3e26iIP1ft5VlFnPcPbs2WB9F1R53c0o5IW4A7/LMbt37w7lRJ4A4zYs9r1Lly65VR5B76IkgcVn9CmAOQdO4bO4WajDAtxNHlMnSQ51GPXarBk0FFCX54HiQuhUG04XaTD6H7NmzXqVfbiTzNCTwhMYF79gwYK3EGOq5Wm5ggEzweIGiLpqfQYwa0K/Ni8lBoYu2rlzZyou+dkIlQ/Y/rWBA8JzV0jEmAuTzsTN7hMmhScwPnDu3LkTkL1eNz4dCJnP1NQjx8aNG2d7BrsOk8mUwP4VK1aEDE4qSNVB9oGdf/HQOhhms/kq+0cF0KcYNa8bkAQbT9zsR+2MU81uIHZvso+xhnNkob4BXcZQ17vYPypA7Bn1jCb4N06+4arbgMwuU11ugKEy1U2GZ0KaHPyOly16AwbaVPfIgcxqoz7qLMB9FzylAFlpJTPs58O/ITWtqlsDEibMaDRqCsG5MKd7AyMGqkcJ9RETu3AUPwC3ef2LF+y4KFFkhg/lAgZWqG4dL0Hkd6Psuah1SJLfqfaRgxd6VIGduKAPWYZwZ+llXNE4boTGQnZOqG4vBAQE/NDrnPdNALV5D2OLzPHBiduCy7yWQN8KUHSRyWFwfyukp5T/KFddI4TB8D+rHWQfJC0x4QAAAABJRU5ErkJggg==';
var language = getUrlParameter('lang'); // is there a URL parameter?
if (!language) {
// get primary language from Browser
try {
language = navigator.language.split('-')[0]; // get language from browser
} catch (e) {
language = navigator.userLanguage.split('-')[0]; // IE 10 Browser
}
}
//region ------------------------------------------------------------------------------------- ### Generic functions
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? null : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
function reloadWebPage(seconds) {
window.setTimeout(function () {
location.reload();
}, 1000 * seconds);
}
function padToStringLength(str, len) {
while (str.length < len) {
str = ' ' + str + ' ';
}
return str;
}
function fullscreen_On() {
try { // Chrome & Edge
document.documentElement.webkitRequestFullscreen();
} catch (e) { // IE 10
document.documentElement.msRequestFullscreen();
}
}
function fullscreen_Off() {
try { // Chrome & Edge
document.webkitExitFullscreen();
} catch (e) { // IE 10
document.msExitFullscreen();
}
}
function toggleFullScreen(forcestate) {
try { // Chrome & Edge
if (!document.webkitFullscreenElement || forcestate) {
showDaySeeControls();
document.documentElement.webkitRequestFullscreen();
} else {
if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
} catch (e) { // IE 10
if (!document.msFullscreenElement || forcestate) {
showDaySeeControls();
document.documentElement.msRequestFullscreen();
} else {
if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
}
}
function programmersError(err) {
if (console) console.error(err);
document.getElementById('programmersError').innerHTML = err;
}
//endregion -------------------------------------------------------------------------------------- Generic functions
//region ------------------------------------------------------------------------------------- ### DaySee functions
function setDate(event,me){
event.stopPropagation();
clockTestDate = me.innerText;
drawFullscreen();
}
var showingDaySeeControls = false;
function showDaySeeControls(show) {
showingDaySeeControls = show;
var dayseeControlsDOMelement = document.getElementById('DaySee_Controls');
if (dayseeControlsDOMelement) dayseeControlsDOMelement.style.visibility = show ? 'visible' : 'hidden';
if (show) {
fullscreen_Off();
language_highlight(language);
//attach click handlers to language flags
[].map.call(document.querySelectorAll("[data-daysee-language]"), function (svgflag) {
console.info(svgflag, language);
svgflag.addEventListener('click', function () {
event.stopPropagation();
language_select(this.getAttribute('data-daysee-language'));
drawFullscreen();
});
});
} else {
fullscreen_On();
}
}
function language_highlight(lang) {
var element = document.querySelector("[data-daysee-language='" + lang + "']");
if (element) element.style.opacity = 1;
}
function language_unselect(lang) {
[].map.call(document.querySelectorAll("[data-daysee-language]"), function (svgflag) {
svgflag.style.opacity = .5;
});
}
function language_select(lang) {
language_unselect();
language = lang;
language_highlight(language);
}
//endregion -------------------------------------------------------------------------------------- DaySee functions
//region ------------------------------------------------------------------------------------- ### application configuration
var clock_faceColor = 'black';
var clock_letterColor = 'wheat';//'antiquewhite';
var clock_letterBorder = 'black';
var clock_letterBorderThinkness = 3;
var clock_handColor = clock_letterColor;
var clock_handBorder = clock_faceColor;
var display24hours = false; // display time on the analog clock in 1 - 24 hour notation
var canvasWidth,
canvasHeight,
canvasHalfWidth,
canvasHalfHeight;
var canvasHalfWidth, canvasHalfHeight;
var isPortrait;
var clockDate;
var clockTestDate = getUrlParameter('date');
var clockfullHours;
var clockHours;
var clockMinutes;
var clockSeconds;
var dayparts; // Array with day part name based on language: ['evening','afternoon','morning','night']
var dateFontSize = 50;
var clockTop;
var clockBottom;
var clockHeight;
var clockRadius;
var clockOffset_X; // X offset from 0,0 center Canvas
var clockOffset_Y; // Y offset from 0,0 center Canvas
var daysee = {};
var analogClockOptions = {
hands: {
"hour": {
length: .4,
width: .125,
border: clock_handBorder,
fill: clock_handColor
},
"minute": {
length: .67,
width: .1,
border: clock_handBorder,
fill: clock_handColor
},
"second": {
length: .65,
width: .01,
border: "transparent",
fill: "grey"
}
}
};
//endregion -------------------------------------------------------------------------------------- application configuration
//region ------------------------------------------------------------------------------------- ### clock language
function getDayAndDate() {
try {
var daypartsLocale = {
/* english */ "en": "evening,afternoon,morning,night",
/* spanish */ "es": "noche,tarde,mañana,noche",
/* french */ "fr": "soir,l'après-midi,le matin,la nuit",
/* dutch */ "nl": "avond,middag,ochtend,nacht",
/* german */ "de": "Abend,Nachmittag,Morgen,Nacht",
/* danish */ "da": "aften,eftermiddag,morgen,aften",
/* italian */ "it": "sera,pomeriggio,mattina,sera",
/* portuges */ "pt": "Noite,tarde,manhã,noite" // todo needs different syntax?
};
if (daypartsLocale.hasOwnProperty(language)) {
dayparts = daypartsLocale[language];
} else {
dayparts = daypartsLocale['en']; // default language when no language is found
}
dayparts = dayparts.split(','); // create an Array with the 4 values
if (clockTestDate) {
clockDate = new Date(clockTestDate);
} else {
clockDate = new Date();
}
clockfullHours = clockDate.getHours();
clockMinutes = clockDate.getMinutes();
clockSeconds = clockDate.getSeconds();
clockHours = clockfullHours % 12; // 1 to 11
var dateString = clockDate.toLocaleDateString(language, { // native JavaScript get Day notation by Language
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
}).split(' ');
daysee.fullDate = {
dayname: dateString[0],
daypart: dayparts[clockfullHours > 17 ? 0 : clockfullHours > 11 ? 1 : clockfullHours > 5 ? 2 : 3],//0=evening,1=night,2=morning,3=afternoon
day: dateString[1],
month: dateString[2],
year: dateString[3]
};
daysee.DM = dateString[1] + ' ' + dateString[2];
daysee.DMY = dateString[1] + ' ' + dateString[2] + ' ' + dateString[3];
} catch (err) {
programmersError(err);
}
}
//endregion -------------------------------------------------------------------------------------- clock language
//region ------------------------------------------------------------------------------------- ### init
var canvasDOMelement = document.getElementById("DaySee_Canvas");
var ctx = canvasDOMelement.getContext("2d");
var clockInterval_Seconds;
var clockInterval_Minutes;
var clockInterval_Hours;
window.addEventListener("resize", function () {//not all browsers support orientationchange event
if (clockInterval_Seconds) clearInterval(clockInterval_Seconds);
if (clockInterval_Minutes) clearInterval(clockInterval_Minutes);
if (clockInterval_Hours) clearInterval(clockInterval_Hours);
drawFullscreen();
}, false);
showDaySeeControls(true);
drawFullscreen();
//endregion -------------------------------------------------------------------------------------- init
function drawFullscreen() {
try {
var container = document.getElementById('DaySee_Container').getBoundingClientRect();
canvasWidth = parseInt(container.width);
canvasHeight = parseInt(container.height);
isPortrait = canvasWidth < canvasHeight;
canvasHalfWidth = parseInt(canvasWidth / 2);
canvasHalfHeight = parseInt(canvasHeight / 2);
canvasDOMelement.width = canvasWidth;
canvasDOMelement.height = canvasHeight;
ctx.setTransform(1, 0, 0, 1, 0, 0);
//region ------------------------------------------------------------------------------------- ### canvas draw functions
function fontSize(n) {
ctx.font = parseInt(n) + "px arial";
}
function drawLine(x1, y1, x2, y2, width, color) {
ctx.lineWidth = width || 2;
ctx.strokeStyle = color || 'red';
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.stroke();
}
function drawHline(y, color, width) {
drawLine(-100, y, 100, y, width, color);
}
function drawClockHand(handoptions, direction, radius) {
var handwidth = radius * handoptions.width;
ctx.beginPath();
ctx.moveTo(0, 0); // move to center of clock
ctx.lineWidth = handwidth;
ctx.strokeStyle = handoptions.border;
ctx.lineCap = "round";
ctx.rotate(direction); // rotate in the (seconds) direction
ctx.lineTo(0, -radius * handoptions.length); // draw a line with length
ctx.stroke();
ctx.rotate(-direction);//back to 0,0 origin // return to center of clock
ctx.lineWidth = handwidth * .8; // smaller width
ctx.strokeStyle = handoptions.fill; // stroke inner color
ctx.stroke();
}
function drawText(txt, x, y, fontsize, maxfontsize, fittowidth, cleanwidth) {
try {
fontSize(fontsize);
if (fittowidth) {
fontsize = 200;
//fit text to specified fittowidth size
do {
fontSize(--fontsize);
} while (ctx.measureText(txt).width > fittowidth);
// limit to the maximum fontsize
do {
fontSize(--fontsize);
} while (fontsize > maxfontsize);
y += fontsize;
}
while ((x + ctx.measureText(txt).width / 2) > canvasWidth / 2) {
--x;
//fontSize(--fontsize);
}
// move text inside bottom edge
do {
y--
} while (y > canvasHalfHeight - fontsize / 1.5);
// clean area where text is drawn
ctx.fillStyle = clock_faceColor;
var x1 = x - (cleanwidth / 2);
var y1 = y - (fontsize / 2) + (fontsize / 10);
ctx.fillRect(
x1,
y1,
cleanwidth,
fontsize);
// draw text
ctx.fillStyle = clock_letterColor;
fontSize(fontsize);
ctx.fillText(txt, x, y);
return {
"x": x,
"y": y,
"fontsize": fontsize,
"top": y - fontsize / 2,
"bottom": y + fontsize / 2,
"width": ctx.measureText(txt).width
};
} catch (e) {
console.error(e);
}
}
//endregion -------------------------------------------------------------------------------------- canvas draw functions
drawClock(true, true, true); // first init with seconds/minutes/hours
clockInterval_Seconds = window.setInterval(function () { // every SECOND
drawClock(true, false, false);
}, 1000);
clockInterval_Minutes = window.setInterval(function () { // every MINUTE
drawClock(true, true, false);
}, 1000 * 60);
clockInterval_Hours = window.setInterval(function () { // very HOUR
drawClock(true, true, true);
}, 1000 * 60 * 60);
function drawClock(newSecond, newMinute, newHour) {
ctx.translate(canvasHalfWidth, canvasHalfHeight);//canvas origin 0,0 is center of clock
getDayAndDate();
try {
ctx.textBaseline = "middle";
ctx.textAlign = "center";
var dateTextPosition_X = 0;
var dateTextPosition_Y = 0;
if (newHour) {
function displayDate_Portrait() {
var positionedDate =
drawText(
/** text */ padToStringLength(daysee.DMY, 10),
/** X */ 0,
/** Y */ canvasHalfHeight,
/** fontsize */ 10,
/**maxfontsize */ canvasHeight / 10,
/** fittowidth */ canvasWidth,
/** cleanwidth */ canvasWidth
);
dateFontSize = positionedDate.fontsize;
clockBottom = parseInt(positionedDate.y - dateFontSize / 2);
dateTextPosition_Y = parseInt(-canvasHalfHeight + dateFontSize / 2);
drawText(
/** text */ daysee.fullDate.dayname,
/** X */ 0,
/** Y */ dateTextPosition_Y,
/** fontsize */ dateFontSize,
/**maxfontsize */ canvasHeight / 10,
/** fittowidth */ false,
/** cleanwidth */ canvasWidth
);
dateTextPosition_Y = dateTextPosition_Y + 10 + dateFontSize;
drawText(
/** text */ daysee.fullDate.daypart,
/** X */ 0,
/** Y */ dateTextPosition_Y,
/** fontsize */ dateFontSize,
/**maxfontsize */ canvasHeight / 10,
/** fittowidth */ false,
/** cleanwidth */ canvasWidth
);
}
function displayDate_Lanscape() {
dateTextPosition_X = canvasWidth / 4;
var positionedDate =
drawText(
/** text */ daysee.DMY,
/** X */ dateTextPosition_X,
/** Y */ canvasHalfHeight,
/** fontsize */ 0,
/**maxfontsize */ canvasHeight / 4,
/** fittowidth */ canvasHalfWidth,
/** cleanwidth */ canvasHalfWidth
);
dateFontSize = positionedDate.fontsize;
clockBottom = parseInt(positionedDate.y - dateFontSize / 2);
ctx.textBaseline = "middle";
//dateFontSize += 20;
dateTextPosition_Y = parseInt(-canvasHalfHeight + dateFontSize / 2);
drawText(
/** text */ daysee.fullDate.dayname,
/** X */ dateTextPosition_X,
/** Y */ dateTextPosition_Y,
/** fontsize */ dateFontSize,
/**maxfontsize */ canvasHeight / 8,
/** fittowidth */ false,
/** cleanwidth */ canvasHalfWidth
);
dateTextPosition_Y = dateTextPosition_Y + 10 + dateFontSize;
drawText(
/** text */ daysee.fullDate.daypart,
/** X */ dateTextPosition_X,
/** Y */ dateTextPosition_Y,
/** fontsize */ dateFontSize,
/**maxfontsize */ canvasHeight / 8,
/** fittowidth */ false,
/** cleanwidth */ canvasHalfWidth
);
}
if (isPortrait) {
displayDate_Portrait();
clockTop = parseInt(dateTextPosition_Y + dateFontSize / 2);
clockHeight = parseInt(clockBottom - clockTop);//clockTop is negative
clockRadius = parseInt(clockHeight / 2);
if (clockHeight > canvasWidth) clockRadius = canvasHalfWidth;
clockOffset_X = 0;
//position clock centered between text
clockOffset_Y = parseInt((clockBottom + clockTop) / 2);//clockTop is negative
} else {
displayDate_Lanscape();
clockTop = -canvasHalfHeight;
clockHeight = canvasHeight;
if (clockHeight > canvasHalfWidth) {
clockRadius = parseInt(canvasWidth / 4);
} else {
clockRadius = parseInt(clockHeight / 2);
}
clockOffset_X = -dateTextPosition_X;
clockOffset_Y = 0;
}
}
//region ------------------------------------------------------------------------------------- ### draw analog clock
/* The whole clock needs to be redrawn to wipe out the previous CANVAS content */
ctx.beginPath();//clock background color
ctx.translate(clockOffset_X, clockOffset_Y);
ctx.arc(0, 0, clockRadius, 0, parseInt(2 * Math.PI));
ctx.fillStyle = clock_faceColor;
ctx.fill();
//region ------------------------------------------------------------------------------------- ### Draw clock numbers
ctx.fillStyle = clock_letterColor;
ctx.strokeStyle = clock_letterBorder;
ctx.lineWidth = clock_letterBorderThinkness;
for (var nmbr = 1; nmbr < 13; nmbr++) {
var numberSize = (nmbr % 3 === 0) ? .3 : 0.2;// scale numbers, 3 6 9 12 are displayed bigger
var numberStr = nmbr;
if (display24hours && clockfullHours > 11) {
numberStr += 12;
numberSize *= .7; // 24 hour clock numbers are displayed smaller
}
fontSize(clockRadius * numberSize);
var angle = nmbr * Math.PI / 6; // angle from 0,0 clock origin
var numberoffset = clockRadius * 0.85; // draw number inside clock face
ctx.rotate(angle); // move to number position
ctx.translate(0, -numberoffset); // set origin to center of Number
ctx.rotate(-angle); // move drawing position upright again
ctx.strokeText(numberStr.toString(), 0, 0); // draw outline
ctx.fillText(numberStr.toString(), 0, 0); // draw fill
ctx.rotate(angle); // rotate back to 0,0 clock origin
ctx.translate(0, numberoffset); // set origin to center of clock
ctx.rotate(-angle); // stroke is upright again
} // draw clock numbers
//endregion -------------------------------------------------------------------------------------- Draw clock numbers
var clockHandDirection = (clockHours * Math.PI / 6) + (clockMinutes * Math.PI / (6 * 60)) + (clockSeconds * Math.PI / (360 * 60));
drawClockHand(
analogClockOptions.hands.hour,
clockHandDirection,
clockRadius
);
clockHandDirection = (clockMinutes * Math.PI / 30) + (clockSeconds * Math.PI / (30 * 60));
drawClockHand(
analogClockOptions.hands.minute,
clockHandDirection,
clockRadius
);
clockHandDirection = (clockSeconds * Math.PI / 30);
if (displaySeconds) drawClockHand(
analogClockOptions.hands.second,
clockHandDirection,
clockRadius
);
ctx.rotate(clockHandDirection);
var x = analogClockOptions.hands.minute.width * clockRadius;
ctx.drawImage(DaySee_Logo_Image, -x / 2, -x / 2, x, x);
ctx.rotate(-clockHandDirection);
ctx.translate(-clockOffset_X, -clockOffset_Y);
//endregion -------------------------------------------------------------------------------------- draw analog clock
if (traceinfo) {
drawHline(clockTop);
drawHline(0, 'green');
drawHline(clockBottom);
drawHline(clockOffset_Y, 'lightgreen');
drawLine(0, clockTop, 0, clockBottom, 4, 'orange');
var info = canvasWidth + ' x ' + canvasHeight
+ ' %' + parseInt((canvasWidth / canvasHeight) * 10) / 10
+ ' '
// + ' s: ' + screen.availWidth + ' x ' + screen.availHeight
// + ' c: ' + clockHeight + ' x ' + clockRadius + ' (' + clockTop + ' / ' + clockBottom
+ dateFontSize
+ ' d: ' + -canvasHalfHeight + ' x ' + canvasHalfHeight;
drawText(
info
/* X */, 0
/* Y */, canvasHalfHeight - 7
/* fontsize */, 10
/* fittowidth */, false
);
//drawText(clockDate.toLocaleTimeString(), 0, -canvasHalfHeight + 10, 20);
}
}
catch (err) {
programmersError(err);
}
ctx.translate(-canvasHalfWidth, -canvasHalfHeight);//canvas origin 0,0 is center of clock
}
} catch (err) {
programmersError(err);
}
}
</script>
</body>
<!--
rasp-pi: http://jpbrown.info/projects/view/dynamic-alzheimers-clock/
clock chronometer: http://gtsparkplugs.com/JSClock.html
css animation and images: https://github.com/fofr/paulrhayes.com-experiments/tree/master/clock
CSS animated alarmclock: http://codepen.io/MischaAbakumova/pen/qrByWp?editors=1100
CSS only Mondriaan clock: https://codepen.io/slyka85/pen/xgRmpa
Digital clock with rotating numbers
https://codepen.io/DawidKrajewski/pen/dPpMXN
Configure device:
Disable auto reboot on Windows
http://www.laptopmag.com/articles/disable-automatic-restart-windows
Run Edge browser in Kiosk mode
https://blogs.msdn.microsoft.com/askie/2015/04/29/how-to-hide-tabs-in-ie11-and-load-in-kiosk-mode-with-or-without-address-bar/
-->
</html>