@@ -632,10 +632,18 @@ function init_weather() {
632632 } )
633633
634634 // init saved weather address
635- config [ "weather_address" ] [ "latitude" ] = result [ "weather_address" ] [ "latitude" ]
636- config [ "weather_address" ] [ "longitude" ] = result [ "weather_address" ] [ "longitude" ]
637- qs ( "#weather-latitude" ) . value = config [ "weather_address" ] [ "latitude" ]
638- qs ( "#weather-longitude" ) . value = config [ "weather_address" ] [ "longitude" ]
635+ if ( result [ "weather_address" ] === undefined ) {
636+ config [ "weather_address" ] = {
637+ "longitude" : null ,
638+ "latitude" : null
639+ }
640+ } else {
641+ config [ "weather_address" ] [ "latitude" ] = result [ "weather_address" ] [ "latitude" ]
642+ config [ "weather_address" ] [ "longitude" ] = result [ "weather_address" ] [ "longitude" ]
643+ qs ( "#weather-latitude" ) . value = config [ "weather_address" ] [ "latitude" ]
644+ qs ( "#weather-longitude" ) . value = config [ "weather_address" ] [ "longitude" ]
645+ }
646+
639647 document . querySelectorAll ( ".weather-coords" ) . forEach ( elem => {
640648 elem . addEventListener ( "input" , settings_set_location )
641649 } )
@@ -645,6 +653,7 @@ function init_weather() {
645653 qs ( "#autolocate" ) . addEventListener ( "input" , allow_weather_refresh )
646654 config [ "autolocate" ] = result [ "autolocate" ]
647655 if ( result [ "autolocate" ] === undefined || result [ "autolocate" ] ) {
656+ config [ "autolocate" ] = true ;
648657 set_autolocation ( true )
649658 qs ( "#autolocate" ) . setAttribute ( "checked" , "checked" )
650659 } else {
@@ -655,6 +664,7 @@ function init_weather() {
655664 qs ( "#enableweather" ) . addEventListener ( "input" , settings_set_weather )
656665 config [ "weather_enabled" ] = result [ "weather_enabled" ]
657666 if ( result [ "weather_enabled" ] === undefined || result [ "weather_enabled" ] ) {
667+ config [ "weather_enabled" ] = true ;
658668 weather_enable ( true )
659669 qs ( "#enableweather" ) . setAttribute ( "checked" , "checked" )
660670 } else {
@@ -1280,7 +1290,7 @@ function initweatherchart() {
12801290 type : 'line' , data : {
12811291 datasets : [ {
12821292 parsing : false ,
1283- data : hourly [ "temperature" ] , // data: [...Array.from({length: 100}, (x, i) => i).map(val => {
1293+ data : hourly [ "temperature" ] . map ( ( { x , y } ) => ( { x : x , y : tunit ( y ) } ) ) , // data: [...Array.from({length: 100}, (x, i) => i).map(val => {
12841294 // return {x: val * 1000 * 60 * 60 * 24, y: tunit(val)}
12851295 // }), {x: 1000 * 60 * 60 * 24 * 10000, y: tunit(100)}],
12861296 label : "Temperature" ,
@@ -1319,7 +1329,7 @@ function initweatherchart() {
13191329 // borderDash: [5, 15],
13201330 } , {
13211331 parsing : false ,
1322- data : hourly [ "apparent_temperature" ] ,
1332+ data : hourly [ "apparent_temperature" ] . map ( ( { x , y } ) => ( { x : x , y : tunit ( y ) } ) ) ,
13231333 label : "Feels Like" ,
13241334 borderColor : gen_hourly_chart_gradient ,
13251335 backgroundColor : gen_hourly_chart_gradient ,
@@ -1506,7 +1516,7 @@ function initweatherchart() {
15061516 type : 'line' , data : {
15071517 datasets : [ {
15081518 parsing : false ,
1509- data : daily [ "high" ] ,
1519+ data : daily [ "high" ] . map ( ( { x , y } ) => ( { x : x , y : tunit ( y ) } ) ) ,
15101520 label : "High" ,
15111521 backgroundColor : CHART_COLORS . red ,
15121522 pointBorderColor : CHART_COLORS . red ,
@@ -1526,7 +1536,7 @@ function initweatherchart() {
15261536 }
15271537 } , {
15281538 parsing : false ,
1529- data : daily [ "apparent_high" ] ,
1539+ data : daily [ "apparent_high" ] . map ( ( { x , y } ) => ( { x : x , y : tunit ( y ) } ) ) ,
15301540 label : "Apparent High" ,
15311541 backgroundColor : CHART_COLORS . red ,
15321542 pointBorderColor : CHART_COLORS . red ,
@@ -1547,7 +1557,7 @@ function initweatherchart() {
15471557 }
15481558 } , {
15491559 parsing : false ,
1550- data : daily [ "low" ] ,
1560+ data : daily [ "low" ] . map ( ( { x , y } ) => ( { x : x , y : tunit ( y ) } ) ) ,
15511561 label : "Low" ,
15521562 backgroundColor : CHART_COLORS . blue ,
15531563 pointBorderColor : CHART_COLORS . blue ,
@@ -1567,7 +1577,7 @@ function initweatherchart() {
15671577 }
15681578 } , {
15691579 parsing : false ,
1570- data : daily [ "apparent_low" ] ,
1580+ data : daily [ "apparent_low" ] . map ( ( { x , y } ) => ( { x : x , y : tunit ( y ) } ) ) ,
15711581 label : "Apparent Low" ,
15721582 backgroundColor : CHART_COLORS . blue ,
15731583 pointBorderColor : CHART_COLORS . blue ,
0 commit comments