Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Replaced getURLParameter & added console warns for mock data - Removed getURLParameter function in favor of config.parameters helper - Added console warn when using mock events, categories & sources data.

ZachTRice9119ece493aa
diff --git a/web/js/naturalEvents/wv.naturalEvents.request.js b/web/js/naturalEvents/wv.naturalEvents.request.js
index cf6a108db..d3237bd5f 100644
--- a/web/js/naturalEvents/wv.naturalEvents.request.js
+++ b/web/js/naturalEvents/wv.naturalEvents.request.js
@@ -59,18 +59,11 @@ wv.naturalEvents.request = wv.naturalEvents.request || function(models, ui, conf
}
};
- function getURLParameter(name) {
- return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
- }
- var mockEventsDate = getURLParameter('mockEvents');
- var mockCategoriesDate = getURLParameter('mockCategories');
- var mockSourcesDate = getURLParameter('mockSources');
-
var queryEvents = function(callback) {
var url = self.apiURL + "/events";
- var mockEventsParam = 'mockEvents=' + mockEventsDate;
- if (window.location.search.indexOf(mockEventsParam) > -1) {
- url = "mock/events_data.json-" + mockEventsDate;
+ if (config.parameters.mockEvents) {
+ console.warn("Using mock events data: " + config.parameters.mockEvents);
+ url = "mock/events_data.json-" + config.parameters.mockEvents;
}
$.getJSON(url, function(data) {
model.data.events = data.events;
@@ -80,9 +73,9 @@ wv.naturalEvents.request = wv.naturalEvents.request || function(models, ui, conf
var queryTypes = function(callback) {
var url = self.apiURL + "/categories";
- var mockCategoriesParam = 'mockCategories=' + mockCategoriesDate;
- if (window.location.search.indexOf(mockCategoriesParam) > -1) {
- url = "mock/categories_data.json-" + mockCategoriesDate;
+ if (config.parameters.mockCategories) {
+ console.warn("Using mock categories data: " + config.parameters.mockEvents);
+ url = "mock/categories_data.json-" + config.parameters.mockCategories;
}
$.getJSON(url, function(data) {
model.data.types = data.categories;
@@ -92,9 +85,9 @@ wv.naturalEvents.request = wv.naturalEvents.request || function(models, ui, conf
var querySources = function(callback) {
var url = self.apiURL + "/sources";
- var mockSourcesParam = 'mockSources=' + mockSourcesDate;
- if (window.location.search.indexOf(mockSourcesParam) > -1) {
- url = "mock/sources_data.json-" + mockSourcesDate;
+ if (config.parameters.mockSources) {
+ console.warn("Using mock sources data: " + config.parameters.mockEvents);
+ url = "mock/sources_data.json-" + config.parameters.mockSources;
}
$.getJSON(url, function(data) {
model.data.sources = data.sources;