Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tableexport

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tableexport - npm Package Compare versions

Comparing version 4.0.0-rc.2 to 4.0.0-rc.3

6

bower.json
{
"name": "tableexport.js",
"version": "4.0.0-rc.2",
"version": "4.0.0-rc.3",
"authors": [

@@ -24,5 +24,5 @@ "clarketm <travis.m.clarke@gmail.com>"

"jquery": "^3.1.1",
"xlsx-js": "^0.8.7",
"file-saverjs": "^1.3.5",
"blobjs": "^1.1.0"
"blobjs": "^1.1.0",
"js-xlsx": "^0.9.12"
},

@@ -29,0 +29,0 @@ "license": "MIT",

/*!
* TableExport.js 4.0.0-rc.2 (https://www.travismclarke.com)
* TableExport.js 4.0.0-rc.3 (https://www.travismclarke.com)
* Copyright 2017 Travis Clarke

@@ -116,3 +116,3 @@ * Licensed under the MIT license

*/
version: '4.0.0-rc.2',
version: '4.0.0-rc.3',
/**

@@ -119,0 +119,0 @@ * Default plugin options.

/*!
* TableExport.js 4.0.0-rc.2 (https://www.travismclarke.com)
* TableExport.js 4.0.0-rc.3 (https://www.travismclarke.com)
* Copyright 2017 Travis Clarke
* Licensed under the MIT license
*/
!function(t,e){"function"==typeof define&&define.amd?define(["jquery","blobjs","file-saverjs","xlsx"],e):"object"==typeof exports&&"string"!=typeof exports.nodeName?module.exports=e(require("jquery"),require("blobjs"),require("file-saverjs"),require("xlsx")):t.TableExport=e(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,r,n){"use strict";function o(){for(var t=arguments,e=1;e<t.length;e++)for(var r in t[e])t[e].hasOwnProperty(r)&&(t[0][r]=t[e][r]);return t[0]}function s(e){return e instanceof NodeList||t&&e instanceof t?[].slice.call(e):[].concat(e)}function i(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.cls)}function a(t,e,r){var n={};return t?(n.bootstrapClass=t[0]+" ",n.bootstrapTheme=t[1]+" ",n.bootstrapSpacing=t[2]+" "):(n.bootstrapClass=r+" ",n.bootstrapTheme="",n.bootstrapSpacing=""),n}var l=function(t,e,r){if(!t)return new Error('"selectors" is required');var i=this;i.settings=r?e:o({},i.defaults,e),i.selectors=s(t);var l=i.settings;l.ignoreRows=l.ignoreRows instanceof Array?l.ignoreRows:[l.ignoreRows],l.ignoreCols=l.ignoreCols instanceof Array?l.ignoreCols:[l.ignoreCols],l.ignoreCSS=i.ignoreCSS instanceof Array?i.ignoreCSS.join(", "):i.ignoreCSS,l.emptyCSS=i.emptyCSS instanceof Array?i.emptyCSS.join(", "):i.emptyCSS,l.formatValue=i.formatValue.bind(this,l.trimWhitespace),l.bootstrapSettings=a(i.bootstrap,i.bootstrapConfig,i.defaultButton);var f={};i.getExportData=function(){return f},i.selectors.forEach(function(t){var e={},o=t.querySelectorAll("caption:not(.head)");r&&o.parentNode.removeChild(o),e.rows=s(t.querySelectorAll("tbody > tr")),e.rows=l.headers?s(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=l.footers?e.rows.concat(s(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=l.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===l.filename?t.getAttribute("id")?t.getAttribute("id"):i.defaultFilename:l.filename?l.filename:i.defaultFilename,e.uuid=p(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption:not(.head)");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=l.bootstrapSettings.bootstrapSpacing+l.position,r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=u.getInstance().getItem(t),n=t.substring(t.indexOf("-")+1);f[e.uuid]=f[e.uuid]||{},f[e.uuid][n]=JSON.parse(r)}}(),l.formats.forEach(function(t){!(!n||"xls"!==t)&&(t="xlsm"),!n&&"xlsx"===t&&(t=null),t&&e.setExportData(i.exporters[t].call(i,e))})});var m=document.querySelectorAll("button[tableexport-id]");return c(m,"click",i.downloadHandler,i),i};l.prototype={version:"4.0.0-rc.2",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&#38;","<":"&#60;",">":"&#62;","'":"&#39;","/":"&#47;"},xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},types:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t.replace(/,/g,""))}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!isNaN(Date.parse(t))}}},exporters:{xlsx:function(t){var e=this,r=e.settings,n={},o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,o){if(!~r.ignoreCols.indexOf(o)&&!i(t,r.ignoreCSS)){if(i(t,r.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(n[a]=n[a]||{},n[a][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var s=1;s<t.getAttribute("rowspan");s++)n[a+s]=n[a+s]||{},n[a+s][o]=1;if(n[a]){for(var l=o+1,u=0,p=0,s=0;s<=Math.max.apply(Math,Object.keys(n[a]))&&(n[a][s]?u=p>=o?u+n[a][s]:u:p++,p!==l);s++);return new Array(u).concat({v:r.formatValue(t.textContent),t:e.getType(t.className)})}return{v:r.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return t}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xlsx.mimeType,fileExtension:l.prototype.xlsx.fileExtension})),p=l.prototype.xlsx.buttonContent,c=l.prototype.xlsx.defaultClass,m=f({uuid:t.uuid,type:"xlsx"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},xlsm:function(t){var e=this,r=e.settings,n={},o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,o){if(!~r.ignoreCols.indexOf(o)&&!i(t,r.ignoreCSS)){if(i(t,r.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(n[a]=n[a]||{},n[a][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var s=1;s<t.getAttribute("rowspan");s++)n[a+s]=n[a+s]||{},n[a+s][o]=1;if(n[a]){for(var l=o+1,u=0,p=0,s=0;s<=Math.max.apply(Math,Object.keys(n[a]))&&(n[a][s]?u=p>=o?u+n[a][s]:u:p++,p!==l);s++);return new Array(u).concat({v:r.formatValue(t.textContent),t:e.getType(t.className)})}return{v:r.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return t}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension})),p=l.prototype.xls.buttonContent,c=l.prototype.xls.defaultClass,m=f({uuid:t.uuid,type:"xls"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},xls:function(t){var e=this,r=e.settings,n=l.prototype.xls.separator,o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,n){if(!~r.ignoreCols.indexOf(n)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":{v:r.formatValue(t.textContent),t:e.getType(t.className)}}).join(n)}}).join(e).map(function(t){return[].concat.apply([],t)}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension})),p=l.prototype.xls.buttonContent,c=l.prototype.xls.defaultClass,m=f({uuid:t.uuid,type:"xls"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},csv:function(t){var e=this,r=e.settings,n=l.prototype.csv.separator,o=s(t.rows).map(function(e,o){if(!~r.ignoreRows.indexOf(o-t.thAdj)&&!i(e,r.ignoreCSS)){var a=e.querySelectorAll("th, td");return s(a).map(function(t,e){if(!~r.ignoreCols.indexOf(e)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":'"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"'}).join(n)}}).join(e.rowDel),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.csv.mimeType,fileExtension:l.prototype.csv.fileExtension})),p=l.prototype.csv.buttonContent,c=l.prototype.csv.defaultClass,m=f({uuid:t.uuid,type:"csv"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},txt:function(t){var e=this,r=e.settings,n=l.prototype.txt.separator,o=s(t.rows).map(function(e,o){if(!~r.ignoreRows.indexOf(o-t.thAdj)&&!i(e,r.ignoreCSS)){var a=e.querySelectorAll("th, td");return s(a).map(function(t,e){if(!~r.ignoreCols.indexOf(e)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":r.formatValue(t.textContent)}).join(n)}}).join(e.rowDel),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.txt.mimeType,fileExtension:l.prototype.txt.fileExtension})),p=l.prototype.txt.buttonContent,c=l.prototype.txt.defaultClass,m=f({uuid:t.uuid,type:"txt"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m}},createObjButton:function(t,e,r,n,o){var s=document.createElement("button");return s.setAttribute("tableexport-id",t),s.className=o.bootstrapClass+o.bootstrapTheme+n,s.textContent=r,s},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.prototype.entityMap[t]})},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=l.prototype.types;return~t.indexOf(e.string.defaultClass)?"s":~t.indexOf(e.number.defaultClass)?"n":~t.indexOf(e["boolean"].defaultClass)?"b":~t.indexOf(e.date.defaultClass)?"d":""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t);return(r-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},o=l.prototype.types,s=0;s!==t.length;++s)for(var i=0;i!==t[s].length;++i){r.s.r>s&&(r.s.r=s),r.s.c>i&&(r.s.c=i),r.e.r<s&&(r.e.r=s),r.e.c<i&&(r.e.c=i);var a=t[s][i];if(a&&a.v){var u=n.utils.encode_cell({c:i,r:s});a.t||(o.number.assert(a.v)?a.t="n":o["boolean"].assert(a.v)?a.t="b":o.date.assert(a.v)?a.t="d":a.t="s"),"d"===a.t&&(a.t="n",a.z=n.SSF._table[14],a.v=this.dateNum(a.v)),e[u]=a}}return r.s.c<1e7&&(e["!ref"]=n.utils.encode_range(r)),e},downloadHandler:function(t){var e=t.target,r=JSON.parse(u.getInstance().getItem(e.getAttribute("tableexport-id"))),n=r.data,o=r.filename,s=r.mimeType,i=r.fileExtension;this.export2file(n,s,o,i)},Workbook:function(){this.SheetNames=[],this.Sheets={}},string2ArrayBuffer:function(t){for(var e=new ArrayBuffer(t.length),r=new Uint8Array(e),n=0;n!==t.length;++n)r[n]=255&t.charCodeAt(n);return e},export2file:function(t,o,s,i){if(n&&".xls"===i.substr(0,4)){var a=new this.Workbook,l=this.createSheet(t);a.SheetNames.push(s),a.Sheets[s]=l;var u={bookType:i.substr(1,3)+(i.substr(4)||"m"),bookSST:!1,type:"binary"},p=n.write(a,u);t=this.string2ArrayBuffer(p)}r(new e([t],{type:o+";"+this.charset}),s+i,!0)},update:function(t){},reset:function(){},remove:function(){},LocalStorage:function(){this.store=localStorage,this.namespace="te-",this.getKey=function(t){return this.namespace+t},this.setItem=function(t,e,r){var n=this.getKey(t);if(!this.exists(n)||r)return"string"!=typeof e?this.error('"value" must be a string'):this.store.setItem(n,e)},this.getItem=function(t){var e=this.getKey(t);return this.store.getItem(e)},this.exists=function(t){var e=this.getKey(t);return null!==this.store.getItem(e)},this.removeItem=function(t){var e=this.getKey(t);return this.store.removeItem(e)},this.error=function(t){return new Error("error:",t)}}};var u=l.prototype.LocalStorage;u.getInstance=function(){return u._instance=null,function(){return u._instance||(u._instance=new u),u._instance}}();var p=function(){var t=0;return function(e){return e.id||(e.id="tableexport-"+ ++t),e.id}}(),f=function(){var t,e,r=0;return function(n){var o=n.type;if(n=JSON.stringify(n),0===n.length)return r;for(t=0;t<n.length;t++)e=n.charCodeAt(t),r=(r<<5)-r+e,r|=0;return r.toString(16).substring(1)+"-"+o}}(),c=function(){var t=null;return function(e,r,n,o){for(var s=n.bind(o),i=0;i<e.length;++i)t&&e[i].removeEventListener(r,t,!1),e[i].addEventListener(r,s,!1);t=s}}();if(t){t.fn.tableExport=function(t,e){return new l(this,t,e)};for(var m in l.prototype)t.fn.tableExport[m]=l.prototype[m]}return l});
!function(t,e){"function"==typeof define&&define.amd?define(["jquery","blobjs","file-saverjs","xlsx"],e):"object"==typeof exports&&"string"!=typeof exports.nodeName?module.exports=e(require("jquery"),require("blobjs"),require("file-saverjs"),require("xlsx")):t.TableExport=e(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,r,n){"use strict";function o(){for(var t=arguments,e=1;e<t.length;e++)for(var r in t[e])t[e].hasOwnProperty(r)&&(t[0][r]=t[e][r]);return t[0]}function s(e){return e instanceof NodeList||t&&e instanceof t?[].slice.call(e):[].concat(e)}function i(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.cls)}function a(t,e,r){var n={};return t?(n.bootstrapClass=t[0]+" ",n.bootstrapTheme=t[1]+" ",n.bootstrapSpacing=t[2]+" "):(n.bootstrapClass=r+" ",n.bootstrapTheme="",n.bootstrapSpacing=""),n}var l=function(t,e,r){if(!t)return new Error('"selectors" is required');var i=this;i.settings=r?e:o({},i.defaults,e),i.selectors=s(t);var l=i.settings;l.ignoreRows=l.ignoreRows instanceof Array?l.ignoreRows:[l.ignoreRows],l.ignoreCols=l.ignoreCols instanceof Array?l.ignoreCols:[l.ignoreCols],l.ignoreCSS=i.ignoreCSS instanceof Array?i.ignoreCSS.join(", "):i.ignoreCSS,l.emptyCSS=i.emptyCSS instanceof Array?i.emptyCSS.join(", "):i.emptyCSS,l.formatValue=i.formatValue.bind(this,l.trimWhitespace),l.bootstrapSettings=a(i.bootstrap,i.bootstrapConfig,i.defaultButton);var f={};i.getExportData=function(){return f},i.selectors.forEach(function(t){var e={},o=t.querySelectorAll("caption:not(.head)");r&&o.parentNode.removeChild(o),e.rows=s(t.querySelectorAll("tbody > tr")),e.rows=l.headers?s(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=l.footers?e.rows.concat(s(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=l.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===l.filename?t.getAttribute("id")?t.getAttribute("id"):i.defaultFilename:l.filename?l.filename:i.defaultFilename,e.uuid=p(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption:not(.head)");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=l.bootstrapSettings.bootstrapSpacing+l.position,r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=u.getInstance().getItem(t),n=t.substring(t.indexOf("-")+1);f[e.uuid]=f[e.uuid]||{},f[e.uuid][n]=JSON.parse(r)}}(),l.formats.forEach(function(t){!(!n||"xls"!==t)&&(t="xlsm"),!n&&"xlsx"===t&&(t=null),t&&e.setExportData(i.exporters[t].call(i,e))})});var m=document.querySelectorAll("button[tableexport-id]");return c(m,"click",i.downloadHandler,i),i};l.prototype={version:"4.0.0-rc.3",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&#38;","<":"&#60;",">":"&#62;","'":"&#39;","/":"&#47;"},xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},types:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t.replace(/,/g,""))}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!isNaN(Date.parse(t))}}},exporters:{xlsx:function(t){var e=this,r=e.settings,n={},o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,o){if(!~r.ignoreCols.indexOf(o)&&!i(t,r.ignoreCSS)){if(i(t,r.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(n[a]=n[a]||{},n[a][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var s=1;s<t.getAttribute("rowspan");s++)n[a+s]=n[a+s]||{},n[a+s][o]=1;if(n[a]){for(var l=o+1,u=0,p=0,s=0;s<=Math.max.apply(Math,Object.keys(n[a]))&&(n[a][s]?u=p>=o?u+n[a][s]:u:p++,p!==l);s++);return new Array(u).concat({v:r.formatValue(t.textContent),t:e.getType(t.className)})}return{v:r.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return t}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xlsx.mimeType,fileExtension:l.prototype.xlsx.fileExtension})),p=l.prototype.xlsx.buttonContent,c=l.prototype.xlsx.defaultClass,m=f({uuid:t.uuid,type:"xlsx"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},xlsm:function(t){var e=this,r=e.settings,n={},o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,o){if(!~r.ignoreCols.indexOf(o)&&!i(t,r.ignoreCSS)){if(i(t,r.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(n[a]=n[a]||{},n[a][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var s=1;s<t.getAttribute("rowspan");s++)n[a+s]=n[a+s]||{},n[a+s][o]=1;if(n[a]){for(var l=o+1,u=0,p=0,s=0;s<=Math.max.apply(Math,Object.keys(n[a]))&&(n[a][s]?u=p>=o?u+n[a][s]:u:p++,p!==l);s++);return new Array(u).concat({v:r.formatValue(t.textContent),t:e.getType(t.className)})}return{v:r.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return t}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension})),p=l.prototype.xls.buttonContent,c=l.prototype.xls.defaultClass,m=f({uuid:t.uuid,type:"xls"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},xls:function(t){var e=this,r=e.settings,n=l.prototype.xls.separator,o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,n){if(!~r.ignoreCols.indexOf(n)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":{v:r.formatValue(t.textContent),t:e.getType(t.className)}}).join(n)}}).join(e).map(function(t){return[].concat.apply([],t)}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension})),p=l.prototype.xls.buttonContent,c=l.prototype.xls.defaultClass,m=f({uuid:t.uuid,type:"xls"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},csv:function(t){var e=this,r=e.settings,n=l.prototype.csv.separator,o=s(t.rows).map(function(e,o){if(!~r.ignoreRows.indexOf(o-t.thAdj)&&!i(e,r.ignoreCSS)){var a=e.querySelectorAll("th, td");return s(a).map(function(t,e){if(!~r.ignoreCols.indexOf(e)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":'"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"'}).join(n)}}).join(e.rowDel),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.csv.mimeType,fileExtension:l.prototype.csv.fileExtension})),p=l.prototype.csv.buttonContent,c=l.prototype.csv.defaultClass,m=f({uuid:t.uuid,type:"csv"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},txt:function(t){var e=this,r=e.settings,n=l.prototype.txt.separator,o=s(t.rows).map(function(e,o){if(!~r.ignoreRows.indexOf(o-t.thAdj)&&!i(e,r.ignoreCSS)){var a=e.querySelectorAll("th, td");return s(a).map(function(t,e){if(!~r.ignoreCols.indexOf(e)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":r.formatValue(t.textContent)}).join(n)}}).join(e.rowDel),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.txt.mimeType,fileExtension:l.prototype.txt.fileExtension})),p=l.prototype.txt.buttonContent,c=l.prototype.txt.defaultClass,m=f({uuid:t.uuid,type:"txt"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m}},createObjButton:function(t,e,r,n,o){var s=document.createElement("button");return s.setAttribute("tableexport-id",t),s.className=o.bootstrapClass+o.bootstrapTheme+n,s.textContent=r,s},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.prototype.entityMap[t]})},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=l.prototype.types;return~t.indexOf(e.string.defaultClass)?"s":~t.indexOf(e.number.defaultClass)?"n":~t.indexOf(e["boolean"].defaultClass)?"b":~t.indexOf(e.date.defaultClass)?"d":""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t);return(r-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},o=l.prototype.types,s=0;s!==t.length;++s)for(var i=0;i!==t[s].length;++i){r.s.r>s&&(r.s.r=s),r.s.c>i&&(r.s.c=i),r.e.r<s&&(r.e.r=s),r.e.c<i&&(r.e.c=i);var a=t[s][i];if(a&&a.v){var u=n.utils.encode_cell({c:i,r:s});a.t||(o.number.assert(a.v)?a.t="n":o["boolean"].assert(a.v)?a.t="b":o.date.assert(a.v)?a.t="d":a.t="s"),"d"===a.t&&(a.t="n",a.z=n.SSF._table[14],a.v=this.dateNum(a.v)),e[u]=a}}return r.s.c<1e7&&(e["!ref"]=n.utils.encode_range(r)),e},downloadHandler:function(t){var e=t.target,r=JSON.parse(u.getInstance().getItem(e.getAttribute("tableexport-id"))),n=r.data,o=r.filename,s=r.mimeType,i=r.fileExtension;this.export2file(n,s,o,i)},Workbook:function(){this.SheetNames=[],this.Sheets={}},string2ArrayBuffer:function(t){for(var e=new ArrayBuffer(t.length),r=new Uint8Array(e),n=0;n!==t.length;++n)r[n]=255&t.charCodeAt(n);return e},export2file:function(t,o,s,i){if(n&&".xls"===i.substr(0,4)){var a=new this.Workbook,l=this.createSheet(t);a.SheetNames.push(s),a.Sheets[s]=l;var u={bookType:i.substr(1,3)+(i.substr(4)||"m"),bookSST:!1,type:"binary"},p=n.write(a,u);t=this.string2ArrayBuffer(p)}r(new e([t],{type:o+";"+this.charset}),s+i,!0)},update:function(t){},reset:function(){},remove:function(){},LocalStorage:function(){this.store=localStorage,this.namespace="te-",this.getKey=function(t){return this.namespace+t},this.setItem=function(t,e,r){var n=this.getKey(t);if(!this.exists(n)||r)return"string"!=typeof e?this.error('"value" must be a string'):this.store.setItem(n,e)},this.getItem=function(t){var e=this.getKey(t);return this.store.getItem(e)},this.exists=function(t){var e=this.getKey(t);return null!==this.store.getItem(e)},this.removeItem=function(t){var e=this.getKey(t);return this.store.removeItem(e)},this.error=function(t){return new Error("error:",t)}}};var u=l.prototype.LocalStorage;u.getInstance=function(){return u._instance=null,function(){return u._instance||(u._instance=new u),u._instance}}();var p=function(){var t=0;return function(e){return e.id||(e.id="tableexport-"+ ++t),e.id}}(),f=function(){var t,e,r=0;return function(n){var o=n.type;if(n=JSON.stringify(n),0===n.length)return r;for(t=0;t<n.length;t++)e=n.charCodeAt(t),r=(r<<5)-r+e,r|=0;return r.toString(16).substring(1)+"-"+o}}(),c=function(){var t=null;return function(e,r,n,o){for(var s=n.bind(o),i=0;i<e.length;++i)t&&e[i].removeEventListener(r,t,!1),e[i].addEventListener(r,s,!1);t=s}}();if(t){t.fn.tableExport=function(t,e){return new l(this,t,e)};for(var m in l.prototype)t.fn.tableExport[m]=l.prototype[m]}return l});
{
"name": "tableexport",
"version": "4.0.0-rc.2",
"version": "4.0.0-rc.3",
"authors": [

@@ -5,0 +5,0 @@ "clarketm <travis.m.clarke@gmail.com>"

@@ -7,3 +7,3 @@ [![Build Status](https://travis-ci.org/clarketm/TableExport.svg?branch=master)](https://travis-ci.org/clarketm/TableExport)

## [`v4.0.0-rc.2`](https://github.com/clarketm/TableExport/releases/tag/v4.0.0-rc.2) Release Candidate:
## [`v4.0.0-rc.3`](https://github.com/clarketm/TableExport/releases/tag/v4.0.0-rc.3) Release Candidate:
> **Notice:** In May 2017, [v3.0.0](https://github.com/clarketm/TableExport/releases/tag/v3.3.9) will be superceded by [v4.0.0](https://github.com/clarketm/TableExport/releases/tag/v4.0.0-alpha.5). Althought this is a major version bump, fear not, because all changes will be 100% backwards-compatible.

@@ -10,0 +10,0 @@

/*!
* TableExport.js 4.0.0-rc.2 (https://www.travismclarke.com)
* TableExport.js 4.0.0-rc.3 (https://www.travismclarke.com)
* Copyright 2017 Travis Clarke

@@ -116,3 +116,3 @@ * Licensed under the MIT license

*/
version: '4.0.0-rc.2',
version: '4.0.0-rc.3',
/**

@@ -119,0 +119,0 @@ * Default plugin options.

/*!
* TableExport.js 4.0.0-rc.2 (https://www.travismclarke.com)
* TableExport.js 4.0.0-rc.3 (https://www.travismclarke.com)
* Copyright 2017 Travis Clarke
* Licensed under the MIT license
*/
!function(t,e){"function"==typeof define&&define.amd?define(["jquery","blobjs","file-saverjs","xlsx"],e):"object"==typeof exports&&"string"!=typeof exports.nodeName?module.exports=e(require("jquery"),require("blobjs"),require("file-saverjs"),require("xlsx")):t.TableExport=e(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,r,n){"use strict";function o(){for(var t=arguments,e=1;e<t.length;e++)for(var r in t[e])t[e].hasOwnProperty(r)&&(t[0][r]=t[e][r]);return t[0]}function s(e){return e instanceof NodeList||t&&e instanceof t?[].slice.call(e):[].concat(e)}function i(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.cls)}function a(t,e,r){var n={};return t?(n.bootstrapClass=t[0]+" ",n.bootstrapTheme=t[1]+" ",n.bootstrapSpacing=t[2]+" "):(n.bootstrapClass=r+" ",n.bootstrapTheme="",n.bootstrapSpacing=""),n}var l=function(t,e,r){if(!t)return new Error('"selectors" is required');var i=this;i.settings=r?e:o({},i.defaults,e),i.selectors=s(t);var l=i.settings;l.ignoreRows=l.ignoreRows instanceof Array?l.ignoreRows:[l.ignoreRows],l.ignoreCols=l.ignoreCols instanceof Array?l.ignoreCols:[l.ignoreCols],l.ignoreCSS=i.ignoreCSS instanceof Array?i.ignoreCSS.join(", "):i.ignoreCSS,l.emptyCSS=i.emptyCSS instanceof Array?i.emptyCSS.join(", "):i.emptyCSS,l.formatValue=i.formatValue.bind(this,l.trimWhitespace),l.bootstrapSettings=a(i.bootstrap,i.bootstrapConfig,i.defaultButton);var f={};i.getExportData=function(){return f},i.selectors.forEach(function(t){var e={},o=t.querySelectorAll("caption:not(.head)");r&&o.parentNode.removeChild(o),e.rows=s(t.querySelectorAll("tbody > tr")),e.rows=l.headers?s(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=l.footers?e.rows.concat(s(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=l.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===l.filename?t.getAttribute("id")?t.getAttribute("id"):i.defaultFilename:l.filename?l.filename:i.defaultFilename,e.uuid=p(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption:not(.head)");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=l.bootstrapSettings.bootstrapSpacing+l.position,r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=u.getInstance().getItem(t),n=t.substring(t.indexOf("-")+1);f[e.uuid]=f[e.uuid]||{},f[e.uuid][n]=JSON.parse(r)}}(),l.formats.forEach(function(t){!(!n||"xls"!==t)&&(t="xlsm"),!n&&"xlsx"===t&&(t=null),t&&e.setExportData(i.exporters[t].call(i,e))})});var m=document.querySelectorAll("button[tableexport-id]");return c(m,"click",i.downloadHandler,i),i};l.prototype={version:"4.0.0-rc.2",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&#38;","<":"&#60;",">":"&#62;","'":"&#39;","/":"&#47;"},xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},types:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t.replace(/,/g,""))}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!isNaN(Date.parse(t))}}},exporters:{xlsx:function(t){var e=this,r=e.settings,n={},o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,o){if(!~r.ignoreCols.indexOf(o)&&!i(t,r.ignoreCSS)){if(i(t,r.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(n[a]=n[a]||{},n[a][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var s=1;s<t.getAttribute("rowspan");s++)n[a+s]=n[a+s]||{},n[a+s][o]=1;if(n[a]){for(var l=o+1,u=0,p=0,s=0;s<=Math.max.apply(Math,Object.keys(n[a]))&&(n[a][s]?u=p>=o?u+n[a][s]:u:p++,p!==l);s++);return new Array(u).concat({v:r.formatValue(t.textContent),t:e.getType(t.className)})}return{v:r.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return t}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xlsx.mimeType,fileExtension:l.prototype.xlsx.fileExtension})),p=l.prototype.xlsx.buttonContent,c=l.prototype.xlsx.defaultClass,m=f({uuid:t.uuid,type:"xlsx"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},xlsm:function(t){var e=this,r=e.settings,n={},o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,o){if(!~r.ignoreCols.indexOf(o)&&!i(t,r.ignoreCSS)){if(i(t,r.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(n[a]=n[a]||{},n[a][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var s=1;s<t.getAttribute("rowspan");s++)n[a+s]=n[a+s]||{},n[a+s][o]=1;if(n[a]){for(var l=o+1,u=0,p=0,s=0;s<=Math.max.apply(Math,Object.keys(n[a]))&&(n[a][s]?u=p>=o?u+n[a][s]:u:p++,p!==l);s++);return new Array(u).concat({v:r.formatValue(t.textContent),t:e.getType(t.className)})}return{v:r.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return t}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension})),p=l.prototype.xls.buttonContent,c=l.prototype.xls.defaultClass,m=f({uuid:t.uuid,type:"xls"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},xls:function(t){var e=this,r=e.settings,n=l.prototype.xls.separator,o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,n){if(!~r.ignoreCols.indexOf(n)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":{v:r.formatValue(t.textContent),t:e.getType(t.className)}}).join(n)}}).join(e).map(function(t){return[].concat.apply([],t)}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension})),p=l.prototype.xls.buttonContent,c=l.prototype.xls.defaultClass,m=f({uuid:t.uuid,type:"xls"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},csv:function(t){var e=this,r=e.settings,n=l.prototype.csv.separator,o=s(t.rows).map(function(e,o){if(!~r.ignoreRows.indexOf(o-t.thAdj)&&!i(e,r.ignoreCSS)){var a=e.querySelectorAll("th, td");return s(a).map(function(t,e){if(!~r.ignoreCols.indexOf(e)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":'"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"'}).join(n)}}).join(e.rowDel),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.csv.mimeType,fileExtension:l.prototype.csv.fileExtension})),p=l.prototype.csv.buttonContent,c=l.prototype.csv.defaultClass,m=f({uuid:t.uuid,type:"csv"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},txt:function(t){var e=this,r=e.settings,n=l.prototype.txt.separator,o=s(t.rows).map(function(e,o){if(!~r.ignoreRows.indexOf(o-t.thAdj)&&!i(e,r.ignoreCSS)){var a=e.querySelectorAll("th, td");return s(a).map(function(t,e){if(!~r.ignoreCols.indexOf(e)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":r.formatValue(t.textContent)}).join(n)}}).join(e.rowDel),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.txt.mimeType,fileExtension:l.prototype.txt.fileExtension})),p=l.prototype.txt.buttonContent,c=l.prototype.txt.defaultClass,m=f({uuid:t.uuid,type:"txt"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m}},createObjButton:function(t,e,r,n,o){var s=document.createElement("button");return s.setAttribute("tableexport-id",t),s.className=o.bootstrapClass+o.bootstrapTheme+n,s.textContent=r,s},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.prototype.entityMap[t]})},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=l.prototype.types;return~t.indexOf(e.string.defaultClass)?"s":~t.indexOf(e.number.defaultClass)?"n":~t.indexOf(e["boolean"].defaultClass)?"b":~t.indexOf(e.date.defaultClass)?"d":""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t);return(r-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},o=l.prototype.types,s=0;s!==t.length;++s)for(var i=0;i!==t[s].length;++i){r.s.r>s&&(r.s.r=s),r.s.c>i&&(r.s.c=i),r.e.r<s&&(r.e.r=s),r.e.c<i&&(r.e.c=i);var a=t[s][i];if(a&&a.v){var u=n.utils.encode_cell({c:i,r:s});a.t||(o.number.assert(a.v)?a.t="n":o["boolean"].assert(a.v)?a.t="b":o.date.assert(a.v)?a.t="d":a.t="s"),"d"===a.t&&(a.t="n",a.z=n.SSF._table[14],a.v=this.dateNum(a.v)),e[u]=a}}return r.s.c<1e7&&(e["!ref"]=n.utils.encode_range(r)),e},downloadHandler:function(t){var e=t.target,r=JSON.parse(u.getInstance().getItem(e.getAttribute("tableexport-id"))),n=r.data,o=r.filename,s=r.mimeType,i=r.fileExtension;this.export2file(n,s,o,i)},Workbook:function(){this.SheetNames=[],this.Sheets={}},string2ArrayBuffer:function(t){for(var e=new ArrayBuffer(t.length),r=new Uint8Array(e),n=0;n!==t.length;++n)r[n]=255&t.charCodeAt(n);return e},export2file:function(t,o,s,i){if(n&&".xls"===i.substr(0,4)){var a=new this.Workbook,l=this.createSheet(t);a.SheetNames.push(s),a.Sheets[s]=l;var u={bookType:i.substr(1,3)+(i.substr(4)||"m"),bookSST:!1,type:"binary"},p=n.write(a,u);t=this.string2ArrayBuffer(p)}r(new e([t],{type:o+";"+this.charset}),s+i,!0)},update:function(t){},reset:function(){},remove:function(){},LocalStorage:function(){this.store=localStorage,this.namespace="te-",this.getKey=function(t){return this.namespace+t},this.setItem=function(t,e,r){var n=this.getKey(t);if(!this.exists(n)||r)return"string"!=typeof e?this.error('"value" must be a string'):this.store.setItem(n,e)},this.getItem=function(t){var e=this.getKey(t);return this.store.getItem(e)},this.exists=function(t){var e=this.getKey(t);return null!==this.store.getItem(e)},this.removeItem=function(t){var e=this.getKey(t);return this.store.removeItem(e)},this.error=function(t){return new Error("error:",t)}}};var u=l.prototype.LocalStorage;u.getInstance=function(){return u._instance=null,function(){return u._instance||(u._instance=new u),u._instance}}();var p=function(){var t=0;return function(e){return e.id||(e.id="tableexport-"+ ++t),e.id}}(),f=function(){var t,e,r=0;return function(n){var o=n.type;if(n=JSON.stringify(n),0===n.length)return r;for(t=0;t<n.length;t++)e=n.charCodeAt(t),r=(r<<5)-r+e,r|=0;return r.toString(16).substring(1)+"-"+o}}(),c=function(){var t=null;return function(e,r,n,o){for(var s=n.bind(o),i=0;i<e.length;++i)t&&e[i].removeEventListener(r,t,!1),e[i].addEventListener(r,s,!1);t=s}}();if(t){t.fn.tableExport=function(t,e){return new l(this,t,e)};for(var m in l.prototype)t.fn.tableExport[m]=l.prototype[m]}return l});
!function(t,e){"function"==typeof define&&define.amd?define(["jquery","blobjs","file-saverjs","xlsx"],e):"object"==typeof exports&&"string"!=typeof exports.nodeName?module.exports=e(require("jquery"),require("blobjs"),require("file-saverjs"),require("xlsx")):t.TableExport=e(t.jQuery,t.Blob,t.saveAs,t.XLSX)}(this,function(t,e,r,n){"use strict";function o(){for(var t=arguments,e=1;e<t.length;e++)for(var r in t[e])t[e].hasOwnProperty(r)&&(t[0][r]=t[e][r]);return t[0]}function s(e){return e instanceof NodeList||t&&e instanceof t?[].slice.call(e):[].concat(e)}function i(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.cls)}function a(t,e,r){var n={};return t?(n.bootstrapClass=t[0]+" ",n.bootstrapTheme=t[1]+" ",n.bootstrapSpacing=t[2]+" "):(n.bootstrapClass=r+" ",n.bootstrapTheme="",n.bootstrapSpacing=""),n}var l=function(t,e,r){if(!t)return new Error('"selectors" is required');var i=this;i.settings=r?e:o({},i.defaults,e),i.selectors=s(t);var l=i.settings;l.ignoreRows=l.ignoreRows instanceof Array?l.ignoreRows:[l.ignoreRows],l.ignoreCols=l.ignoreCols instanceof Array?l.ignoreCols:[l.ignoreCols],l.ignoreCSS=i.ignoreCSS instanceof Array?i.ignoreCSS.join(", "):i.ignoreCSS,l.emptyCSS=i.emptyCSS instanceof Array?i.emptyCSS.join(", "):i.emptyCSS,l.formatValue=i.formatValue.bind(this,l.trimWhitespace),l.bootstrapSettings=a(i.bootstrap,i.bootstrapConfig,i.defaultButton);var f={};i.getExportData=function(){return f},i.selectors.forEach(function(t){var e={},o=t.querySelectorAll("caption:not(.head)");r&&o.parentNode.removeChild(o),e.rows=s(t.querySelectorAll("tbody > tr")),e.rows=l.headers?s(t.querySelectorAll("thead > tr")).concat(e.rows):e.rows,e.rows=l.footers?e.rows.concat(s(t.querySelectorAll("tfoot > tr"))):e.rows,e.thAdj=l.headers?t.querySelectorAll("thead > tr").length:0,e.filename="id"===l.filename?t.getAttribute("id")?t.getAttribute("id"):i.defaultFilename:l.filename?l.filename:i.defaultFilename,e.uuid=p(t),e.checkCaption=function(e){var r=t.querySelectorAll("caption:not(.head)");r.length?r[0].appendChild(e):(r=document.createElement("caption"),r.className=l.bootstrapSettings.bootstrapSpacing+l.position,r.appendChild(e),t.insertBefore(r,t.firstChild))},e.setExportData=function(){return function(t){var r=u.getInstance().getItem(t),n=t.substring(t.indexOf("-")+1);f[e.uuid]=f[e.uuid]||{},f[e.uuid][n]=JSON.parse(r)}}(),l.formats.forEach(function(t){!(!n||"xls"!==t)&&(t="xlsm"),!n&&"xlsx"===t&&(t=null),t&&e.setExportData(i.exporters[t].call(i,e))})});var m=document.querySelectorAll("button[tableexport-id]");return c(m,"click",i.downloadHandler,i),i};l.prototype={version:"4.0.0-rc.3",defaults:{headers:!0,footers:!0,formats:["xls","csv","txt"],filename:"id",bootstrap:!1,exportButtons:!0,position:"bottom",ignoreRows:null,ignoreCols:null,trimWhitespace:!0},charset:"charset=utf-8",defaultFilename:"myDownload",defaultButton:"button-default",ignoreCSS:"tableexport-ignore",emptyCSS:"tableexport-empty",bootstrapConfig:["btn","btn-default","btn-toolbar"],rowDel:"\r\n",entityMap:{"&":"&#38;","<":"&#60;",">":"&#62;","'":"&#39;","/":"&#47;"},xlsx:{defaultClass:"xlsx",buttonContent:"Export to xlsx",mimeType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fileExtension:".xlsx"},xls:{defaultClass:"xls",buttonContent:"Export to xls",separator:"\t",mimeType:"application/vnd.ms-excel",fileExtension:".xls"},csv:{defaultClass:"csv",buttonContent:"Export to csv",separator:",",mimeType:"text/csv",fileExtension:".csv"},txt:{defaultClass:"txt",buttonContent:"Export to txt",separator:" ",mimeType:"text/plain",fileExtension:".txt"},types:{string:{defaultClass:"tableexport-string"},number:{defaultClass:"tableexport-number",assert:function(t){return!isNaN(t.replace(/,/g,""))}},"boolean":{defaultClass:"tableexport-boolean",assert:function(t){return"true"===t.toLowerCase()||"false"===t.toLowerCase()}},date:{defaultClass:"tableexport-date",assert:function(t){return!isNaN(Date.parse(t))}}},exporters:{xlsx:function(t){var e=this,r=e.settings,n={},o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,o){if(!~r.ignoreCols.indexOf(o)&&!i(t,r.ignoreCSS)){if(i(t,r.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(n[a]=n[a]||{},n[a][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var s=1;s<t.getAttribute("rowspan");s++)n[a+s]=n[a+s]||{},n[a+s][o]=1;if(n[a]){for(var l=o+1,u=0,p=0,s=0;s<=Math.max.apply(Math,Object.keys(n[a]))&&(n[a][s]?u=p>=o?u+n[a][s]:u:p++,p!==l);s++);return new Array(u).concat({v:r.formatValue(t.textContent),t:e.getType(t.className)})}return{v:r.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return t}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xlsx.mimeType,fileExtension:l.prototype.xlsx.fileExtension})),p=l.prototype.xlsx.buttonContent,c=l.prototype.xlsx.defaultClass,m=f({uuid:t.uuid,type:"xlsx"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},xlsm:function(t){var e=this,r=e.settings,n={},o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,o){if(!~r.ignoreCols.indexOf(o)&&!i(t,r.ignoreCSS)){if(i(t,r.emptyCSS))return" ";if(t.hasAttribute("colspan")&&(n[a]=n[a]||{},n[a][o+1]=t.getAttribute("colspan")-1),t.hasAttribute("rowspan"))for(var s=1;s<t.getAttribute("rowspan");s++)n[a+s]=n[a+s]||{},n[a+s][o]=1;if(n[a]){for(var l=o+1,u=0,p=0,s=0;s<=Math.max.apply(Math,Object.keys(n[a]))&&(n[a][s]?u=p>=o?u+n[a][s]:u:p++,p!==l);s++);return new Array(u).concat({v:r.formatValue(t.textContent),t:e.getType(t.className)})}return{v:r.formatValue(t.textContent),t:e.getType(t.className)}}}).filter(function(t){return t})}}).map(function(t){return t&&[].concat.apply([],t)}).filter(function(t){return t}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension})),p=l.prototype.xls.buttonContent,c=l.prototype.xls.defaultClass,m=f({uuid:t.uuid,type:"xls"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},xls:function(t){var e=this,r=e.settings,n=l.prototype.xls.separator,o=s(t.rows).map(function(o,a){if(!~r.ignoreRows.indexOf(a-t.thAdj)&&!i(o,r.ignoreCSS)){var l=o.querySelectorAll("th, td");return s(l).map(function(t,n){if(!~r.ignoreCols.indexOf(n)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":{v:r.formatValue(t.textContent),t:e.getType(t.className)}}).join(n)}}).join(e).map(function(t){return[].concat.apply([],t)}),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.xls.mimeType,fileExtension:l.prototype.xls.fileExtension})),p=l.prototype.xls.buttonContent,c=l.prototype.xls.defaultClass,m=f({uuid:t.uuid,type:"xls"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},csv:function(t){var e=this,r=e.settings,n=l.prototype.csv.separator,o=s(t.rows).map(function(e,o){if(!~r.ignoreRows.indexOf(o-t.thAdj)&&!i(e,r.ignoreCSS)){var a=e.querySelectorAll("th, td");return s(a).map(function(t,e){if(!~r.ignoreCols.indexOf(e)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":'"'+r.formatValue(t.textContent.replace(/"/g,'""'))+'"'}).join(n)}}).join(e.rowDel),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.csv.mimeType,fileExtension:l.prototype.csv.fileExtension})),p=l.prototype.csv.buttonContent,c=l.prototype.csv.defaultClass,m=f({uuid:t.uuid,type:"csv"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m},txt:function(t){var e=this,r=e.settings,n=l.prototype.txt.separator,o=s(t.rows).map(function(e,o){if(!~r.ignoreRows.indexOf(o-t.thAdj)&&!i(e,r.ignoreCSS)){var a=e.querySelectorAll("th, td");return s(a).map(function(t,e){if(!~r.ignoreCols.indexOf(e)&&!i(t,r.ignoreCSS))return i(t,r.emptyCSS)?" ":r.formatValue(t.textContent)}).join(n)}}).join(e.rowDel),a=l.prototype.escapeHtml(JSON.stringify({data:o,filename:t.filename,mimeType:l.prototype.txt.mimeType,fileExtension:l.prototype.txt.fileExtension})),p=l.prototype.txt.buttonContent,c=l.prototype.txt.defaultClass,m=f({uuid:t.uuid,type:"txt"}),x=r.exportButtons&&l.prototype.createObjButton(m,a,p,c,r.bootstrapSettings);return x&&t.checkCaption(x),u.getInstance().setItem(m,a,!0),m}},createObjButton:function(t,e,r,n,o){var s=document.createElement("button");return s.setAttribute("tableexport-id",t),s.className=o.bootstrapClass+o.bootstrapTheme+n,s.textContent=r,s},escapeHtml:function(t){return String(t).replace(/[&<>'\/]/g,function(t){return l.prototype.entityMap[t]})},formatValue:function(t,e){return t?e.trim():e},getType:function(t){if(!t)return"";var e=l.prototype.types;return~t.indexOf(e.string.defaultClass)?"s":~t.indexOf(e.number.defaultClass)?"n":~t.indexOf(e["boolean"].defaultClass)?"b":~t.indexOf(e.date.defaultClass)?"d":""},dateNum:function(t,e){e&&(t+=1462);var r=Date.parse(t);return(r-new Date(Date.UTC(1899,11,30)))/864e5},createSheet:function(t){for(var e={},r={s:{c:1e7,r:1e7},e:{c:0,r:0}},o=l.prototype.types,s=0;s!==t.length;++s)for(var i=0;i!==t[s].length;++i){r.s.r>s&&(r.s.r=s),r.s.c>i&&(r.s.c=i),r.e.r<s&&(r.e.r=s),r.e.c<i&&(r.e.c=i);var a=t[s][i];if(a&&a.v){var u=n.utils.encode_cell({c:i,r:s});a.t||(o.number.assert(a.v)?a.t="n":o["boolean"].assert(a.v)?a.t="b":o.date.assert(a.v)?a.t="d":a.t="s"),"d"===a.t&&(a.t="n",a.z=n.SSF._table[14],a.v=this.dateNum(a.v)),e[u]=a}}return r.s.c<1e7&&(e["!ref"]=n.utils.encode_range(r)),e},downloadHandler:function(t){var e=t.target,r=JSON.parse(u.getInstance().getItem(e.getAttribute("tableexport-id"))),n=r.data,o=r.filename,s=r.mimeType,i=r.fileExtension;this.export2file(n,s,o,i)},Workbook:function(){this.SheetNames=[],this.Sheets={}},string2ArrayBuffer:function(t){for(var e=new ArrayBuffer(t.length),r=new Uint8Array(e),n=0;n!==t.length;++n)r[n]=255&t.charCodeAt(n);return e},export2file:function(t,o,s,i){if(n&&".xls"===i.substr(0,4)){var a=new this.Workbook,l=this.createSheet(t);a.SheetNames.push(s),a.Sheets[s]=l;var u={bookType:i.substr(1,3)+(i.substr(4)||"m"),bookSST:!1,type:"binary"},p=n.write(a,u);t=this.string2ArrayBuffer(p)}r(new e([t],{type:o+";"+this.charset}),s+i,!0)},update:function(t){},reset:function(){},remove:function(){},LocalStorage:function(){this.store=localStorage,this.namespace="te-",this.getKey=function(t){return this.namespace+t},this.setItem=function(t,e,r){var n=this.getKey(t);if(!this.exists(n)||r)return"string"!=typeof e?this.error('"value" must be a string'):this.store.setItem(n,e)},this.getItem=function(t){var e=this.getKey(t);return this.store.getItem(e)},this.exists=function(t){var e=this.getKey(t);return null!==this.store.getItem(e)},this.removeItem=function(t){var e=this.getKey(t);return this.store.removeItem(e)},this.error=function(t){return new Error("error:",t)}}};var u=l.prototype.LocalStorage;u.getInstance=function(){return u._instance=null,function(){return u._instance||(u._instance=new u),u._instance}}();var p=function(){var t=0;return function(e){return e.id||(e.id="tableexport-"+ ++t),e.id}}(),f=function(){var t,e,r=0;return function(n){var o=n.type;if(n=JSON.stringify(n),0===n.length)return r;for(t=0;t<n.length;t++)e=n.charCodeAt(t),r=(r<<5)-r+e,r|=0;return r.toString(16).substring(1)+"-"+o}}(),c=function(){var t=null;return function(e,r,n,o){for(var s=n.bind(o),i=0;i<e.length;++i)t&&e[i].removeEventListener(r,t,!1),e[i].addEventListener(r,s,!1);t=s}}();if(t){t.fn.tableExport=function(t,e){return new l(this,t,e)};for(var m in l.prototype)t.fn.tableExport[m]=l.prototype[m]}return l});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc