File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 27
27
}
28
28
}
29
29
30
+ const urlParams = new URLSearchParams (window .location .search );
31
+
32
+ // Overwrite default source & sensor if these are present in the URL
33
+ if (urlParams .has (' source' )) {
34
+ sourceValue = urlParams .get (' source' );
35
+
36
+ if (urlParams .has (' sensor' )) {
37
+ sensorValue = urlParams .get (' sensor' );
38
+ }
39
+ }
40
+
30
41
$: isWeekly = sensor ? sensor .isWeeklySignal : false ;
31
42
$: formatDate = isWeekly ? (d ) => formatWeek (d).replace (' W' , ' ' ) : formatDateISO;
32
43
33
- let geoType = ' county' ;
44
+ let geoType = urlParams . has ( ' geo ' ) ? urlParams . get ( ' geo ' ) : ' county' ;
34
45
35
46
let startDate = new Date ();
36
47
let endDate = new Date ();
37
48
38
49
function initDate (date ) {
39
50
const param = new DateParam (date);
40
- endDate = param .sparkLineTimeFrame .max ;
41
- startDate = param .sparkLineTimeFrame .min ;
51
+
52
+ // Populate date based on URL params or, if absent, the current date
53
+ startDate = urlParams .has (' start' ) ? new Date (urlParams .get (' start' )) : param .sparkLineTimeFrame .min ;
54
+ endDate = urlParams .has (' end' ) ? new Date (urlParams .get (' end' )) : param .sparkLineTimeFrame .max ;
42
55
}
43
56
$: initDate ($currentDateObject);
44
57
You can’t perform that action at this time.
0 commit comments