@@ -406,6 +406,12 @@ <h1 id="headline">WORTUHR NESSI 3.1</h1>
406406 < input name = "frameSecondsIncDecCycle " id ="frameSecondsIncDecCycle " type ="checkbox " class ="toggle ">
407407 </ div >
408408 </ div >
409+ < div class ="checkbox-container ">
410+ < label for ="calendarActive " style ="align-self: flex-start "> Kalender LED: Ein/Aus </ label >
411+ < div >
412+ < input name = "calendarActive " id ="calendarActive " type ="checkbox " class ="toggle ">
413+ </ div >
414+ </ div >
409415 < div class ="checkbox-container ">
410416 < label for ="AutoChange " style ="align-self: flex-start "> Modus automatisch wechseln: Aus/Ein </ label >
411417 < div >
@@ -446,6 +452,29 @@ <h1 id="headline">WORTUHR NESSI 3.1</h1>
446452 </ div >
447453 </ div >
448454
455+ < div class ="main-container hidden " id ="calendarcolorcontainer ">
456+ < div class ="verticalline ">
457+ </ div >
458+ < div class ="headline ">
459+ KALENDER FARBEN
460+ </ div >
461+ < div class ="control-container ">
462+ < div class ="number-container ">
463+ < label for ="caldowcolor "> Wochentag Farbe</ label >
464+ < input type ="color " id ="caldowcolor " name ="caldowcolor ">
465+ </ div >
466+ < div class ="number-container ">
467+ < label for ="caldomcolor "> Monatstag Farbe</ label >
468+ < input type ="color " id ="caldomcolor " name ="caldomcolor ">
469+ </ div >
470+ < div class ="number-container ">
471+ < label for ="calmonthcolor "> Monat Farbe</ label >
472+ < input type ="color " id ="calmonthcolor " name ="calmonthcolor ">
473+ </ div >
474+ < div class ="buttonClass save-button " onclick ="saveCalendarColors() "> SAVE</ div >
475+ </ div >
476+ </ div >
477+
449478
450479 < div class ="main-container hidden " id ="snakecontainer ">
451480 < div class ="verticalline ">
@@ -741,13 +770,40 @@ <h1 id="headline">WORTUHR NESSI 3.1</h1>
741770 sendCommand ( "./cmd?frameSecondsIncDecCycle=0" ) ;
742771 }
743772 } ) ;
773+
774+ var ckb_calendarActive = document . querySelector ( 'input[id="calendarActive"]' ) ;
775+ if ( myVar . calendar == "1" ) {
776+ console . log ( "calendar == 1" ) ;
777+ ckb_calendarActive . checked = false ;
778+ }
779+ else {
780+ console . log ( "calendar == 0" ) ;
781+ ckb_calendarActive . checked = true ;
782+ }
783+ ckb_calendarActive . addEventListener ( 'change' , ( ) => {
784+ if ( ckb_calendarActive . checked ) {
785+ document . getElementById ( "calendarcolorcontainer" ) . classList . remove ( "hidden" ) ;
786+ sendCommand ( "./cmd?calendar=0" ) ;
787+ } else {
788+ document . getElementById ( "calendarcolorcontainer" ) . classList . add ( "hidden" ) ;
789+ sendCommand ( "./cmd?calendar=1" ) ;
790+ }
791+ } ) ;
744792
745793 document . getElementById ( "nm_start" ) . value = myVar . nightModeStart . replace ( "-" , ":" ) ;
746794 document . getElementById ( "nm_end" ) . value = myVar . nightModeEnd . replace ( "-" , ":" ) ;
747795 document . getElementById ( "brightness" ) . value = parseInt ( myVar . brightness ) ;
748796 document . getElementById ( "brightnessFrame" ) . value = parseInt ( myVar . brightnessFrame ) ;
749797 document . getElementById ( "colorshiftspeed" ) . value = parseInt ( myVar . colorshiftspeed ) ;
750798
799+ // Load calendar colors
800+ var caldow = myVar . caldow . split ( "-" ) ;
801+ var caldom = myVar . caldom . split ( "-" ) ;
802+ var calmonth = myVar . calmonth . split ( "-" ) ;
803+ document . getElementById ( "caldowcolor" ) . value = rgbToHex ( parseInt ( caldow [ 0 ] ) , parseInt ( caldow [ 1 ] ) , parseInt ( caldow [ 2 ] ) ) ;
804+ document . getElementById ( "caldomcolor" ) . value = rgbToHex ( parseInt ( caldom [ 0 ] ) , parseInt ( caldom [ 1 ] ) , parseInt ( caldom [ 2 ] ) ) ;
805+ document . getElementById ( "calmonthcolor" ) . value = rgbToHex ( parseInt ( calmonth [ 0 ] ) , parseInt ( calmonth [ 1 ] ) , parseInt ( calmonth [ 2 ] ) ) ;
806+
751807 updateDisplay ( parseInt ( myVar . modeid ) ) ;
752808 console . log ( myVar ) ;
753809 }
@@ -812,6 +868,33 @@ <h1 id="headline">WORTUHR NESSI 3.1</h1>
812868 xmlhttp . send ( ) ;
813869 }
814870
871+ function rgbToHex ( r , g , b ) {
872+ return "#" + ( ( 1 << 24 ) + ( r << 16 ) + ( g << 8 ) + b ) . toString ( 16 ) . slice ( 1 ) ;
873+ }
874+
875+ function hexToRgb ( hex ) {
876+ var result = / ^ # ? ( [ a - f \d ] { 2 } ) ( [ a - f \d ] { 2 } ) ( [ a - f \d ] { 2 } ) $ / i. exec ( hex ) ;
877+ return result ? {
878+ r : parseInt ( result [ 1 ] , 16 ) ,
879+ g : parseInt ( result [ 2 ] , 16 ) ,
880+ b : parseInt ( result [ 3 ] , 16 )
881+ } : null ;
882+ }
883+
884+ function saveCalendarColors ( ) {
885+ var caldowcolor = document . getElementById ( "caldowcolor" ) . value ;
886+ var caldomcolor = document . getElementById ( "caldomcolor" ) . value ;
887+ var calmonthcolor = document . getElementById ( "calmonthcolor" ) . value ;
888+
889+ var dow = hexToRgb ( caldowcolor ) ;
890+ var dom = hexToRgb ( caldomcolor ) ;
891+ var month = hexToRgb ( calmonthcolor ) ;
892+
893+ sendCommand ( "./cmd?caldow=" + dow . r + "-" + dow . g + "-" + dow . b ) ;
894+ sendCommand ( "./cmd?caldom=" + dom . r + "-" + dom . g + "-" + dom . b ) ;
895+ sendCommand ( "./cmd?calmonth=" + month . r + "-" + month . g + "-" + month . b ) ;
896+ }
897+
815898 function saveSettings ( ) {
816899 var nmStart = document . getElementById ( "nm_start" ) ;
817900 var nmEnd = document . getElementById ( "nm_end" ) ;
0 commit comments