(function(a){a.fn.extend({tableExport:function(g){var n={separator:",",ignoreColumn:[],tableName:"yourTableName",type:"csv",pdfFontSize:14,pdfLeftMargin:20,escape:"true",htmlContent:"false",consoleLog:"false"};var g=a.extend(n,g);var d=this;if(n.type=="csv"||n.type=="txt"){var f="";a(d).find("thead").find("tr").each(function(){f+="\n";a(this).filter(":visible").find("th").each(function(t,u){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(t)==-1){f+='"'+k(a(this))+'"'+n.separator}}});f=a.trim(f);f=a.trim(f).substring(0,f.length-1)});a(d).find("tbody").find("tr").each(function(){f+="\n";a(this).filter(":visible").find("td").each(function(t,u){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(t)==-1){f+='"'+k(a(this))+'"'+n.separator}}});f=a.trim(f).substring(0,f.length-1)});if(n.consoleLog=="true"){console.log(f)}var c="base64,"+a.base64.encode(f);window.open("data:application/"+n.type+";filename=exportData;"+c)}else{if(n.type=="sql"){var f="INSERT INTO `"+n.tableName+"` (";a(d).find("thead").find("tr").each(function(){a(this).filter(":visible").find("th").each(function(t,u){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(t)==-1){f+="`"+k(a(this))+"`,"}}});f=a.trim(f);f=a.trim(f).substring(0,f.length-1)});f+=") VALUES ";a(d).find("tbody").find("tr").each(function(){f+="(";a(this).filter(":visible").find("td").each(function(t,u){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(t)==-1){f+='"'+k(a(this))+'",'}}});f=a.trim(f).substring(0,f.length-1);f+="),"});f=a.trim(f).substring(0,f.length-1);f+=";";if(n.consoleLog=="true"){console.log(f)}var c="base64,"+a.base64.encode(f);window.open("data:application/sql;filename=exportData;"+c)}else{if(n.type=="json"){var e=[];a(d).find("thead").find("tr").each(function(){var u="";var t=[];a(this).filter(":visible").find("th").each(function(v,w){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(v)==-1){t.push(k(a(this)))}}});e.push(t)});var o=[];a(d).find("tbody").find("tr").each(function(){var u="";var t=[];a(this).filter(":visible").find("td").each(function(v,w){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(v)==-1){t.push(k(a(this)))}}});o.push(t)});var q=[];q.push({header:e,data:o});if(n.consoleLog=="true"){console.log(JSON.stringify(q))}var c="base64,"+a.base64.encode(JSON.stringify(q));window.open("data:application/json;filename=exportData;"+c)}else{if(n.type=="xml"){var h='';h+="";a(d).find("thead").find("tr").each(function(){a(this).filter(":visible").find("th").each(function(t,u){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(t)==-1){h+=""+k(a(this))+""}}})});h+="";var m=1;a(d).find("tbody").find("tr").each(function(){h+='';var t=0;a(this).filter(":visible").find("td").each(function(u,v){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(u)==-1){h+=""+k(a(this))+""}}t++});m++;h+=""});h+="";if(n.consoleLog=="true"){console.log(h)}var c="base64,"+a.base64.encode(h);window.open("data:application/xml;filename=exportData;"+c)}else{if(n.type=="excel"||n.type=="doc"||n.type=="powerpoint"){var b="";a(d).find("thead").find("tr").each(function(){b+="";a(this).filter(":visible").find("th").each(function(t,u){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(t)==-1){b+=""}}});b+=""});var m=1;a(d).find("tbody").find("tr").each(function(){b+="";var t=0;a(this).filter(":visible").find("td").each(function(u,v){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(u)==-1){b+=""}}t++});m++;b+=""});b+="
"+k(a(this))+"
"+k(a(this))+"
";if(n.consoleLog=="true"){console.log(b)}var i="";i+="";i+="";i+="";i+="";i+=b;i+="";i+="";var c="base64,"+a.base64({data:i,type:0});window.open("data:application/vnd.ms-"+n.type+";filename=exportData.doc;"+c)}else{if(n.type=="png"){html2canvas(a(d),{onrendered:function(u){var t=u.toDataURL("image/png");window.open(t)}})}else{if(n.type=="pdf"){var r=new jsPDF("p","pt","a4",true);r.setFontSize(n.pdfFontSize);var l=n.pdfLeftMargin;a(d).find("thead").find("tr").each(function(){a(this).filter(":visible").find("th").each(function(t,v){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(t)==-1){var u=l+(t*50);r.text(u,20,k(a(this)))}}})});var p=20;var j=1;var s=0;a(d).find("tbody").find("tr").each(function(t,u){rowCalc=t+1;if(rowCalc%26==0){r.addPage();j++;p=p+10}s=(p+(rowCalc*10))-((j-1)*280);a(this).filter(":visible").find("td").each(function(v,x){if(a(this).css("display")!="none"){if(n.ignoreColumn.indexOf(v)==-1){var w=l+(v*50);r.text(w,s,k(a(this)))}}})});r.output("datauri")}}}}}}}function k(t){if(n.htmlContent=="true"){content_data=t.html().trim()}else{content_data=t.text().trim()}if(n.escape=="true"){content_data=escape(content_data)}return content_data}}})})(jQuery);