Fixup table rendering

This commit is contained in:
hodasemi 2018-11-15 16:53:57 +01:00
parent 65c3f0cacc
commit ff604645b1
4 changed files with 63 additions and 52 deletions

View file

@ -148,11 +148,11 @@ h1 {
margin-bottom: 15px; margin-bottom: 15px;
vertical-align: middle; vertical-align: middle;
width: 100%; width: 100%;
overflow-x: scroll; overflow: hidden;
} }
.world_table { .world_table {
width: 100% width: 100%;
} }
.world_table tr:nth-child(odd) { .world_table tr:nth-child(odd) {
@ -162,6 +162,7 @@ h1 {
.world_table th { .world_table th {
background-color: #fff; background-color: #fff;
white-space: nowrap; /* kein umbruch bei schmaler ansicht */ white-space: nowrap; /* kein umbruch bei schmaler ansicht */
padding-right: 1em;
} }
.world_table th:hover { .world_table th:hover {
@ -173,12 +174,15 @@ h1 {
color: lightgreen; color: lightgreen;
} }
.world_table th td { .world_table td {
line-height: 1em; line-height: 1em;
padding: 11px 0; padding: 11px 0;
font-size: 14px; /* same as section */ font-size: 14px; /* same as section */
white-space: nowrap;
padding-right: 1em;
} }
/*
@media only screen and (max-width: 700px) { @media only screen and (max-width: 700px) {
.world_table>tbody>tr>td, .world_table>tbody>tr>td,
.world_table>tbody>tr>th, .world_table>tbody>tr>th,
@ -191,8 +195,8 @@ h1 {
display: none; display: none;
} }
} }
*/
/*
@media only screen and (max-width: 1200px) { @media only screen and (max-width: 1200px) {
.world_table th:nth-child(n+7), .world_table td:nth-child(n+7) { .world_table th:nth-child(n+7), .world_table td:nth-child(n+7) {
display: none; display: none;
@ -208,7 +212,6 @@ h1 {
display: none; display: none;
} }
} }
*/
.boxed { .boxed {
border: 1px solid green; border: 1px solid green;

View file

@ -72,7 +72,7 @@ error_reporting(E_ALL);
</section> </section>
<div class="page"> <div id="footer_div" class="page">
<footer class="footer"> <footer class="footer">
<div class="foo-left"> <div class="foo-left">
<p>Copyright © 2018 world_data</p> <p>Copyright © 2018 world_data</p>

View file

@ -43,25 +43,28 @@ function rerequestFile(path, columns) {
} }
function processData(csv, path) { function processData(csv, path) {
let table = document.getElementById('t01');
if (table) {
var columnAmount = 7; var columnAmount = 7;
var table = ""; var table_content = "";
var checkbox = ""; var checkbox = "";
// split rows // split rows
var allTextLines = csv.split(/\r\n|\n/); var allTextLines = csv.split(/\r\n|\n/);
// create table header // create table header
table += "<thead><tr>"; table_content += "<thead><tr>";
checkbox += "<ul>"; checkbox += "<ul>";
var data = allTextLines[0].split(","); var data = allTextLines[0].split(",");
for (var j = 0; j < columnAmount; j++) { for (var j = 0; j < columnAmount; j++) {
// create table column header // create table column header
table += "<th onclick=\"sortTable(" + j + ")\" >"; table_content += "<th onclick=\"sortTable(" + j + ")\" >";
table += stringPerToSlash(data[j]); table_content += stringPerToSlash(data[j]);
table += ' <i class="fas fa-chevron-up"></i>&nbsp;<i class="fas fa-chevron-down"></i>'; table_content += ' <i class="fas fa-chevron-up"></i>&nbsp;<i class="fas fa-chevron-down"></i>';
table += "</th>"; table_content += "</th>";
// create dropdown elements // create dropdown elements
checkbox += "<li>"; checkbox += "<li>";
@ -71,28 +74,29 @@ function processData(csv, path) {
} }
checkbox += "</ul>"; checkbox += "</ul>";
table += "</tr></thead><tbody>"; table_content += "</tr></thead><tbody>";
// 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_content += "<tr>";
for (var j = 0; j < columnAmount; j++) { for (var j = 0; j < columnAmount; j++) {
table += "<td>"; table_content += "<td>";
table += data[j]; table_content += data[j];
table += "</td>"; table_content += "</td>";
} }
table += "</tr>"; table_content += "</tr>";
} }
table += "</tbody>"; table_content += "</tbody>";
document.getElementById('t01').innerHTML = table; table.innerHTML = table_content;
document.getElementById('options').innerHTML = checkbox; document.getElementById('options').innerHTML = checkbox;
} }
}
function toggleColumn(file) { function toggleColumn(file) {
var activated_columns = []; var activated_columns = [];

View file

@ -59,6 +59,7 @@
<i class="fas fa-chevron-up"></i> <i class="fas fa-chevron-up"></i>
<i class="fas fa-chevron-down"></i> <i class="fas fa-chevron-down"></i>
</th> </th>
<!--
<th onclick="sortTable(7)"> <th onclick="sortTable(7)">
gdp / capita growth gdp / capita growth
<i class="fas fa-chevron-up"></i> <i class="fas fa-chevron-up"></i>
@ -94,6 +95,7 @@
<i class="fas fa-chevron-up"></i> <i class="fas fa-chevron-up"></i>
<i class="fas fa-chevron-down"></i> <i class="fas fa-chevron-down"></i>
</th> </th>
-->
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -106,6 +108,7 @@
<td><xsl:value-of select="children_per_woman"/></td> <td><xsl:value-of select="children_per_woman"/></td>
<td><xsl:value-of select="electricity_consumption_per_capita"/></td> <td><xsl:value-of select="electricity_consumption_per_capita"/></td>
<td><xsl:value-of select="gdp_per_capita"/></td> <td><xsl:value-of select="gdp_per_capita"/></td>
<!--
<td><xsl:value-of select="gdp__per__capita__growth"/></td> <td><xsl:value-of select="gdp__per__capita__growth"/></td>
<td><xsl:value-of select="inflation_annual"/></td> <td><xsl:value-of select="inflation_annual"/></td>
<td><xsl:value-of select="internet_user_per_100"/></td> <td><xsl:value-of select="internet_user_per_100"/></td>
@ -113,6 +116,7 @@
<td><xsl:value-of select="military_expenditure_percent_of_gdp"/></td> <td><xsl:value-of select="military_expenditure_percent_of_gdp"/></td>
<td><xsl:value-of select="gps_lat"/></td> <td><xsl:value-of select="gps_lat"/></td>
<td><xsl:value-of select="gps_long"/></td> <td><xsl:value-of select="gps_long"/></td>
-->
</tr> </tr>
</xsl:for-each> </xsl:for-each>
</tbody> </tbody>