/*! Widget: math - updated 5/17/2015 (v2.22.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){return console.log(a,c.error[b]),"none"},events:"tablesorter-initialized update updateAll updateRows addRows updateCell filterReset filterEnd ".split(" ").join(".tsmath "),processText:function(a,c){var d=c.attr(a.textAttribute);return"undefined"==typeof d&&(d=c[0].textContent||c.text()),d=b.formatFloat(d.replace(/[^\w,. \-()]/g,""),a.table)||0,isNaN(d)?0:d},getRow:function(b,d){var e=b.widgetOptions,f=[],g=d.closest("tr"),h=g.children().not("["+e.math_dataAttrib+"=ignore]");return g.hasClass(e.filter_filteredRow||"filtered")||(e.math_ignore.length&&(h=h.not("[data-column="+e.math_ignore.join("],[data-column=")+"]")),f=h.not(d).map(function(){return c.processText(b,a(this))}).get()),f},getColumn:function(a,b,d){var e,f,g,h,i,j=[],k=a.widgetOptions,l=k.filter_filteredRow||"filtered",m=parseInt(b.attr("data-column"),10),n=a.$table.children("tbody").children(),o=b.closest("tr");if("above"===d)for(g=n.index(o),e=g;e>=0;)f=n.eq(e).children().filter("[data-column="+m+"]"),i=f.filter("["+k.math_dataAttrib+"^=above]").length,(!n.eq(e).hasClass(l)&&n.eq(e).not("["+k.math_dataAttrib+"=ignore]").length&&e!==g||i&&e!==g)&&(i?e=0:f.length&&j.push(c.processText(a,f))),e--;else for(h=n.not("["+k.math_dataAttrib+"=ignore]"),g=h.length,e=0;g>e;e++)f=h.eq(e).children().filter("[data-column="+m+"]"),h.eq(e).hasClass(l)||!f.not("["+k.math_dataAttrib+"^=above],["+k.math_dataAttrib+"^=col]").length||f.is(b)||j.push(c.processText(a,f));return j},getAll:function(b){var d,e,f,g,h,i,j,k,l=[],m=b.widgetOptions,n=m.filter_filteredRow||"filtered",o=b.$table.children("tbody").children().not("["+m.math_dataAttrib+"=ignore]");for(h=o.length,g=0;h>g;g++)if(f=o.eq(g),!f.hasClass(n))for(i=f.children().not("["+m.math_dataAttrib+"=ignore]"),k=i.length,j=0;k>j;j++)d=i.eq(j),e=parseInt(d.attr("data-column"),10),!d.filter("["+m.math_dataAttrib+"]").length&&a.inArray(e,m.math_ignore)<0&&l.push(c.processText(b,d));return l},recalculate:function(a,d,e,f){if(d&&(!e.math_isUpdating||f)){f&&b.computeColumnIndex(d.$table.children("tbody").children()),e.math_dataAttrib="data-"+(e.math_data||"math");var g=d.$tbodies.find("["+e.math_dataAttrib+"]");c.mathType(d,g,e.math_priority),g=d.$table.children("."+d.cssInfoBlock+", tfoot").find("["+e.math_dataAttrib+"]"),c.mathType(d,g,e.math_priority),g=d.$table.find("["+e.math_dataAttrib+"^=all]"),c.mathType(d,g,["all"]),e.math_isUpdating=!0,d.debug&&console[console.group?"group":"log"]("Math widget triggering an update after recalculation"),d.$table.trigger("update")}},mathType:function(d,e,f){if(e.length){var g,h,i,j,k,l,m,n,o=d.widgetOptions,p=b.equations;"all"===f[0]&&(k=c.getAll(d)),d.debug&&console[console.group?"group":"log"]("Tablesorter Math widget recalculation"),a.each(f,function(a,b){if(l=e.filter("["+o.math_dataAttrib+"^="+b+"]"),n=l.length){for(d.debug&&console[console.group?"group":"log"](b),m=0;n>m;m++)i=l.eq(m),g=(i.attr(o.math_dataAttrib)||"").replace(b+"-",""),j="row"===b?c.getRow(d,i):"all"===b?k:c.getColumn(d,i,b),p[g]&&(j.length?(h=p[g](j),d.debug&&console.log(i.attr(o.math_dataAttrib),j,"=",h)):h=c.invalid(g,"mean"===g?0:"undef"),c.output(i,o,h,j));d.debug&&console.groupEnd&&console.groupEnd()}}),d.debug&&console.groupEnd&&console.groupEnd()}},output:function(a,c,d,e){var f=a.attr("data-"+c.math_data+"-mask")||c.math_mask,g=b.formatMask(f,d,c.math_wrapPrefix,c.math_wrapSuffix);"function"==typeof c.math_complete&&(g=c.math_complete(a,c,g,d,e)),g!==!1&&a.html(g)}};/** * @preserve IntegraXor Web SCADA - JavaScript Number Formatter * http:// www.integraxor.com/ * author: KPL, KHL * (c)2011 ecava * Dual licensed under the MIT or GPL Version 2 licenses. */ b.formatMask=function(a,b,c,d){if(!a||isNaN(+b))return b;var e,f,g,h,i,j,k,m,n,o,p,q,r,s,t,u="",v=a.length,w=a.search(/[0-9\-\+#]/),x=w>0?a.substring(0,w):"",y=x;if(w>0&&c&&(y=/\{content\}/.test(c||"")?(c||"").replace(/\{content\}/g,x||""):(c||"")+x),t=a.split("").reverse().join(""),s=t.search(/[0-9\-\+#]/),r=v-s,r+="."===a.substring(r,r+1)?1:0,x=s>0?a.substring(r,v):"",u=x,""!==x&&d&&(u=/\{content\}/.test(d||"")?(d||"").replace(/\{content\}/g,x||""):x+(d||"")),a=a.substring(w,r),b="-"==a.charAt(0)?-b:+b,e=0>b?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"),m=b.split("."),(!m[1]||m[1]&&m[1].length<=j)&&(b=(+b).toFixed(j+1)),n=a[0].split(h),a[0]=n.join(""),i=a[0]&&a[0].indexOf("0"),i>-1)for(;m[0].lengthr;r++)p+=o.charAt(r),!((r-q+1)%k)&&rb;b++)d+=a[b];return d},mean:function(a){var c=b.equations.sum(a);return c/a.length},median:function(a){var b,d=a.length;return d>1?(a.sort(function(a,b){return a-b}),b=Math.floor(d/2),d%2?a[b]:(a[b-1]+a[b])/2):c.invalid("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.push(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){for(var e,f=b.equations.mean(a),g=0,h=a.length;h--;)g+=Math.pow(a[h]-f,2);return e=a.length-(d?0:1),0===e?c.invalid("variance",0):g/=e},varp:function(a){return b.equations.variance(a,!0)},vars:function(a){return b.equations.variance(a)},stdevs:function(a){var c=b.equations.variance(a);return Math.sqrt(c)},stdevp:function(a){var c=b.equations.variance(a,!0);return Math.sqrt(c)}},b.addWidget({id:"math",priority:100,options:{math_data:"math",math_ignore:[],math_mask:"#,##0.00",math_complete:null,math_priority:["row","above","col"],math_prefix:"",math_suffix:"",math_event:"recalculate"},init:function(a,d,e,f){var g=b.hasWidget(a,"filter")?"filterEnd":"updateComplete";e.$table.off((c.events+" updateComplete.tsmath "+f.math_event).replace(/\s+/g," ")).on(c.events+" "+f.math_event,function(d){var g="tablesorter-initialized"===d.type;(!f.math_isUpdating||g)&&(/filter/.test(d.type)||b.computeColumnIndex(e.$table.children("tbody").children()),c.recalculate(a,e,f,g))}).on(g+".tsmath",function(){setTimeout(function(){f.math_isUpdating&&e.debug&&console.groupEnd&&console.groupEnd(),f.math_isUpdating=!1},40)}),f.math_isUpdating=!1},remove:function(a,b,d,e){e||b.$table.off((c.events+" updateComplete.tsmath "+d.math_event).replace(/\s+/g," ")).find("[data-"+d.math_data+"]").empty()}})}(jQuery);