-
Notifications
You must be signed in to change notification settings - Fork 0
/
tbdb.js
30 lines (26 loc) · 48 KB
/
tbdb.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
if(!window.loadcssimported){document.addEventListener("DOMContentLoaded",function(){let css=`
.hidden{display:none}.numPages,.page,.pageSize{width:3em}.arrows{float:right}.pagination{display:none;width:100%}teeby-deeby{-webkit-border-horizontal-spacing:0;-webkit-border-vertical-spacing:0;td,th,tr{-webkit-border-horizontal-spacing:0;-webkit-border-vertical-spacing:0}table{background-color:#aaa;border-radius:5px}td,th,tr{margin:1px}td,th{border:1px solid gray;border-radius:3px;padding:8px;text-align:left}tr:nth-child(2n){background-color:#f2f2f2}tr:nth-child(odd){background-color:#fff}th{background-color:#555;color:#fff;padding-right:20px;position:relative}th:after,th:before{border:5px solid transparent;font-size:.5em;opacity:.1;position:absolute;right:5px;top:50%}th:after{content:"▲";transform:translateY(-70%) scaleX(125%)}th:before{content:"▼";transform:translateY(-10%) scaleX(125%)}th.down:before,th.up:after{opacity:.8}th.none:hover:after,th.none:hover:before{opacity:.3}th.down:hover:after,th.up:hover:before{opacity:.5}tbody:hover{tr{filter:brightness(95%)}tr:hover{filter:brightness(110%)}}thead:hover{th{filter:brightness(95%)}th:hover{filter:brightness(110%)}tbody{brightness:95%}}td:hover{filter:brightness(120%)}tfoot{td{border:none;font-size:.75em;padding:6px}}tfoot{display:none}input[type=checkbox]{filter:grayscale(1)}}teeby-deeby.dragover{opacity:.5}teeby-deeby.pager{.pagination{display:block}}teeby-deeby.footer{tfoot{display:table-row-group}}teeby-deeby.wide{table{width:100%}}teeby-deeby.w80{table{width:80%}}teeby-deeby.third{table{width:33.3%}}teeby-deeby.quarter{table{width:25%}}teeby-deeby.scroll{table{table-layout:fixed}table,tbody{display:block}tbody{max-height:88vh;overflow-y:scroll}}teeby-deeby.h50{tbody{max-height:50vh}}teeby-deeby.p16{td,th{padding:16px}}teeby-deeby.p12{td,th{padding:12px}}teeby-deeby.p8{td,th{padding:8px}}teeby-deeby.p4{td,th{padding:4px}}teeby-deeby.p2{td,th{padding:2px}}teeby-deeby.round{table{border-radius:5px}td,th{border-radius:3px}}teeby-deeby.soft{table{border-radius:3px}td,th{border-radius:2px}}teeby-deeby.square{table,td,th{border-radius:0}}teeby-deeby.zero{-webkit-border-horizontal-spacing:0;-webkit-border-vertical-spacing:0;table,td,th,thead,tr{-webkit-border-horizontal-spacing:0;-webkit-border-vertical-spacing:0}td,th{border:0}}teeby-deeby.nogap{-webkit-border-horizontal-spacing:0;-webkit-border-vertical-spacing:0;table,td,th,thead,tr{-webkit-border-horizontal-spacing:0;-webkit-border-vertical-spacing:0}}teeby-deeby.gap1{-webkit-border-horizontal-spacing:1px;-webkit-border-vertical-spacing:1px;table,td,th,thead,tr{-webkit-border-horizontal-spacing:1px;-webkit-border-vertical-spacing:1px}}teeby-deeby.gap2{-webkit-border-horizontal-spacing:2px;-webkit-border-vertical-spacing:2px;table,td,th,thead,tr{-webkit-border-horizontal-spacing:2px;-webkit-border-vertical-spacing:2px}}@media (prefers-color-scheme:dark){table{background-color:#000}th{background-color:#212121}tr{background-color:#616161;color:#fff}tr:nth-child(2n){background-color:#424242}}teeby-deeby.dark{table{background-color:#000}th{background-color:#212121}tr{background-color:#616161;color:#fff}tr:nth-child(2n){background-color:#424242}}teeby-deeby.yellow{table{background-color:#b8860b}th{background-color:#ffeb3b}}teeby-deeby.green{table{background-color:#006400}th{background-color:#4caf50}}teeby-deeby.blue{table{background-color:#00008b}th{background-color:#2196ff}}teeby-deeby.purple{table{background-color:darkpurple}th{background-color:#9c27b0}}teeby-deeby.red{table{background-color:darkred}th{background-color:#f44336}}teeby-deeby.orange{table{background-color:#ff8c00}th{background-color:#ff9800}}teeby-deeby.rainbow{th{background-color:#000}tr{color:#fff}tr:nth-child(7n+1){background-color:red}tr:nth-child(7n+2){background-color:orange;color:#000}tr:nth-child(7n+3){background-color:#ff0;color:#000}tr:nth-child(7n+4){background-color:green}tr:nth-child(7n+5){background-color:blue}tr:nth-child(7n+6){background-color:indigo}tr:nth-child(7n+7){background-color:violet}}teeby-deeby.dblue{table{background-color:#000}th{background-color:#003}tr{background-color:#616161;color:#fff}tr:nth-child(2n){background-color:#424242}td{color:#fff}}teeby-deeby.dgreen{table{background-color:#000}th{background-color:#030}tr{background-color:#616161;color:#fff}tr:nth-child(2n){background-color:#424242}td{color:#fff}}\\n\/*# sourceMappingURL=data:application\/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNzcy90ZWVieWRlZWJ5LmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxRQUNJLFlBQ0osQ0FDQSwwQkFDSSxTQUNKLENBQ0EsUUFDSSxXQUNKLENBQ0EsWUFFSSxZQUFhLENBRGIsVUFFSixDQUdBLFlBQ0ksbUNBQXNDLENBQ3RDLGlDQUFvQyxDQUNwQyxTQUNJLG1DQUFzQyxDQUN0QyxpQ0FDSixDQUVBLE1BRUkscUJBQXNCLENBRHRCLGlCQUVKLENBRUEsU0FDSSxVQUNKLENBRUEsTUFDSSxxQkFBc0IsQ0FHdEIsaUJBQWtCLENBRmxCLFdBQVksQ0FDWixlQUVKLENBQ0EsaUJBQ0ksd0JBQ0osQ0FDQSxrQkFDSSxxQkFDSixDQUlBLEdBQ0kscUJBQXNCLENBQ3RCLFVBQVksQ0FJZCxrQkFBbUIsQ0FEbkIsaUJBRkYsQ0FNQSxtQkFLRSw0QkFBNkIsQ0FDN0IsY0FBZ0IsQ0FDaEIsVUFBWSxDQUxaLGlCQUFrQixDQUNsQixTQUFVLENBQ1YsT0FJRixDQUNBLFNBQ0UsV0FBWSxDQUNaLHVDQUNGLENBQ0EsVUFDRSxXQUFZLENBQ1osdUNBQ0YsQ0FLQSwyQkFDSSxVQUNKLENBRUEseUNBRUksVUFDSixDQUlBLHVDQUNJLFVBQ0osQ0FFQSxZQUNJLEdBQ0ksc0JBQ0osQ0FDQSxT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yaWdodG5lc3MoMTEwJSk7XHJcbiAgICAgICAgfVxyXG4gICAgfVxyXG4gICAgdGhlYWQ6aG92ZXIge1xyXG4gICAgICAgIHRoIHtcclxuICAgICAgICAgICAgZmlsdGVyOiBicmlnaHRuZXNzKDk1JSk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoOmhvdmVyIHtcclxuICAgICAgICAgICAgZmlsdGVyOiBicmlnaHRuZXNzKDExMCUpO1xyXG4gICAgICAgIH1cclxuICAgICAgICB0Ym9keSB7XHJcbiAgICAgICAgICAgIGJyaWdodG5lc3M6IDk1JTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcbiAgICB0ZDpob3ZlciB7XHJcbiAgICAgICAgZmlsdGVyOiBicmlnaHRuZXNzKDEyMCUpO1xyXG4gICAgfVxyXG5cclxuICAgIHRmb290IHtcclxuICAgICAgICB0ZCB7XHJcbiAgICAgICAgICAgIHBhZGRpbmc6IDZweDtcclxuICAgICAgICAgICAgZm9udC1zaXplOiAwLjc1ZW07XHJcbiAgICAgICAgICAgIGJvcmRlcjogbm9uZTtcclxuICAgICAgICB9XHJcbiAgICB9XHJcblxyXG4gICAgdGZvb3Qge1xyXG4gICAgICAgIGRpc3BsYXk6IG5vbmU7XHJcbiAgICB9XHJcblxyXG4gICAgaW5wdXRbdHlwZT1jaGVja2JveF0ge1xyXG4gICAgICAgIGZpbHRlcjogZ3JheXNjYWxlKDEpO1xyXG4gICAgfVxyXG59XHJcblxyXG5cclxudGVlYnktZGVlYnkuZHJhZ292ZXIge1xyXG4gICAgb3BhY2l0eTogMC41O1xyXG59XHJcblxyXG50ZWVieS1kZWVieS5wYWdlciB7XHJcbiAgICAucGFnaW5hdGlvbiB7XHJcbiAgICAgICAgZGlzcGxheTogYmxvY2s7XHJcbiAgICB9XHJcbn1cclxuXHJcblxyXG50ZWVieS1kZWVieS5mb290ZXIge1xyXG4gICAgdGZvb3Qge1xyXG4gICAgICAgIGRpc3BsYXk6IHRhYmxlLXJvdy1nc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sZSB7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogZGFya2dyZWVuO1xyXG4gICAgfVxyXG4gICAgdGgge1xyXG4gICAgICAgIGJhY2tncm91bmQtY29sb3I6ICM0Q0FGNTA7XHJcbiAgICB9XHJcbn1cclxudGVlYnktZGVlYnkuYmx1ZSB7XHJcbiAgICB0YWJsZSB7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogZGFya2JsdWU7XHJcbiAgICB9XHJcbiAgICB0aCB7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogIzIxOTZGRjtcclxuICAgIH1cclxufVxyXG50ZWVieS1kZWVieS5wdXJwbGUge1xyXG4gICAgdGFibGUge1xyXG4gICAgICAgIGJhY2tncm91bmQtY29sb3I6IGRhcmtwdXJwbGU7XHJcbiAgICB9XHJcbiAgICB0aCB7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogIzlDMjdCMDtcclxuICAgIH1cclxufVxyXG50ZWVieS1kZWVieS5yZWQge1xyXG4gICAgdGFibGUge1xyXG4gICAgICAgIGJhY2tncm91bmQtY29sb3I6IGRhcmtyZWQ7XHJcbiAgICB9XHJcbiAgICB0aCB7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogI0Y0NDMzNjtcclxuICAgIH1cclxufVxyXG50ZWVieS1kZWVieS5vcmFuZ2Uge1xyXG4gICAgdGFibGUge1xyXG4gICAgICAgIGJhY2tncm91bmQtY29sb3I6IGRhcmtvcmFuZ2U7XHJcbiAgICB9XHJcbiAgICB0aCB7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogI0ZGOTgwMDtcclxuICAgIH1cclxufVxyXG50ZWVieS1kZWVieS5yYWluYm93IHtcclxuXHJcbiAgICB0aCB7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogYmxhY2s7XHJcbiAgICB9XHJcbiAgICB0ciB7XHJcbiAgICAgICAgY29sb3I6IHdoaXRlO1xyXG4gICAgfVxyXG4gICAgdHI6bnRoLWNoaWxkKDduKzEpe1xyXG4gICAgICAgIGJhY2tncm91bmQtY29sb3I6IHJlZDtcclxuICAgIH1cclxuICAgIHRyOm50aC1jaGlsZCg3bisyKXtcclxuICAgICAgICBiYWNrZ3JvdW5kLWNvbG9yOiBvcmFuZ2U7XHJcbiAgICAgICAgY29sb3I6IGJsYWNrO1xyXG4gICAgfVxyXG4gICAgdHI6bnRoLWNoaWxkKDduKzMpe1xyXG4gICAgICAgIGJhY2tncm91bmQtY29sb3I6IHllbGxvdztcclxuICAgICAgICBjb2xvcjogYmxhY2s7XHJcbiAgICB9XHJcbiAgICB0cjpudGgtY2hpbGQoN24rNCl7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogZ3JlZW47XHJcbiAgICB9XHJcbiAgICB0cjpudGgtY2hpbGQoN24rNSl7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogYmx1ZTtcclxuICAgIH1cclxuICAgIHRyOm50aC1jaGlsZCg3bis2KXtcclxuICAgICAgICBiYWNrZ3JvdW5kLWNvbG9yOiBpbmRpZ287XHJcbiAgICB9XHJcbiAgICB0cjpudGgtY2hpbGQoN24rNyl7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogdmlvbGV0O1xyXG4gICAgfVxyXG5cclxufVxyXG5cclxudGVlYnktZGVlYnkuZGJsdWUge1xyXG4gICAgdGFibGUge1xyXG4gICAgICAgIGJhY2tncm91bmQtY29sb3I6IGJsYWNrO1xyXG4gICAgfVxyXG4gICAgdGgge1xyXG4gICAgICAgIGJhY2tncm91bmQtY29sb3I6ICMwMDM7XHJcbiAgICB9XHJcbiAgICB0ciB7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogIzYxNjE2MTtcclxuICAgICAgICBjb2xvcjogd2hpdGU7XHJcbiAgICB9XHJcbiAgICB0cjpudGgtY2hpbGQoZXZlbikge1xyXG4gICAgICAgIGJhY2tncm91bmQtY29sb3I6ICM0MjQyNDI7XHJcbiAgICB9XHJcbiAgICB0ZCB7XHJcbiAgICAgICAgY29sb3I6IHdoaXRlO1xyXG4gICAgfVxyXG59XHJcbnRlZWJ5LWRlZWJ5LmRncmVlbiB7XHJcbiAgICB0YWJsZSB7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogYmxhY2s7XHJcbiAgICB9XHJcbiAgICB0aCB7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogIzAzMDtcclxuICAgIH1cclxuICAgIHRyIHtcclxuICAgICAgICBiYWNrZ3JvdW5kLWNvbG9yOiAjNjE2MTYxO1xyXG4gICAgICAgIGNvbG9yOiB3aGl0ZTtcclxuICAgIH1cclxuICAgIHRyOm50aC1jaGlsZChldmVuKSB7XHJcbiAgICAgICAgYmFja2dyb3VuZC1jb2xvcjogIzQyNDI0MjtcclxuICAgIH1cclxuICAgIHRkIHtcclxuICAgICAgICBjb2xvcjogd2hpdGU7XHJcbiAgICB9XHJcbn1cclxuIl19 *\/\\n
`;let head=document.head||document.getElementsByTagName("head")[0];let style=document.createElement("style");style.type="text/css";if(style.styleSheet){style.styleSheet.cssText=css}else{style.appendChild(document.createTextNode(css))}head.appendChild(style)});window.loadcssimported=true}if(!window.celltypeimported){window.celltypes={undefined:v=>v===undefined,array:v=>v instanceof Array||typeof v==="string"&&v.startsWith("[")&&v.endsWith("]"),object:v=>v instanceof Object||typeof v==="string"&&v.startsWith("{")&&v.endsWith("}"),boolean:v=>[true,false,"true","false","True","False"].includes(v),empty:v=>v===""||v===null||v===undefined,image:v=>v.startsWith("data:image")||v.endsWith(".jpg")||v.endsWith(".png")||v.endsWith(".gif")||v.endsWith(".svg"),url:v=>v.startsWith("http")||v.startsWith("www"),email:v=>v.startsWith("mailto:"),currency:v=>v.startsWith("$")&&!isNaN(v.slice(1)),hexcolor:v=>v.startsWith("#")&&!isNaN(v.slice(1)),rgbcolor:v=>v.startsWith("rgb(")&&v.endsWith(")"),percent:v=>v.endsWith("%")&&!isNaN(v.slice(0,-1)),number:v=>!isNaN(v),date:v=>!isNaN(new Date(v)),time:v=>!isNaN(new Date("1970-01-01T"+v)),string:v=>typeof v==="string"};function detectCellType(value){let matchedTypes=[];for(let t in window.celltypes){try{if(window.celltypes[t](value)){matchedTypes.push(t)}}catch(e){}}return matchedTypes}function setCellValue(cell,value,editable=false,preferences=[]){let matchedTypes=detectCellType(value);let existingTypes=matchedTypes.filter(t=>cell.classList.contains(t));let preferredTypes=preferences.filter(t=>matchedTypes.includes(t));let t=existingTypes.length>0?existingTypes[0]:preferredTypes.length>0?preferredTypes[0]:matchedTypes[0];for(let ty of Object.keys(window.celltypes)){if(ty!==t){cell.classList.remove(ty)}}cell.classList.add(t);if(t==="undefined"){cell.innerHTML=""}else if(t==="boolean"){let checkbox=document.createElement("input");checkbox.type="checkbox";checkbox.checked=value;cell.appendChild(checkbox);if(!editable){checkbox.setAttribute("disabled",true)}}else if(t==="number"){cell.innerHTML=value}else if(t==="date"){let date=document.createElement("input");date.type="date";date.value=value;cell.appendChild(date);if(!editable){date.setAttribute("disabled",true)}}else if(t==="time"){let time=document.createElement("input");time.type="time";time.value=value;cell.appendChild(time);if(!editable){time.setAttribute("disabled",true)}}else if(t==="image"){let img=document.createElement("img");img.src=value;cell.appendChild(img)}else if(t==="url"){let link=document.createElement("a");link.href=value;link.innerHTML=value;cell.appendChild(link)}else{cell.innerHTML=value}}window.detectCellType=detectCellType;window.setCellValue=setCellValue;window.celltypeimported=true}if(!window.inputparserimported){window.dlz=window.LZString?window.LZString.decompressFromEncodedURIComponent:()=>{console.error('LZString not found. add <script src="https://cdnjs.cloudflare.com/ajax/libs/lz-string/1.4.4/lz-string.min.js"><\/script> to your html');return""};class InputParser{constructor(defaultFromDictMode="horizontal"){this.parse=this.parse.bind(this);this.testString=this.testString.bind(this);this.parseString=this.parseString.bind(this);this.isDict=this.isDict.bind(this);this.defaultFromDictMode=defaultFromDictMode;this.fromData=this.fromData.bind(this);this.fromString=this.fromString.bind(this);this.fromSRC=this.fromSRC.bind(this);this.fromJSON=this.fromJSON.bind(this);this.fromCSV=this.fromCSV.bind(this);this.fromMarkdown=this.fromMarkdown.bind(this);this.fromDict=this.fromDict.bind(this);this.fromHeadersAndDict=this.fromHeadersAndDict.bind(this);this.fromHeadersAndListOfDicts=this.fromHeadersAndListOfDicts.bind(this);this.fromHeadersAndListOfLists=this.fromHeadersAndListOfLists.bind(this);this.fromListOfDicts=this.fromListOfDicts.bind(this);this.fromListOfLists=this.fromListOfLists.bind(this);this.fromHeaders=this.fromHeaders.bind(this)}isDict(v){return v!==undefined&&v instanceof Object&&!(v instanceof Array)}parse(data){if(!data){return[]}else if(data instanceof Object){return data}if(typeof data==="string"){if(data.startsWith("[")&&data.endsWith("]")||data.startsWith("{")&&data.endsWith("}")){return JSON.parse(data)}else{return data.split(",").map(x=>x.trim())}}}testString(data){return/,|\||\n|\[|\]|\{|\}|\//.test(data)}parseString(data){data=data.trim();if(!data){return""}if(!this.testString(data)){let newdata;try{newdata=dlz(data);if(this.testString(newdata)){return newdata}}catch(e){}try{newdata=atob(data);if(this.testString(newdata)){return newdata}}catch(e){throw new Error("unable to interpret string")}}data=data.trim();return data}fromSRC(src){src=this.parseString(src);return fetch(src).then(r=>r.text()).then(t=>this.fromString(t))}fromData(headers,data){if(!headers&&!data){return[[],[]]}headers=this.parse(headers);data=this.parse(data);if(headers&&headers.length>0){if(this.isDict(data)){return this.fromHeadersAndDict(headers,data)}else if(data instanceof Array){if(data.every(x=>x instanceof Array)){return this.fromHeadersAndListOfLists(headers,data)}else if(data.every(x=>x instanceof Object)){return this.fromHeadersAndListOfDicts(headers,data)}}else{throw new Error("Data is not a dict, list of lists or a list of dicts")}}else{if(this.isDict(data)){return this.fromDict(data)}else if(data instanceof Array){if(data.every(x=>x instanceof Array)){return this.fromListOfLists(data)}else if(data.every(x=>x instanceof Object)){return this.fromListOfDicts(data)}}else{throw new Error("Data is not a dict, list of lists or a list of dicts")}}return[headers,data]}fromString(data){data=this.parseString(data);if(this.testString(data)){if(data.startsWith("[")&&data.endsWith("]")||data.startsWith("{")&&data.endsWith("}")){return this.fromJSON(data)}else if(data.startsWith("|")&&data.endsWith("|")){return this.fromMarkdown(data)}else if(data.startsWith("<")&&data.endsWith(">")){return this.fromHTML(data)}else{return this.fromCSV(data)}}else{throw new Error("unable to interpret string")}}fromJSON(json){return this.fromData(undefined,json)}fromCSV(csv){csv=this.parseString(csv);console.log("from csv",csv);let rows=csv.split("\n");console.log("rows",rows);rows=rows.filter(row=>row.trim());rows=rows.map(row=>{const cells=row.match(/(".*?"|[^",]+)(?=\s*,|\s*$)/g);return cells.map(cell=>{return cell.trim().replace(/^"|"$/g,"")})});let headers=rows[0];let data=rows.slice(1);let numCols=headers.length;if(!data.every(row=>row.length===numCols)){throw new Error("Number of columns in data does not match number of columns in headers")}return this.fromHeadersAndListOfLists(headers,data)}fromMarkdown(md){md=this.parseString(md);console.log("from markdown",md);let rows=md.trim().split("\n").map(row=>row.trim());rows=rows.filter((row,index)=>index!==1);let parsedRows=rows.map(row=>{row=row.replace(/\\\|/g,"\0");let cells=row.split("|").map(cell=>cell.trim());cells=cells.map(cell=>cell.replace(/\0/g,"|").trim());return cells.filter(cell=>cell)});let headers=parsedRows[0];let data=parsedRows.slice(1);let numCols=headers.length;if(!data.every(row=>row.length===numCols)){throw new Error("Number of columns in data does not match number of columns in headers")}return this.fromHeadersAndListOfLists(headers,data)}fromHTML(html){if(!html.startsWith("<table>")){html=`<table>${html}</table>`}console.log("from html",html);let parser=new DOMParser;let doc=parser.parseFromString(html,"text/html");let table=doc.querySelector("table");const tableData=[];const parseSection=section=>{section.querySelectorAll("tr").forEach(row=>{const rowData=[];row.querySelectorAll("th, td").forEach(cell=>{rowData.push(cell.textContent||cell.innerText)});tableData.push(rowData)})};const sections=table.querySelectorAll("thead, tbody, tfoot");if(sections.length){sections.forEach(section=>parseSection(section))}else{parseSection(table)}let headers=tableData[0];let data=tableData.slice(1);return this.fromHeadersAndListOfLists(headers,data)}fromHeaders(headers){headers=this.parse(headers);console.log("from headers",headers);return[headers,[]]}fromHeadersAndDict(headers,data){headers=this.parse(headers);data=this.parse(data);console.log("from headers and dict",headers,data);return this.fromHeadersAndListOfDicts(headers,[data])}fromDict(data,mode){mode=mode||this.defaultFromDictMode;data=this.parse(data);let values=Array.from(Object.values(data));if(values.every(x=>x instanceof Array)){let headers=Array.from(Object.keys(data));let i=0;let numRows=data[headers[0]].length;if(!values.every(x=>x.length===numRows)){throw new Error("Number of rows in data does not match number of rows in headers")}let newdata=[];for(i=0;i<numRows;i++){let row=[];for(let header of headers){row.push(data[header][i])}newdata.push(row)}return this.fromHeadersAndListOfLists(headers,newdata)}else if(values.every(this.isDict)){let keyIsValueInEveryDict=true;for(let[k,v]of Object.entries(data)){if(!Object.keys(v).includes(k)){return false}}if(keyIsValueInEveryDict){return this.fromListOfDicts(values)}let headers=[];for(let row of values){for(let key in row){if(!headers.includes(key)){headers.push(key)}}}let keyNameChoices=["name","id","key","pk"];let keyName=keyNameChoices.find(x=>!headers.includes(x));let newValues=[];for(let[k,v]of Object.entries(data)){v[keyName]=k;newValues.push(v)}return this.fromListOfDicts(newValues)}if(mode==="horizontal"){console.log("from dict (horizontal)",data);let headers=Object.keys(data);data=[Array.from(Object.values(data))];return[headers,data]}else if(mode==="vertical"){console.log("from dict (vertical)",data);let headers=["key","value"];data=Object.entries(data);return[headers,data]}}fromHeadersAndListOfDicts(headers,data){data=this.parse(data);console.log("from headers and list of dicts",headers,data);return[headers,data]}fromHeadersAndListOfLists(headers,data){data=this.parse(data);console.log("from headers and list of lists",headers,data);return[headers,data]}fromListOfDicts(data){data=this.parse(data);console.log("from list of dicts",data);let headers=[];for(let row of data){for(let key in row){if(!headers.includes(key)){headers.push(key)}}}return[headers,data]}fromListOfLists(data){data=this.parse(data);console.log("from list of lists",data);let headers=new Array(data[0].length).fill(null).map((x,i)=>`#<${i}>`);return[headers,data]}}window.InputParser=InputParser;window.inputparserimported=true}if(!window.outputparserimported){window.lz=window.LZString?window.LZString.compressToEncodedURIComponent:()=>{console.error('LZString not found. add <script src="https://cdnjs.cloudflare.com/ajax/libs/lz-string/1.4.4/lz-string.min.js"><\/script> to your html');return""};class OutputParser{constructor(tbdb){this.tbdb=tbdb;this.getColumn=this.getColumn.bind(this)}getColumn(which){for(let[i,h]of this.headers.entries()){if(h===which){return this.rows.map(row=>row[i])}}for(let[i,h]of this.headers.entries()){if(h===i){return this.tbdb.rows.map(row=>row[i])}}}get headers(){return this.tbdb.headers}get data(){return this.tbdb.data}get rows(){return this.tbdb.rows}get columnData(){let d={};for(let[i,h]of this.headers.entries()){d[h]=this.rows.map(row=>row[i])}return d}get json(){return JSON.stringify(this.data)}get lzdata(){return LZString.compressToEncodedURIComponent(JSON.stringify(this.data))}get b64data(){return btoa(JSON.stringify(this.data))}get url(){let u=new URL(window.location.href);u.search=new URLSearchParams({u:new URLSearchParams({data:btoa(JSON.stringify(this.data))}).toString()}).toString();return u.toString()}get lzurl(){let u=new URL(window.location.href);u.search=new URLSearchParams({data:this.lzdata}).toString();return u.toString()}get csv(){let r;let csv="";let rows=[this.headers,...this.rows];for(let row of rows){r=row.map(x=>x.includes(",")?`"${x}"`:x);csv+=r.join(",")+"\n"}return csv}get lzcsv(){return LZString.compressToEncodedURIComponent(this.csv)}get b64csv(){return btoa(this.csv)}get md(){let r;let md="";let rows=[this.headers,...this.rows];for(let row of rows){r=row.map(x=>x.includes("|")?x.replace(/\|/g,"\\|"):x);md+="|"+r.join("|")+"|\n"}return md}get lzmd(){return LZString.compressToEncodedURIComponent(this.md)}get b64md(){return btoa(this.md)}}window.OutputParser=OutputParser;window.outputparserimported=true}if(!window.teebydeebyimported){class TeebyDeeby extends HTMLElement{constructor(){super();this.parser=new InputParser;this.out=new OutputParser(this);this.fromSRC=this.fromSRC.bind(this);this.setContent=this.setContent.bind(this);this.clear=this.clear.bind(this);this.setCellValue=this.setCellValue.bind(this);this.addColumn=this.addColumn.bind(this);this.removeColumn=this.removeColumn.bind(this);this.addRow=this.addRow.bind(this);this.removeRow=this.removeRow.bind(this);this.moveColumn=this.moveColumn.bind(this);this.moveRow=this.moveRow.bind(this);this.sort=this.sort.bind(this);this.setPageSize=this.setPageSize.bind(this);this.setPage=this.setPage.bind(this);this._setupInnerHTML=this._setupInnerHTML.bind(this);this._onload=this._onload.bind(this);this._rowToDict=this._rowToDict.bind(this);this._rePage=this._rePage.bind(this);this._onTHClick=this._onTHClick.bind(this);this._onHeaderEdit=this._onHeaderEdit.bind(this);this._onDataEdit=this._onDataEdit.bind(this);this._onDataEditInput=this._onDataEditInput.bind(this);this._onHeaderEditInput=this._onHeaderEditInput.bind(this);this._resizeThead=this._resizeThead.bind(this);this._pageSize=25;this._page=0;this._headers=[];this._data=[];this._unsavedHeaderEdits={};this._unsavedDataEdits={};this._resizing=0;this._contentEditable=false;this._headersEditable=false;for(let method of Object.getOwnPropertyNames(Object.getPrototypeOf(this.parser))){if(method.startsWith("from")){if(!this[method]){this[method]=function(a,b){let[h,d]=this.parser[method](a,b);this.setContent(h,d)}.bind(this)}}}document.addEventListener("DOMContentLoaded",this._onload)}fromSRC(src){this.parser.fromSRC(src).then(([h,d])=>this.setContent(h,d))}setContent(headers,data){this.clear();for(let h of headers){this.addColumn(h)}for(let d of data){this.addRow(d)}if(this.table.offsetHeight>window.innerHeight){let h=window.innerHeight*.9;let top=this.table.getBoundingClientRect().top;let maxBottom=top+h;let n=0;let row;while(true){n+=1;row=this.tbody.children[n];if(row.getBoundingClientRect().bottom>maxBottom){n-=1;break}}this.pageSize=Math.max(5,5*Math.floor(n/5));if(!this.page){this.page=1}}console.log("set content",this.classList,this.classList.contains("scroll"));if(this.classList.contains("scroll")){this._resizeThead()}}setCellValue(rowInd,colInd,value){this._data[rowInd][colInd]=value;let cell=this.tbody.children[rowInd].children[colInd];console.log("set cell value",rowInd,colInd,value,cell);setCellValue(cell,value,this._contentEditable)}addColumn(headerKey=null,index=-1,fillValue=undefined){console.log("adding column contenteditable",this._contentEditable);if(index<0){index=this._headers.length+index+1}if(headerKey===null){headerKey=`#<${index}>`}this._headers.splice(index,0,headerKey);let th=document.createElement("th");th.innerHTML=headerKey;th.classList.add("none");if(this._headersEditable){th.setAttribute("contenteditable",true);th.addEventListener("input",e=>{this._onHeaderEditInput(th.cellIndex,e.target.innerHTML)});th.addEventListener("blur",e=>{this._onHeaderEdit(th.cellIndex,e.target.innerHTML)})}th.addEventListener("click",this._onTHClick);if(index===this._headers.length-1){this.thead.appendChild(th)}else{this.thead.insertBefore(th,this.thead.children[index])}let tf=document.createElement("td");tf.innerHTML="";if(index===this._headers.length-1){this.tfoot.appendChild(tf)}else{this.tfoot.insertBefore(tf,this.tfoot.children[index])}this._headers=this._headers.map((x,i)=>{if(x.startsWith("#<")&&x.endsWith(">")){return`#<${i}>`}return x});for(let data of this._data){let isfunc=typeof fillValue==="function";if(isfunc){data.splice(index,0,null);fillValue=fillValue(this._rowToDict(data));data[index]=fillValue}else{data.splice(index,0,fillValue)}}for(let row of this.tbody.children){if(i==0){continue}let cell=row.insertCell(index);if(this._contentEditable){cell.setAttribute("contenteditable",true);cell.addEventListener("input",e=>{this._onDataEditInput(row.rowIndex,cell.cellIndex,e.target.innerHTML)});cell.addEventListener("blur",e=>{this._onDataEdit(row.rowIndex,cell.cellIndex,e.target.innerHTML)})}cell.innerHTML=fillValue}}removeColumn(index){if(index<0){index=this._headers.length+index}this._headers.splice(index,1);for(let data of this._data){data.splice(index,1)}for(let row of this.tbody.children){row.deleteCell(index)}}addRow(data=undefined){if(data===undefined){data=new Array(this._headers.length).fill(null)}else if(data instanceof Array){}else if(data instanceof Object){data=this._headers.map(h=>data[h])}this._data.push(data);let row=this.tbody.insertRow(-1);for(let value of data){let cell=row.insertCell(-1);if(this._contentEditable){cell.setAttribute("contenteditable",true);cell.addEventListener("input",e=>{this._onDataEditInput(row.rowIndex,cell.cellIndex,e.target.innerHTML)});cell.addEventListener("blur",e=>{this._onDataEdit(row.rowIndex,cell.cellIndex,e.target.innerHTML)})}this.setCellValue(this.tbody.children.length-1,cell.cellIndex,value)}let rowInd=this._data.length-1;if(this.minRow<=rowInd&&rowInd<this.maxRow){row.classList.remove("hidden")}else{row.classList.add("hidden")}this.numPagesInput.value=this.numPages}removeRow(index){this._data.splice(index,1);this.tbody.deleteRow(index);if(index<0){index=this._data.length+index}let nextRow=this.tbody.children[index];if(nextRow){if(this.minRow<=index&&index<this.maxRow){nextRow.classList.remove("hidden")}else{nextRow.classList.add("hidden")}}}clear(){this._headers=[];this._data=[];this.thead.innerHTML="";this.tbody.innerHTML="";this.tfoot.innerHTML=""}setData(data){this.clear();this.fromJSON(data)}moveColumn(startIndex,endIndex){if(startIndex<0){startIndex=this._headers.length+startIndex}if(endIndex<0){endIndex=this._headers.length+endIndex}let header=this._headers.splice(startIndex,1)[0];this._headers.splice(endIndex,0,header);for(let data of this._data){let value=data.splice(startIndex,1)[0];data.splice(endIndex,0,value)}for(let row of this.tbody.children){let cell=row.deleteCell(startIndex);row.insertBefore(cell,row.children[endIndex])}}moveRow(startIndex,endIndex){let data=this._data.splice(startIndex,1)[0];this._data.splice(endIndex,0,data);let row=this.tbody.deleteRow(startIndex);this.tbody.insertBefore(row,this.tbody.children[endIndex]);this._rePage()}sort(colInd,dir=1){if(typeof colInd==="string"){colInd=this._headers.indexOf(colInd)}else if(colInd<0){colInd=this._headers.length+colInd}if(dir==="up"){dir=1}if(dir==="down"){dir=-1}if(dir==="none"||!dir){dir=0}let th=this.thead.children[colInd];let oldDir=parseInt(th.getAttribute("dir")||"0");if(oldDir===dir){return}th.classList.remove("down");th.classList.remove("up");th.classList.remove("none");if(dir===0){th.classList.add("none")}else if(dir===1){th.classList.add("up")}else if(dir===-1){th.classList.add("down")}else{throw new Error("dir must be 1, 0, or -1")}th.setAttribute("dir",dir);let column=this._data.map((row,i)=>{return{value:row[colInd],index:i}});let sortFunc=(a,b)=>{let av=a.value;let bv=b.value;let ta=(""+av).replace("$","");let tb=(""+bv).replace("$","");if(!isNaN(ta)&&!isNaN(tb)){av=parseFloat(ta);bv=parseFloat(tb)}if(av<bv){return dir}if(av>bv){return-dir}return 0};column.sort(sortFunc);let oldRows=Array.from(this.tbody.children);let newData=[];this.tbody.innerHTML="";for(let row of column){newData.push(this._data[row.index]);this.tbody.appendChild(oldRows[row.index])}this._data=newData;this._rePage()}setPageSize(value){value=parseInt(value);this._pageSize=value;this.pageSizeInput.value=value;this.numPagesInput.value=this.numPages;this.setAttribute("pagesize",value);this.pageInput.setAttribute("max",this.numPages);console.warn("set page size",value,this.numPages);this._rePage()}setPage(value){value=parseInt(value);this._page=value;this.pageInput.value=value;this.setAttribute("page",value);this._rePage()}get minRow(){return this.page?(this._page-1)*this._pageSize:0}get maxRow(){return this.page?this._page*this._pageSize:this._data.length}get pageSize(){return this._pageSize}set pageSize(value){this.setPageSize(value)}get page(){return this._page}set page(value){this.setPage(value)}get numPages(){return Math.ceil(this._data.length/this._pageSize)}get headers(){return this._headers}get rows(){return this._data}set rows(value){let oldHeaders=JSON.parse(JSON.stringify(this._headers));this.clear();this.fromData(oldHeaders,value)}get data(){return this._data.map(this._rowToDict)}set data(value){this.clear();this.fromJSON(value)}get json(){return this.out.json}set json(value){this.fromJSON(value)}get csv(){return this.out.csv}set csv(value){this.fromCSV(value)}get md(){return this.out.md}set md(value){this.fromMarkdown(value)}get lz(){return this.out.lzdata}set lz(value){this.fromData(undefined,value)}get url(){return this.out.url}set url(value){this.fromSRC(value)}_onload(){let url=new URL(window.location.href);let s=url.searchParams;let u=s.get("u");if(u){let p=new URLSearchParams(atob(u));for(let k of p.keys()){s.set(k,p.get(k))}}let mode=this.getAttribute("mode")||url.searchParams.get("mode")||"horizontal";let uclass=s.get("class");let pagetitle=this.getAttribute("pagetitle")||s.get("pagetitle")||undefined;if(pagetitle!==undefined){document.title=pagetitle}let faviconSrc=this.getAttribute("favicon")||s.get("favicon")||undefined;if(faviconSrc!==undefined){let link=document.createElement("link");link.rel="icon";link.href=faviconSrc;document.head.appendChild(link)}this._contentEditable=this.getAttribute("contenteditable")||s.get("contenteditable")||false;this._headersEditable=this.getAttribute("headerseditable")||s.get("headerseditable")||false;let _pageSize=this.getAttribute("pagesize")||s.get("pagesize");this._pageSize=parseInt(this.getAttribute("pagesize")||s.get("pagesize")||this._pageSize);if(this._pageSize instanceof String||typeof this._pageSize==="string"){this._pageSize=parseInt(this._pageSize)}let _page=this.getAttribute("page")||s.get("page");this._page=parseInt(_page||this._page);if(this._page instanceof String||typeof this._page==="string"){this._page=parseInt(this._page)}if(_page===null&&parseInt(_pageSize)>0){this._page=1}if(this._page>0&&this._pageSize>0){this.classList.add("pager")}if(uclass){for(let cls of uclass.split(" ")){this.classList.add(cls.trim())}}this.parser.defaultFromDictMode=mode;let t=this.innerHTML.trim();this._setupInnerHTML();if(t){return this.fromString(t)}let headers=this.getAttribute("headers");let data=this.getAttribute("data");let markdown=this.getAttribute("md");let csv=this.getAttribute("csv");let src=this.getAttribute("src");if(src){return this.fromSRC(src)}if(!headers&&!data){if(markdown){return this.fromMarkdown(markdown)}else if(csv){return this.fromCSV(csv)}else{headers=s.get("headers");data=s.get("data");markdown=s.get("md");csv=s.get("csv");src=s.get("src");if(src){return this.fromSRC(src)}console.log("url",{headers:headers,data:data,markdown:markdown,csv:csv});if(!headers&&!data){console.log("no headers or data");if(markdown){return this.fromMarkdown(markdown)}else if(csv){return this.fromCSV(csv)}else{console.log("displaying default");return this.fromData(["fmt","what","attribute(s)","lz okay","b64 okay"],[["json","autodetect","data","yes","yes"],["url","path to .json, .md, .csv","src","yes","yes"],["markdown","table","md","yes","yes"],["csv","table","csv","yes","yes"],["innerHTML","table","N/A","no","no"],["headers + list of lists","list","headers","yes","yes"],["list of lists","row values","data","yes","yes"],["list of dicts","row values","data","yes","yes"],["dict of dicts","row values","data","yes","yes"],["dict of lists","column values","data","yes","yes"],["dict of values","single row (if mode = 'horizontal')","data","yes","yes"],["dict of values","key/value columns (if mode = 'vertical')","data","yes","yes"]])}}return this.fromData(headers,data)}}return this.fromData(headers,data)}_setupInnerHTML(){this.innerHTML=`
<table>
<thead>
</thead>
<tbody>
</tbody>
<tfoot>
</tfoot>
<div class="pagination">
<span>Page </span>
<input type="number" class="page" value="0" min="0" max="10000" >
<span>/</span>
<input type="number" class="numPages" min="0" max="10000" value="0" disabled>
<span>(size</span>
<input type="number" class="pageSize" min="0" max="10000" value="50">
<span>)</span>
<div class="arrows hidden">
<button class="prev">prev</button>
<button class="next">next</button>
</div>
</div>
<input type="file" id="file_input" style="display:none;" />
</table>
`;this.table=this.querySelector("table");this.thead=this.querySelector("thead");this.tbody=this.querySelector("tbody");this.tfoot=this.querySelector("tfoot");this.pager=this.querySelector(".pager");this.pageInput=this.querySelector(".page");this.pageInput.value=this._page;this.numPagesInput=this.querySelector(".numPages");this.numPagesInput.value=this._numPages;this.pageInput.setAttribute("max",this.numPages);this.pageSizeInput=this.querySelector(".pageSize");this.pageSizeInput.value=this._pageSize;this.pageSizeInput.addEventListener("input",e=>{this.pageSize=e.target.value});this.pageInput.addEventListener("input",e=>{this.page=e.target.value});this.prev=this.querySelector(".prev");this.next=this.querySelector(".next");if(this.prev){this.prev.addEventListener("click",e=>{this.page-=1})}if(this.next){this.next.addEventListener("click",e=>{this.page+=1})}this.addEventListener("dragover",event=>{console.log("dragover",event.dataTransfer.items);event.preventDefault();if(event.dataTransfer.items&&event.dataTransfer.items.length>0&&event.dataTransfer.items[0].kind==="file"){this.classList.add("dragover")}});this.addEventListener("dragleave",event=>{this.classList.remove("dragover")});this.addEventListener("drop",event=>{event.preventDefault();this.classList.remove("dragover");if(event.dataTransfer.items&&event.dataTransfer.items.length>0&&event.dataTransfer.items[0].kind==="file"){let file=event.dataTransfer.items[0].getAsFile();console.log("file",file);let stringContent="";let reader=new FileReader;reader.onload=e=>{stringContent=e.target.result;console.log("file",file,stringContent);this.fromString(stringContent)};reader.readAsText(file)}})}_onDataEditInput(rowInd,colInd,value){console.log("data edit input",rowInd,colInd,value);if(!this._unsavedDataEdits[rowInd]){this._unsavedDataEdits[rowInd]={}}this._unsavedDataEdits[rowInd][colInd]=value;if(this.onDataEditInput){this.onDataEditInput(rowInd,colInd,value)}if(this.addedResize){this._resizeThead()}}_onDataEdit(rowInd,colInd,value){if(this._unsavedDataEdits[rowInd]&&this._unsavedDataEdits[rowInd][colInd]){delete this._unsavedDataEdits[rowInd][colInd];if(Object.keys(this._unsavedDataEdits[rowInd]).length===0){delete this._unsavedDataEdits[rowInd]}}if(value===this._data[rowInd][colInd]){return}this.setCellValue(rowInd,colInd,value);if(this.onDataEdit){this.onDataEdit(rowInd,colInd,value)}}_onHeaderEditInput(colInd,value){console.log("header edit input",colInd,value);this._unsavedHeaderEdits[colInd]=value;if(this.onHeaderEditInput){this.onHeaderEditInput(colInd,value)}if(this.addedResize){this._resizeThead()}}_onHeaderEdit(colInd,value){delete this._unsavedHeaderEdits[colInd];if(value===this._headers[colInd]){return}console.log("header edit",colInd,value);this._headers[colInd]=value;if(this.onHeaderEdit){this.onHeaderEdit(colInd,value)}}_onTHClick(e){console.log("th click",e);let th=e.target;let colInd=Array.from(th.parentElement.children).indexOf(th);console.log("colInd",colInd);if(th.classList.contains("up")){this.sort(colInd,-1)}else{this.sort(colInd,1)}}_resizeThead(){this._resizing+=1;let r=this._resizing;const firstRowCells=Array.from(this.tbody.children[0].children);const headerCells=Array.from(this.thead.children);const tbodyWidth=this.tbody.children[0].offsetWidth;const theadWidth=this.table.offsetWidth;const scrollbarWidth=(theadWidth-tbodyWidth)/2;for(let i=0;i<20;i++){if(this._resizing!==r){return}firstRowCells.map((cell,index)=>{if(headerCells[index]!==undefined){const cellWidth=cell.offsetWidth;if(index===firstRowCells.length-1){headerCells[index].style.width=`${cellWidth+scrollbarWidth}px`}else{headerCells[index].style.width=`${cellWidth}px`}}});headerCells.map((cell,index)=>{if(firstRowCells[index]!==undefined){const cellWidth=cell.offsetWidth;if(index===firstRowCells.length-1){firstRowCells[index].style.width=`${cellWidth-scrollbarWidth}px`}else{firstRowCells[index].style.width=`${cellWidth}px`}}})}if(!this.addedResize){window.addEventListener("resize",this._resizeThead.bind(this));this.addedResize=true}}_rePage(){if(this._page>0&&this._pageSize>0){this.classList.add("pager")}for(let i=0;i<this._data.length;i++){let row=this.tbody.children[i];if(this.minRow<=i&&i<this.maxRow){row.classList.remove("hidden")}else{row.classList.add("hidden")}}if(this.addedResize){this._resizeThead()}}_rowToDict(row){let dict={};for(let i=0;i<this._headers.length;i++){dict[this._headers[i]]=row[i]}return dict}}customElements.define("teeby-deeby",TeebyDeeby);class TbDb extends TeebyDeeby{constructor(){super()}}customElements.define("tb-db",TbDb);window.TeebyDeeby=TeebyDeeby;window.TbDb=TbDb;let script=document.currentScript;if(script){let attrs=Array.from(script.attributes).map(x=>x.name).filter(x=>x!=="src");if(attrs.length||script.innerHTML.trim()){let tbdb=document.createElement("teeby-deeby");for(let attr of attrs){tbdb.setAttribute(attr,script.getAttribute(attr))}tbdb.innerHTML=script.innerHTML;let head=document.head||document.getElementsByTagName("head")[0];let body=document.body||document.getElementsByTagName("body")[0];if(script.parentElement===head){body.appendChild(tbdb);script.innerHTML=""}else{script.replaceWith(tbdb)}}}window.teebydeebyimported=true}