From 00721b32f1bc07dc2e2c1dfed5b4f923f5d64d57 Mon Sep 17 00:00:00 2001 From: seli Date: Sun, 4 Nov 2018 14:01:09 +0100 Subject: [PATCH] onload-Handler + nur 7 Spalten --- index.html | 4 ---- js/table.js | 28 +++++++--------------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/index.html b/index.html index c9be005..59cedff 100644 --- a/index.html +++ b/index.html @@ -69,10 +69,6 @@
-
diff --git a/js/table.js b/js/table.js index e67e679..654cef0 100644 --- a/js/table.js +++ b/js/table.js @@ -4,6 +4,10 @@ // Source: https://www.w3schools.com/howto/howto_js_sort_table.asp // Source: https://stackoverflow.com/questions/19105009/how-to-insert-variables-in-javascript-strings +window.onload = function() { + handleFile("resources/world_data_v1.csv"); +}; + function handleFile(path) { // Check for the various File API support. if (window.FileReader) { @@ -38,6 +42,7 @@ function rerequestFile(path, columns) { } function processData(csv, path) { + var columnAmount = 7; var table = ""; var checkbox = ""; @@ -50,7 +55,7 @@ function processData(csv, path) { var data = allTextLines[0].split(","); - for (var j = 0; j < data.length; j++) { + for (var j = 0; j < columnAmount; j++) { // create table column header table += ""; table += data[j]; @@ -66,32 +71,13 @@ function processData(csv, path) { checkbox += ""; table += ""; - /* - for (var j = 0; j < data.length; j++) { - var test = j % 3; - - if (test == 0) { - checkbox += "
"; - } - } - */ - // create table content for (var i = 1; i < allTextLines.length; i++) { var data = allTextLines[i].split(','); table += ""; - for (var j = 0; j < data.length; j++) { + for (var j = 0; j < columnAmount; j++) { table += ""; table += data[j]; table += "";