Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Remove time URL parameter & change timeline width based on active layers - Changed date save state method to include attributes for time and falls back to date if no time info has been added. - Added thisTime util for comparing time intervals. Works the same as the today function but doesn't reset time to 00:00:00 - Added classes to timeline-header to collapse and expand the timeline based on if there is a subdaily layer - Reworked the timeline CSS to be more flexible - Added CSS clearfix util class and added into .timeline-inner element

ZachTRice7c0b263767dd
diff --git a/web/css/timeline.css b/web/css/timeline.css
index 74c9b4333..ec5de945c 100644
--- a/web/css/timeline.css
+++ b/web/css/timeline.css
@@ -5,12 +5,20 @@
#timeline {
position: absolute;
bottom: 10px;
- left: 10px;
- right: 10px;
+ left: 0;
+ right: 0;
+ width: 100%;
+ background: transparent;
+ min-width: 286px;
+}
+
+.timeline-inner {
+ position: relative;
border: 1px solid #333;
background: rgba(40, 40, 40, 0.9);
- min-width: 286px;
border-radius: 5px;
+ margin-left: 10px;
+ margin-right: 10px;
}
#timeline-footer text {
@@ -125,6 +133,10 @@ g.plot rect.data-bar-invisible {
#timeline-header {
margin-top: 2px;
+ width: 296px;
+}
+
+#timeline-header.subdaily {
width: 402px;
}
@@ -294,7 +306,6 @@ g.plot rect.data-bar-invisible {
#timeline-footer,
#timeline-header,
-#timeline-hide,
#timeline-zoom {
float: left;
}
@@ -411,11 +422,15 @@ g.plot rect.data-bar-invisible {
}
#timeline-hide {
+ position: absolute;
+ top: 0;
+ right: 0;
height: 65px;
width: 20px;
cursor: pointer;
- float: right;
border-left: 1px solid #1a1a1a;
+ border-top-right-radius: 5px;
+ border-bottom-right-radius: 5px;
}
#timeline-hide:hover {
diff --git a/web/css/util.css b/web/css/util.css
index ad3cb0727..86eb4b4ca 100644
--- a/web/css/util.css
+++ b/web/css/util.css
@@ -192,3 +192,10 @@ button[data-tooltip] {
[data-tooltip-length="fit"]::after {
width: 100%;
}
+
+/* Clearfix classes */
+.clearfix::after {
+ content: "";
+ display: table;
+ clear: both;
+}
diff --git a/web/index.html b/web/index.html
index 79e573c70..db1fbc880 100644
--- a/web/index.html
+++ b/web/index.html
@@ -69,113 +69,115 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
<div id="timewheels" style="display:none"></div>
<section id="timeline" style="display: none">
- <div id="timeline-header">
- <div id="focus-guard-1" class="focus-guard" tabindex="1"></div>
- <div id="input-wrapper-year" class="input-wrapper">
- <div class="date-arrows date-arrow-up" data-interval="year" data-value="1">
- <svg width="25" height="8">
- <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>
- </svg>
- </div>
- <input type="text" size="4" maxlength="4" class="button-input-group" id="year-input-group" tabindex="2" />
- <div class="date-arrows date-arrow-down" data-interval="year" data-value="-1">
- <svg width="25" height="8">
- <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>
- </svg>
+ <div class="timeline-inner clearfix">
+ <div id="timeline-header">
+ <div id="focus-guard-1" class="focus-guard" tabindex="1"></div>
+ <div id="input-wrapper-year" class="input-wrapper">
+ <div class="date-arrows date-arrow-up" data-interval="year" data-value="1">
+ <svg width="25" height="8">
+ <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>
+ </svg>
+ </div>
+ <input type="text" size="4" maxlength="4" class="button-input-group" id="year-input-group" tabindex="2" />
+ <div class="date-arrows date-arrow-down" data-interval="year" data-value="-1">
+ <svg width="25" height="8">
+ <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>
+ </svg>
+ </div>
</div>
- </div>
- <div id="input-wrapper-month" class="input-wrapper">
- <div class="date-arrows date-arrow-up" data-interval="month" data-value="1">
- <svg width="25" height="8">
- <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>
- </svg>
- </div>
- <input type="text" size="3" maxlength="3" class="button-input-group" id="month-input-group" tabindex="3" />
- <div class="date-arrows date-arrow-down" data-interval="month" data-value="-1">
- <svg width="25" height="8">
- <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>
- </svg>
+ <div id="input-wrapper-month" class="input-wrapper">
+ <div class="date-arrows date-arrow-up" data-interval="month" data-value="1">
+ <svg width="25" height="8">
+ <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>
+ </svg>
+ </div>
+ <input type="text" size="3" maxlength="3" class="button-input-group" id="month-input-group" tabindex="3" />
+ <div class="date-arrows date-arrow-down" data-interval="month" data-value="-1">
+ <svg width="25" height="8">
+ <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>
+ </svg>
+ </div>
</div>
- </div>
- <div id="input-wrapper-day" class="input-wrapper">
- <div class="date-arrows date-arrow-up" data-interval="day" data-value="1">
- <svg width="25" height="8">
- <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>
- </svg>
- </div>
- <input type="text" size="2" maxlength="2" class="button-input-group" id="day-input-group" tabindex="4" onkeypress="return (event.charCode >= 48 && event.charCode <= 57) || event.keyCode == 13 || event.keyCode == 9 || even.keyCode == 8" />
- <div class="date-arrows date-arrow-down" data-interval="day" data-value="-1">
- <svg width="25" height="8">
- <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>
- </svg>
+ <div id="input-wrapper-day" class="input-wrapper">
+ <div class="date-arrows date-arrow-up" data-interval="day" data-value="1">
+ <svg width="25" height="8">
+ <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>
+ </svg>
+ </div>
+ <input type="text" size="2" maxlength="2" class="button-input-group" id="day-input-group" tabindex="4" onkeypress="return (event.charCode >= 48 && event.charCode <= 57) || event.keyCode == 13 || event.keyCode == 9 || even.keyCode == 8" />
+ <div class="date-arrows date-arrow-down" data-interval="day" data-value="-1">
+ <svg width="25" height="8">
+ <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>
+ </svg>
+ </div>
</div>
- </div>
- <div id="input-wrapper-hour" class="input-wrapper">
- <div class="date-arrows date-arrow-up" data-interval="hour" data-value="1">
- <svg width="25" height="8">
- <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>
- </svg>
- </div>
- <input type="text" size="2" maxlength="2" class="button-input-group" id="hour-input-group" tabindex="5" />
- <div class="date-arrows date-arrow-down" data-interval="hour" data-value="-1">
- <svg width="25" height="8">
- <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>
- </svg>
+ <div id="input-wrapper-hour" class="input-wrapper">
+ <div class="date-arrows date-arrow-up" data-interval="hour" data-value="1">
+ <svg width="25" height="8">
+ <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>
+ </svg>
+ </div>
+ <input type="text" size="2" maxlength="2" class="button-input-group" id="hour-input-group" tabindex="5" />
+ <div class="date-arrows date-arrow-down" data-interval="hour" data-value="-1">
+ <svg width="25" height="8">
+ <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>
+ </svg>
+ </div>
</div>
- </div>
- <div id="input-wrapper-minute" class="input-wrapper">
- <div class="date-arrows date-arrow-up" data-interval="minute" data-value="1">
- <svg width="25" height="8">
- <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>
- </svg>
- </div>
- <input type="text" size="2" maxlength="2" class="button-input-group" id="minute-input-group" tabindex="6" />
- <div class="date-arrows date-arrow-down" data-interval="minute" data-value="-1">
- <svg width="25" height="8">
- <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>
- </svg>
- </div>
- </div>
- <div id="focus-guard-2" class="focus-guard" tabindex="5"></div>
- <div id="time-buttons-group" class="">
- <div id="timeline-zoom">
- <a class="zoom-btn" id="zoom-minutes">Minutes</a>
- <a class="zoom-btn" id="zoom-days">Days</a>
- <a class="zoom-btn" id="zoom-months">Months</a>
- <a class="zoom-btn" id="zoom-years">Years</a>
- </div>
- <div class="button-action-group" id="left-arrow-group" title="Click and hold to animate backwards">
- <svg width="24" height="30">
- <path
- d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z"
- class="arrow"></path>
+ <div id="input-wrapper-minute" class="input-wrapper">
+ <div class="date-arrows date-arrow-up" data-interval="minute" data-value="1">
+ <svg width="25" height="8">
+ <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>
</svg>
- </div>
- <div class="button-action-group" id="right-arrow-group" title="Click and hold to animate forwards">
- <svg width="24" height="30" >
- <path
- d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z"
- class="arrow"></path>
+ </div>
+ <input type="text" size="2" maxlength="2" class="button-input-group" id="minute-input-group" tabindex="6" />
+ <div class="date-arrows date-arrow-down" data-interval="minute" data-value="-1">
+ <svg width="25" height="8">
+ <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>
</svg>
+ </div>
+ </div>
+ <div id="focus-guard-2" class="focus-guard" tabindex="5"></div>
+ <div id="time-buttons-group" class="">
+ <div id="timeline-zoom">
+ <a class="zoom-btn" id="zoom-minutes">Minutes</a>
+ <a class="zoom-btn" id="zoom-days">Days</a>
+ <a class="zoom-btn" id="zoom-months">Months</a>
+ <a class="zoom-btn" id="zoom-years">Years</a>
+ </div>
+ <div class="button-action-group" id="left-arrow-group" title="Click and hold to animate backwards">
+ <svg width="24" height="30">
+ <path
+ d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z"
+ class="arrow"></path>
+ </svg>
+ </div>
+ <div class="button-action-group" id="right-arrow-group" title="Click and hold to animate forwards">
+ <svg width="24" height="30" >
+ <path
+ d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z"
+ class="arrow"></path>
+ </svg>
+ </div>
</div>
- </div>
- <div class="button-action-group animate-button" id="animate-button" title="Set up animation">
- <i id="wv-animate" class="fa fa-video-camera wv-animate"></i>
- </div>
-
- </div>
- <div id="timeline-footer">
- <div id="wv-animation-widet-case"> </div>
- </div>
- <div id="timeline-hide">
- <svg class="hamburger" width="10" height="9">
- <path d="M 0,0 0,1 10,1 10,0 0,0 z M 0,4 0,5 10,5 10,4 0,4 z M 0,8 0,9 10,9 10,8 0,8 z"></path>
- </svg>
- </div>
+ <div class="button-action-group animate-button" id="animate-button" title="Set up animation">
+ <i id="wv-animate" class="fa fa-video-camera wv-animate"></i>
+ </div>
+
+ </div>
+ <div id="timeline-footer">
+ <div id="wv-animation-widet-case"> </div>
+ </div>
+ <div id="timeline-hide">
+ <svg class="hamburger" width="10" height="9">
+ <path d="M 0,0 0,1 10,1 10,0 0,0 z M 0,4 0,5 10,5 10,4 0,4 z M 0,8 0,9 10,9 10,8 0,8 z"></path>
+ </svg>
+ </div>
+ </div>
</section>
</div>
diff --git a/web/js/date/config.js b/web/js/date/config.js
index ad0fd41f0..235d608dd 100644
--- a/web/js/date/config.js
+++ b/web/js/date/config.js
@@ -32,49 +32,24 @@ export function timelineConfig(models, config, ui) {
var paddedRange;
var activeLayers = models.layers.active;
- var yearlyFound = false;
- var monthlyFound = false;
- var dailyFound = false;
var subdailyFound = false;
for (var i = 0; i < activeLayers.length; i++) {
switch (activeLayers[i].period) {
- case 'yearly':
- yearlyFound = true;
- break;
- case 'monthly':
- monthlyFound = true;
- break;
- case 'daily':
- dailyFound = true;
- break;
case 'subdaily':
subdailyFound = true;
break;
}
}
- // if (!yearlyFound) {
- // document.getElementById('zoom-years').style.display = 'none';
- // self.currentZoom = 3;
- // }
- //
- // if (!monthlyFound) {
- // document.getElementById('zoom-months').style.display = 'none';
- // self.currentZoom = 3;
- // }
- //
- // if (!dailyFound) {
- // document.getElementById('zoom-days').style.display = 'none';
- // self.currentZoom = 3;
- // }
-
if (!subdailyFound) {
document.getElementById('zoom-minutes').style.display = 'none';
document.getElementById('input-wrapper-hour').style.display = 'none';
document.getElementById('input-wrapper-minute').style.display = 'none';
- document.getElementById('timeline-header').style.width = '296px';
+ document.getElementById('timeline-header').classList.remove('subdaily');
self.currentZoom = 3;
+ } else {
+ document.getElementById('timeline-header').classList.add('subdaily');
}
switch (level) {
diff --git a/web/js/date/model.js b/web/js/date/model.js
index 63fbcd55f..7f5a48971 100644
--- a/web/js/date/model.js
+++ b/web/js/date/model.js
@@ -73,9 +73,8 @@ export function dateModel(config, spec) {
self.save = function (state) {
state.t = self.selected.toISOString()
- .split('T')[0];
- state.t2 = self.selected.toISOString()
- .split('T')[1].slice(0, -5).replace(/:/g, '-');
+ .split('T')[0] + '-' + self.selected.toISOString()
+ .split('T')[1].slice(0, -5).replace(/:/g, '-');
if (self.selectedZoom) {
state.z = self.selectedZoom.toString();
}
@@ -85,10 +84,6 @@ export function dateModel(config, spec) {
if (state.t) {
self.select(state.t);
}
- // If there is a time, load using the corresponding date state
- if (state.t && state.t2) {
- self.select(state.t);
- }
if (state.z) {
self.selectedZoom = Number(state.z);
}
diff --git a/web/js/date/timeline-input.js b/web/js/date/timeline-input.js
index 381de94c7..8cf141872 100644
--- a/web/js/date/timeline-input.js
+++ b/web/js/date/timeline-input.js
@@ -24,8 +24,8 @@ export function timelineInput(models, config, ui) {
var forwardNextMinute = function () { // FIXME: Limit animation correctly
var nextMinute = new Date(new Date(model.selected)
- .setUTCDate(model.selected.getUTCMinutes() + 10));
- if (nextMinute <= util.today()) {
+ .setUTCMinutes(model.selected.getUTCMinutes() + 10));
+ if (nextMinute <= util.thisTime()) {
animateForward('minute');
} else {
self.stop();
@@ -112,8 +112,8 @@ export function timelineInput(models, config, ui) {
var reversePrevMinute = function () {
var prevMinute = new Date(new Date(model.selected)
- .setUTCDate(model.selected.getUTCMinutes() - 10));
- if (prevMinute >= tl.data.start()) {
+ .setUTCMinutes(model.selected.getUTCMinutes() - 10));
+ if (prevMinute >= tl.data.thisTime()) {
animateReverse('minute');
} else {
self.stop();
@@ -390,6 +390,7 @@ export function timelineInput(models, config, ui) {
$incrementBtn
.mousedown(function (e) {
e.preventDefault();
+ console.log(ui.timeline.config.currentZoom);
switch (ui.timeline.config.currentZoom) {
case 1:
forwardNextYear();
diff --git a/web/js/date/timeline-ticks.js b/web/js/date/timeline-ticks.js
index f5935ab93..b4e6dd1ac 100644
--- a/web/js/date/timeline-ticks.js
+++ b/web/js/date/timeline-ticks.js
@@ -86,8 +86,8 @@ export function timelineTicks(models, config, ui) {
if (!$(this)
.find('line.tick-week')
.length) {
- var currentTick = d3.select(this);
- var currentTickData = currentTick.data()[0];
+ let currentTick = d3.select(this);
+ let currentTickData = currentTick.data()[0];
if ((currentTickData.getUTCDay() === 0) &&
(currentTickData.getUTCDate() !== 1)) {
currentTick
@@ -98,6 +98,22 @@ export function timelineTicks(models, config, ui) {
.classed('tick-week', true);
}
}
+ } else if (tl.config.currentZoom === 4) {
+ if (!$(this)
+ .find('line.tick-week')
+ .length) {
+ let currentTick = d3.select(this);
+ let currentTickData = currentTick.data()[0];
+ if ((currentTickData.getUTCMinutes() === 0) &&
+ (currentTickData.getUTCMinutes() !== 1)) {
+ currentTick
+ .insert('line', 'rect')
+ .attr('y1', 0)
+ .attr('y2', -10)
+ .attr('x2', 0)
+ .classed('tick-week', true);
+ }
+ }
}
});
diff --git a/web/js/date/timeline.js b/web/js/date/timeline.js
index 0d31e7eab..2b01fbc33 100644
--- a/web/js/date/timeline.js
+++ b/web/js/date/timeline.js
@@ -27,7 +27,7 @@ export function timeline(models, config, ui) {
.outerWidth(true) -
$('#timeline-hide')
.outerWidth(true) -
- self.margin.left - self.margin.right - 2;
+ self.margin.left - self.margin.right - 22;
return self.width;
};
@@ -41,8 +41,6 @@ export function timeline(models, config, ui) {
var gp = d3.select('#guitarpick');
if (tl.is(':hidden')) {
var afterShow = function () {
- $('#timeline')
- .css('right', '10px');
tlg.attr('style', 'clip-path:url("#timeline-boundary")');
gp.attr('style', 'display:block;clip-path:url(#guitarpick-boundary);');
};
@@ -52,12 +50,14 @@ export function timeline(models, config, ui) {
} else {
tl.show('slow', afterShow);
}
+ $('#timeline')
+ .css('right', '10px').css('width', '100%');
} else {
tlg.attr('style', 'clip-path:none');
gp.attr('style', 'display:none;clip-path:none');
tl.hide('slow');
$('#timeline')
- .css('right', 'auto');
+ .css('right', 'auto').css('width', 'auto');
}
};
@@ -128,6 +128,21 @@ export function timeline(models, config, ui) {
};
var drawContainers = function () {
+ var activeLayers = models.layers.active;
+ var subdailyFound = false;
+
+ for (var i = 0; i < activeLayers.length; i++) {
+ switch (activeLayers[i].period) {
+ case 'subdaily':
+ subdailyFound = true;
+ break;
+ }
+ }
+ if (!subdailyFound) {
+ document.getElementById('timeline-header').classList.remove('subdaily');
+ } else {
+ document.getElementById('timeline-header').classList.add('subdaily');
+ }
self.getWidth();
self.svg = d3.select('#timeline-footer')
diff --git a/web/js/layers/active.js b/web/js/layers/active.js
index 5b3ae6e4e..b11abe792 100644
--- a/web/js/layers/active.js
+++ b/web/js/layers/active.js
@@ -11,6 +11,7 @@ import lodashEach from 'lodash/each';
import lodashEachRight from 'lodash/eachRight';
import util from '../util/util';
import wvui from '../ui/ui';
+import { timeline } from '../date/timeline';
import { layersInfo } from './info';
import { layersOptions } from './options';
import { palettesLegend } from '../palettes/legend';
@@ -392,6 +393,7 @@ export function layersActive(models, ui, config) {
if (legends[layer.id]) {
delete legends[layer.id];
}
+ toggleSubdailyZoom();
sizeProductsTab();
};
@@ -402,9 +404,39 @@ export function layersActive(models, ui, config) {
if (layer.palette) {
renderLegendCanvas(layer);
}
+ toggleSubdailyZoom();
+ model.events.trigger('timeline-change');
sizeProductsTab();
};
+ var toggleSubdailyZoom = function () {
+ var activeLayers = models.layers.active;
+ var subdailyFound = false;
+
+ for (var i = 0; i < activeLayers.length; i++) {
+ switch (activeLayers[i].period) {
+ case 'subdaily':
+ subdailyFound = true;
+ break;
+ }
+ }
+
+ if (!subdailyFound) {
+ document.getElementById('zoom-minutes').style.display = 'none';
+ document.getElementById('input-wrapper-hour').style.display = 'none';
+ document.getElementById('input-wrapper-minute').style.display = 'none';
+ document.getElementById('timeline-header').classList.remove('subdaily');
+ document.getElementById('zoom-days').click(); // Switch back to 'Days' view
+ models.date.events.trigger('resize');
+ } else {
+ document.getElementById('zoom-minutes').style.display = null;
+ document.getElementById('input-wrapper-hour').style.display = null;
+ document.getElementById('input-wrapper-minute').style.display = null;
+ document.getElementById('timeline-header').classList.add('subdaily');
+ models.date.events.trigger('resize');
+ }
+ };
+
var toggleVisibility = function () {
if ($(this)
.parent()
@@ -533,7 +565,7 @@ export function layersActive(models, ui, config) {
// Account for offset between the map's top zoom level and the
// lowest-resolution TileMatrix in polar layers
- var zoomOffset = ((proj == 'arctic') || (proj == 'antarctic')) ? 1 : 0;
+ var zoomOffset = ((proj === 'arctic') || (proj === 'antarctic')) ? 1 : 0;
var matrixSet = layer.projections[proj].matrixSet;
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 06dbe111f..5157d9332 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -580,6 +580,10 @@ export default (function (self) {
return self.clearTimeUTC(self.now());
};
+ self.thisTime = function () {
+ return self.now();
+ };
+
/**
* General error handler.
*