Table Generation

Developer
Size
3,609 Kb
Views
54,648

How do I make an table generation?

Javascript simple table generation, still a Work In Progress. What is a table generation? How do you make a table generation? This script and codes were developed by Event Horizon on 30 July 2022, Saturday.

Table Generation Previews

Table Generation - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Table Generation</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container"> <div class="row"> <div class="col-md-12"> <div class="page-header"> <h1>Table Generation<small>, check Javascript for generation, line 90.</small></h1> </div> </div> </div>
</div> <script src="js/index.js"></script>
</body>
</html>

Table Generation - Script Codes CSS Codes

h1{ display:block; font-size:2em; font-weight:bold; margin:16px; text-align:center;
}
/*Default Table Styling*/
table{ margin:16px auto; overflow: hidden;/*Required for column hover*/ z-index: 1;/*Required for column hover*/
}
table td, table th {/*Required for column hover*/ position: relative;
}
table tbody tr:nth-child(2n+1){ background-color:#eee;
}
table tr:hover{ background-color:#ccc!important;
}
table th{ font-weight:bold;
}
table th, table td{ padding:8px 16px;
}
/*Start Column Hover*/
table td:hover::after, table th:hover::after { background-color: #ccc; content:'\00a0'; height: 10000px; left: 0; position: absolute; top: -5000px; width: 100%; z-index: -1;
}
/*End Column Hover*/
table td:hover, table th:hover{ background-color: #aaa;
}
table tfoot td{ font-style:italic; font-size:0.8em;
}
/* might change from attribute to containing span or something similar*/
table tr th[data-theader=true]:first-child, table tr td[data-theader=true]:first-child{ font-weight:bold;
}
/***********************/

Table Generation - Script Codes JS Codes

/* * Event-Horizon */
//swiftTable
var sTable = function(data) { var that = this; this.data = data; this.orientation = this.data.orientation; this.header = (this.data.header === undefined || this.data.header === null) ? true : this.data.header; this.footer = this.data.footer || false; this.data.tableString = (that.data.fromString&&that.data.fromString.tString) ? that.data.fromString.tString : false; this.tStringDelimiters = (that.data.fromString&&that.data.fromString.delimiters) ? that.data.fromString.delimiters : false; this.stringToTable = function(tStr) { var result = [], newTString, del1, del2; if(that.tStringDelimiters) { del1 = that.tStringDelimiters[0]; del2 = that.tStringDelimiters[1]; } else { del1 = "|"; del2 = "||"; } newTString = tStr.split(del2); for(var x = 0; x < newTString.length; x += 1) { newTString[x] = newTString[x].split(del1); } result = newTString; return result; }; if(that.data.tableString && !that.data.rows) { //manage string into table array that.data.rows = that.stringToTable(that.data.tableString); } this.html = function() { var htmlTableInner = "", htmlTable = document.createElement("table"), dataLength = that.data.rows.length; //build htmlTableInner, based on orientation for(var row = 0; row < dataLength; row += 1) { //loop through rows if(row === 0 && that.header) { htmlTableInner += "<thead>"; } else if(row === dataLength - 1 && that.footer) { htmlTableInner += "<tfoot>"; } else { if((row === 0 && !that.header)) { htmlTableInner += "<tbody>"; } if(row === 1 && that.header) { htmlTableInner += "<tbody>"; } } htmlTableInner += "<tr>"; for(var column = 0; column < that.data.rows[row].length; column += 1) { //loop through columns if(that.orientation === "vertical") { htmlTableInner += (column === 0 && that.header) ? "<th>" : "<td>"; } else if(that.orientation === "horizontal" || that.orientation === undefined) { htmlTableInner += (row === 0 && that.header) ? "<th>" : "<td>"; } htmlTableInner += that.data.rows[row][column]; if(that.orientation === "vertical") { htmlTableInner += (column === 0 && that.header) ? "</th>" : "</td>"; } else if(that.orientation === "horizontal" || that.orientation === undefined) { htmlTableInner += (row === 0 && that.header) ? "</th>" : "</td>"; } } htmlTableInner += "</tr>"; if(row === 0 && that.header) { htmlTableInner += "</thead>"; } else if(row === dataLength - 1 && that.footer) { htmlTableInner += "</tfoot>"; } else { if((row === dataLength - 1 && !that.footer)) { htmlTableInner += "</tbody>"; } if(row === dataLength - 2 && that.footer) { htmlTableInner += "</tbody>"; } } } //end htmlTableInner build htmlTable.innerHTML = htmlTableInner; return htmlTable; }; return this;
};
//end swiftTable
/*****************************************************************************************************************************/
//USING SWIFT TABLE
document.addEventListener("DOMContentLoaded", function() { var outEl = document.body; //setup first table, header and footer usage/example var table1 = new sTable({ rows: [ ["", "userID", "username", "email", ""], ["", "0", "jonesj", "[email protected]", ""], ["", "1", "jonesj2", "[email protected]", ""], ["", "2", "jonesj3", "[email protected]", ""], ["", "3", "jonesj4", "[email protected]", ""], ["", "4", "jonesj5", "[email protected]", ""], ["", "5", "jonesj6", "[email protected]", ""], ["Total Users:", "", "", "","6"] ], header: true, footer: true }); outEl.appendChild(table1.html());//attaching table to body //setup second table, omitting header footer defaults to header true, footer false var table2 = new sTable({ rows: [ ["One", "Two", "Three", "Four"], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4] ] }); outEl.appendChild(table2.html());//attaching table to body //setup third table, getting an html table out of a markdown like string, setting custom delimiters is optional, very easy to use var table3 = new sTable({ fromString: { tString: "Col1|Col2|Col3|Col4||Row1|x|x|x||Row2|x|x|x", delimiters: ["|", "||"] } }); outEl.appendChild(table3.html());//attaching table to body
});
Table Generation - Script Codes
Table Generation - Script Codes
Home Page Home
Developer Event Horizon
Username Event_Horizon
Uploaded July 30, 2022
Rating 3
Size 3,609 Kb
Views 54,648
Do you need developer help for Table Generation?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Event Horizon (Event_Horizon) Script Codes
Create amazing video scripts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!