@@ -6,7 +6,7 @@ class AnalogClock extends HTMLElement {
6
6
} ;
7
7
8
8
if ( ! this . content ) {
9
- console . info ( `%c ANALOG-CLOCK v3.0 ` , 'color: white; font-weight: bold; background: black' ) ;
9
+ console . info ( `%c ANALOG-CLOCK v3.2 ` , 'color: white; font-weight: bold; background: black' ) ;
10
10
var config = this . config ;
11
11
const card = document . createElement ( 'ha-card' ) ;
12
12
this . content = document . createElement ( 'div' ) ;
@@ -45,6 +45,34 @@ class AnalogClock extends HTMLElement {
45
45
layerMinSecCtx . textBaseline = 'middle' ;
46
46
layerMinSecCtx . translate ( canvas . width / 2 , canvas . height / 2 ) ;
47
47
48
+ var color_Background = getComputedStyle ( document . documentElement ) . getPropertyValue ( '--primary-background-color' ) ;
49
+ var color_Ticks = 'Silver' ;
50
+ var hide_MinorTicks = false ;
51
+ var hide_MajorTicks = false ;
52
+ var color_FaceDigits = 'Silver' ;
53
+ var locale = hass . language ;
54
+ var color_DigitalTime = 'red' ;
55
+ var color_HourHand = '#CCCCCC' ;
56
+ var color_MinuteHand = '#EEEEEE' ;
57
+ var color_SecondHand = 'Silver' ;
58
+ var color_Time = 'Silver' ;
59
+ var color_Text = 'Silver' ;
60
+ var timezone = Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone ;
61
+ var timezonedisplayname = "" ;
62
+ var showtimezone = false ;
63
+ var hide_WeekNumber = true ;
64
+ var hide_FaceDigits = false ;
65
+ var hide_Date = false ;
66
+ var hide_WeekDay = false ;
67
+ var hide_DigitalTime = false ;
68
+ var hide_SecondHand = false ;
69
+ var style_HourHand = 1 ;
70
+ var style_MinuteHand = 1 ;
71
+ var style_SecondHand = 3 ;
72
+ var dateMask = "" ;
73
+ var timeFormat = "" ;
74
+ var demo = false ;
75
+
48
76
var layerCachedForMinute = - 1 ;
49
77
getConfig ( ) ;
50
78
@@ -456,128 +484,101 @@ class AnalogClock extends HTMLElement {
456
484
}
457
485
458
486
function getConfig ( ) {
459
- globalThis . color_Background = getComputedStyle ( document . documentElement ) . getPropertyValue ( '--primary-background-color' ) ;
460
487
if ( config . color_Background ) color_Background = config . color_Background ;
461
488
if ( config . color_background ) color_Background = config . color_background ;
462
489
if ( color_Background . startsWith ( '--' ) ) {
463
490
color_Background = getComputedStyle ( document . documentElement ) . getPropertyValue ( color_Background ) ;
464
491
}
465
492
466
- globalThis . color_Ticks = 'Silver' ;
467
493
if ( config . color_Ticks ) color_Ticks = config . color_Ticks ;
468
494
if ( config . color_ticks ) color_Ticks = config . color_ticks ;
469
495
if ( color_Ticks . startsWith ( '--' ) ) {
470
496
color_Ticks = getComputedStyle ( document . documentElement ) . getPropertyValue ( color_Ticks ) ;
471
497
}
472
498
473
- globalThis . hide_MinorTicks = false ;
474
499
if ( config . hide_minorticks == true ) hide_MinorTicks = config . hide_minorticks ;
475
500
476
- globalThis . hide_MajorTicks = false ;
477
501
if ( config . hide_majorticks == true ) hide_MajorTicks = config . hide_majorticks ;
478
502
479
- globalThis . color_FaceDigits = 'Silver' ;
480
503
if ( config . color_FaceDigits ) color_FaceDigits = config . color_FaceDigits ;
481
504
if ( config . color_facedigits ) color_FaceDigits = config . color_facedigits ;
482
505
if ( color_FaceDigits . startsWith ( '--' ) ) {
483
506
color_FaceDigits = getComputedStyle ( document . documentElement ) . getPropertyValue ( color_FaceDigits ) ;
484
507
}
485
508
486
- globalThis . locale = hass . language ;
487
509
if ( config . locale ) locale = config . locale ;
488
510
489
- globalThis . color_DigitalTime = 'red' ;
490
511
if ( config . color_DigitalTime ) color_DigitalTime = config . color_DigitalTime ;
491
512
if ( config . color_digitaltime ) color_DigitalTime = config . color_digitaltime ;
492
513
if ( color_DigitalTime . startsWith ( '--' ) ) {
493
514
color_DigitalTime = getComputedStyle ( document . documentElement ) . getPropertyValue ( color_DigitalTime ) ;
494
515
}
495
516
496
- globalThis . color_HourHand = '#CCCCCC' ;
497
517
if ( config . color_HourHand ) color_HourHand = config . color_HourHand ;
498
518
if ( config . color_hourhand ) color_HourHand = config . color_hourhand ;
499
519
if ( color_HourHand . startsWith ( '--' ) ) {
500
520
color_HourHand = getComputedStyle ( document . documentElement ) . getPropertyValue ( color_HourHand ) ;
501
521
}
502
522
503
- globalThis . color_MinuteHand = '#EEEEEE' ;
504
523
if ( config . color_MinuteHand ) color_MinuteHand = config . color_MinuteHand ;
505
524
if ( config . color_minutehand ) color_MinuteHand = config . color_minutehand ;
506
525
if ( color_MinuteHand . startsWith ( '--' ) ) {
507
526
color_MinuteHand = getComputedStyle ( document . documentElement ) . getPropertyValue ( color_MinuteHand ) ;
508
527
}
509
528
510
- globalThis . color_SecondHand = 'Silver' ;
511
529
if ( config . color_SecondHand ) color_SecondHand = config . color_SecondHand ;
512
530
if ( config . color_secondhand ) color_SecondHand = config . color_secondhand ;
513
531
if ( color_SecondHand . startsWith ( '--' ) ) {
514
532
color_SecondHand = getComputedStyle ( document . documentElement ) . getPropertyValue ( color_SecondHand ) ;
515
533
}
516
534
517
- globalThis . color_Time = 'Silver' ;
518
535
if ( config . color_Time ) color_Time = config . color_Time ;
519
536
if ( config . color_time ) color_Time = config . color_time ;
520
537
if ( color_Time . startsWith ( '--' ) ) {
521
538
color_Time = getComputedStyle ( document . documentElement ) . getPropertyValue ( color_Time ) ;
522
539
}
523
540
524
- globalThis . color_Text = 'Silver' ;
525
541
if ( config . color_Text ) color_Text = config . color_Text ;
526
542
if ( config . color_text ) color_Text = config . color_text ;
527
543
if ( color_Text . startsWith ( '--' ) ) {
528
544
color_Text = getComputedStyle ( document . documentElement ) . getPropertyValue ( color_Text ) ;
529
545
}
530
546
531
- globalThis . timezone = Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone ;
532
547
if ( config . timezone ) timezone = config . timezone ;
533
548
534
- globalThis . timezonedisplayname = "" ;
535
549
if ( config . timezonedisplayname ) timezonedisplayname = config . timezonedisplayname ;
536
550
537
- globalThis . showtimezone = false ;
538
551
if ( config . showtimezone == true ) showtimezone = true ;
539
552
if ( config . show_timezone == true ) showtimezone = true ;
540
553
541
- globalThis . hide_WeekNumber = true ;
542
554
if ( config . hide_WeekNumber == false ) hide_WeekNumber = false ;
543
555
if ( config . hide_weeknumber == false ) hide_WeekNumber = false ;
544
556
545
- globalThis . hide_FaceDigits = false ;
546
557
if ( config . hide_FaceDigits == true ) hide_FaceDigits = true ;
547
558
if ( config . hide_facedigits == true ) hide_FaceDigits = true ;
548
559
549
- globalThis . hide_Date = false ;
550
560
if ( config . hide_Date == true ) hide_Date = true ;
551
561
if ( config . hide_date == true ) hide_Date = true ;
552
562
553
- globalThis . hide_WeekDay = false ;
554
563
if ( config . hide_WeekDay == true ) hide_WeekDay = true ;
555
564
if ( config . hide_weekday == true ) hide_WeekDay = true ;
556
565
557
- globalThis . hide_DigitalTime = false ;
558
566
if ( config . hide_DigitalTime == true ) hide_DigitalTime = true ;
559
567
if ( config . hide_digitaltime == true ) hide_DigitalTime = true ;
560
568
561
- globalThis . hide_SecondHand = false ;
562
569
if ( config . hide_SecondHand == true ) hide_SecondHand = true ;
563
570
if ( config . hide_secondhand == true ) hide_SecondHand = true ;
564
571
565
- globalThis . style_HourHand = 1 ;
566
572
if ( config . style_hourhand ) style_HourHand = config . style_hourhand ;
567
573
568
- globalThis . style_MinuteHand = 1 ;
569
574
if ( config . style_minutehand ) style_MinuteHand = config . style_minutehand ;
570
575
571
- globalThis . style_SecondHand = 3 ;
572
576
if ( config . style_secondhand ) style_SecondHand = config . style_secondhand ;
573
577
574
- globalThis . dateMask = "" ;
575
578
if ( config . dateformat ) dateMask = config . dateformat ;
576
579
577
- globalThis . timeFormat = "" ;
578
580
if ( config . timeformat ) timeFormat = config . timeformat ;
579
581
580
- globalThis . demo = false ;
581
582
if ( config . demo == true ) demo = true ;
582
583
583
584
var themes = config . themes ;
0 commit comments