otsdaq_utilities  v2_05_02_indev
html_table_import.min.js
1 /* Tabulator v4.5.3 (c) Oliver Folkerd */
2 var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},HtmlTableImport=function(t){this.table=t,this.fieldIndex=[],this.hasIndex=!1};HtmlTableImport.prototype.parseTable=function(){var t=this,e=t.table.element,o=t.table.options,a=(o.columns,e.getElementsByTagName("th")),n=e.getElementsByTagName("tbody")[0],r=[];t.hasIndex=!1,t.table.options.htmlImporting.call(this.table),n=n?n.getElementsByTagName("tr"):[],t._extractOptions(e,o),a.length?t._extractHeaders(a,n):t._generateBlankHeaders(a,n);for(var l=0;l<n.length;l++){var i=n[l],s=i.getElementsByTagName("td"),p={};t.hasIndex||(p[o.index]=l);for(var m=0;m<s.length;m++){var d=s[m];void 0!==this.fieldIndex[m]&&(p[this.fieldIndex[m]]=d.innerHTML)}r.push(p)}var f=document.createElement("div"),u=e.attributes;for(var m in u)"object"==_typeof(u[m])&&f.setAttribute(u[m].name,u[m].value);e.parentNode.replaceChild(f,e),o.data=r,t.table.options.htmlImported.call(this.table),this.table.element=f},HtmlTableImport.prototype._extractOptions=function(t,e,o){var a=t.attributes,n=o?Object.assign([],o):Object.keys(e),r={};n.forEach(function(t){r[t.toLowerCase()]=t});for(var l in a){var i,s=a[l];s&&"object"==(void 0===s?"undefined":_typeof(s))&&s.name&&0===s.name.indexOf("tabulator-")&&(i=s.name.replace("tabulator-",""),void 0!==r[i]&&(e[r[i]]=this._attribValue(s.value)))}},HtmlTableImport.prototype._attribValue=function(t){return"true"===t||"false"!==t&&t},HtmlTableImport.prototype._findCol=function(t){return this.table.options.columns.find(function(e){return e.title===t})||!1},HtmlTableImport.prototype._extractHeaders=function(t,e){for(var o=0;o<t.length;o++){var a,n,r=t[o],l=!1,i=this._findCol(r.textContent);i?l=!0:i={title:r.textContent.trim()},i.field||(i.field=r.textContent.trim().toLowerCase().replace(" ","_")),a=r.getAttribute("width"),a&&!i.width&&(i.width=a),n=r.attributes,this._extractOptions(r,i,Column.prototype.defaultOptionList);for(var s in n){var p,m=n[s];m&&"object"==(void 0===m?"undefined":_typeof(m))&&m.name&&0===m.name.indexOf("tabulator-")&&(p=m.name.replace("tabulator-",""),i[p]=this._attribValue(m.value))}this.fieldIndex[o]=i.field,i.field==this.table.options.index&&(this.hasIndex=!0),l||this.table.options.columns.push(i)}},HtmlTableImport.prototype._generateBlankHeaders=function(t,e){for(var o=0;o<t.length;o++){var a=t[o],n={title:"",field:"col"+o};this.fieldIndex[o]=n.field;var r=a.getAttribute("width");r&&(n.width=r),this.table.options.columns.push(n)}},Tabulator.prototype.registerModule("htmlTableImport",HtmlTableImport);