onload-Handler + nur 7 Spalten
This commit is contained in:
parent
51d0054c82
commit
00721b32f1
2 changed files with 7 additions and 25 deletions
|
@ -69,10 +69,6 @@
|
||||||
|
|
||||||
<div class="table">
|
<div class="table">
|
||||||
<table id="t01"></table>
|
<table id="t01"></table>
|
||||||
<script>
|
|
||||||
// create table
|
|
||||||
handleFile("resources/world_data_v1.csv")
|
|
||||||
</script>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
28
js/table.js
28
js/table.js
|
@ -4,6 +4,10 @@
|
||||||
// Source: https://www.w3schools.com/howto/howto_js_sort_table.asp
|
// Source: https://www.w3schools.com/howto/howto_js_sort_table.asp
|
||||||
// Source: https://stackoverflow.com/questions/19105009/how-to-insert-variables-in-javascript-strings
|
// 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) {
|
function handleFile(path) {
|
||||||
// Check for the various File API support.
|
// Check for the various File API support.
|
||||||
if (window.FileReader) {
|
if (window.FileReader) {
|
||||||
|
@ -38,6 +42,7 @@ function rerequestFile(path, columns) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function processData(csv, path) {
|
function processData(csv, path) {
|
||||||
|
var columnAmount = 7;
|
||||||
var table = "";
|
var table = "";
|
||||||
var checkbox = "";
|
var checkbox = "";
|
||||||
|
|
||||||
|
@ -50,7 +55,7 @@ function processData(csv, path) {
|
||||||
|
|
||||||
var data = allTextLines[0].split(",");
|
var data = allTextLines[0].split(",");
|
||||||
|
|
||||||
for (var j = 0; j < data.length; j++) {
|
for (var j = 0; j < columnAmount; j++) {
|
||||||
// create table column header
|
// create table column header
|
||||||
table += "<th onclick=\"sortTable(" + j + ")\" >";
|
table += "<th onclick=\"sortTable(" + j + ")\" >";
|
||||||
table += data[j];
|
table += data[j];
|
||||||
|
@ -66,32 +71,13 @@ function processData(csv, path) {
|
||||||
checkbox += "</ul>";
|
checkbox += "</ul>";
|
||||||
table += "</tr>";
|
table += "</tr>";
|
||||||
|
|
||||||
/*
|
|
||||||
for (var j = 0; j < data.length; j++) {
|
|
||||||
var test = j % 3;
|
|
||||||
|
|
||||||
if (test == 0) {
|
|
||||||
checkbox += "<div class='did'><ul>";
|
|
||||||
}
|
|
||||||
|
|
||||||
checkbox += "<li>";
|
|
||||||
checkbox += "<input id='" + data[j] + "' type='checkbox' checked='checked' onclick=\"toggleColumn('" + path + "')\"/>";
|
|
||||||
checkbox += data[j];
|
|
||||||
checkbox += "</li>";
|
|
||||||
|
|
||||||
if (test == 2) {
|
|
||||||
checkbox += "</ul></div>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// create table content
|
// create table content
|
||||||
for (var i = 1; i < allTextLines.length; i++) {
|
for (var i = 1; i < allTextLines.length; i++) {
|
||||||
var data = allTextLines[i].split(',');
|
var data = allTextLines[i].split(',');
|
||||||
|
|
||||||
table += "<tr>";
|
table += "<tr>";
|
||||||
|
|
||||||
for (var j = 0; j < data.length; j++) {
|
for (var j = 0; j < columnAmount; j++) {
|
||||||
table += "<td>";
|
table += "<td>";
|
||||||
table += data[j];
|
table += data[j];
|
||||||
table += "</td>";
|
table += "</td>";
|
||||||
|
|
Loading…
Reference in a new issue