Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add 10 minute step to forward and prev buttons. Save time to URL - Added method to move minutes forward and backwards 10 minutes with left/right arrows - Added `t2` variable to the URL via the date.model.save method

ZachTRice6f762982427f
diff --git a/web/index.html b/web/index.html
index 390764db6..79e573c70 100644
--- a/web/index.html
+++ b/web/index.html
@@ -72,69 +72,73 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
<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>
+ <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 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 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>
+ <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 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 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>
+ <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 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 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>
+ <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 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 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="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 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="">
diff --git a/web/js/date/model.js b/web/js/date/model.js
index 5b35188cf..0f98a7764 100644
--- a/web/js/date/model.js
+++ b/web/js/date/model.js
@@ -20,7 +20,7 @@ export function dateModel(config, spec) {
};
self.select = function (date) {
- date = self.clamp(util.clearTimeUTC(date));
+ date = self.clamp(date);
var updated = false;
if (!self.selected || date.getTime() !== self.selected.getTime()) {
self.selected = date;
@@ -74,6 +74,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, '-');
if (self.selectedZoom) {
state.z = self.selectedZoom.toString();
}
diff --git a/web/js/date/timeline-input.js b/web/js/date/timeline-input.js
index 48693f950..381de94c7 100644
--- a/web/js/date/timeline-input.js
+++ b/web/js/date/timeline-input.js
@@ -22,6 +22,16 @@ export function timelineInput(models, config, ui) {
var $incrementBtn = $('#right-arrow-group');
var $decrementBtn = $('#left-arrow-group');
+ var forwardNextMinute = function () { // FIXME: Limit animation correctly
+ var nextMinute = new Date(new Date(model.selected)
+ .setUTCDate(model.selected.getUTCMinutes() + 10));
+ if (nextMinute <= util.today()) {
+ animateForward('minute');
+ } else {
+ self.stop();
+ }
+ };
+
var forwardNextDay = function () { // FIXME: Limit animation correctly
var nextDay = new Date(new Date(model.selected)
.setUTCDate(model.selected.getUTCDate() + 1));
@@ -100,6 +110,16 @@ export function timelineInput(models, config, ui) {
prepareFrame();
};
+ var reversePrevMinute = function () {
+ var prevMinute = new Date(new Date(model.selected)
+ .setUTCDate(model.selected.getUTCMinutes() - 10));
+ if (prevMinute >= tl.data.start()) {
+ animateReverse('minute');
+ } else {
+ self.stop();
+ }
+ };
+
var reversePrevDay = function () { // FIXME: Limit animation correctly
var prevDay = new Date(new Date(model.selected)
.setUTCDate(model.selected.getUTCDate() - 1));
@@ -380,6 +400,9 @@ export function timelineInput(models, config, ui) {
case 3:
forwardNextDay();
break;
+ case 4:
+ forwardNextMinute();
+ break;
default:
forwardNextDay();
}
@@ -399,6 +422,9 @@ export function timelineInput(models, config, ui) {
case 3:
reversePrevDay();
break;
+ case 4:
+ reversePrevMinute();
+ break;
default:
reversePrevDay();
}
diff --git a/web/js/util/util.js b/web/js/util/util.js
index d93c45a47..06dbe111f 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -170,7 +170,7 @@ export default (function (self) {
*
* @method parseDateUTC
* @static
- * @param str {string} Date to parse in the form of ``YYYY-MM-DD``.
+ * @param str {string} Date to parse in the form of YYYY-MM-DD HH:MM:SS`.
* @return {Date} converted string as a date object, throws an exception if
* the string is invalid
*/
@@ -198,6 +198,7 @@ export default (function (self) {
second = hhmmss[2] || 0;
millisecond = hhmmss[3] || 0;
}
+
var date = new Date(Date.UTC(year, month, day, hour, minute, second,
millisecond));
if (isNaN(date.getTime())) {
@@ -271,9 +272,9 @@ export default (function (self) {
* @return {Date} the date object
*/
self.clearTimeUTC = function (date) {
- date.setUTCHours(0);
- date.setUTCMinutes(0);
- date.setUTCSeconds(0);
+ // date.setUTCHours(0);
+ // date.setUTCMinutes(0);
+ // date.setUTCSeconds(0);
date.setUTCMilliseconds(0);
return date;
};