/*! Widget: math - updated 11/26/2016 (v2.28.0) */ !function(a){"use strict";var b=a.tablesorter,c={error:{0:"Infinity result: Divide by zero",1:"Need more than one element to make this calculation",undef:"No elements found"},invalid:function(a,b,d){return console.warn(b,c.error[d]),a&&a.widgetOptions.math_none||""},events:"tablesorter-initialized update updateAll updateRows addRows updateCell filterReset ".split(" ").join(".tsmath "),processText:function(d,e){var f,g=b.getElementText(d,e,c.getCellIndex(e)),h=d.widgetOptions.math_prefix;return/"+h+"").text().replace(/\{content\}/g,"").trim(),g=g.replace(f,"")),g=b.formatFloat(g.replace(/[^\w,. \-()]/g,""),d.table)||0,isNaN(g)?0:g},getRow:function(b,d,e){var f,g=b.widgetOptions,h=[],i=d.closest("tr"),j=i.hasClass(g.filter_filteredRow||"filtered");return e&&(i=i.filter(e)),!e&&j||(f=i.children().not("["+g.math_dataAttrib+"=ignore]"),g.math_ignore.length&&(f=f.filter(function(){return a.inArray(c.getCellIndex(a(this)),g.math_ignore)===-1})),h=f.not(d).map(function(){return c.processText(b,a(this))}).get()),h},getColumn:function(b,d,e,f){var g,h,i,j,k,l,m=b.widgetOptions,n=[],o=d.closest("tr"),p=m.math_dataAttrib,q="["+p+"=ignore]",r=m.filter_filteredRow||"filtered",s=c.getCellIndex(d),t=b.$table.children("tbody").children(),u=["["+p+"^=above]","["+p+"^=below]","["+p+"^=col]","["+p+"^=all]"];if("above"===e)for(j=t.index(o),g=j;g>=0;)i=t.eq(g),l=i.children().filter(u[0]).length,f&&(i=i.filter(f)),h=i.children().filter(function(){return c.getCellIndex(a(this))===s}),((f||!i.hasClass(r))&&i.not(q).length&&g!==j||l&&g!==j)&&(l?g=0:h.length&&(n[n.length]=c.processText(b,h))),g--;else if("below"===e)for(j=t.length,g=t.index(o)+1;g0;if(e>1?(e--,f=!0):e<1&&(e=1),d.children("[rowspan]").length>0)for(b=this.cells,c=0;c0?a.substring(0,v):"",x=w;if(c&&(x=/\{content\}/.test(c||"")?(c||"").replace(/\{content\}/g,w||""):(c||"")+w),s=a.split("").reverse().join(""),r=s.search(/[0-9\-\+#]/),q=u-r,q+="."===a.substring(q,q+1)?1:0,w=r>0?a.substring(q,u):"",t=w,d&&(t=/\{content\}/.test(d||"")?(d||"").replace(/\{content\}/g,w||""):w+(d||"")),a=a.substring(v,q),b="-"==a.charAt(0)?-b:+b,e=b<0?b=-b:0,f=a.match(/[^\d\-\+#]/g),g=f&&f[f.length-1]||".",h=f&&f[1]&&f[0]||",",a=a.split(g),b=b.toFixed(a[1]&&a[1].length),b=+b+"",j=a[1]&&a[1].lastIndexOf("0"),l=b.split("."),(!l[1]||l[1]&&l[1].length<=j)&&(b=(+b).toFixed(j+1)),m=a[0].split(h),a[0]=m.join(""),(i=a[0]&&a[0].indexOf("0"))>-1)for(;l[0].length1?(a.sort(function(a,b){return a-b}),d=Math.floor(e/2),e%2?a[d]:(a[d-1]+a[d])/2):c.invalid(b,"median",1)},mode:function(a){var b,c,d,e={},f=1,g=[a[0]];for(b=0;bf?(g=[c],f=d):d===f&&(g[g.length]=c,f=d);return g.sort(function(a,b){return a-b})},max:function(a){return Math.max.apply(Math,a)},min:function(a){return Math.min.apply(Math,a)},range:function(a){var b=a.sort(function(a,b){return a-b});return b[a.length-1]-b[0]},variance:function(a,d,e){for(var f,g=b.equations.mean(a),h=0,i=a.length;i--;)h+=Math.pow(a[i]-g,2);return 0===(f=a.length-(d?0:1))?c.invalid(e,"variance",0):h/=f},varp:function(a,c){return b.equations.variance(a,!0,c)},vars:function(a,c){return b.equations.variance(a,!1,c)},stdevs:function(a,c){var d=b.equations.variance(a,!1,c);return Math.sqrt(d)},stdevp:function(a,c){var d=b.equations.variance(a,!0,c);return Math.sqrt(d)}},b.addWidget({id:"math",priority:100,options:{math_data:"math",math_debug:!1,math_ignore:[],math_mask:"#,##0.00",math_complete:null,math_priority:["row","above","below","col"],math_prefix:"",math_suffix:"",math_none:"N/A",math_event:"recalculate",math_rowFilter:""},init:function(a,d,e,f){var g=(b.hasWidget(a,"filter")?"filterEnd":"updateComplete")+".tsmath";c.events+=(b.hasWidget(a,"pager")?"pagerComplete":"filterEnd")+".tsmath ",e.$table.off((c.events+"updateComplete.tsmath "+f.math_event).replace(/\s+/g," ")).on(c.events+f.math_event,function(a){if(this.hasInitialized){var b="tablesorter-initialized"===a.type;f.math_isUpdating&&!b||(/filter/.test(a.type)||b||c.setColumnIndexes(e),c.recalculate(e,f,b))}}).on(g,function(){setTimeout(function(){c.updateComplete(e)},40)}),f.math_isUpdating=!1,a.hasInitialized&&c.recalculate(e,f,!0)},remove:function(a,b,d,e){e||b.$table.off((c.events+" updateComplete.tsmath "+d.math_event).replace(/\s+/g," ")).children().children("tr").children("[data-"+d.math_data+"]").empty()}})}(jQuery);