/*! Widget: Build Table - updated 2018-03-18 (v2.30.0) */
!function(e){"use strict";var t=e.tablesorter=e.tablesorter||{},r=t.buildTable=function(l,o){e.extend(!0,t.defaults.widgetOptions,r.defaults);var n="TABLE"===l.nodeName?e(l):e("
").appendTo(l),i=n[0],d=o.widgetOptions=e.extend(!0,{},r.defaults,o.widgetOptions),s=d.build_processing,a=d.build_type,u=d.build_source||o.data,c=t.debug(o,"build"),b=function(t){var l=e.type(t),n=t instanceof jQuery;if("function"==typeof s&&(t=s(t,d)),o.data=t,n||"string"===l){if(n||/<\s*\/tr\s*>/.test(t))return r.html(i,t,d);try{if(t=e.parseJSON(t||"null"))return r.object(i,t,d)}catch(e){}}return"array"===l||"string"===l||"array"===a||"csv"===a?r.csv(i,t,d):r.object(i,t,d)};if(i.config=o,!t.buildTable.hasOwnProperty(a)&&""!==a)return c&&console.error("Build >> ERROR: Aborting build table widget, incorrect build type"),!1;u instanceof jQuery?b(e.trim(u.html())):u&&(u.hasOwnProperty("url")||"json"===a)?e.ajax(d.build_source).done(function(e){b(e)}).fail(function(e,t){c&&console.error("Build >> ERROR: Aborting build table widget, failed ajax load"),n.html(''+e.status+" "+t+" |
")}):b(u)};t.defaults.data="",r.defaults={build_type:"",build_source:"",build_processing:null,build_complete:"tablesorter-build-complete",build_headers:{rows:1,classes:[],text:[],widths:[]},build_footers:{rows:1,classes:[],text:[]},build_numbers:{addColumn:!1,sortable:!1},build_csvStartLine:0,build_csvSeparator:",",build_objectRowKey:"rows",build_objectCellKey:"cells",build_objectHeaderKey:"headers",build_objectFooterKey:"footers"},r.build={colgroup:function(t){var r="";return t&&t.length&&(r+="",e.each(t,function(e,t){r+=""}),r+=""),r},cell:function(t,r,l,o,n){var i,d,s=n?e(""):"",a=r.build_headers.classes,u=r.build_headers.widths;if(/string|number/.test(typeof t))d=e("<"+l+(a&&a[o]?' class="'+a[o]+'"':"")+">"+t+""+l+">"),n&&u&&u[o]&&s.width(u[o]||"");else{d=e("<"+l+">");for(i in t)t.hasOwnProperty(i)&&("text"===i||"html"===i?d[i](t[i]):n&&"width"===i?s.width(t[i]||""):d.attr(i,t[i]))}return[d,s]},header:function(t,r){var l=r.build_headers.text,o=r.build_headers.classes,n=""+(r.build_numbers.addColumn?""+r.build_numbers.addColumn+" | ":"");return e.each(t,function(e,t){/<\s*\/t(d|h)\s*>/.test(t)?n+=t:n+=""+(l&&l[e]?l[e]:t)+" | "}),n+"
"},rows:function(t,r,l,o,n,i){var d=i?"th":"td",s=""+(o.build_numbers.addColumn?"<"+d+">"+(i?"":n)+""+d+">":"");return e.each(t,function(e,t){/<\s*\/t(d|h)\s*>/.test(t)?s+=t:s+="<"+(i?d+(l&&l[e]?' class="'+l[e]+'"':""):d)+">"+(i&&r&&r.length&&r[e]?r[e]:t)+""+d+">"}),s+"
"}},r.buildComplete=function(r,l){e(r).triggerHandler(l.build_complete),r.config&&t.debug(r.config,"build")&&console.log("Build >> Table build complete"),t.setup(r,r.config)},r.array=function(e,t,l){return r.csv(e,t,l)},r.csv=function(t,l,o){var n,i,d,s="csv"===o.build_type||"string"==typeof l,a=e(t),u=s?l.replace("\r","").split("\n"):l,c=u.length,b=0,h=!1,p=o.build_headers.rows+(s?o.build_csvStartLine:0),f=o.build_footers.rows,g=0,y="",_=r.build.colgroup(o.build_headers.widths)+"";e.each(u,function(e,t){e>=c-f&&(h=!0),(!s||e>=o.build_csvStartLine)&&e=p&&(e===p&&(_+="
"),d=s?r.splitCSV(t,o.build_csvSeparator):t,h&&f>0&&(_+=(e===c-f?"":"")+(e===c?"":"")),d.length>1&&(b++,d.length!==g&&(y+="error on line "+e+": Item count ("+d.length+") does not match header count ("+g+") \n"),n=h?o.build_footers.classes:"",_+=r.build.rows(d,o.build_footers.text,n,o,b,h)))}),_+=f>0?"":"",y?a.html(y):(a.html(_),r.buildComplete(t,o))},r.splitCSV=function(t,r){var l,o,n=e.trim(t).split(r=r||",");for(l=n.length-1;l>=0;l--)'"'===n[l].replace(/\"\s+$/,'"').charAt(n[l].length-1)?(o=n[l].replace(/^\s+\"/,'"')).length>1&&'"'===o.charAt(0)?n[l]=n[l].replace(/^\s*"|"\s*$/g,"").replace(/""/g,'"'):l?n.splice(l-1,2,[n[l-1],n[l]].join(r)):n=n.shift().split(r).concat(n):n[l].replace(/""/g,'"');return n},r.html=function(t,l,o){var n=e(t);l instanceof jQuery?n.empty().append(l):n.html(l),r.buildComplete(t,o)},r.object=function(l,o,n){var i,d,s,a,u,c,b,h=l.config,p=n.build_objectHeaderKey,f=n.build_objectRowKey,g=o.hasOwnProperty(p)&&!e.isEmptyObject(o.kh)?o.kh:!!o.hasOwnProperty("headers")&&o.headers,y=o.hasOwnProperty(f)&&!e.isEmptyObject(o.kr)?o.kr:!!o.hasOwnProperty("rows")&&o.rows;if(!g||!y||0===g.length||0===y.length)return t.debug(h,"build")&&console.error("Build >> ERROR: Aborting build table widget, missing data for object build"),!1;a=e(""),u=e(""),e.each(g,function(t,l){for(b=e("").appendTo(u.find("thead")),d=l.length,i=0;i"),e.each(y,function(t,l){var o;if((s="object"===e.type(l))&&l.newTbody){c=e("").appendTo(u);for(o in l)l.hasOwnProperty(o)&&"newTbody"!==o&&c.attr(o,l[o])}else{if(0===t&&c.appendTo(u),b=e("").appendTo(c),s){for(o in l)l.hasOwnProperty(o)&&o!==n.build_objectCellKey&&b.attr(o,l[o]);l.hasOwnProperty(n.build_objectCellKey)&&(l=l.cells)}for(d=l.length,o=0;o"+a+"")):(a=e("").appendTo(u),e.each(s,function(t,l){for(b=e("").appendTo(a),d=l.length,i=0;i