Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Issue #295

ZachTRice4902aa01eb1b
diff --git a/web/css/wv.events.css b/web/css/wv.events.css
index 4c8baafaf..80f1f3297 100644
--- a/web/css/wv.events.css
+++ b/web/css/wv.events.css
@@ -17,9 +17,6 @@
background: transparent;
}
-.map-item-list li.item .incomplete-date {
- cursor: default;
-}
.map-item-list li.item h4 {
font-size:0.85em;
color:#ccc;
@@ -59,7 +56,7 @@
padding-left: 15px;
}
-#wv-events li.item .dates a.date.active {
+#wv-events li.item ul li.dates a.active {
font-weight: bold;
}
diff --git a/web/js/naturalEvents/wv.naturalEvents.ui.js b/web/js/naturalEvents/wv.naturalEvents.ui.js
index ece74bf87..990550056 100644
--- a/web/js/naturalEvents/wv.naturalEvents.ui.js
+++ b/web/js/naturalEvents/wv.naturalEvents.ui.js
@@ -159,9 +159,14 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
$current.click();
}
var dataIndex = $(this).attr("data-index");
- showEvent(dataIndex);
+ if ($(this).find("ul li.dates a").first().hasClass("date-today")) {
+ var newID = $(self.selector + "content ul li.dates").next().children("a").attr("data-date-index");
+ showEvent(dataIndex, newID);
+ } else {
+ showEvent(dataIndex);
+ }
$(self.selector + "content li").removeClass('item-selected');
- $(self.selector + "content a.date").removeClass('active');
+ $(self.selector + "content ul li.dates a").removeClass('active');
$(this).addClass('item-selected');
if (wv.util.browser.small){
ui.sidebar.collapseNow();
@@ -170,7 +175,7 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
$current = $(this);
}, function() {
$(self.selector + "content li").removeClass('item-selected');
- $(self.selector + "content a.date").removeClass('active');
+ $(self.selector + "content ul li.dates a").removeClass('active');
hideEvent();
mapController.dispose();
mapController.current = null;
@@ -178,23 +183,18 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
});
$(self.selector + "content li").click( function() {
- $(this).find("ul li.dates:first a.date").addClass('active');
+ $(this).find("ul li.dates a.date").first().addClass('active');
});
//Bind click event to each date contained in events with dates
- $(self.selector + "content a.date").click(function(event) {
+ $(self.selector + "content ul li.dates a").click(function(event) {
var dataIndex = $(this).attr("data-index");
showEvent(dataIndex, $(this).attr("data-date-index"));
- $(self.selector + "content a.date").not(this).removeClass('active');
+ $(self.selector + "content ul li.dates a").not(this).removeClass('active');
$(this).addClass('active');
event.stopPropagation();
});
- $(".incomplete-date span").click(function(event) {
- console.log('clicked');
- event.stopPropagation();
- });
-
resize();
};
@@ -332,63 +332,35 @@ wv.naturalEvents.ui = wv.naturalEvents.ui || function(models, ui, config, reques
.attr('title', event.categories[0].title);
var $dates = $("<ul></ul>").addClass("dates").hide();
- // Check if an event is an Severe Storms (10)
- if(eventCategoryID == 10) {
- var latestDate = geoms[0].date;
- var datesFound = 0;
-
- // Find all events date in the geoms object matching today's date
- for(var i = 0; i < geoms.length; i++) {
- var getEventDate = geoms[i].date;
- var geomsLatestDate = wv.util.parseDateUTC(getEventDate);
- var eventDateISOString = wv.util.toISOStringDate(geomsLatestDate);
- var todayDateISOString = wv.util.toISOStringDate(wv.util.today());
- if (eventDateISOString == todayDateISOString) {
- datesFound++;
- }
- }
-
- // Store today's events
- var eventsRemoved = geoms.splice(0, datesFound);
-
- // Append today's events to top
- if ( eventsRemoved.length > 1 ) {
- console.log(eventsRemoved);
- _.each(eventsRemoved, function(geometry, dateIndex) {
-
- date = geometry.date.split(/T/)[0];
- if (date === lastDate){
- return;
- }
-
- $date = $("<span></span>")
- .addClass("date")
- // .attr("data-date-index", dateIndex)
- // .attr("data-index", index)
- .html(date);
-
- $dates.append($("<li class='incomplete-date'></li>").append($date));
- lastDate = date;
- });
- }
- }
if ( event.geometries.length > 1 ) {
var lastDate;
var eventIndex = 0;
_.each(event.geometries, function(geometry, dateIndex) {
eventIndex++;
-
date = geometry.date.split(/T/)[0];
+ var todayDateISOString = wv.util.toISOStringDate(wv.util.today());
+
if (date === lastDate){
return;
}
+ // Check first multi-day event
if(eventIndex == 1) {
- $date = $("<a></a>")
- .addClass("date active")
- .attr("data-date-index", dateIndex)
- .attr("data-index", index)
- .html(date);
+ //If it's date is today and it is a Severe Storm, mark it
+ //and don't make it active.
+ if ((date === todayDateISOString) && (eventCategoryID == 10)) {
+ $date = $("<a></a>")
+ .addClass("date-today")
+ .attr("data-date-index", dateIndex)
+ .attr("data-index", index)
+ .html(date);
+ } else {
+ $date = $("<a></a>")
+ .addClass("date active")
+ .attr("data-date-index", dateIndex)
+ .attr("data-index", index)
+ .html(date);
+ }
} else {
$date = $("<a></a>")
.addClass("date")
diff --git a/web/mock/events_data.json-20170530 b/web/mock/events_data.json-20170530
index 04028e17e..7ba37ef89 100644
--- a/web/mock/events_data.json-20170530
+++ b/web/mock/events_data.json-20170530
@@ -6,26 +6,70 @@
"events": [
{
"id": "EONET_99999",
- "title": "Testing Event with Test Category",
+ "title": "Testing Event",
"description": "",
"link": "http://www.example.com",
"categories": [
{
- "id": 99,
- "title": "Testing"
+ "id": 10,
+ "title": "Severe Storms"
}
],
"sources": [
{
- "id": "TEST",
- "url": "http://www.example.com"
+ "id": "UNISYS",
+ "url": "http://weather.unisys.com/hurricane/n_indian/2017/MORA/track.dat"
}
],
"geometries": [
{
- "date": "2017-05-18T00:00:00Z",
- "type": "Point", "coordinates": [ -120.37116, 36.12089 ]
+ "date": "2017-05-27T18:00:00Z",
+ "type": "Point", "coordinates": [ 88.70, 14.00 ]
+ },
+ {
+ "date": "2017-05-28T00:00:00Z",
+ "type": "Point", "coordinates": [ 88.90, 14.20 ]
+ },
+ {
+ "date": "2017-05-28T06:00:00Z",
+ "type": "Point", "coordinates": [ 90.40, 14.80 ]
+ },
+ {
+ "date": "2017-05-28T12:00:00Z",
+ "type": "Point", "coordinates": [ 91.20, 15.80 ]
+ },
+ {
+ "date": "2017-05-28T18:00:00Z",
+ "type": "Point", "coordinates": [ 91.00, 16.30 ]
+ },
+ {
+ "date": "2017-05-29T00:00:00Z",
+ "type": "Point", "coordinates": [ 90.90, 17.00 ]
+ },
+ {
+ "date": "2017-05-29T06:00:00Z",
+ "type": "Point", "coordinates": [ 91.50, 17.70 ]
+ },
+ {
+ "date": "2017-05-30T00:00:00Z",
+ "type": "Point", "coordinates": [ 92.50, 17.70 ]
+ },
+ {
+ "date": "2017-05-30T06:00:00Z",
+ "type": "Point", "coordinates": [ 93.50, 17.70 ]
+ },
+ {
+ "date": "2017-05-31T18:00:00Z",
+ "type": "Point", "coordinates": [ 88.70, 14.00 ]
+ },
+ {
+ "date": "2017-05-31T18:00:00Z",
+ "type": "Point", "coordinates": [ 89.70, 14.00 ]
+ },
+ {
+ "date": "2017-05-31T18:00:00Z",
+ "type": "Point", "coordinates": [ 90.70, 14.00 ]
}
]