Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add space-before-function-paren never eslint rule

Benjamin King60e076147e02
diff --git a/.eslintrc b/.eslintrc
index f92f5a6c9..4a2d288e6 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -12,8 +12,14 @@
"jsx": true
}
},
- "plugins": ["react", "jest"],
- "extends": ["standard", "plugin:react/recommended"],
+ "plugins": [
+ "react",
+ "jest"
+ ],
+ "extends": [
+ "standard",
+ "plugin:react/recommended"
+ ],
"parser": "babel-eslint",
"settings": {
"react": {
@@ -21,15 +27,29 @@
}
},
"rules": {
- "semi": ["error", "always"],
+ "semi": [
+ "error",
+ "always"
+ ],
"space-before-function-paren": "off",
- "object-curly-spacing": ["error", "always"],
- "quotes": [2, "single", { "avoidEscape": true }]
+ "object-curly-spacing": [
+ "error",
+ "always"
+ ],
+ "quotes": [
+ 2,
+ "single",
+ {
+ "avoidEscape": true
+ }
+ ]
},
-
"overrides": [
{
- "files": ["web/**/*.js", "test/**/*.js"],
+ "files": [
+ "web/**/*.js",
+ "test/**/*.js"
+ ],
"rules": {
"no-octal": "error",
"no-unused-vars": "error",
@@ -43,10 +63,15 @@
"operator-linebreak": "error",
"comma-dangle": "error",
"no-use-before-define": "error",
- "camelcase": ["error", {
- "allow": ["^UNSAFE_"],
- "properties": "never"
- }],
+ "camelcase": [
+ "error",
+ {
+ "allow": [
+ "^UNSAFE_"
+ ],
+ "properties": "never"
+ }
+ ],
"no-extend-native": "error",
"one-var": "error",
"no-extra-parens": "error",
@@ -65,20 +90,30 @@
"no-useless-call": "error",
"no-trailing-spaces": "error",
"standard/computed-property-even-spacing": "error",
+ "space-before-function-paren": [
+ "error",
+ "never"
+ ],
"wrap-iife": "error",
"new-cap": "error",
- "semi": ["error", "always"],
+ "semi": [
+ "error",
+ "always"
+ ],
"react/no-danger": "warn",
"react/prop-types": "warn",
"react/no-did-update-set-state": "warn",
"react/no-render-return-value": "warn",
- "react/sort-prop-types": ["warn", {
- "ignoreCase": true,
- "requiredFirst": true,
- "sortShapeProp": true
- }],
+ "react/sort-prop-types": [
+ "warn",
+ {
+ "ignoreCase": true,
+ "requiredFirst": true,
+ "sortShapeProp": true
+ }
+ ],
"react/no-string-refs": "warn"
}
}
]
-}
+}
\ No newline at end of file
diff --git a/web/js/brand.js b/web/js/brand.js
index bfe04edec..007b05c7f 100644
--- a/web/js/brand.js
+++ b/web/js/brand.js
@@ -3,7 +3,7 @@ import lodashIndexOf from 'lodash/indexOf';
* @class wv.brand
* @static
*/
-export default (function () {
+export default (function() {
var self = {};
/**
@@ -54,11 +54,11 @@ export default (function () {
* @return true if the build script has populated the VERSION field,
* otherwise returns false.
*/
- self.release = function () {
+ self.release = function() {
return self.VERSION[0] !== '@';
};
- self.url = function (base) {
+ self.url = function(base) {
var joiner = (lodashIndexOf(base, '?') < 0) ? '?' : '&';
return base + joiner + 'v=' + self.BUILD_NONCE;
};
diff --git a/web/js/components/layer/settings/vector-style.js b/web/js/components/layer/settings/vector-style.js
index 8272e2577..15f5f0ea2 100644
--- a/web/js/components/layer/settings/vector-style.js
+++ b/web/js/components/layer/settings/vector-style.js
@@ -84,7 +84,7 @@ class VectorStyleSelect extends React.Component {
var vectorStyle = vectorStyles[vectorStyleId];
var vectorStyleLayers = vectorStyle['layers'];
- var uniqueStyleLayers = vectorStyleLayers.filter(function (a) {
+ var uniqueStyleLayers = vectorStyleLayers.filter(function(a) {
if (!this[a.id]) {
this[a.id] = true;
return true;
diff --git a/web/js/components/timeline/timeline-controls/interval-timescale-change.js b/web/js/components/timeline/timeline-controls/interval-timescale-change.js
index 8306aee92..15fd44c97 100644
--- a/web/js/components/timeline/timeline-controls/interval-timescale-change.js
+++ b/web/js/components/timeline/timeline-controls/interval-timescale-change.js
@@ -76,13 +76,13 @@ class TimeScaleIntervalChange extends PureComponent {
});
}
- componentDidMount () {
+ componentDidMount() {
if (this.props.customDelta !== 1 && this.props.customIntervalZoomLevel) {
this.setCustomIntervalText();
}
}
- componentDidUpdate (prevProps) {
+ componentDidUpdate(prevProps) {
const {
customDelta,
timeScaleChangeUnit,
diff --git a/web/js/edsc.js b/web/js/edsc.js
index 582c7aff9..2849237f6 100644
--- a/web/js/edsc.js
+++ b/web/js/edsc.js
@@ -14,7 +14,7 @@ L.Polyline = {
};
L.Polygon = {
- extend: function () {},
+ extend: function() {},
prototype: {}
};
@@ -40,22 +40,22 @@ L.EditToolbar = {
L.Draw = {
Polygon: {
- extend: function () {}
+ extend: function() {}
}
};
L.Edit = {
Poly: {
- extend: function () {}
+ extend: function() {}
}
};
L.Util = {
- isArray: function (value) {
+ isArray: function(value) {
return value.constructor === Array;
}
};
-function LatLng (lat, lng) {
+function LatLng(lat, lng) {
if (lat.lat) {
var latlng = lat;
this.lat = latlng.lat;
@@ -67,7 +67,7 @@ function LatLng (lat, lng) {
}
L.LatLng = LatLng;
-L.latLng = function (lat, lng) {
+L.latLng = function(lat, lng) {
return new L.LatLng(lat, lng);
};
edsc.Coordinate = edscCoordinate(L);
diff --git a/web/js/map/map.js b/web/js/map/map.js
index f0744c989..039267840 100644
--- a/web/js/map/map.js
+++ b/web/js/map/map.js
@@ -31,7 +31,7 @@ export function mapParser(state, errors) {
delete state.map;
}
if (state.v) {
- var extent = lodashMap(state.v.split(','), function (str) {
+ var extent = lodashMap(state.v.split(','), function(str) {
return parseFloat(str);
});
var valid = mapIsExtentValid(extent);
@@ -65,7 +65,7 @@ export function mapIsExtentValid(extent) {
if (extent.toArray) {
extent = extent.toArray();
}
- lodashEach(extent, function (value) {
+ lodashEach(extent, function(value) {
if (isNaN(value)) {
valid = false;
return false;
diff --git a/web/js/map/natural-events/util.js b/web/js/map/natural-events/util.js
index 0b3c1435c..08d5c4f8c 100644
--- a/web/js/map/natural-events/util.js
+++ b/web/js/map/natural-events/util.js
@@ -7,8 +7,8 @@ import lodashFind from 'lodash/find';
* @param {String} id Event Id
* @return {Object} Eonet Event Object
*/
-export function naturalEventsUtilGetEventById (events, id) {
- return lodashFind(events, function (e) {
+export function naturalEventsUtilGetEventById(events, id) {
+ return lodashFind(events, function(e) {
return e.id === id;
});
};
diff --git a/web/js/ol/lookupimagetile.js b/web/js/ol/lookupimagetile.js
index d1b4ab0a8..2693d7108 100644
--- a/web/js/ol/lookupimagetile.js
+++ b/web/js/ol/lookupimagetile.js
@@ -52,7 +52,7 @@ LookupImageTile.prototype.load = function() {
};
export function lookupFactory(lookup, sourceOptions) {
- return function (tileCoord, state, src, crossOrigin, tileLoadFunction) {
+ return function(tileCoord, state, src, crossOrigin, tileLoadFunction) {
return new LookupImageTile(lookup, tileCoord, state, src,
crossOrigin, tileLoadFunction, sourceOptions);
};
diff --git a/web/js/polyfill.js b/web/js/polyfill.js
index bb3b6aca9..0c83950cc 100644
--- a/web/js/polyfill.js
+++ b/web/js/polyfill.js
@@ -7,22 +7,22 @@
/* eslint-disable no-extend-native */
-export function polyfill () {
+export function polyfill() {
/*
* Date.toISOString
*
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
*/
if (!Date.prototype.toISOString) {
- (function () {
- function pad (number) {
+ (function() {
+ function pad(number) {
if (number < 10) {
return '0' + number;
}
return number;
}
- Date.prototype.toISOString = function () {
+ Date.prototype.toISOString = function() {
return this.getUTCFullYear() +
'-' + pad(this.getUTCMonth() + 1) +
'-' + pad(this.getUTCDate()) +
@@ -41,12 +41,12 @@ export function polyfill () {
* console
*/
if (!window.console) {
- (function () {
+ (function() {
window.console = {
- log: function () {},
- warn: function () {},
- info: function () {},
- error: function () {}
+ log: function() {},
+ warn: function() {},
+ info: function() {},
+ error: function() {}
};
})();
}
@@ -54,8 +54,8 @@ export function polyfill () {
/*
* Get rid of address bar on iphone/ipod
*/
- (function () {
- var execute = function () {
+ (function() {
+ var execute = function() {
window.scrollTo(0, 0);
if (document.body) {
document.body.style.height = '100%';
@@ -73,7 +73,7 @@ export function polyfill () {
/*
* Hide the URL bar
*/
- (function () {
+ (function() {
window.scrollTo(0, 0);
})();
@@ -83,8 +83,8 @@ export function polyfill () {
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/contains
*/
if (!('contains' in String.prototype)) {
- (function () {
- String.prototype.contains = function (str, startIndex) {
+ (function() {
+ String.prototype.contains = function(str, startIndex) {
return String.prototype.indexOf.call(this, str,
startIndex) !== -1;
};
@@ -97,12 +97,12 @@ export function polyfill () {
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
*/
if (!String.prototype.startsWith) {
- (function () {
+ (function() {
Object.defineProperty(String.prototype, 'startsWith', {
enumerable: false,
configurable: false,
writable: false,
- value: function (searchString, position) {
+ value: function(searchString, position) {
position = position || 0;
return this.indexOf(searchString, position) === position;
}
@@ -116,12 +116,12 @@ export function polyfill () {
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
*/
if (!String.prototype.endsWith) {
- (function () {
+ (function() {
Object.defineProperty(String.prototype, 'endsWith', {
enumerable: false,
configurable: false,
writable: false,
- value: function (searchString, position) {
+ value: function(searchString, position) {
position = position || this.length;
position = position - searchString.length;
var lastIndex = this.lastIndexOf(searchString);
@@ -134,7 +134,7 @@ export function polyfill () {
/*
* Mobile device quirks. This section is mostly overwriting things that jquery.mobile is adding
*/
- (function () {
+ (function() {
if (navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/iPhone/i) ||
@@ -147,7 +147,7 @@ export function polyfill () {
}
if (navigator.userAgent.indexOf('iPhone') !== -1 || navigator.userAgent.indexOf('Android') !== -1) {
- addEventListener('load', function () {
+ addEventListener('load', function() {
if (mobile) {
$('.layerPicker a[href=\'#DataDownload\']')
.hide();
@@ -157,14 +157,14 @@ export function polyfill () {
$('#app, .ui-mobile, .ui-mobile .ui-page')
.css('min-height', 0);
}, false);
- addEventListener('orientationchange', function () {
+ addEventListener('orientationchange', function() {
window.scrollTo(0, 1);
setHeight();
}, false);
}
// Set the div height
- function setHeight ($body) {
+ function setHeight($body) {
if (navigator.userAgent.match(/(iPad|iPhone|iPod touch);.*CPU.*OS 6_\d/i)) {
var newHeight = $(window)
.height();
diff --git a/web/js/ui/indicator.js b/web/js/ui/indicator.js
index b9768666c..85153b6bb 100644
--- a/web/js/ui/indicator.js
+++ b/web/js/ui/indicator.js
@@ -5,7 +5,7 @@ import lodashRemove from 'lodash/remove';
import lodashIsEmpty from 'lodash/isEmpty';
import lodashLast from 'lodash/last';
-export default (function () {
+export default (function() {
var self = {};
var $indicator;
@@ -14,7 +14,7 @@ export default (function () {
self.active = [];
- var init = function () {
+ var init = function() {
$indicator = $('<div></div>')
.attr('id', 'indicator');
$icon = $('<img />');
@@ -27,7 +27,7 @@ export default (function () {
.append($indicator);
};
- self.show = function (message, icon) {
+ self.show = function(message, icon) {
self._show(message, icon);
var id = lodashUniqueId();
self.active.push({
@@ -38,11 +38,11 @@ export default (function () {
return id;
};
- self.hide = function (hides) {
+ self.hide = function(hides) {
if (lodashIsString(hides)) {
hides = [hides];
}
- lodashEach(hides, function (id) {
+ lodashEach(hides, function(id) {
lodashRemove(self.active, {
id: id
});
@@ -55,12 +55,12 @@ export default (function () {
}
};
- self.replace = function (hides, message, icon) {
+ self.replace = function(hides, message, icon) {
self.hide(hides);
return self.show(message, icon);
};
- self._show = function (message, icon) {
+ self._show = function(message, icon) {
if (!$indicator) {
init();
}
@@ -77,40 +77,40 @@ export default (function () {
$indicator.show();
};
- self._hide = function () {
+ self._hide = function() {
if ($indicator) {
$indicator.hide();
}
};
- self.searching = function (hides) {
+ self.searching = function(hides) {
if (hides) {
self.hide(hides);
}
return self.show('Searching for Data', 'images/activity.gif');
};
- self.loading = function (hides) {
+ self.loading = function(hides) {
if (hides) {
self.hide(hides);
}
return self.show('Loading', 'images/activity.gif');
};
- self.noData = function (hides) {
+ self.noData = function(hides) {
if (hides) {
self.hide(hides);
}
return self.show('No Data Available', 'images/red-x.svg');
};
- self.delayed = function (promise, delay) {
+ self.delayed = function(promise, delay) {
delay = delay || 1000;
var id;
- var timeout = setTimeout(function () {
+ var timeout = setTimeout(function() {
id = self.loading();
}, delay);
- promise.always(function () {
+ promise.always(function() {
clearTimeout(timeout);
if (id) {
self.hide(id);
diff --git a/web/js/ui/indicator.test.js b/web/js/ui/indicator.test.js
index eb6af3ea1..3f7f45d31 100644
--- a/web/js/ui/indicator.test.js
+++ b/web/js/ui/indicator.test.js
@@ -22,7 +22,7 @@ test('delayed indicator shown', (done) => {
indicator.hide = jest.fn();
const promise = jQuery.Deferred();
indicator.delayed(promise, 10);
- setTimeout(function () {
+ setTimeout(function() {
promise.resolve();
expect(indicator._show).toBeCalled();
expect(indicator.hide).toBeCalled();
@@ -35,7 +35,7 @@ test('delayed indicator not shown', (done) => {
indicator.hide = jest.fn();
const promise = jQuery.Deferred();
indicator.delayed(promise, 1000);
- setTimeout(function () {
+ setTimeout(function() {
promise.resolve();
expect(indicator._show).not.toBeCalled();
expect(indicator.hide).not.toBeCalled();
diff --git a/web/js/ui/info.js b/web/js/ui/info.js
index c6d7b4c63..3f9a5380e 100644
--- a/web/js/ui/info.js
+++ b/web/js/ui/info.js
@@ -3,7 +3,7 @@ import wvui from './ui';
import util from '../util/util';
import { feedbackUi } from '../feedback';
-export function uiInfo (ui, config) {
+export function uiInfo(ui, config) {
var feedbackDialog = feedbackUi();
var selector = '#wv-info-button';
var $button = $('<input />')
@@ -26,7 +26,7 @@ export function uiInfo (ui, config) {
text: false
});
- $button.click(function (event) {
+ $button.click(function(event) {
event.stopPropagation();
wvui.close();
var checked = $('#wv-info-button-check')
@@ -36,7 +36,7 @@ export function uiInfo (ui, config) {
}
});
- var show = function () {
+ var show = function() {
var $menu = wvui.getMenu()
.attr('id', 'wv-info-menu');
var $alerts;
@@ -74,7 +74,7 @@ export function uiInfo (ui, config) {
});
$menuItems.hide();
- $about.click(function () {
+ $about.click(function() {
if (util.browser.small) {
window.open('pages/about.html?v=@BUILD_NONCE@', '_blank');
} else {
@@ -95,16 +95,16 @@ export function uiInfo (ui, config) {
.addClass('wv-opaque');
}
});
- $source.click(function (e) {
+ $source.click(function(e) {
window.open('https://github.com/nasa-gibs/worldview', '_blank');
});
- $feedback.click(function (event) {
+ $feedback.click(function(event) {
event.preventDefault();
feedbackDialog.showFeedback();
});
- $tour.click(function () {
+ $tour.click(function() {
ui.tour.startTour();
});
@@ -116,7 +116,7 @@ export function uiInfo (ui, config) {
direction: 'up'
});
- var clickOut = function (event) {
+ var clickOut = function(event) {
if ($button.parent()
.has(event.target)
.length > 0) {
@@ -133,7 +133,7 @@ export function uiInfo (ui, config) {
.off('click', clickOut)
.off('touchstart', clickOut);
};
- $menuItems.on('touchstart', function (event) {
+ $menuItems.on('touchstart', function(event) {
event.stopPropagation();
});
$('html')
diff --git a/web/js/util/events.js b/web/js/util/events.js
index aec2b6aa2..bf1eaa255 100644
--- a/web/js/util/events.js
+++ b/web/js/util/events.js
@@ -1,14 +1,14 @@
import lodashEach from 'lodash/each';
import lodashPull from 'lodash/pull';
-export function events () {
+export function events() {
var self = {};
// Object of event types. Each event type is an array of listeners.
var events = {};
var allListeners = [];
- self.on = function (event, callback) {
+ self.on = function(event, callback) {
if (!callback) {
throw new Error('No listener specified');
}
@@ -21,7 +21,7 @@ export function events () {
return self;
};
- self.off = function (event, callback) {
+ self.off = function(event, callback) {
var listeners = events[event];
if (listeners) {
lodashPull(listeners, callback);
@@ -29,23 +29,23 @@ export function events () {
return self;
};
- self.any = function (callback) {
+ self.any = function(callback) {
if (!callback) {
throw new Error('No listener specified');
}
allListeners.push(callback);
};
- self.trigger = function (event) {
+ self.trigger = function(event) {
var listeners = events[event];
if (!listeners && !allListeners) {
return;
}
var eventArguments = Array.prototype.slice.call(arguments, 1);
- lodashEach(events[event], function (listener) {
+ lodashEach(events[event], function(listener) {
listener.apply(self, eventArguments);
});
- lodashEach(allListeners, function (listener) {
+ lodashEach(allListeners, function(listener) {
listener.apply(self, eventArguments);
});
return self;
diff --git a/web/js/util/load.js b/web/js/util/load.js
index 130fe0740..a8b5459ae 100644
--- a/web/js/util/load.js
+++ b/web/js/util/load.js
@@ -2,14 +2,14 @@ import lodashSize from 'lodash/size';
import wvui from '../ui/ui';
import brand from '../brand';
-export default (function () {
+export default (function() {
var self = {};
var configPromises = {};
var loading = 0;
var indicatorTimeout = null;
var indicatorId = null;
- self.config = function (root, attr, url) {
+ self.config = function(root, attr, url) {
var promise = $.Deferred();
// If a request is already outstanding, chain to that one
if (configPromises[url]) {
@@ -23,14 +23,14 @@ export default (function () {
loading += 1;
promise = $.getJSON(brand.url(url));
if (loading === 1) {
- indicatorTimeout = setTimeout(function () {
+ indicatorTimeout = setTimeout(function() {
indicatorId = wvui.indicator.loading();
}, 2000);
}
- promise.done(function (result) {
+ promise.done(function(result) {
root[attr] = result;
})
- .always(function () {
+ .always(function() {
delete configPromises[url];
loading -= 1;
if (loading === 0) {
diff --git a/web/js/util/util.js b/web/js/util/util.js
index f7a2cd961..18834962e 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -22,7 +22,7 @@ import isFirstDayOfMonth from 'date-fns/is_first_day_of_month';
import isLastDayOfMonth from 'date-fns/is_last_day_of_month';
import lastDayOfYear from 'date-fns/last_day_of_year';
-export default (function (self) {
+export default (function(self) {
var canvas = null;
// Export other util methods
@@ -58,7 +58,7 @@ export default (function (self) {
}
};
- self.repeat = function (value, length) {
+ self.repeat = function(value, length) {
var result = '';
for (var i = 0; i < length; i++) {
result += value;
@@ -66,7 +66,7 @@ export default (function (self) {
return result;
};
- self.pad = function (value, width, padding) {
+ self.pad = function(value, width, padding) {
value = '' + value;
if (value.length < width) {
var add = width - value.length;
@@ -100,7 +100,7 @@ export default (function (self) {
* object.
* @return {object} object representation of the query string.
*/
- self.fromQueryString = function (queryString) {
+ self.fromQueryString = function(queryString) {
if (!queryString) {
return {};
}
@@ -144,12 +144,12 @@ export default (function (self) {
* "format=image/png"
* @return {String} converted query string
*/
- self.toQueryString = function (kvps, exceptions) {
+ self.toQueryString = function(kvps, exceptions) {
exceptions = exceptions || {};
var parts = [];
- lodashEach(kvps, function (value, key) {
+ lodashEach(kvps, function(value, key) {
var part = key + '=' + encodeURIComponent(value);
- lodashEach(exceptions, function (exception) {
+ lodashEach(exceptions, function(exception) {
var regexp = new RegExp(exception, 'ig');
var decoded = decodeURIComponent(exception);
part = part.replace(regexp, decoded);
@@ -173,7 +173,7 @@ export default (function (self) {
* @return {Date} converted string as a datetime object, throws an
* exception if the string is invalid.
*/
- self.parseTimestampUTC = function (str) {
+ self.parseTimestampUTC = function(str) {
return self.parseDateUTC(str);
};
@@ -187,7 +187,7 @@ export default (function (self) {
* @return y {Number} Y value on canvas
* @return {Object} Canvas image data.
*/
- self.getCanvasPixelData = function (canvas, x, y) {
+ self.getCanvasPixelData = function(canvas, x, y) {
var context = canvas.getContext('2d');
return context.getImageData(x, y, 1, 1)
.data;
@@ -203,7 +203,7 @@ export default (function (self) {
* the string is invalid
*/
// NOTE: Older Safari doesn't like Date.parse
- self.parseDateUTC = function (dateAsString) {
+ self.parseDateUTC = function(dateAsString) {
var dateTimeArr = dateAsString.split(/T/);
var yyyymmdd = dateTimeArr[0].split(/[\s-]+/);
@@ -233,7 +233,7 @@ export default (function (self) {
}
return date;
};
- self.appendAttributesForURL = function (item) {
+ self.appendAttributesForURL = function(item) {
if (lodashIsObject(item)) {
let part = item.id || '';
const attributes = [];
@@ -268,7 +268,7 @@ export default (function (self) {
* @return {Date} converted string as a non UTC date object, throws an exception if
* the string is invalid
*/
- self.parseDate = function (dateAsString) {
+ self.parseDate = function(dateAsString) {
var dateTimeArr = dateAsString.split(/T/);
var yyyymmdd = dateTimeArr[0].split(/[\s-]+/);
@@ -307,7 +307,7 @@ export default (function (self) {
*
* @see http://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393
*/
- self.getTextWidth = function (text, font) {
+ self.getTextWidth = function(text, font) {
// re-use canvas object for better performance
canvas = canvas || document.createElement('canvas');
var context = canvas.getContext('2d');
@@ -323,7 +323,7 @@ export default (function (self) {
* @param {Date} date {Date} the date to convert
* @return {string} Julian date string in the form of `YYYYDDD`
*/
- self.toJulianDate = function (date) {
+ self.toJulianDate = function(date) {
var jStart, jDate;
jStart = self.parseDateUTC(date.getUTCFullYear() + '-01-01');
jDate = '00' + (1 + Math.ceil((date.getTime() - jStart) / 86400000));
@@ -338,7 +338,7 @@ export default (function (self) {
* @param date {Date} the date to convert
* @return {string} ISO string in the form of ``YYYY-MM-DD``.
*/
- self.toISOStringDate = function (date) {
+ self.toISOStringDate = function(date) {
return date.toISOString()
.split('T')[0];
};
@@ -351,7 +351,7 @@ export default (function (self) {
* @param {Date} date the date to convert
* @return {string} ISO string in the form of `YYYY-MM-DDThh:mm:ssZ`.
*/
- self.toISOStringSeconds = function (date) {
+ self.toISOStringSeconds = function(date) {
return date.toISOString().split('.')[0] + 'Z';
};
@@ -363,7 +363,7 @@ export default (function (self) {
* @param {Date} date the date to convert
* @return {string} ISO string in the form of `YYYY-MM-DDThh:mmZ`.
*/
- self.toISOStringMinutes = function (date) {
+ self.toISOStringMinutes = function(date) {
const parts = date.toISOString().split(':');
return parts[0] + ':' + parts[1] + 'Z';
};
@@ -376,7 +376,7 @@ export default (function (self) {
* @param date {Date} the date to convert
* @return {string} ISO string in the form of HH:MM`.
*/
- self.toHourMinutes = function (date) {
+ self.toHourMinutes = function(date) {
var time = date.toISOString()
.split('T')[1];
var parts = time.split('.')[0].split(':');
@@ -391,7 +391,7 @@ export default (function (self) {
* @param time {Date} date
* @return {number} rounded date
*/
- self.roundTimeOneMinute = function (time) {
+ self.roundTimeOneMinute = function(time) {
var timeToReturn = new Date(time);
timeToReturn.setMilliseconds(Math.round(timeToReturn.getMilliseconds() / 1000) * 1000);
@@ -409,7 +409,7 @@ export default (function (self) {
* to zero.
* @return {Date} the date object
*/
- self.clearTimeUTC = function (date) {
+ self.clearTimeUTC = function(date) {
date.setUTCHours(0);
date.setUTCMinutes(0);
date.setUTCSeconds(0);
@@ -418,7 +418,7 @@ export default (function (self) {
return date;
};
- self.dateAdd = function (date, interval, amount) {
+ self.dateAdd = function(date, interval, amount) {
var month, maxDay, year;
var newDate = new Date(date);
switch (interval) {
@@ -461,7 +461,7 @@ export default (function (self) {
return i;
};
- self.daysInMonth = function (d) {
+ self.daysInMonth = function(d) {
var year;
var month;
if (d.getUTCFullYear) {
@@ -475,14 +475,14 @@ export default (function (self) {
return lastDay.getUTCDate();
};
- self.daysInYear = function (date) {
+ self.daysInYear = function(date) {
var jStart, jDate;
jStart = self.parseDateUTC(date.getUTCFullYear() + '-01-01');
jDate = '00' + (Math.ceil((date.getTime() - jStart) / 86400000) + 1);
return (jDate).substr((jDate.length) - 3);
};
- self.objectLength = function (obj) {
+ self.objectLength = function(obj) {
return Object.keys(obj)
.length;
};
@@ -495,7 +495,7 @@ export default (function (self) {
* @param date {Date} date object of which to determine week day
* @return {String} the full name of the day of the week
*/
- self.giveWeekDay = function (d) {
+ self.giveWeekDay = function(d) {
var day = [
'Sunday',
'Monday',
@@ -517,7 +517,7 @@ export default (function (self) {
* @param date {Date} date object of which to determine the Month name
* @return {String} the full name of the month
*/
- self.giveMonth = function (d) {
+ self.giveMonth = function(d) {
var month = [
'January',
'February',
@@ -536,7 +536,7 @@ export default (function (self) {
return month[d.getUTCMonth()];
};
- self.clamp = function (val, min, max) {
+ self.clamp = function(val, min, max) {
if (val < min) {
return min;
}
@@ -546,7 +546,7 @@ export default (function (self) {
return val;
};
- self.roll = function (val, min, max) {
+ self.roll = function(val, min, max) {
if (val < min) {
return max - (min - val) + 1;
}
@@ -556,15 +556,15 @@ export default (function (self) {
return val;
};
- self.minDate = function () {
+ self.minDate = function() {
return new Date(Date.UTC(1000, 0, 1, 0, 0));
};
- self.maxDate = function () {
+ self.maxDate = function() {
return new Date(Date.UTC(3000, 11, 30, 23, 59));
};
- self.rollRange = function (date, interval, minDate, maxDate) {
+ self.rollRange = function(date, interval, minDate, maxDate) {
var year = date.getUTCFullYear();
var month = date.getUTCMonth();
var first, last;
@@ -616,7 +616,7 @@ export default (function (self) {
};
};
- self.rollDate = function (date, interval, amount, minDate, maxDate) {
+ self.rollDate = function(date, interval, amount, minDate, maxDate) {
minDate = minDate || self.minDate();
maxDate = maxDate || self.maxDate();
var range = self.rollRange(date, interval, minDate, maxDate);
@@ -669,7 +669,7 @@ export default (function (self) {
* @return {String} string representation in the form of
* ``YYYYMMDDHHMMSSsss``
*/
- self.toCompactTimestamp = function (date) {
+ self.toCompactTimestamp = function(date) {
return date.toISOString()
.replace(/[-:TZ.]/g, '');
};
@@ -683,7 +683,7 @@ export default (function (self) {
* ``YYYYMMDDHHMMSSsss``.
* @return {Date} the converted date object.
*/
- self.fromCompactTimestamp = function (str) {
+ self.fromCompactTimestamp = function(str) {
var v = str.match(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{3})/);
if (lodashIsNull(v)) {
throw new Error('Invalid timestamp:' + str);
@@ -706,13 +706,13 @@ export default (function (self) {
* @static
* @return {Date} The current time or an overriden value.
*/
- var now = function () {
+ var now = function() {
return new Date();
};
self.now = now;
- self.resetNow = function () {
+ self.resetNow = function() {
self.now = now;
};
@@ -725,7 +725,7 @@ export default (function (self) {
* @return {Date} The current time with the UTC hours, minutes, and seconds
* fields set to zero or an overriden value.
*/
- self.today = function () {
+ self.today = function() {
return self.now();
};
@@ -741,7 +741,7 @@ export default (function (self) {
* @param {string} message Message to display to the end user.
* @param {Exception} cause The exception object that caused the error
*/
- self.error = function (message, cause) {
+ self.error = function(message, cause) {
wvui.error(message, cause);
};
@@ -755,16 +755,16 @@ export default (function (self) {
* @param {object*} messages Messages to display to the end user.
*/
self.warn = (console && console.warn && console.warn.bind)
- ? console.warn.bind(console) : function () {};
+ ? console.warn.bind(console) : function() {};
- self.hexToRGB = function (str) {
+ self.hexToRGB = function(str) {
return 'rgb(' +
parseInt(str.substring(0, 2), 16) + ',' +
parseInt(str.substring(2, 4), 16) + ',' +
parseInt(str.substring(4, 6), 16) + ')';
};
- self.hexToRGBA = function (str) {
+ self.hexToRGBA = function(str) {
return 'rgba(' +
parseInt(str.substring(0, 2), 16) + ',' +
parseInt(str.substring(2, 4), 16) + ',' +
@@ -772,15 +772,15 @@ export default (function (self) {
parseInt(str.substring(6, 8), 16) + ')';
};
- self.rgbaToHex = function (r, g, b) {
- function hex (c) {
+ self.rgbaToHex = function(r, g, b) {
+ function hex(c) {
var strHex = c.toString(16);
return strHex.length === 1 ? '0' + strHex : strHex;
}
return hex(r) + hex(g) + hex(b) + 'ff';
};
- self.hexColorDelta = function (hex1, hex2) {
+ self.hexColorDelta = function(hex1, hex2) {
var r1 = parseInt(hex1.substring(0, 2), 16);
var g1 = parseInt(hex1.substring(2, 4), 16);
var b1 = parseInt(hex1.substring(4, 6), 16);
@@ -817,7 +817,7 @@ export default (function (self) {
* @param {Object} [spec.options] options to pass to jscache on setItem.
*
*/
- self.ajaxCache = function (spec) {
+ self.ajaxCache = function(spec) {
spec = spec || {};
var size = spec.size || null;
var options = spec.options || {};
@@ -835,7 +835,7 @@ export default (function (self) {
* when the query returns, or resolves immedately if the results
* are cached.
*/
- submit: function (parameters) {
+ submit: function(parameters) {
var key = 'url=' + parameters.url;
if (parameters.data) {
key += '&query=' + $.param(parameters.data, true);
@@ -848,7 +848,7 @@ export default (function (self) {
.promise();
} else {
var promise = $.ajax(parameters);
- promise.done(function (results) {
+ promise.done(function(results) {
cache.setItem(key, results, options);
});
return promise;
@@ -873,8 +873,8 @@ export default (function (self) {
* @param {function} func the function to wrap
* @return the function wrapped in a try/catch block.
*/
- self.wrap = function (func) {
- return function () {
+ self.wrap = function(func) {
+ return function() {
try {
return func.apply(func, arguments);
} catch (error) {
@@ -891,14 +891,14 @@ export default (function (self) {
* @param {url} func the function to wrap
* @return {object} Promise
*/
- self.get = function (url) {
+ self.get = function(url) {
// Return a new promise.
- return new Promise(function (resolve, reject) {
+ return new Promise(function(resolve, reject) {
// Do the usual XHR stuff
var req = new XMLHttpRequest();
req.open('GET', url);
- req.onload = function () {
+ req.onload = function() {
// This is called even on 404 etc
// so check the status
if (req.status === 200) {
@@ -911,7 +911,7 @@ export default (function (self) {
}
};
// Handle network errors
- req.onerror = function () {
+ req.onerror = function() {
reject(Error('Network Error'));
};
// Make the request
@@ -920,20 +920,20 @@ export default (function (self) {
};
// FIXME: Should be replaced with $.when
- self.ajaxJoin = function (calls) {
+ self.ajaxJoin = function(calls) {
var completed = 0;
var result = {};
var deferred = $.Deferred();
- $.each(calls, function (index, call) {
- call.promise.done(function (data) {
+ $.each(calls, function(index, call) {
+ call.promise.done(function(data) {
result[call.item] = data;
completed += 1;
if (completed === calls.length) {
deferred.resolve(result);
}
})
- .fail(function (jqXHR, textStatus, errorThrown) {
+ .fail(function(jqXHR, textStatus, errorThrown) {
deferred.reject(jqXHR, textStatus, errorThrown);
});
});
@@ -970,7 +970,7 @@ export default (function (self) {
});
};
- self.metrics = function () {
+ self.metrics = function() {
if (window.ntptEventTag) {
ntptEventTag.apply(null, arguments);
} else {
@@ -1020,7 +1020,7 @@ export default (function (self) {
self.formatDMS = (value, type) => formatDegrees(value, type, true);
self.formatDM = (value, type) => formatDegrees(value, type, false);
- self.setCoordinateFormat = function (type) {
+ self.setCoordinateFormat = function(type) {
if (!browser.localStorage) return;
if (type !== 'latlon-dd' && type !== 'latlon-dms' && type !== 'latlon-dm') {
throw new Error('Invalid coordinate format: ' + type);
@@ -1028,12 +1028,12 @@ export default (function (self) {
localStorage.setItem('coordinateFormat', type);
};
- self.getCoordinateFormat = function () {
+ self.getCoordinateFormat = function() {
if (!browser.localStorage) return 'latlon-dd';
return localStorage.getItem('coordinateFormat') || 'latlon-dd';
};
- self.formatCoordinate = function (coord, format) {
+ self.formatCoordinate = function(coord, format) {
var type = format || self.getCoordinateFormat();
if (type === 'latlon-dms') {
return self.formatDMS(coord[1], 'latitude') + ', ' +
@@ -1051,7 +1051,7 @@ export default (function (self) {
// arguments array contains all args passed. String must be formatted
// so that first replacement starts with "{1}"
// usage example: wv.util.format("{1}{2}",'World','view')
- self.format = function () {
+ self.format = function() {
var formatted = arguments[0];
for (var i = 1; i < arguments.length; i++) {
var regexp = new RegExp('\\{' + i + '\\}', 'gi');
@@ -1060,7 +1060,7 @@ export default (function (self) {
return formatted;
};
- self.toArray = function (value) {
+ self.toArray = function(value) {
if (!value) {
return [];
}
@@ -1091,7 +1091,7 @@ export default (function (self) {
return numberOfMonths;
};
- self.dayDiff = function (startDate, endDate) {
+ self.dayDiff = function(startDate, endDate) {
var date1 = new Date(startDate);
var date2 = new Date(endDate);
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
@@ -1099,7 +1099,7 @@ export default (function (self) {
return dayDiff;
};
- self.minuteDiff = function (startDate, endDate) {
+ self.minuteDiff = function(startDate, endDate) {
var date1 = new Date(startDate);
var date2 = new Date(endDate);
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
@@ -1117,10 +1117,10 @@ export default (function (self) {
* If false, only return the dates from the range the current date falls in.
* @return {array} An array of dates with normalized timezones
*/
- self.datesinDateRanges = function (def, date, containRange) {
+ self.datesinDateRanges = function(def, date, containRange) {
var dateArray = [];
var currentDate = new Date(date.getTime());
- lodashEach(def.dateRanges, function (dateRange) {
+ lodashEach(def.dateRanges, function(dateRange) {
var yearDifference;
var monthDifference;
var dayDifference;
@@ -1237,7 +1237,7 @@ export default (function (self) {
* @param {array} dateArray An array of dates
* @return {object} The date object with normalized timeszone.
*/
- self.prevDateInDateRange = function (def, date, dateArray) {
+ self.prevDateInDateRange = function(def, date, dateArray) {
var currentDate = new Date(date.getTime());
if (!dateArray) return date;
if ((def.period === 'monthly' && (isFirstDayOfMonth(currentDate) || isLastDayOfMonth(currentDate))) ||