Links start and end dates of timeSeriesMenu
[wrfxweb.git] / fdds / js / simVars.js
blob98cf0d2d8bba297316ae277a20314e5cd9e5c656
1 export const simVars = (function createSimVars() {
2 const urlParams = new URLSearchParams(window.location.search);
4 let presetVars = ({
5 zoom: urlParams.get('zoom'),
6 pan: urlParams.get('pan'),
7 jobId: urlParams.get('job_id'),
8 domain: urlParams.get('domain'),
9 timestamp: urlParams.get('timestamp'),
10 rasters: null,
11 startDate: urlParams.get('startDate'),
12 endDate: urlParams.get('endDate'),
13 opacity: urlParams.get('opacity'),
14 });
16 let pan = urlParams.get('pan');
17 if (pan) {
18 pan = pan.split(',').map(coord => Number(coord));
19 presetVars.pan = pan;
22 let rasters = urlParams.get('rasters');
23 if (rasters) {
24 rasters = rasters.split(',');
25 presetVars.rasters = rasters;
28 let simVars = ({
29 currentSimulation: '',
30 currentDescription: '',
31 rasters: [],
32 rasterBase: '',
33 sortedTimestamps: [],
34 showColorbar: () => {
35 const rasterColorbarContainer = document.querySelector('#raster-colorbar-bg');
36 rasterColorbarContainer.classList.remove('hidden');
38 hideColorbar: () => {
39 const rasterColorbarContainer = document.querySelector('#raster-colorbar-bg');
40 rasterColorbarContainer.classList.add('hidden');
42 setColorbarURL: (url) => {
43 const rasterColorbar = document.querySelector('#raster-colorbar');
44 rasterColorbar.src = url;
46 noLevels: (function makeNoLevels() {
47 const noLevels = new Set();
48 const makeKey = (layerName, domain, timestamp) => {
49 return layerName + ',' + domain + ',' + timestamp;
51 const addNoLevels = (layerName, domain, timestamp) => {
52 let key = makeKey(layerName, domain, timestamp);
53 noLevels.add(key);
55 const hasNoLevels = (layerName, domain, timestamp) => {
56 let key = makeKey(layerName, domain, timestamp);
57 return noLevels.has(key);
60 return ({
61 add: addNoLevels,
62 has: hasNoLevels,
63 clear: () => noLevels.clear()
64 });
65 })(),
66 overlayOrder: [],
67 startTime: null,
68 endTime: null,
69 displayedColorbar: null,
70 organization: 'WIRC',
71 overlayList: ['WINDVEC', 'WINDVEC1000FT', 'WINDVEC4000FT', 'WINDVEC6000FT', 'SMOKE1000FT', 'SMOKE4000FT', 'SMOKE6000FT', 'FIRE_AREA', 'SMOKE_INT', 'FGRNHFX', 'FLINEINT'],
72 baseLayerDict: {
74 'MapQuest': L.tileLayer('http://{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
75 attribution: 'Data and imagery by MapQuest',
76 subdomains: ['otile1', 'otile2', 'otile3', 'otile4']}),
78 'MapQuest' : MQ.mapLayer(),
79 /* 'MQ Satellite': L.tileLayer('http://{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.png', {
80 attribution: 'Data and imagery by MapQuest',
81 subdomains: ['otile1', 'otile2', 'otile3', 'otile4']}),*/
82 'OSM': L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
83 attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'})
85 presets: presetVars,
86 clientWidth: document.body.clientWidth,
87 generateTimeSeriesCallback: () => {},
88 cancelTimeSeriesCallback: () => {},
89 });
91 return simVars;
92 })();