Interactive interface for browsing global, full-resolution satellite imagery
WV-553: wget now works
Mike McGann92e70dc8c65f
diff --git a/src/js/Worldview/DataDownload/WgetPage.js b/src/js/Worldview/DataDownload/WgetPage.jsindex 3693ab550..1e82f8202 100644--- a/src/js/Worldview/DataDownload/WgetPage.js+++ b/src/js/Worldview/DataDownload/WgetPage.js@@ -15,114 +15,16 @@ Worldview.DataDownload.WgetPage = (function() {var ns = {};ns.show = function(selection) {- var text = window.open('', 'Worldview_' + new Date());- text.document.write("<html>");- writeHeader(text.document);- writePreamble(text.document);- $.each(selection, function(key, product) {- writeProduct(text.document, product);-+ var storage = {};+ $.each(selection, function(name, product) {+ storage[name] = {+ list: product.list,+ name: product.name,+ noBulkDownload: product.noBulkDownload || false+ };});- text.document.write("</div></body></html>");- text.document.close();- };-- var writeHeader = function(doc) {- doc.write(- "<header>" +- "<title>wget.html</title>" +-- "<style>" +- "body { " +- "background-color: rgb(25, 28, 32);" +- "}" +- "h3 { " +- "margin-top: 0;" +- "}" +- "h4 { " +- "margin-bottom: 0;" +- "}" +- "#page { " +- "background-color: #ffffff;" +- "margin: 20px; " +- "padding: 20px; " +- "border-radius: 5px; " +- "}" +- "pre {" +- "background-color: #eeeeee;" +- "padding: 5px;" +- "border: 1px dashed #dddddd;" +- "}" +- ".label {" +- "margin-top: 10px; " +- "font-style: italic;" +- "color: #808080;" +- "}" +- "</style>" +- "</header>"- );- };-- var writePreamble = function(doc) {- doc.write(- "<body>" +- "<div id='page'>" +- "<div id='instructions'>" +- "<h3>Using <code>wget</code> to Bulk Download Your Data</h3>" +- "1) Save this HTML page as <code>wget.html</code> to your " +- "local computer.<br>" +- "2) Execute the following command to download all of your " +- "requested files:" +- "<pre>" +- "wget --input-file=wget.html --force-html" +- "</pre><br>" +- "<b>Note</b>: if User Registration System (URS) credentials are required, " +- "create a file (only readable by you) called " +- "<code>urs.credentials</code> with the following:" +- "<pre>" +- "user=<i>urs_user</i>\n" +- "password=<i>urs_password</i>" +- "</pre>" +- "where <i>urs_user</i> is your URS user name and " +- "<i>urs_password</i> is your URS password. To download, "+- "use the following command instead of step 2 above:" +- "<pre>" +- "wget --input-file=wget.html --force-html --config=urs.credentials" +- "</pre><br>" +- "</div>"- );- };-- var writeProduct = function(doc, product) {- console.log(product);- doc.write("<h4>" + product.name + "</h4>");- if ( product.noBulkDownload ) {- doc.write("<p>" +- "These granules are not available for bulk download. " +- "Please visit each link and download manually." +- "</p>");- }- $.each(product.list, function(index, item) {- // Don't print twice if the item and product names are the same.- if ( item.label !== product.name ) {- doc.write("<div class='label'>" + item.label + "</div>");- }- $.each(item.links, function(index, link) {- if ( !product.noBulkDownload ) {- doc.write(- "<div>" +- "<a href='" + link.href + "'>" + link.href + "</a>" +- "</div>"- );- } else {- doc.write(- "<div class='label'>" +- link.href +- "</div>"- );- }- });- });+ localStorage.wget = JSON.stringify(storage);+ var text = window.open('pages/wget.html', 'Worldview_' + new Date());};return ns;diff --git a/src/pages/wget.html b/src/pages/wget.htmlnew file mode 100644index 000000000..390a58953--- /dev/null+++ b/src/pages/wget.html@@ -0,0 +1,115 @@+<!doctype html>+<html>+ <head>+ <title>wget.html</title>+ <style>+ body {+ background-color: rgb(25, 28, 32);+ }+ h3 {+ margin-top: 0;+ }+ h4 {+ margin-bottom: 0+ }+ #page {+ background-color: #ffffff;+ margin: 20px;+ padding: 20px;+ border-radius: 5px;+ }+ pre {+ background-color: #eeeeee;+ padding: 5px;+ border: 1px dashed #dddddd;+ }+ .label {+ margin-top: 10px;+ font-style: italic;+ color: #808080;+ }+ </style>++<script>+var productText = function(product) {+ var html = [];+ html.push("<h4>" + product.name + "</h4>");+ if ( product.noBulkDownload ) {+ html.push("<p>" ++ "These granules are not available for bulk download. " ++ "Please visit each link and download manually." ++ "</p>");+ }+ for ( var i = 0; i < product.list.length; i++ ) {+ var item = product.list[i];+ // Don't print twice if the item and product names are the same.+ if ( item.label !== product.name ) {+ html.push("<div class='label'>" + item.label + "</div>");+ }+ for ( var j = 0; j < item.links.length; j++ ) {+ var link = item.links[j];+ if ( !product.noBulkDownload ) {+ html.push(+ "<div>" ++ "<a href='" + link.href + "'>" + link.href + "</a>" ++ "</div>"+ );+ } else {+ html.push(+ "<div class='label'>" ++ link.href ++ "</div>"+ );+ }+ }+ }+ return html.join("\n");+};++window.onload = function() {+ var div = document.getElementById("list");+ if ( div.innerHTML !== "" ) {+ return;+ }+ var html = [];+ var storage = localStorage.wget;+ if ( !storage ) {+ return;+ }+ var selection = JSON.parse(storage);+ for ( var product in selection ) {+ html.push(productText(selection[product]));+ }+ div.innerHTML = html.join("\n");+};+</script>++ </head>+ <body>+ <div id='page'>+ <div id='instructions'>+ <h3>Using <code>wget</code> to Bulk Download Your Data</h3>+ 1) Save this HTML page as <code>wget.html</code> to your+ local computer using the Web Page, Complete+ format.<br/>+ 2) Execute the following command to download all of your+ requested files:+ <pre>+wget --input-file=wget.html --force-html</pre><br/>+ <b>Note:</b> If User Registration System (URS) credentials are required,+ create a file (only readable by you) called+ <code>urs.credentials</code> with the following:+ <pre>+user=<i>urs_user</i>+password=<i>urs_password</i></pre>+ where <i>urs_user</i> is your URS user name and+ <i>urs_password</i> is your URS password. To download,+ use the following command instead of step 2 above:+ <pre>+wget --input-file=wget.html --force-html --config=urs.credentials</pre><br/>+ </div>+ <div id='list'></div>+ </div>+ </body>+</html>+