Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Added year 2014

Mike McGann9abcf237b8f8
diff --git a/src/js/dateSpan.js b/src/js/dateSpan.js
index 5cda10c62..4e5ab3469 100644
--- a/src/js/dateSpan.js
+++ b/src/js/dateSpan.js
@@ -2,14 +2,14 @@ SOTE.namespace("SOTE.widget.DateSpan");
/**
- * A date selection object for a configurable period of days, containing thumnails of a sample data
- * product image for each day
+ * A date selection object for a configurable period of days, containing thumnails of a sample data
+ * product image for each day
*
* @module SOTE.widget
* @class DateSpan
* @constructor
* @this {dateSpan}
- * @param {String} containerId is the container id of the div in which to render the object
+ * @param {String} containerId is the container id of the div in which to render the object
* @param {Object} [config] is a hash allowing configuration of this component
* @config {String} [minDate] an ISO8601 formatted date string containing the minimum bound for the dateSpan
* @config {String} [maxDate] an ISO8601 formatted date string containing the maximum bound for the dateSpan
@@ -24,23 +24,23 @@ SOTE.namespace("SOTE.widget.DateSpan");
* @config {boolean} [slideToSelect] whether the selection slider is visible or not
* @config {boolean} [isExpanded] whether the dateSpan thumbnails should be visible or not
* @augments SOTE.widget.Component
- *
+ *
*/
SOTE.widget.DateSpan = function(containerId, config){
this.log = Logging.getLogger("Worldview.Widget.DateSpan");
this.SLIDER_WIDTH = 1000;
this.DAY_IN_MS = 24*60*60*1000;
this.sliders = new Object();
- this.sliders["Year"] = [2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013];
+ this.sliders["Year"] = [2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014];
this.sliders["Month"] = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
this.sliders["Day"] = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
this.months = [31,28,31,30,31,30,31,31,30,31,30,31];
this.monthNames = [ "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November",
+ "July", "August", "September", "October", "November",
"December" ];
-
+
this.sliderContent = [];
-
+
this.container=document.getElementById(containerId);
if (this.container==null){
this.setStatus("Error: element '"+containerId+"' not found!",true);
@@ -48,25 +48,25 @@ SOTE.widget.DateSpan = function(containerId, config){
}
this.id = containerId;
//Store the container's ID
- this.containerId=containerId;
+ this.containerId=containerId;
- //Define an object for holding configuration
+ //Define an object for holding configuration
if (config===undefined){
- config={};
+ config={};
}
-
+
if(config.dataSourceUrl === undefined){
config.dataSourceUrl = null;
}
if(config.thumbSource === undefined){
- config.thumbSource = null;
+ config.thumbSource = null;
}
if(config.extent === undefined){
config.extent = null;
- }
-
+ }
+
if(config.product === undefined){
config.product = null;
}
@@ -88,23 +88,23 @@ SOTE.widget.DateSpan = function(containerId, config){
if(config.range === undefined){
config.range = 7*this.DAY_IN_MS;
}
-
+
if(config.selected === undefined){
config.selected = this.getToday();
}
-
+
if(config.slideToSelect === undefined){
config.slideToSelect = true;
}
-
+
if(config.isCollapsed === undefined){
config.isCollapsed = false;//(config.thumbSource === null || config.hasThumbnail === false)? true: false;
}
-
+
if(config.hasThumbnail === undefined){
config.hasThumbnail = true;
}
-
+
this.maps = [];
this.startDate = config.startDate;
@@ -116,27 +116,27 @@ SOTE.widget.DateSpan = function(containerId, config){
this.hasThumbnail = config.hasThumbnail;
this.extent = config.extent;
this.product = config.product;
- this.value = config.selected;
+ this.value = config.selected;
this.dataSourceUrl = config.dataSourceUrl;
this.statusStr = "";
this.init();
-
+
$(window).bind("resize",{self:this},SOTE.widget.DateSpan.refreshSliders);
-
+
};
SOTE.widget.DateSpan.prototype = new SOTE.widget.Component;
/**
- * Displays the selectable dateSpan in HTML containing a thumbnail for each day in the span. If the date range contains
- * more days than the visible day span, create horizontal scrolling capability. All callbacks should be set. The
+ * Displays the selectable dateSpan in HTML containing a thumbnail for each day in the span. If the date range contains
+ * more days than the visible day span, create horizontal scrolling capability. All callbacks should be set. The
* component UI should be rendered with controllers to call the events.
- *
+ *
* @this {dateSpan}
* @requires SOTE.widget.Map
*/
SOTE.widget.DateSpan.prototype.init = function(){
-
+
// inherit styles into the user-specified div
this.container.setAttribute("class","datespan");
@@ -145,7 +145,7 @@ SOTE.widget.DateSpan.prototype.init = function(){
dateHolder.setAttribute('class','dateHolder');
dateHolder.innerHTML = 'Friday September 21, 2012';
this.container.appendChild(dateHolder);
-
+
var ecbutton = document.createElement("a");
ecbutton.setAttribute("class","ecbutton collapse");
ecbutton.setAttribute("id",this.id+"ecbutton");
@@ -173,7 +173,7 @@ SOTE.widget.DateSpan.prototype.init = function(){
SOTE.widget.DateSpan.prototype.getToday = function() {
// If at the beginning of the day, wait on the previous day until GIBS
- // catches up.
+ // catches up.
var today = Worldview.today();
var now = Worldview.now();
if ( now.getUTCHours() < Worldview.GIBS_HOUR_DELAY ) {
@@ -181,7 +181,7 @@ SOTE.widget.DateSpan.prototype.getToday = function() {
return today;
} else {
return today;
- }
+ }
};
SOTE.widget.DateSpan.refreshSliders = function(e){
@@ -189,15 +189,15 @@ SOTE.widget.DateSpan.refreshSliders = function(e){
setTimeout(function() {
self.refreshSlider("Year");
self.refreshSlider("Month");
- self.refreshSlider("Day");
+ self.refreshSlider("Day");
},100);
-
+
};
SOTE.widget.DateSpan.prototype.refreshSlider = function(type){
var labels = this.sliders[type];
var wwidth = $(window).width() - 10;
-
+
if(labels != undefined){
var width = 50/labels.length;
width = width.toFixed(1);
@@ -211,9 +211,9 @@ SOTE.widget.DateSpan.prototype.refreshSlider = function(type){
$('#'+this.id+'sliderLabel'+type).children().css('width',Math.floor(wwidth*pwidth) + "px");
$('#'+this.id+'sliderLabel'+type).children().css('margin-left',Math.floor(wwidth*pspacer/2) + "px");
$('#'+this.id+'sliderLabel'+type).children().css('margin-right',Math.floor(wwidth*pspacer/2) + "px");
- $('#'+this.id+'slider'+type).siblings('.ui-slider').css('width',eval(finalwidth*labels.length)+"px");
- }
-
+ $('#'+this.id+'slider'+type).siblings('.ui-slider').css('width',eval(finalwidth*labels.length)+"px");
+ }
+
};
SOTE.widget.DateSpan.prototype.createSlider = function(type){
@@ -222,11 +222,11 @@ SOTE.widget.DateSpan.prototype.createSlider = function(type){
slider.setAttribute('class','sliderDiv'+type+' slider');
slider.innerHTML = '<input type="range" name="slider" id="'+this.id+'slider'+type+'" class="dateSpanSlider" value="'+this.SLIDER_WIDTH+'" min="0" max="'+this.SLIDER_WIDTH+'" step="1" />';
this.container.appendChild(slider);
-
+
var width = 0;
var wwidth = $(window).width() - 10;
var labels = this.sliders[type];
-
+
if(labels != undefined){
width = 50/labels.length;
width = width.toFixed(1);
@@ -247,21 +247,21 @@ SOTE.widget.DateSpan.prototype.createSlider = function(type){
item.innerHTML = labels[i];
item.style.width = Math.floor(wwidth*pwidth) + "px";
item.style.marginLeft = Math.floor(wwidth*pspacer/2) + "px";
- item.style.marginRight = Math.floor(wwidth*pspacer/2) + "px";
+ item.style.marginRight = Math.floor(wwidth*pspacer/2) + "px";
label.appendChild(item);
- }
+ }
this.container.appendChild(label);
}
-
+
var labelslength = labels.length;
-
- $('#'+this.id+'slider'+type).slider();
+
+ $('#'+this.id+'slider'+type).slider();
$('#'+this.id+'slider'+type).bind("change",{self:this,type:type},SOTE.widget.DateSpan.handleSlide);
- $('#'+this.id+'slider'+type).siblings('.ui-slider').css('width',eval(finalwidth*labels.length)+"px");
- $('#'+this.id+'slider'+type).siblings('.ui-slider').bind("vmouseup",{self:this,type:type},SOTE.widget.DateSpan.snap);
+ $('#'+this.id+'slider'+type).siblings('.ui-slider').css('width',eval(finalwidth*labels.length)+"px");
+ $('#'+this.id+'slider'+type).siblings('.ui-slider').bind("vmouseup",{self:this,type:type},SOTE.widget.DateSpan.snap);
if(width!=0){$('.sliderDiv'+type+' a.ui-slider-handle').css('width',eval(width*1.1).toFixed(1)+"%");}
//this.widths[type] = width;
-
+
};
/**
@@ -289,11 +289,11 @@ SOTE.widget.DateSpan.handleSlide = function(e,ui){
var type = e.data.type;
var self = e.data.self;
var oldDate = self.value;
-
+
var numitems = self.sliders[type].length;
var displacement = Math.floor(value*(numitems/self.SLIDER_WIDTH));
-
+
if(self.sliders[type][displacement]){
var newDate = self.value.clone();
if(type == "Year"){
@@ -311,23 +311,23 @@ SOTE.widget.DateSpan.handleSlide = function(e,ui){
}
else if (type == "Day"){
if(self.sliders[type][displacement] <= self.months[self.value.getUTCMonth()]){
- newDate.setUTCDate(self.sliders[type][displacement]);
+ newDate.setUTCDate(self.sliders[type][displacement]);
}
else {
self.setValue(newDate.toISOString());
}
}
-
+
if(newDate.getTime() < self.startDate.getTime()){
- self.setValue(self.startDate.toISOString());
+ self.setValue(self.startDate.toISOString());
}
else if(newDate.getTime() > self.endDate.getTime()){
- self.setValue(self.endDate.toISOString());
+ self.setValue(self.endDate.toISOString());
}
else {
self.value = newDate.clone();
}
-
+
}
else {
if(displacement >= self.sliders[type].length){
@@ -337,22 +337,22 @@ SOTE.widget.DateSpan.handleSlide = function(e,ui){
self.setValue(self.value.toISOString());
}
}
- self.validate();
- if ( oldDate.compareTo(self.value) !== 0 ) {
+ self.validate();
+ if ( oldDate.compareTo(self.value) !== 0 ) {
self.fire()
self.setVisualDate();
}
-
+
/*
var x = (self.range - self.DAY_IN_MS) * (self.SLIDER_WIDTH-value)/self.SLIDER_WIDTH;
-
+
var time = new Date(self.endDate.getTime() - x);
if(self.value.getTime() !== time.getTime()){
self.value = time.clone();
self.setVisualDate();
self.fire();
}*/
-
+
};
@@ -374,7 +374,7 @@ SOTE.widget.DateSpan.toggle = function(e,ui){
//$('a.ui-slider-handle').css('top','-25px');
self.isCollapsed = true;
self.hideSliders();
- }
+ }
};
SOTE.widget.DateSpan.snap = function(e,ui){
@@ -387,7 +387,7 @@ SOTE.widget.DateSpan.snap = function(e,ui){
var width = self.SLIDER_WIDTH/numitems;
var move = displacement*width + width/4 - width*.05;
move = move.toFixed(1);
- //move = move * $(window).width();
+ //move = move * $(window).width();
$("#"+self.id+"slider"+type).val((move)).slider("refresh");
//alert(self.sliders[type][displacement]);
if(self.sliders[type][displacement]){
@@ -403,29 +403,29 @@ SOTE.widget.DateSpan.snap = function(e,ui){
}
else{
newDate.setUTCMonth(displacement);
- }
+ }
}
else if (type == "Day"){
if(self.sliders[type][displacement] <= self.months[self.value.getUTCMonth()]){
- newDate.setUTCDate(self.sliders[type][displacement]);
+ newDate.setUTCDate(self.sliders[type][displacement]);
}
else {
newDate = this.value.clone();
self.setValue(newDate);
}
}
-
-
+
+
if(newDate.getTime() < self.startDate.getTime()){
- self.setValue(self.startDate.toISOString());
+ self.setValue(self.startDate.toISOString());
}
else if(newDate.getTime() > self.endDate.getTime()){
- self.setValue(self.endDate.toISOString());
+ self.setValue(self.endDate.toISOString());
}
else {
self.value = newDate.clone();
}
-
+
//self.setValue(SOTE.util.ISO8601StringFromDate(self.value));
}
@@ -438,7 +438,7 @@ SOTE.widget.DateSpan.snap = function(e,ui){
}
}
self.validate();
- self.setVisualDate();
+ self.setVisualDate();
/*var x = (self.range - (24*60*60*1000)) * (100-value)/100;
var time = new Date(self.endDate.getTime() - x);
time.setHours(12);
@@ -452,7 +452,7 @@ SOTE.widget.DateSpan.snapToTime = function(e,ui){
var self = e.data.self;
var time = e.data.time;
//time = new Date(time.getTime() - time.getTimezoneOffset()*60000);
-
+
//self.setValue(SOTE.util.ISO8601StringFromDate(time));
};
@@ -481,18 +481,18 @@ SOTE.widget.DateSpan.prototype.showSliders = function(){
SOTE.widget.DateSpan.prototype.setValue = function(value){
var d;
try {
- var d = value ? Date.parseISOString(value)
+ var d = value ? Date.parseISOString(value)
: this.getToday();
} catch ( error ) {
- this.log.warn("Invalid time: " + value + ", reason: " + error +
- "; using today");
- d = Worldview.today();
+ this.log.warn("Invalid time: " + value + ", reason: " + error +
+ "; using today");
+ d = Worldview.today();
}
-
+
if(d.getTime() < this.startDate.getTime()) {
d = this.startDate;
}
- if(d.getTime() <= this.endDate.getTime() &&
+ if(d.getTime() <= this.endDate.getTime() &&
d.getTime() >= this.startDate.getTime()) {
var changed = false;
if ( this.value.compareTo(d) !== 0 ) {
@@ -503,14 +503,14 @@ SOTE.widget.DateSpan.prototype.setValue = function(value){
values["Year"] = this.sliders["Year"].indexOf(this.value.getUTCFullYear());
values["Month"] = this.value.getUTCMonth();
values["Day"] = this.sliders["Day"].indexOf(this.value.getUTCDate());
-
+
for(var type in values){
var numitems = this.sliders[type].length;
var displacement = values[type];
var width = this.SLIDER_WIDTH/numitems;
var move = displacement*width + (width/4) - (width*.05);
move = move.toFixed(1);
- $("#"+this.id+"slider"+type).val(move).slider("refresh");
+ $("#"+this.id+"slider"+type).val(move).slider("refresh");
}
this.validate();
@@ -523,17 +523,17 @@ SOTE.widget.DateSpan.prototype.setValue = function(value){
var thisDay = d.toISOStringDate();
var startDay = this.startDate.toISOStringDate();
var today = this.endDate.toISOStringDate();
-
+
if ( d.getTime() < this.startDate.getTime() ) {
/*
SOTE.util.throwError("Data is not available for " + thisDay +
- ". The day of " + startDay + " is the earliest available " +
+ ". The day of " + startDay + " is the earliest available " +
"data at this time. The date has been adjusted to today.");
*/
} else if ( d.getTime() >= this.endDate.getTime() ) {
- SOTE.util.throwError("Data is not available for " + thisDay +
+ SOTE.util.throwError("Data is not available for " + thisDay +
" yet. Try again later. The date has been adjusted to today.")
- }
+ }
}
};
@@ -562,11 +562,11 @@ SOTE.widget.DateSpan.prototype.get = function(){
/**
* Modify the component based on dependencies (i.e. total number of dates in span, start date of span, selected date, thumbnails)
- *
+ *
* @this {dateSpan}
* @param {String} querystring contains all values of dependencies (from registry)
* @returns {boolean} true or false depending on if the selected date validates against the updated criteria
- *
+ *
*/
SOTE.widget.DateSpan.prototype.updateComponent = function(qs){
/* var bbox = SOTE.util.extractFromQuery('map',qs);
@@ -601,7 +601,7 @@ SOTE.widget.DateSpan.prototype.updateComponent = function(qs){
/**
* Sets the selected date from the querystring, [containerId]=[selectedDate]
- *
+ *
* @this {dateSpan}
* @param {String} qs contains the querystring (must contain [containerId]=[selectedDate] in the string)
* @returns {boolean} true or false depending on if the extracted date validates
@@ -613,7 +613,7 @@ SOTE.widget.DateSpan.prototype.loadFromQuery = function(qs){
/**
* Validates that the selected date is not null and within bounds
- *
+ *
* @this {dateSpan}
* @returns {boolean} true or false depending on whether the date is not null and within bounds
*/
@@ -633,7 +633,7 @@ SOTE.widget.DateSpan.prototype.validate = function(){
$("#"+descriptor).addClass("disabledItem");
}
else {
- $("#"+descriptor).removeClass("disabledItem");
+ $("#"+descriptor).removeClass("disabledItem");
}
}
if(type == "Month"){
@@ -641,7 +641,7 @@ SOTE.widget.DateSpan.prototype.validate = function(){
$("#"+descriptor).addClass("disabledItem");
}
else {
- $("#"+descriptor).removeClass("disabledItem");
+ $("#"+descriptor).removeClass("disabledItem");
}
}
if(type == "Day"){
@@ -649,19 +649,19 @@ SOTE.widget.DateSpan.prototype.validate = function(){
$("#"+descriptor).addClass("disabledItem");
}
else {
- $("#"+descriptor).removeClass("disabledItem");
+ $("#"+descriptor).removeClass("disabledItem");
}
}
}
}
-
+
};
/**
* Sets the data accessor that provides state change instructions given dependencies
*
* @this {dateSpan}
- * @param {String} datasourceurl is the relative location of the data accessor
+ * @param {String} datasourceurl is the relative location of the data accessor
*
*/
SOTE.widget.DateSpan.prototype.setDataSourceUrl = function(datasourceurl){
@@ -670,7 +670,7 @@ SOTE.widget.DateSpan.prototype.setDataSourceUrl = function(datasourceurl){
/**
* Gets the data accessor
- *
+ *
* @this {dateSpan}
* @returns {String} the relative location of the accessor
*
@@ -751,7 +751,7 @@ SOTE.widget.DateSpan.prototype.parse = function(queryString, object) {
try {
object.time = Date.parseISOString(timeString).clearUTCTime();
} catch ( error ) {
- this.log.warn("Invalid time: " + timeString + ", reason: " +
+ this.log.warn("Invalid time: " + timeString + ", reason: " +
error);
object.time = Worldview.today();
}