File tree Expand file tree Collapse file tree 3 files changed +23
-19
lines changed
Expand file tree Collapse file tree 3 files changed +23
-19
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,14 @@ export const TWLSample = (props: any) => {
125125 url . searchParams . get ( 'op' ) === 'screenshot'
126126 ) {
127127 setIsSh ( true ) ;
128+ if ( url . searchParams . has ( 'year' ) ) {
129+ const y = url . searchParams . get ( 'year' ) ;
130+ if ( y ) {
131+ setTimeout ( ( ) => {
132+ setCurrYear ( parseInt ( y ) , mode ) ;
133+ } , 1250 ) ;
134+ }
135+ }
128136 } else {
129137 if ( ! yearSet ) {
130138 let dt = new Date ( + cdata . time ) . getFullYear ( ) ;
Original file line number Diff line number Diff line change @@ -421,18 +421,17 @@ export const MapPopup: React.FunctionComponent<MapPopupProps> = props => {
421421 let atv = 0 ;
422422 let url = new URL ( window . location . href ) ;
423423 let yrparam = url . searchParams . get ( 'year' ) ;
424- let yrfield = document . getElementsByClassName ( 'timecontrol-date' ) ;
425- let yrstring =
426- data === 'forecast' ? '2035' : ( new Date ( ) . getFullYear ( ) - 1 ) . toString ( ) ;
427- if ( yrfield . length > 0 ) {
428- yrstring = yrfield [ 0 ] . textContent ! ;
429- } else if ( yrparam ) {
424+ let yrstring : string | null | undefined = null ;
425+
426+ if ( yrparam ) {
430427 yrstring = yrparam ;
431428 }
432429 try {
433- yr = parseInt ( yrstring , 10 ) ;
434- if ( isNaN ( yr ) )
435- yr = data === 'forecast' ? 2035 : new Date ( ) . getFullYear ( ) - 1 ;
430+ if ( yrstring ) {
431+ yr = parseInt ( yrstring , 10 ) ;
432+ if ( isNaN ( yr ) )
433+ yr = data === 'forecast' ? 2035 : new Date ( ) . getFullYear ( ) - 1 ;
434+ }
436435 } catch ( ex ) {
437436 yr = data === 'forecast' ? 2035 : new Date ( ) . getFullYear ( ) - 1 ;
438437 }
Original file line number Diff line number Diff line change @@ -485,12 +485,12 @@ export function MapPage(props: MapPageProps) {
485485 useEffect ( ( ) => {
486486 let year = '' ;
487487 try {
488- year =
489- currentMap . aggregation_period === 'annual'
490- ? new Date ( ( mapRef . current as any ) . timeDimension ?. getCurrentTime ( ) )
491- . getFullYear ( )
492- . toString ( )
493- : '' ;
488+ let url = new URL ( window . location . href ) ;
489+ if ( url . searchParams . has ( 'year' ) ) {
490+ // @ts -ignore
491+ year = url . searchParams . get ( 'year' ) ;
492+ }
493+
494494 console . log ( 'showing year' , year ) ;
495495 } catch ( e ) {
496496 // console.log('no year');
@@ -585,8 +585,7 @@ export function MapPage(props: MapPageProps) {
585585 let year = '' ;
586586 if ( yrparam ) {
587587 year = yrparam ;
588- }
589- try {
588+ } else {
590589 year =
591590 currentMap . aggregation_period === 'annual' ||
592591 currentMap . aggregation_period === 'test'
@@ -597,8 +596,6 @@ export function MapPage(props: MapPageProps) {
597596 . toString ( )
598597 : '' ;
599598 console . log ( 'showing year' , year ) ;
600- } catch ( e ) {
601- // console.log('no year');
602599 }
603600
604601 setInProgress ( true ) ;
You can’t perform that action at this time.
0 commit comments