jsonify-my-table

Convert a HTML table to JSON
git clone http://git.hanabi.in/repos/jsonify-my-table.git
Log | Files | Refs | LICENSE

commit 497f085360a12db48695b4900b78b05dd090f789
parent c5988b8daa51e2d4f826a61b5bb8896bbdad52e4
Author: Agastya Chandrakant <acagastya@outlook.com>
Date:   Thu, 13 Jun 2019 20:06:22 +0530

minify
Diffstat:
Mjsonify-my-table.min.js | 22+---------------------
1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/jsonify-my-table.min.js b/jsonify-my-table.min.js @@ -1,21 +1 @@ -class jsonifyMyTable { - constructor(e) { - if (((this.table = document.getElementById(e)), !this.table)) - return (this.error = !0), void console.error("Table not found."); - this.headers = []; - for (let e = 0; e < this.table.rows[0].cells.length; e += 1) - this.headers.push(this.table.rows[0].cells[e].innerText); - if (this.headers.length > new Set(this.headers).size) - return (this.error = !0), void console.error("Headers repeat."); - this.res = []; - for (let e = 1; e < this.table.rows.length; e += 1) { - let t = []; - for (let s = 0; s < this.table.rows[e].cells.length; s += 1) - t.push(this.table.rows[e].cells[s].innerText); - let s = {}; - this.headers.forEach((e, r) => (s = { ...s, [e.valueOf()]: t[r] })), - this.res.push(s); - } - } -} -exports.jsonifyMyTable = jsonifyMyTable; +class jsonifyMyTable{constructor(e){if(this.table=document.getElementById(e),!this.table)return this.error=!0,void console.error("Table not found.");this.headers=[];for(let e=0;e<this.table.rows[0].cells.length;e+=1)this.headers.push(this.table.rows[0].cells[e].innerText);if(this.headers.length>new Set(this.headers).size)return this.error=!0,void console.error("Headers repeat.");this.res=[];for(let e=1;e<this.table.rows.length;e+=1){let s=[];for(let t=0;t<this.table.rows[e].cells.length;t+=1)s.push(this.table.rows[e].cells[t].innerText);let t={};this.headers.forEach((e,r)=>t={...t,[e.valueOf()]:s[r]}),this.res.push(t)}}}exports.jsonifyMyTable=jsonifyMyTable;