Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add setQueueLength method, improve subdaily toggle function and styles - Move set queueLength by animation speed to separate setQueueLength method - Improve subdailyToggle function to only toggle parent element class - Add classes to timeline input and change CSS to target classes - Change animation/ui to use ES6 double arrow functions

ZachTRiced9a97903a1d7
diff --git a/web/css/timeline.css b/web/css/timeline.css
index d223ec672..e30841cae 100644
--- a/web/css/timeline.css
+++ b/web/css/timeline.css
@@ -139,6 +139,22 @@ g.plot rect.data-bar-invisible {
width: 396px;
}
+#timeline-header .timeline-zoom,
+#timeline-header .input-wrapper-hour,
+#timeline-header .input-time-divider,
+#timeline-header .input-wrapper-minute,
+#timeline-header .input-time-zmark {
+ display: none;
+}
+
+#timeline-header.subdaily .timeline-zoom,
+#timeline-header.subdaily .input-wrapper-hour,
+#timeline-header.subdaily .input-time-divider,
+#timeline-header.subdaily .input-wrapper-minute,
+#timeline-header.subdaily .input-time-zmark {
+ display: inline-block;
+}
+
#timeline-header .input-wrapper {
background: transparent;
border: 1px solid transparent;
@@ -159,12 +175,12 @@ g.plot rect.data-bar-invisible {
max-width: 31px;
}
-#timeline-header #input-wrapper-hour,
-#timeline-header #input-wrapper-minute {
+#timeline-header .input-wrapper-hour,
+#timeline-header .input-wrapper-minute {
width: 31px;
}
-#timeline-header #input-wrapper-hour {
+#timeline-header .input-wrapper-hour {
margin-left: 8px;
}
@@ -208,7 +224,7 @@ g.plot rect.data-bar-invisible {
display: inline-block;
}
-#timeline-header #input-time-divider {
+#timeline-header .input-time-divider {
font-family: 'Roboto Mono', monospace;
color: #fff;
font-size: 24px;
@@ -218,7 +234,7 @@ g.plot rect.data-bar-invisible {
margin-left: -9px;
}
-#timeline-header #input-time-zmark {
+#timeline-header .input-time-zmark {
font-family: 'Roboto Mono', monospace;
color: #fff;
font-size: 24px;
@@ -394,7 +410,7 @@ g.plot rect.data-bar-invisible {
stroke: #4682b4;
}
-#timeline-header #timeline-zoom {
+#timeline-header .timeline-zoom {
display: block;
width: 80px;
margin-left: auto;
@@ -447,7 +463,7 @@ g.plot rect.data-bar-invisible {
color: #1a1a1a;
}
-#timeline-zoom .zoom-btn {
+.timeline-zoom .zoom-btn {
display: block;
clear: both;
cursor: pointer;
@@ -460,7 +476,7 @@ g.plot rect.data-bar-invisible {
padding: 2px 0;
}
-#timeline-zoom .zoom-btn:hover {
+.timeline-zoom .zoom-btn:hover {
background-color: #fff;
color: #1a1a1a;
}
diff --git a/web/index.html b/web/index.html
index 73bc9cbc6..6f156bfbe 100644
--- a/web/index.html
+++ b/web/index.html
@@ -71,7 +71,7 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
<section id="timeline" class="timeline-inner clearfix" 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 selectable">
+ <div id="input-wrapper-year" class="input-wrapper input-wrapper-year selectable">
<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>
@@ -84,7 +84,7 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
</svg>
</div>
</div>
- <div id="input-wrapper-month" class="input-wrapper selectable">
+ <div id="input-wrapper-month" class="input-wrapper input-wrapper-month selectable">
<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>
@@ -98,7 +98,7 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
</div>
</div>
- <div id="input-wrapper-day" class="input-wrapper selectable">
+ <div id="input-wrapper-day" class="input-wrapper input-wrapper-day selectable">
<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>
@@ -112,7 +112,7 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
</div>
</div>
- <div id="input-wrapper-hour" class="input-wrapper">
+ <div id="input-wrapper-hour" class="input-wrapper input-wrapper-hour">
<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>
@@ -126,9 +126,9 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
</div>
</div>
- <div id="input-time-divider">:</div>
+ <div id="input-time-divider" class="input-time-divider">:</div>
- <div id="input-wrapper-minute" class="input-wrapper">
+ <div id="input-wrapper-minute" class="input-wrapper input-wrapper-minute">
<div class="date-arrows date-arrow-up" data-interval="minute" data-value="10">
<svg width="25" height="8">
<path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>
@@ -141,13 +141,13 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
</svg>
</div>
</div>
- <div id="input-time-zmark">Z</div>
+ <div id="input-time-zmark" class="input-time-zmark">Z</div>
<div id="focus-guard-2" class="focus-guard" tabindex="7"></div>
<div id="zoom-buttons-group">
<div id="zoom-btn-container">
<span id="current-zoom" class="zoom-btn zoom-btn-active" data-zoom="3">Days</span>
<div class="wv-tooltip">
- <div id="timeline-zoom">
+ <div id="timeline-zoom" class="timeline-zoom">
<span id="zoom-years" class="zoom-btn zoom-btn-inactive" data-zoom="1">Years</span>
<span id="zoom-months" class="zoom-btn zoom-btn-inactive" data-zoom="2">Months</span>
<span id="zoom-days" class="zoom-btn zoom-btn-inactive" data-zoom="3">Days</span>
diff --git a/web/js/animation/ui.js b/web/js/animation/ui.js
index 15d3e65c4..6b95463a8 100644
--- a/web/js/animation/ui.js
+++ b/web/js/animation/ui.js
@@ -26,7 +26,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.init = function () {
+ self.init = () => {
self.refreshState();
animModel.events.on('play', self.onPushedPlay);
animModel.events.on('gif-click', self.refreshState);
@@ -60,7 +60,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.dateChange = function () {
+ self.dateChange = () => {
if (!self.state.playing) {
self.refreshState();
}
@@ -77,7 +77,7 @@ export function animationUi(models, ui) {
*
*/
- self.refreshState = function () {
+ self.refreshState = () => {
preloadArray = [];
preload = {};
pastDates = {};
@@ -105,7 +105,7 @@ export function animationUi(models, ui) {
* @returns {string} ISO string Date
*
*/
- self.getStartDate = function () {
+ self.getStartDate = () => {
var state;
var endDate;
var startDate;
@@ -129,7 +129,21 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.onPushedPlay = function () {
+
+ self.onPushedPlay = () => {
+ queueLength = self.setQueueLength();
+ self.checkQueue(queueLength, self.state.playIndex);
+ self.checkShouldPlay();
+ };
+
+ /**
+ * Returns the queueLength based on the play speed selected
+ * @method setQueueLength
+ * @static
+ *
+ * @return {number} The queueLength amount
+ */
+ self.setQueueLength = () => {
var speed = animModel.rangeState.speed;
switch (true) {
case (speed > 8 && speed <= 10):
@@ -148,8 +162,7 @@ export function animationUi(models, ui) {
queueLength = 10;
break;
}
- self.checkQueue(queueLength, self.state.playIndex);
- self.checkShouldPlay();
+ return queueLength;
};
/*
@@ -161,7 +174,7 @@ export function animationUi(models, ui) {
* @returns {string} Zoom increment
*
*/
- self.getInterval = function () {
+ self.getInterval = () => {
return zooms[ui.timeline.config.currentZoom - 1];
};
@@ -177,7 +190,7 @@ export function animationUi(models, ui) {
* @returns {object} JS Date
*
*/
- self.nextDate = function (date) {
+ self.nextDate = (date) => {
if (models.date.selectedZoom === 4) {
return util.dateAdd(date, self.getInterval(), 10);
} else {
@@ -197,7 +210,7 @@ export function animationUi(models, ui) {
* @returns {object} JS Date
*
*/
- self.addDate = function (date) {
+ self.addDate = (date) => {
self.addToInQueue(date);
queue.add(function () {
if (animModel.rangeState.state === 'on' && animModel.rangeState.playing) {
@@ -229,7 +242,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.addToInQueue = function (date) {
+ self.addToInQueue = (date) => {
var strDate = util.toISOStringSeconds(date);
inQueue[strDate] = date;
preloadArray.push(strDate);
@@ -248,7 +261,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.addDateToCache = function (date) {
+ self.addDateToCache = (date) => {
var strDate = util.toISOStringSeconds(date);
preload[strDate] = date;
delete inQueue[strDate];
@@ -265,7 +278,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.shiftCache = function () {
+ self.shiftCache = () => {
var key;
if (preload[preloadArray[0]] &&
util.objectLength(preload) > queueLength + (queueLength / 2) + 1 &&
@@ -291,7 +304,7 @@ export function animationUi(models, ui) {
* @returns {boolean}
*
*/
- self.isInToPlayGroup = function (testDate) {
+ self.isInToPlayGroup = (testDate) => {
var loop = animModel.rangeState.loop;
var i = 0;
var day = new Date(self.state.playIndex);
@@ -325,7 +338,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.clearCache = function () {
+ self.clearCache = () => {
preload = {};
preloadArray = [];
};
@@ -342,7 +355,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.checkQueue = function (bufferLength, index) {
+ self.checkQueue = (bufferLength, index) => {
var currentDate;
var startDate = util.parseDateUTC(animModel.rangeState.startDate);
var endDate = util.parseDateUTC(animModel.rangeState.endDate);
@@ -372,7 +385,7 @@ export function animationUi(models, ui) {
* @returns {boolean}
*
*/
- self.hasCustomLayers = function () {
+ self.hasCustomLayers = () => {
var layer;
var layers = models.layers.get();
@@ -399,7 +412,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.customQueuer = function (currentDate, startDate, endDate) {
+ self.customQueuer = (currentDate, startDate, endDate) => {
var nextDateStr;
var nextDate = self.nextDate(currentDate);
if (nextDate > endDate) {
@@ -428,7 +441,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.initialPreload = function (currentDate, startDate, endDate, lastToQueue) {
+ self.initialPreload = (currentDate, startDate, endDate, lastToQueue) => {
var day = currentDate;
queueLength = self.getQueueLength(startDate, endDate);
if (queueLength <= 1) { // if only one frame will play just move to that date
@@ -469,7 +482,7 @@ export function animationUi(models, ui) {
* @returns {number} new buffer length
*
*/
- self.getQueueLength = function (startDate, endDate) {
+ self.getQueueLength = (startDate, endDate) => {
var day = startDate;
var i = 0;
while (i < queueLength) {
@@ -495,7 +508,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.addItemToQueue = function (currentDate, startDate, endDate) {
+ self.addItemToQueue = (currentDate, startDate, endDate) => {
var nextDate = self.getNextBufferDate(currentDate, startDate, endDate);
var nextDateStr = util.toISOStringSeconds(nextDate);
@@ -522,7 +535,7 @@ export function animationUi(models, ui) {
* @returns {object} JS Date
*
*/
- self.getNextBufferDate = function (currentDate, startDate, endDate) {
+ self.getNextBufferDate = (currentDate, startDate, endDate) => {
var lastInBuffer = util.parseDateUTC(preloadArray[preloadArray.length - 1]);
var nextDate = self.nextDate(lastInBuffer);
if (lastInBuffer >= endDate || self.nextDate(lastInBuffer) > endDate) {
@@ -545,7 +558,7 @@ export function animationUi(models, ui) {
* @returns {string} Date string
*
*/
- self.getLastBufferDateStr = function (currentDate, startDate, endDate) {
+ self.getLastBufferDateStr = (currentDate, startDate, endDate) => {
var day = currentDate;
var loop = animModel.rangeState.loop;
var i = 1;
@@ -577,7 +590,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.checkShouldLoop = function (playIndexJSDate) {
+ self.checkShouldLoop = (playIndexJSDate) => {
if (animModel.rangeState.loop) {
self.shiftCache();
self.state.playIndex = util.toISOStringSeconds(self.setNewDate(playIndexJSDate, new Date(animModel.rangeState.startDate)));
@@ -603,7 +616,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.checkShouldPlay = function () {
+ self.checkShouldPlay = () => {
var currentDate = util.parseDateUTC(self.state.playIndex);
var endDate = util.parseDateUTC(animModel.rangeState.endDate);
var startDate = util.parseDateUTC(animModel.rangeState.startDate);
@@ -636,7 +649,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.play = function (index) {
+ self.play = (index) => {
self.state.playing = true;
uiIndicator.hide(loader);
uiIndicator._hide(loader);
@@ -659,7 +672,7 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.setNewDate = function (date, newDate) {
+ self.setNewDate = (date, newDate) => {
return newDate;
};
@@ -674,12 +687,12 @@ export function animationUi(models, ui) {
* @returns {void}
*
*/
- self.animate = function (index) {
+ self.animate = (index) => {
var interval;
var playIndex = index;
var playIndexJSDate;
var endDate = util.parseDateUTC(animModel.rangeState.endDate);
- var player = function () {
+ var player = () => {
self.shiftCache();
self.checkQueue(queueLength, playIndex);
diff --git a/web/js/layers/active.js b/web/js/layers/active.js
index 2db2e8921..bea9d7b12 100644
--- a/web/js/layers/active.js
+++ b/web/js/layers/active.js
@@ -428,27 +428,17 @@ export function layersActive(models, ui, config) {
var toggleSubdaily = function () {
if (subdailyCheck()) {
setMaxZoomlevel(4);
- document.getElementById('zoom-minutes').style.display = null;
- document.getElementById('input-wrapper-hour').style.display = null;
+ document.getElementById('timeline-header').classList.add('subdaily');
document.getElementById('input-wrapper-hour').classList.add('selectable');
- document.getElementById('input-time-divider').style.display = null;
- document.getElementById('input-wrapper-minute').style.display = null;
document.getElementById('input-wrapper-minute').classList.add('selectable');
- document.getElementById('input-time-zmark').style.display = null;
- document.getElementById('timeline-header').classList.add('subdaily');
} else {
setMaxZoomlevel(3);
if (ui.timeline && ui.timeline.config.currentZoom > 3) {
document.getElementById('zoom-days').click();
}
- document.getElementById('zoom-minutes').style.display = 'none';
- document.getElementById('input-wrapper-hour').style.display = 'none';
+ document.getElementById('timeline-header').classList.remove('subdaily');
document.getElementById('input-wrapper-hour').classList.remove('selectable');
- document.getElementById('input-time-divider').style.display = 'none';
- document.getElementById('input-wrapper-minute').style.display = 'none';
document.getElementById('input-wrapper-minute').classList.remove('selectable');
- document.getElementById('input-time-zmark').style.display = 'none';
- document.getElementById('timeline-header').classList.remove('subdaily');
}
models.date.events.trigger('update-timewheel');
};