diff --git a/extension/devtools/views/SitemapExportDataCSV.html b/extension/devtools/views/SitemapExportDataCSV.html index 4cfc595a..87e232f7 100644 --- a/extension/devtools/views/SitemapExportDataCSV.html +++ b/extension/devtools/views/SitemapExportDataCSV.html @@ -1,4 +1,22 @@ -

- Export {{_id}} data as CSV.
Waiting for the download button to appear. > - Download now! +

Export {{_id}} data as CSV

+
+ + + +
+ + + +
+ + + +
+ + +
+
+ +

+ Waiting for process to finish. > Download now!

\ No newline at end of file diff --git a/extension/scripts/Controller.js b/extension/scripts/Controller.js index 3caa4cab..4212266f 100644 --- a/extension/scripts/Controller.js +++ b/extension/scripts/Controller.js @@ -1070,13 +1070,26 @@ SitemapController.prototype = { var exportPanel = ich.SitemapExportDataCSV(sitemap); $("#viewport").html(exportPanel); + $(".result").hide(); + // generate data - $(".download-button").hide(); - this.store.getSitemapData(sitemap, function (data) { - var blob = sitemap.getDataExportCsvBlob(data); - $(".download-button a").attr("href", window.URL.createObjectURL(blob)); - $(".download-button a").attr("download", sitemap._id + ".csv"); - $(".download-button").show(); + $("#generate-csv").click(function () { + $(".result").show(); + $(".download-button").hide(); + + var options = { + "delimiter": $("#delimiter").val(), + "newline": $("#newline").prop('checked'), + "containBom": $("#utf-bom").prop('checked') + }; + + this.store.getSitemapData(sitemap, function (data) { + var blob = sitemap.getDataExportCsvBlob(data, options); + $(".download-button a").attr("href", window.URL.createObjectURL(blob)); + $(".download-button a").attr("download", sitemap._id + ".csv"); + $(".download-button").show(); + }.bind(this)); + }.bind(this)); return true; diff --git a/extension/scripts/Sitemap.js b/extension/scripts/Sitemap.js index 0cfaf47a..144acd53 100644 --- a/extension/scripts/Sitemap.js +++ b/extension/scripts/Sitemap.js @@ -174,12 +174,19 @@ Sitemap.prototype = { return columns; }, - getDataExportCsvBlob: function (data) { - - var columns = this.getDataColumns(), - delimiter = ',', - newline = "\n", - csvData = ['\ufeff']; // utf-8 bom char + getDataExportCsvBlob: function (data, option) { + + var delimiterKey = "delimiter"; + var newlineKey = "newline"; + var containBomKey = "containBom"; + + var columns = this.getDataColumns(), + // default delimiter is comma + delimiter = option.hasOwnProperty(delimiterKey) ? option[delimiterKey] : ',', + // per default, new line is included at end of lines + newline = option.hasOwnProperty(newlineKey) ? (option[newlineKey] == true ? "\n" : "") : "\n", + // per default, utf8 BOM is included at the beginning. + csvData = option.hasOwnProperty(containBomKey) ? (option[containBomKey] == true ? ['\ufeff'] : []) : ['\ufeff']; // utf-8 bom char // header csvData.push(columns.join(delimiter) + newline)