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