From 1d4be9b05f2a4468dbbd1c492e2fdde92995b5e6 Mon Sep 17 00:00:00 2001 From: Yassine Chaouche Date: Wed, 21 Dec 2016 11:28:48 +0100 Subject: [PATCH 1/4] Added "type" attributes to script tags fixing #29 --- index.html | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 4fd9b2dd..fa0eff90 100644 --- a/index.html +++ b/index.html @@ -15,8 +15,8 @@ @@ -43,14 +43,15 @@

CSV to HTML Table

- - - - - - + + + + + + - - + @@ -60,11 +60,10 @@

CSV to HTML Table

} CsvToHtmlTable.init({ - csv_path: 'data/mail.csv', + csv_path: 'data/Health Clinics in Chicago.csv', element: 'table-container', allow_download: true, - //csv_options: {separator: ',', delimiter: '"'}, - csv_options: {separator: ',', delimiter:"`"}, + csv_options: {separator: ',', delimiter: '"'}, datatables_options: {"paging": false}, custom_formatting: [[4, format_link]] }); From 69c98d3f782529e2f861da606bb8bc8accc42d0d Mon Sep 17 00:00:00 2001 From: Yassine Chaouche Date: Wed, 21 Dec 2016 14:47:02 +0100 Subject: [PATCH 3/4] HTML escaping Some CSV files contain nasty things like "<" and ">" which corrupt the rendering of the table. This double for loop cleans the csv_data array before rendering the table. --- js/csv_to_html_table.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/csv_to_html_table.js b/js/csv_to_html_table.js index 3af5454a..5a3fe0c5 100644 --- a/js/csv_to_html_table.js +++ b/js/csv_to_html_table.js @@ -16,7 +16,12 @@ CsvToHtmlTable = { $.when($.get(csv_path)).then( function(data){ var csv_data = $.csv.toArrays(data, csv_options); - + // escape nasty HTML entities + for (i=0;i").text(csv_data[i][j]).html(); + } + } var table_head = ""; for (head_id = 0; head_id < csv_data[0].length; head_id++) { @@ -53,4 +58,4 @@ CsvToHtmlTable = { $("#" + el).append("

Download as CSV

"); }); } -} \ No newline at end of file +} From f70525c2b41aff9e5725b92a8fb493f4af299314 Mon Sep 17 00:00:00 2001 From: Derek Eder Date: Tue, 17 Jan 2017 15:00:43 -0600 Subject: [PATCH 4/4] removed html escape block --- js/csv_to_html_table.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/js/csv_to_html_table.js b/js/csv_to_html_table.js index 5a3fe0c5..6550d974 100644 --- a/js/csv_to_html_table.js +++ b/js/csv_to_html_table.js @@ -16,12 +16,7 @@ CsvToHtmlTable = { $.when($.get(csv_path)).then( function(data){ var csv_data = $.csv.toArrays(data, csv_options); - // escape nasty HTML entities - for (i=0;i").text(csv_data[i][j]).html(); - } - } + var table_head = ""; for (head_id = 0; head_id < csv_data[0].length; head_id++) {