Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

replace data-ui with react component #1118

Benjamin King068a50c9bd10
diff --git a/web/js/data/ui.js b/web/js/data/ui.js
index eede5e216..b5d935596 100644
--- a/web/js/data/ui.js
+++ b/web/js/data/ui.js
@@ -29,194 +29,25 @@ export function dataUi(models, ui, config) {
self.selector = '#wv-data';
self.id = 'wv-data';
- var init = function () {
+ var init = function() {
model.events
.on('activate', onActivate)
.on('deactivate', onDeactivate)
- .on('productSelect', onProductSelect)
- .on('layerUpdate', onLayerUpdate)
.on('query', onQuery)
.on('queryResults', onQueryResults)
.on('queryCancel', onQueryCancel)
.on('queryError', onQueryError)
- .on('queryTimeout', onQueryTimeout)
- .on('granuleSelect', updateSelection)
- .on('granuleUnselect', updateSelection);
- $(window)
- .resize(sizeDownloadTab);
+ .on('queryTimeout', onQueryTimeout);
- ui.sidebar.events.on('selectTab', function (tab) {
+ ui.sidebar.events.on('selectTab', function(tab) {
if (tab === 'download') {
- sizeDownloadTab();
model.activate();
} else {
model.deactivate();
}
});
};
-
- self.render = function () {
- var $footer = $('<footer />');
- var $container = $(self.selector).empty();
- var $actionButton = $('<button />', {
- id: 'wv-data-download-button',
- class: 'action',
- type: 'button',
- value: '',
- click: showDownloadList,
- text: 'No Data Selected'
- });
- var $wrapper = $('<div />', {
- class: 'wv-datalist sidebar-panel content'
- });
- var $list = $('<div />', {
- id: 'wv-datacontent'
- });
- $actionButton.button();
- $footer.append($actionButton);
- $wrapper.append($list);
- $container.append($wrapper);
- $container.append($footer);
-
- self.refresh();
- };
-
- self.refresh = function () {
- var $content = $('#wv-datacontent');
-
- $content = $('#wv-datacontent')
- .empty();
- var data = model.groupByProducts();
- $.each(data, function (key, value) {
- refreshProduct($content, key, value);
- });
-
- $('.dl-group[value="__NO_PRODUCT"] h3 span')
- .click(function () {
- showUnavailableReason();
- });
-
- sizeDownloadTab();
- };
-
- var refreshProduct = function ($content, key, value) {
- var title = value.title;
- var $header = $('<h3></h3>')
- .addClass('head')
- .html(title);
-
- // FIXME: Why is this needed?
- var $productSelector;
- if (!value.notSelectable) {
- var $selectedCount = $('<i></i>')
- .attr('id', key + 'dynamictext')
- .addClass('dynamic')
- .html('0 selected');
- $productSelector = $('<input type=\'radio\'></input>')
- .attr('value', key)
- .attr('data-product', key);
-
- $header.prepend($productSelector)
- .append($selectedCount);
- }
- if (model.selectedProduct === key) {
- $productSelector.each(function () {
- this.checked = true;
- });
- }
- var $contentDlGroup = $('<div class=\'dl-group\'></div>')
- .attr('value', key)
- .attr('data-product', key)
- .click(function () {
- model.selectProduct($(this)
- .find('input')
- .attr('data-product'));
- $('.dl-group')
- .removeClass('dl-group-selected');
- $(this)
- .addClass('dl-group-selected');
- $('.dl-group input')
- .each(function () {
- this.checked = false;
- });
- $(this)
- .find('input')
- .each(function () {
- this.checked = true;
- });
- })
- .append($header);
-
- $content.append($contentDlGroup);
-
- var $products = $('<ul></ul>')
- .attr('id', self.id + key)
- .addClass(self.id + 'category');
-
- $.each(value.items, function (index, item) {
- refreshLayers($products, key, value, item);
- });
- $contentDlGroup.append($products);
- };
-
- var refreshLayers = function ($container, key, value, layer) {
- var $item = $('<li></li>')
- .attr('id', self.id + key + util.encodeId(layer.value))
- .addClass('item')
- .addClass('item-static');
- $item.append('<h4>' + layer.label + '</h4>');
- $item.append('<p>' + layer.sublabel + '</p>');
- $container.append($item);
- };
-
- var productsIsOverflow = false;
- var sizeDownloadTab = function () {
- var $tabPanel = $('#wv-data');
- var $tabFooter = $tabPanel.find('footer');
- var footerIsVisible = $tabFooter.css('display') === 'block';
- var windowHeight = $(window).outerHeight(true);
- var tabBarHeight = $('ul#productsHolder-tabs').outerHeight(true);
- var footerHeight = $tabFooter.outerHeight(true);
- var distanceFromTop = $('#productsHolder').offset().top;
-
- var maxHeight = windowHeight - tabBarHeight - distanceFromTop;
- var innerMaxHeight = windowHeight - tabBarHeight - distanceFromTop - footerHeight;
-
- if (footerIsVisible) {
- $tabPanel.css('padding-bottom', footerHeight);
- innerMaxHeight = innerMaxHeight - footerHeight;
- } else {
- $tabPanel.css('padding-bottom', 0);
- }
-
- if (!util.browser.small) {
- maxHeight = maxHeight - 10 - 5;
- innerMaxHeight = innerMaxHeight - footerHeight - 10 - 5;
- }
- $tabPanel.css('max-height', maxHeight);
-
- var childrenHeight = $('#wv-datacontent').outerHeight(true);
-
- // https://github.com/utatti/perfect-scrollbar/tree/0.8.1#before-using-perfect-scrollbar
- $('.wv-datalist').css('position', 'relative');
-
- if ((innerMaxHeight <= childrenHeight)) {
- $('.wv-datalist').css('height', innerMaxHeight).css('padding-right', '10px');
- if (productsIsOverflow) {
- $('.wv-datalist').perfectScrollbar('update');
- } else {
- $('.wv-datalist').perfectScrollbar();
- productsIsOverflow = true;
- }
- } else {
- $('.wv-datalist').css('height', '').css('padding-right', '');
- if (productsIsOverflow) {
- $('.wv-datalist').perfectScrollbar('destroy');
- productsIsOverflow = false;
- }
- }
- };
- self.onViewChange = function () {
+ self.onViewChange = function() {
var map = ui.map.selected;
if (!model.active || queryActive || !lastResults) {
@@ -227,14 +58,12 @@ export function dataUi(models, ui, config) {
}
var hasCentroids = false;
var inView = false;
- var extent = map.getView()
- .calculateExtent(map.getSize());
+ var extent = map.getView().calculateExtent(map.getSize());
var crs = models.proj.selected.crs;
- lodashEach(lastResults.granules, function (granule) {
+ lodashEach(lastResults.granules, function(granule) {
if (granule.centroid && granule.centroid[crs]) {
hasCentroids = true;
- if (olExtent.intersects(extent,
- granule.centroid[crs].getExtent())) {
+ if (olExtent.intersects(extent, granule.centroid[crs].getExtent())) {
inView = true;
return true;
}
@@ -242,21 +71,17 @@ export function dataUi(models, ui, config) {
});
uiIndicator.hide(indicators.noneInView);
if (hasCentroids && !inView) {
- indicators.noneInView =
- uiIndicator.show('Zoom out or move map');
+ indicators.noneInView = uiIndicator.show('Zoom out or move map');
}
};
- var onActivate = function () {
- ui.sidebar.selectTab('download');
+ var onActivate = function() {
if (!mapController) {
mapController = dataMap(model, maps, config);
}
- onLayerUpdate();
- updateSelection();
};
- var onDeactivate = function () {
+ var onDeactivate = function() {
uiIndicator.hide(indicators);
if (selectionListPanel) {
selectionListPanel.hide();
@@ -267,19 +92,7 @@ export function dataUi(models, ui, config) {
mapController.dispose();
};
- var onProductSelect = function (product) {
- $(self.selector + ' input[value=\'' + product + '\']')
- .prop('checked', 'true');
- };
-
- var onLayerUpdate = function () {
- if (!model.active) {
- return;
- }
- self.refresh();
- };
-
- var onQuery = function () {
+ var onQuery = function() {
queryActive = true;
indicators.query = uiIndicator.searching(indicators);
if (selectionListPanel) {
@@ -290,7 +103,7 @@ export function dataUi(models, ui, config) {
}
};
- var onQueryResults = function (results) {
+ var onQueryResults = function(results) {
if (selectionListPanel) {
selectionListPanel.hide();
selectionListPanel = null;
@@ -304,76 +117,44 @@ export function dataUi(models, ui, config) {
hasResults = false;
}
if (results.meta.showList && hasResults) {
- selectionListPanel =
- dataUiSelectionListPanel(model, results);
+ selectionListPanel = dataUiSelectionListPanel(model, results);
selectionListPanel.show();
}
- updateSelection();
};
- var onQueryCancel = function () {
+ var onQueryCancel = function() {
queryActive = false;
uiIndicator.hide(indicators);
};
- var onQueryError = function (status, error) {
+ var onQueryError = function(status, error) {
queryActive = false;
uiIndicator.hide(indicators);
if (status !== 'abort') {
console.error('Unable to search', status, error);
- wvui.notify('Unable to search at this time.<br/><br/>Please try ' +
- 'again later.');
+ wvui.notify(
+ 'Unable to search at this time.<br/><br/>Please try ' + 'again later.'
+ );
}
};
- var onQueryTimeout = function () {
+ var onQueryTimeout = function() {
queryActive = false;
uiIndicator.hide(indicators);
wvui.notify(
'No results received yet. This may be due to a ' +
- 'connectivity issue. Please try again later.'
+ 'connectivity issue. Please try again later.'
);
};
- var updateSelection = function () {
- var $button = $('#wv-data-download-button');
- var selected = lodashSize(model.selectedGranules);
- if (selected > 0) {
- $button.button('enable');
- var totalSize = model.getSelectionSize();
- if (totalSize) {
- var formattedSize = Math.round(totalSize * 100) / 100;
- $button.find('.ui-button-text')
- .html('Download Data (' + formattedSize + ' MB)');
- } else {
- $button.find('.ui-button-text')
- .html('Download Selected Data');
- }
- } else {
- $button.button('disable');
- $button.find('.ui-button-text')
- .html('No Data Selected');
- }
-
- var counts = model.getSelectionCounts();
- $.each(counts, function (productId, count) {
- $('#' + productId + 'dynamictext')
- .html('' + count + ' selected');
- });
- if (downloadListPanel && downloadListPanel.visible()) {
- downloadListPanel.refresh();
- }
- };
-
- var showDownloadList = function () {
+ self.showDownloadList = function() {
GoogleAnalytics.event('Data Download', 'Click', 'Download Button');
if (selectionListPanel) {
selectionListPanel.setVisible(false);
}
if (!downloadListPanel) {
- downloadListPanel =
- dataUiDownloadListPanel(config, model);
- downloadListPanel.events.on('close', function () {
+ downloadListPanel = dataUiDownloadListPanel(config, model);
+ downloadListPanel.events.on('close', function() {
if (selectionListPanel) {
selectionListPanel.setVisible(true);
}
@@ -382,38 +163,39 @@ export function dataUi(models, ui, config) {
downloadListPanel.show();
};
- var showUnavailableReason = function () {
- var headerMsg = '<h3 class=\'wv-data-unavailable-header\'>Why are these layers not available for downloading?</h3>';
- var bodyMsg = 'Some layers in Worldview do not have corresponding source data products available for download. These include National Boundaries, Orbit Tracks, Earth at Night, and MODIS Corrected Reflectance products.<br><br>For a downloadable product similar to MODIS Corrected Reflectance, please try the MODIS Land Surface Reflectance layers available in Worldview. If you would like to generate MODIS Corrected Reflectance imagery yourself, please see the following document: <a href="https://earthdata.nasa.gov/sites/default/files/field/document/MODIS_True_Color.pdf" target="_blank">https://earthdata.nasa.gov/sites/default/files/field/document/MODIS_True_Color.pdf</a><br><br>If you would like to download only an image, please use the "camera" icon in the upper right.<br><br> Data download will not work for "Terra and Aqua" Fires, select Terra only Fires and/or Aqua only Fires to download the associated data files.';
+ self.showUnavailableReason = function() {
+ var headerMsg =
+ "<h3 class='wv-data-unavailable-header'>Why are these layers not available for downloading?</h3>";
+ var bodyMsg =
+ 'Some layers in Worldview do not have corresponding source data products available for download. These include National Boundaries, Orbit Tracks, Earth at Night, and MODIS Corrected Reflectance products.<br><br>For a downloadable product similar to MODIS Corrected Reflectance, please try the MODIS Land Surface Reflectance layers available in Worldview. If you would like to generate MODIS Corrected Reflectance imagery yourself, please see the following document: <a href="https://earthdata.nasa.gov/sites/default/files/field/document/MODIS_True_Color.pdf" target="_blank">https://earthdata.nasa.gov/sites/default/files/field/document/MODIS_True_Color.pdf</a><br><br>If you would like to download only an image, please use the "camera" icon in the upper right.<br><br> Data download will not work for "Terra and Aqua" Fires, select Terra only Fires and/or Aqua only Fires to download the associated data files.';
wvui.notify(headerMsg + bodyMsg, 'Notice', 600);
};
init();
return self;
-};
+}
-var dataUiBulkDownloadPage = (function () {
+var dataUiBulkDownloadPage = (function() {
var ns = {};
var pages = {
wget: 'pages/wget.html',
curl: 'pages/curl.html'
};
- ns.show = function (selection, type) {
+ ns.show = function(selection, type) {
var nonce = Date.now();
- var page = window.open(pages[type] + '?v=' + nonce,
- 'Worldview_' + nonce);
+ var page = window.open(pages[type] + '?v=' + nonce, 'Worldview_' + nonce);
var loaded = false;
- page.onload = function () {
+ page.onload = function() {
if (!loaded) {
fillPage(page, selection, type);
loaded = true;
}
};
var checkCount = 0;
- var timer = setInterval(function () {
+ var timer = setInterval(function() {
checkCount++;
if (loaded) {
clearInterval(timer);
@@ -430,28 +212,28 @@ var dataUiBulkDownloadPage = (function () {
}, 100);
};
- var fillPage = function (page, selection, type) {
+ var fillPage = function(page, selection, type) {
var downloadLinks = [];
var hosts = {};
var indirectLinks = [];
- $.each(selection, function (index, product) {
- $.each(product.list, function (index2, granule) {
+ $.each(selection, function(index, product) {
+ $.each(product.list, function(index2, granule) {
var netrc = '';
if (granule.urs) {
netrc = '--netrc ';
}
- $.each(granule.links, function (index2, link) {
+ $.each(granule.links, function(index2, link) {
if (!link.data) {
return;
}
if (product.noBulkDownload) {
- indirectLinks.push('<li><a href=\'' + link.href + '\'>' +
- link.href + '</a></li>');
+ indirectLinks.push(
+ "<li><a href='" + link.href + "'>" + link.href + '</a></li>'
+ );
return;
}
if (type === 'curl') {
- downloadLinks.push('curl --remote-name ' + netrc +
- link.href);
+ downloadLinks.push('curl --remote-name ' + netrc + link.href);
} else {
downloadLinks.push(link.href);
}
@@ -472,36 +254,34 @@ var dataUiBulkDownloadPage = (function () {
var netrcEntries = [];
var hostnames = [];
- $.each(hosts, function (host) {
- netrcEntries.push('machine ' + host + ' login URS_USER ' +
- 'password URS_PASSWORD');
+ $.each(hosts, function(host) {
+ netrcEntries.push(
+ 'machine ' + host + ' login URS_USER ' + 'password URS_PASSWORD'
+ );
hostnames.push(host);
});
if (netrcEntries.length > 0) {
- page.document.getElementById('netrc')
- .innerHTML =
+ page.document.getElementById('netrc').innerHTML =
'<pre>' + netrcEntries.join('\n') + '</pre>';
- page.document.getElementById('bulk-password-notice')
- .style.display = 'block';
- page.document.getElementById('netrc-instructions')
- .style.display = 'block';
- var instructions =
- page.document.getElementById('fdm-password-instructions');
+ page.document.getElementById('bulk-password-notice').style.display =
+ 'block';
+ page.document.getElementById('netrc-instructions').style.display =
+ 'block';
+ var instructions = page.document.getElementById(
+ 'fdm-password-instructions'
+ );
if (instructions) {
instructions.style.display = 'block';
}
- var machineNames =
- page.document.getElementById('fdm-machine-names');
+ var machineNames = page.document.getElementById('fdm-machine-names');
if (machineNames) {
- machineNames.innerHTML = '<pre>' + hostnames.join('\n') +
- '</pre>';
+ machineNames.innerHTML = '<pre>' + hostnames.join('\n') + '</pre>';
}
}
if (indirectLinks.length > 0) {
- page.document.getElementById('indirect-instructions')
- .style.display = 'block';
- page.document.getElementById('indirect')
- .innerHTML =
+ page.document.getElementById('indirect-instructions').style.display =
+ 'block';
+ page.document.getElementById('indirect').innerHTML =
'<ul>' + indirectLinks.join('\n') + '</ul>';
}
return true;
@@ -510,15 +290,15 @@ var dataUiBulkDownloadPage = (function () {
return ns;
})();
-var dataUiDownloadListPanel = function (config, model) {
+var dataUiDownloadListPanel = function(config, model) {
var NOTICE =
- '<div id=\'wv-data-selection-notice\'>' +
- '<i class=\'icon fa fa-info-circle fa-3x\'></i>' +
- '<p class=\'text\'>' +
+ "<div id='wv-data-selection-notice'>" +
+ "<i class='icon fa fa-info-circle fa-3x'></i>" +
+ "<p class='text'>" +
'Some items you have selected require a profile with ' +
'Earthdata Login to download. ' +
'It is simple and free to sign up! ' +
- '<a href=\'https://urs.earthdata.nasa.gov/users/new\' target=\'urs\'>' +
+ "<a href='https://urs.earthdata.nasa.gov/users/new' target='urs'>" +
'Click to register for a profile.</a>' +
'</p>' +
'</div>';
@@ -530,9 +310,8 @@ var dataUiDownloadListPanel = function (config, model) {
self.events = util.events();
- self.show = function () {
- $dialog = wvui.getDialog()
- .attr('id', 'wv-data-selection');
+ self.show = function() {
+ $dialog = wvui.getDialog().attr('id', 'wv-data-selection');
$dialog.dialog({
title: 'Download Links',
@@ -546,62 +325,51 @@ var dataUiDownloadListPanel = function (config, model) {
.addClass('ui-widget-content')
.addClass('ui-helper-clearfix')
.html(bulkDownloadText());
- $('#wv-data-selection')
- .after($bottomPane);
- $('.ui-dialog .ui-dialog-titlebar-close')
- .attr('tabindex', -1);
+ $('#wv-data-selection').after($bottomPane);
+ $('.ui-dialog .ui-dialog-titlebar-close').attr('tabindex', -1);
$dialog.dialog('open');
- $('a.wget')
- .click(showWgetPage);
- $('a.curl')
- .click(showCurlPage);
-
- $dialog.find('.dd-collapse')
- .accordion({
- collapsible: true,
- active: false,
- icons: {
- header: 'fa fa-caret-right fa-fw',
- activeHeader: 'fa fa-caret-down fa-fw'
- }
- });
- $dialog.on('dialogclose', function () {
+ $('a.wget').click(showWgetPage);
+ $('a.curl').click(showCurlPage);
+
+ $dialog.find('.dd-collapse').accordion({
+ collapsible: true,
+ active: false,
+ icons: {
+ header: 'fa fa-caret-right fa-fw',
+ activeHeader: 'fa fa-caret-down fa-fw'
+ }
+ });
+ $dialog.on('dialogclose', function() {
self.events.trigger('close');
});
self.refresh();
};
- self.refresh = function () {
+ self.refresh = function() {
selection = reformatSelection();
- $('#wv-data-selection')
- .html(bodyText(selection));
- var bulkVisible = isBulkDownloadable() &&
- lodashSize(model.selectedGranules) !== 0;
+ $('#wv-data-selection').html(bodyText(selection));
+ var bulkVisible =
+ isBulkDownloadable() && lodashSize(model.selectedGranules) !== 0;
if (bulkVisible) {
- $('wv-data-bulk-download-links')
- .show();
+ $('wv-data-bulk-download-links').show();
} else {
- $('wv-data-bulk-download-links')
- .hide();
+ $('wv-data-bulk-download-links').hide();
}
- $('#wv-data-selection .remove')
- .click(removeGranule);
- $('#wv-data-selection tr')
- .on('mouseenter', onHoverOver);
- $('#wv-data-selection tr')
- .on('mouseleave', onHoverOut);
+ $('#wv-data-selection .remove').click(removeGranule);
+ $('#wv-data-selection tr').on('mouseenter', onHoverOver);
+ $('#wv-data-selection tr').on('mouseleave', onHoverOut);
};
- self.hide = function () {
+ self.hide = function() {
var $d = $('.ui-dialog');
if ($d.length !== 0) {
$d.hide();
}
};
- self.visible = function () {
+ self.visible = function() {
var $d = $('.ui-dialog');
if ($d.length !== 0) {
return $d.is(':visible');
@@ -609,11 +377,11 @@ var dataUiDownloadListPanel = function (config, model) {
return false;
};
- var reformatSelection = function () {
+ var reformatSelection = function() {
var selection = {};
urs = false;
- $.each(model.selectedGranules, function (key, granule) {
+ $.each(model.selectedGranules, function(key, granule) {
if (granule.urs) {
urs = true;
}
@@ -634,21 +402,23 @@ var dataUiDownloadListPanel = function (config, model) {
// For each link that looks like metadata, see if that link is
// repeated in all granules for that product. If so, we want to
// bump that up to product level instead of at the granule level.
- $.each(granule.links, function (index, link) {
+ $.each(granule.links, function(index, link) {
// Formerly relied on metadata being correctly marked as data
// via the cmr.REL_DATA constant; unfortunately this wasn't
// the case in practice so the following workaround was
// implemented to check the link's file extension to see if
// it looks like a data file
- var hrefExt = link.href.toLowerCase()
+ var hrefExt = link.href
+ .toLowerCase()
.split('.')
.slice(-1);
if (hrefExt && hrefExt.length > 0) {
hrefExt = hrefExt[0];
}
- if ((DATA_EXTS.indexOf(hrefExt) === -1 &&
- link.rel !== REL_BROWSE) ||
- link.rel === REL_METADATA) {
+ if (
+ (DATA_EXTS.indexOf(hrefExt) === -1 && link.rel !== REL_BROWSE) ||
+ link.rel === REL_METADATA
+ ) {
if (!product.counts[link.href]) {
product.counts[link.href] = 1;
} else {
@@ -658,28 +428,28 @@ var dataUiDownloadListPanel = function (config, model) {
});
});
- $.each(selection, function (key, product) {
+ $.each(selection, function(key, product) {
product.links = [];
product.list = [];
// Check the first granule, and populate product level links
// where the count equals the number of granules
var granule = product.granules[0];
- $.each(granule.links, function (index, link) {
+ $.each(granule.links, function(index, link) {
var count = product.counts[link.href];
if (count % product.granules.length === 0) {
product.links.push(reformatLink(link));
}
});
- $.each(product.granules, function (index, granule) {
+ $.each(product.granules, function(index, granule) {
var item = {
id: granule.id,
label: granule.downloadLabel || granule.label,
links: [],
urs: granule.urs
};
- $.each(granule.links, function (index, link) {
+ $.each(granule.links, function(index, link) {
// Skip this link if now at the product level
var count = product.counts[link.href];
if (count % product.granules.length === 0) {
@@ -693,7 +463,7 @@ var dataUiDownloadListPanel = function (config, model) {
});
product.list.push(item);
});
- product.list.sort(function (a, b) {
+ product.list.sort(function(a, b) {
if (a.label > b.label) {
return 1;
}
@@ -707,9 +477,9 @@ var dataUiDownloadListPanel = function (config, model) {
return selection;
};
- var isBulkDownloadable = function () {
+ var isBulkDownloadable = function() {
var result = false;
- $.each(selection, function (index, product) {
+ $.each(selection, function(index, product) {
if (!product.noBulkDownload) {
result = true;
}
@@ -717,12 +487,11 @@ var dataUiDownloadListPanel = function (config, model) {
return result;
};
- var reformatLink = function (link) {
+ var reformatLink = function(link) {
// For title, take it if found, otherwise, use the basename of the URI
var titleVal = link.title;
if (!link.title) {
- titleVal = link.href.split('/')
- .slice(-1);
+ titleVal = link.href.split('/').slice(-1);
// Handle special case where link is a directory which ends with /
if (titleVal && titleVal.length && titleVal[0] === '') {
@@ -733,63 +502,71 @@ var dataUiDownloadListPanel = function (config, model) {
return {
href: link.href,
title: titleVal,
- data: (link.rel === REL_DATA)
+ data: link.rel === REL_DATA
};
};
- var linksText = function (links) {
+ var linksText = function(links) {
var elements = [];
elements.push('<ul>');
- $.each(links, function (index, link) {
+ $.each(links, function(index, link) {
elements.push(
- '<li class=\'link\'><a href=\'' + link.href + '\' target=\'_blank\'>' +
- link.title + '</a></li>');
+ "<li class='link'><a href='" +
+ link.href +
+ "' target='_blank'>" +
+ link.title +
+ '</a></li>'
+ );
});
elements.push('</ul>');
return elements.join('\n');
};
- var granuleText = function (product, granule) {
+ var granuleText = function(product, granule) {
var elements;
if (product.name !== granule.label) {
elements = [
- '<tr data-granule=\'' + granule.id + '\'>',
- '<td><input type=\'button\' class=\'remove\' ' +
- 'data-granule=\'' + granule.id + '\' ' +
- 'value=\'X\'></input></td>',
+ "<tr data-granule='" + granule.id + "'>",
+ "<td><input type='button' class='remove' " +
+ "data-granule='" +
+ granule.id +
+ "' " +
+ "value='X'></input></td>",
'<td><nobr><ul><li>' + granule.label + '</li></ul></nobr></td>',
- '<td class=\'wv-data-granule-link\'>' + linksText(granule.links) + '</td>',
+ "<td class='wv-data-granule-link'>" +
+ linksText(granule.links) +
+ '</td>',
'</tr>'
];
} else {
elements = [
- '<tr data-granule=\'' + granule.id + '\'>',
- '<td><input type=\'button\' class=\'remove\' ' +
- 'data-granule=\'' + granule.id + '\' ' +
- 'value=\'X\'></input></td>',
- '<td colspan=\'2\'>' + linksText(granule.links) + '</td>',
+ "<tr data-granule='" + granule.id + "'>",
+ "<td><input type='button' class='remove' " +
+ "data-granule='" +
+ granule.id +
+ "' " +
+ "value='X'></input></td>",
+ "<td colspan='2'>" + linksText(granule.links) + '</td>',
'</tr>'
];
}
return elements.join('\n');
};
- var productText = function (product) {
- var elements = [
- '<h3>' + product.name + '</h3>'
- ];
+ var productText = function(product) {
+ var elements = ['<h3>' + product.name + '</h3>'];
elements.push('<h5>Selected Data</h5>');
elements.push('<table>');
- $.each(product.list, function (index, item) {
+ $.each(product.list, function(index, item) {
elements.push(granuleText(product, item));
});
elements.push('</table>');
if (product.links && product.links.length > 0) {
elements.push('<h5>Data Collection Information</h5>');
- elements.push('<div class=\'product\'>');
+ elements.push("<div class='product'>");
elements.push(linksText(product.links));
elements.push('</div>');
}
@@ -797,7 +574,7 @@ var dataUiDownloadListPanel = function (config, model) {
return elements.join('\n');
};
- var bodyText = function () {
+ var bodyText = function() {
if (lodashSize(model.selectedGranules) === 0) {
return '<br/><h3>Selection Empty</h3>';
}
@@ -806,7 +583,7 @@ var dataUiDownloadListPanel = function (config, model) {
elements.push(NOTICE);
}
var products = [];
- $.each(selection, function (key, product) {
+ $.each(selection, function(key, product) {
products.push(productText(product));
});
elements.push(products.join('<br/><br/><br/>'));
@@ -814,15 +591,15 @@ var dataUiDownloadListPanel = function (config, model) {
return text;
};
- var bulkDownloadText = function () {
+ var bulkDownloadText = function() {
var bulk =
- '<div class=\'bulk dd-collapse\'>' +
+ "<div class='bulk dd-collapse'>" +
'<h5>Bulk Download</h5>' +
- '<ul class=\'BulkDownload\'>' +
- '<li><a class=\'wget\' href=\'#\'>List of Links</a>: ' +
+ "<ul class='BulkDownload'>" +
+ "<li><a class='wget' href='#'>List of Links</a>: " +
'for wget or download managers that accept a list of ' +
'URLs</li>' +
- '<li><a class=\'curl\' href=\'#\'>List of cURL Commands</a>: ' +
+ "<li><a class='curl' href='#'>List of cURL Commands</a>: " +
'can be copied and pasted to ' +
'a terminal window to download using cURL.</li>' +
'</ul>' +
@@ -830,44 +607,47 @@ var dataUiDownloadListPanel = function (config, model) {
return bulk;
};
- var showWgetPage = function () {
+ var showWgetPage = function() {
dataUiBulkDownloadPage.show(selection, 'wget');
};
- var showCurlPage = function () {
+ var showCurlPage = function() {
dataUiBulkDownloadPage.show(selection, 'curl');
};
- var removeGranule = function () {
- var id = $(this)
- .attr('data-granule');
+ var removeGranule = function() {
+ var id = $(this).attr('data-granule');
model.unselectGranule(model.selectedGranules[id]);
onHoverOut.apply(this);
};
- var onHoverOver = function () {
- model.events.trigger('hoverOver',
- model.selectedGranules[$(this).attr('data-granule')]);
+ var onHoverOver = function() {
+ model.events.trigger(
+ 'hoverOver',
+ model.selectedGranules[$(this).attr('data-granule')]
+ );
};
- var onHoverOut = function () {
- model.events.trigger('hoverOut',
- model.selectedGranules[$(this).attr('data-granule')]);
+ var onHoverOut = function() {
+ model.events.trigger(
+ 'hoverOut',
+ model.selectedGranules[$(this).attr('data-granule')]
+ );
};
return self;
};
-var dataUiSelectionListPanel = function (model, results) {
+var dataUiSelectionListPanel = function(model, results) {
var self = {};
var granules = {};
var $dialog;
- var init = function () {
+ var init = function() {
model.events.on('granuleUnselect', onGranuleUnselect);
};
- self.show = function () {
+ self.show = function() {
$dialog = wvui.getDialog('wv-data-list');
$dialog
.attr('id', 'wv-data-list')
@@ -877,24 +657,22 @@ var dataUiSelectionListPanel = function (model, results) {
width: 400,
height: 400
});
- $('button.ui-dialog-titlebar-close')
- .hide();
+ $('button.ui-dialog-titlebar-close').hide();
- $.each(results.granules, function (index, granule) {
+ $.each(results.granules, function(index, granule) {
granules[granule.id] = granule;
});
- $('#wv-data-list input')
- .on('click', toggleSelection);
+ $('#wv-data-list input').on('click', toggleSelection);
};
- self.hide = function () {
+ self.hide = function() {
var $d = $('.ui-dialog');
if ($d.length !== 0) {
$d.hide();
}
};
- self.visible = function () {
+ self.visible = function() {
var $d = $('.ui-dialog');
if ($d.length !== 0) {
return $d.is(':visible');
@@ -902,7 +680,7 @@ var dataUiSelectionListPanel = function (model, results) {
return false;
};
- self.setVisible = function (value) {
+ self.setVisible = function(value) {
if (!value) {
self.hide();
} else {
@@ -910,40 +688,38 @@ var dataUiSelectionListPanel = function (model, results) {
}
};
- var resultsText = function () {
+ var resultsText = function() {
var elements = [];
- $.each(results.granules, function (index, granule) {
- var selected = model.isSelected(granule) ? 'checked=\'true\'' : '';
+ $.each(results.granules, function(index, granule) {
+ var selected = model.isSelected(granule) ? "checked='true'" : '';
elements.push(
'<tr>' +
- '<td>' +
- '<input type=\'checkbox\' value=\'' + granule.id + '\' ' +
- selected + '>' +
- '</td>' +
- '<td class=\'label\'>' + granule.label + '</td>' +
- '</tr>'
+ '<td>' +
+ "<input type='checkbox' value='" +
+ granule.id +
+ "' " +
+ selected +
+ '>' +
+ '</td>' +
+ "<td class='label'>" +
+ granule.label +
+ '</td>' +
+ '</tr>'
);
});
var text = elements.join('\n');
return text;
};
- var bodyText = function () {
- var elements = [
- '<div\'>',
- '<table>',
- resultsText(),
- '</table>',
- '</div>'
- ];
+ var bodyText = function() {
+ var elements = ["<div'>", '<table>', resultsText(), '</table>', '</div>'];
var text = elements.join('\n') + '<br/>';
return text;
};
- var toggleSelection = function () {
+ var toggleSelection = function() {
var granule = granules[$(this).attr('value')];
- var selected = $(this)
- .prop('checked');
+ var selected = $(this).prop('checked');
if (selected) {
model.selectGranule(granule);
} else {
@@ -951,9 +727,8 @@ var dataUiSelectionListPanel = function (model, results) {
}
};
- var onGranuleUnselect = function (granule) {
- $('#wv-data-list input[value=\'' + granule.id + '\']')
- .removeAttr('checked');
+ var onGranuleUnselect = function(granule) {
+ $("#wv-data-list input[value='" + granule.id + "']").removeAttr('checked');
};
init();