diff --git a/apps/habitbuilder/csv.js b/apps/habitbuilder/csv.js index f7e81fbdf2..a97256938d 100644 --- a/apps/habitbuilder/csv.js +++ b/apps/habitbuilder/csv.js @@ -3,7 +3,7 @@ const CSV_HEADER = "date,question,response\n"; // Cleans the CSV data by removing duplicate entries document.addEventListener('click', function (event) { if (event.target.id === 'download-csv') { - Util.saveCSV("habitbuilder.data.csv"); + Util.saveCSV("habitbuilder.data.csv", csvData); return; // String representation of the CSV post-cleaning let cleanCsvStr = CSV_HEADER; diff --git a/apps/habitbuilder/interface.html b/apps/habitbuilder/interface.html index 38bb133621..68653ad48f 100644 --- a/apps/habitbuilder/interface.html +++ b/apps/habitbuilder/interface.html @@ -51,8 +51,17 @@

Settings

}); } +let csvData = ''; + +function getData() { + Util.readStorage('habitbuilder.data.csv', data => { + csvData = data.trim(); + }); +} + // Called when app starts function onInit() { + getData(); getSettings(); }