From 10bc23fa245a376bc1b8a76c0a30189e2ff30436 Mon Sep 17 00:00:00 2001 From: Mottie Date: Tue, 28 Jul 2015 15:57:01 -0500 Subject: [PATCH] Overall: set jsHint "undef" & "unused" options. Fixed issues The math widget had a javascript error which jsHint was not catching --- Gruntfile.js | 9 +++++++-- dist/js/jquery.tablesorter.combined.js | 7 ++++--- dist/js/jquery.tablesorter.js | 2 +- dist/js/jquery.tablesorter.widgets.js | 5 +++-- dist/js/parsers/parser-network.min.js | 2 +- dist/js/widgets/widget-math.min.js | 4 ++-- dist/js/widgets/widget-sort2Hash.min.js | 2 +- js/jquery.tablesorter.combined.js | 7 ++++--- js/jquery.tablesorter.js | 2 +- js/jquery.tablesorter.widgets.js | 5 +++-- js/parsers/parser-globalize.js | 1 + js/parsers/parser-network.js | 9 +++++---- js/widgets/widget-filter.js | 4 ++-- js/widgets/widget-math.js | 13 ++++++------- js/widgets/widget-output.js | 2 +- js/widgets/widget-sort2Hash.js | 5 ++--- js/widgets/widget-storage.js | 1 + 17 files changed, 45 insertions(+), 35 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 60beaebb..7ee6ebff 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -244,15 +244,20 @@ module.exports = function( grunt ) { }, options: { globals: { + 'JSON': false, 'localStorage': false, 'navigator': false, 'console': false, - 'alert': false + 'require': false, + 'define': false, + 'module': false }, 'loopfunc': true, 'jquery': true, 'browser': true, - 'es3': true + 'es3': true, + 'unused': true, + 'undef': true } }, diff --git a/dist/js/jquery.tablesorter.combined.js b/dist/js/jquery.tablesorter.combined.js index 7da1414b..b9ae2c0c 100644 --- a/dist/js/jquery.tablesorter.combined.js +++ b/dist/js/jquery.tablesorter.combined.js @@ -29,7 +29,7 @@ * @contributor Rob Garrison - https://github.com/Mottie/tablesorter */ /*jshint browser:true, jquery:true, unused:false, expr: true */ -/*global console:false, alert:false, require:false, define:false, module:false */ +/*global console:false */ ;(function($){ 'use strict'; $.extend({ @@ -2244,6 +2244,7 @@ })(jQuery); /*! Widget: storage - updated 3/26/2015 (v2.21.3) */ +/*global JSON:false */ ;(function ($, window, document) { 'use strict'; @@ -2705,7 +2706,7 @@ types: { or : function( c, data, vars ) { if ( /\|/.test( data.iFilter ) || ts.filter.regex.orSplit.test( data.filter ) ) { - var indx, filterMatched, txt, query, regex, + var indx, filterMatched, query, regex, // duplicate data but split filter data2 = $.extend( {}, data ), index = data.index, @@ -2740,7 +2741,7 @@ // Look for an AND or && operator ( logical and ) and : function( c, data, vars ) { if ( ts.filter.regex.andTest.test( data.filter ) ) { - var indx, filterMatched, result, txt, query, regex, + var indx, filterMatched, result, query, regex, // duplicate data but split filter data2 = $.extend( {}, data ), index = data.index, diff --git a/dist/js/jquery.tablesorter.js b/dist/js/jquery.tablesorter.js index 794e477a..eaf9ed20 100644 --- a/dist/js/jquery.tablesorter.js +++ b/dist/js/jquery.tablesorter.js @@ -27,7 +27,7 @@ * @contributor Rob Garrison - https://github.com/Mottie/tablesorter */ /*jshint browser:true, jquery:true, unused:false, expr: true */ -/*global console:false, alert:false, require:false, define:false, module:false */ +/*global console:false */ ;(function($){ 'use strict'; $.extend({ diff --git a/dist/js/jquery.tablesorter.widgets.js b/dist/js/jquery.tablesorter.widgets.js index d5bfe723..c7be7600 100644 --- a/dist/js/jquery.tablesorter.widgets.js +++ b/dist/js/jquery.tablesorter.widgets.js @@ -11,6 +11,7 @@ }(function($) { /*! Widget: storage - updated 3/26/2015 (v2.21.3) */ +/*global JSON:false */ ;(function ($, window, document) { 'use strict'; @@ -472,7 +473,7 @@ types: { or : function( c, data, vars ) { if ( /\|/.test( data.iFilter ) || ts.filter.regex.orSplit.test( data.filter ) ) { - var indx, filterMatched, txt, query, regex, + var indx, filterMatched, query, regex, // duplicate data but split filter data2 = $.extend( {}, data ), index = data.index, @@ -507,7 +508,7 @@ // Look for an AND or && operator ( logical and ) and : function( c, data, vars ) { if ( ts.filter.regex.andTest.test( data.filter ) ) { - var indx, filterMatched, result, txt, query, regex, + var indx, filterMatched, result, query, regex, // duplicate data but split filter data2 = $.extend( {}, data ), index = data.index, diff --git a/dist/js/parsers/parser-network.min.js b/dist/js/parsers/parser-network.min.js index ff4a74af..2d3ce51c 100644 --- a/dist/js/parsers/parser-network.min.js +++ b/dist/js/parsers/parser-network.min.js @@ -2,4 +2,4 @@ !function(a){"use strict";var b,c,d=a.tablesorter;/*! IPv6 Address parser (WIP) */ a.extend(d.regex,{},{ipv4Validate:/((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})/,ipv4Extract:/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/,ipv6Validate:/^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/i}),d.addParser({id:"ipv6Address",is:function(a){return d.regex.ipv6Validate.test(a)},format:function(a,b){var c,e,f,g,h,i=b?"boolean"==typeof b?b:b&&b.config.ipv6HexFormat||!1:!1,j="",k="",l=8;if(a=a.replace(/\s*/g,""),d.regex.ipv4Validate.test(a)){for(g=a.match(d.regex.ipv4Extract),e="",c=1;cc;c++)j+="0000:";j+=f[1]}for(g=j.split(":"),c=0;l>c;c++)g[c]=i?("0000"+g[c]).slice(-4):("00000"+(parseInt(g[c],16)||0)).slice(-5),k+=c!=l-1?g[c]+":":g[c];return i?k:k.replace(/:/g,"")},type:"numeric"}),c=function(a){return/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/.test(a)},b=function(a,b){var c,e=a?a.split("."):"",f="",g=e.length;for(c=0;g>c;c++)f+=("000"+e[c]).slice(-3);return a?d.formatFloat(f,b):a},/*! Parser: ipv4Address (a.k.a. ipAddress) */ d.addParser({id:"ipAddress",is:c,format:b,type:"numeric"}),d.addParser({id:"ipv4Address",is:c,format:b,type:"numeric"}),/*! Parser: MAC address */ -d.addParser({id:"MAC",is:function(a){return!1},format:function(a){var b,c,d="",e=(a||"").replace(/[:.-]/g,"").match(/\w{2}/g);if(e){for(c=e.length,b=0;c>b;b++)d+=("000"+parseInt(e[b],16)).slice(-3);return d}return a},type:"numeric"})}(jQuery); \ No newline at end of file +d.addParser({id:"MAC",is:function(){return!1},format:function(a){var b,c,d="",e=(a||"").replace(/[:.-]/g,"").match(/\w{2}/g);if(e){for(c=e.length,b=0;c>b;b++)d+=("000"+parseInt(e[b],16)).slice(-3);return d}return a},type:"numeric"})}(jQuery); \ No newline at end of file diff --git a/dist/js/widgets/widget-math.min.js b/dist/js/widgets/widget-math.min.js index 328d1839..2ba70df5 100644 --- a/dist/js/widgets/widget-math.min.js +++ b/dist/js/widgets/widget-math.min.js @@ -1,9 +1,9 @@ /*! Widget: math - updated 7/28/2015 (v2.22.4) */ -!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)}};/** +!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){if(a&&(!d.math_isUpdating||e)){e&&b.computeColumnIndex(a.$table.children("tbody").children()),d.math_dataAttrib="data-"+(d.math_data||"math");var f=a.$tbodies.find("["+d.math_dataAttrib+"]");c.mathType(a,f,d.math_priority),f=a.$table.children("."+a.cssInfoBlock+", tfoot").find("["+d.math_dataAttrib+"]"),c.mathType(a,f,d.math_priority),f=a.$table.find("["+d.math_dataAttrib+"^=all]"),c.mathType(a,f,["all"]),d.math_isUpdating=!0,a.debug&&console[console.group?"group":"log"]("Math widget triggering an update after recalculation"),a.$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); \ No newline at end of file +b.formatMask=function(a,b,c,d){if(!a||isNaN(+b))return b;var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t="",u=a.length,v=a.search(/[0-9\-\+#]/),w=v>0?a.substring(0,v):"",x=w;if(v>0&&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,""!==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=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"),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"),i>-1)for(;l[0].lengthq;q++)o+=n.charAt(q),!((q-p+1)%k)&&u-k>q&&(o+=h);b[0]=o}return b[1]=a[1]&&b[1]?g+b[1]:"",x+((e?"-":"")+b[0]+b[1])+t},b.equations={count:function(a){return a.length},sum:function(a){var b,c=a.length,d=0;for(b=0;c>b;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(a){var d="tablesorter-initialized"===a.type;(!f.math_isUpdating||d)&&(/filter/.test(a.type)||b.computeColumnIndex(e.$table.children("tbody").children()),c.recalculate(e,f,d))}).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); \ No newline at end of file diff --git a/dist/js/widgets/widget-sort2Hash.min.js b/dist/js/widgets/widget-sort2Hash.min.js index 6ab3cda2..8e31de51 100644 --- a/dist/js/widgets/widget-sort2Hash.min.js +++ b/dist/js/widgets/widget-sort2Hash.min.js @@ -1,2 +1,2 @@ /*! Widget: sort2Hash - updated 7/28/2015 (v2.22.4) */ -!function(a){"use strict";var b=a.tablesorter||{},c={init:function(a,d){var e=b.hasWidget(a.table,"saveSort"),f=c.getSort(a,d);(f&&!e||f&&e&&d.sort2Hash_overrideSaveSort)&&c.processHash(a,d,f),a.$table.on("sortEnd.sort2hash",function(){c.setHash(a,d)})},getTableId:function(b,c){return c.sort2Hash_tableId||b.table.id||"table"+a("table").index(b.$table)},getSort:function(a,b,d){var e,f=c.getTableId(a,b).replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"),g=new RegExp("[\\#&]"+f+"=([^&]*)").exec(window.location.hash);return null===g?"":(e=c.processSort(a,b,g[1]),d?(window.location.hash=window.location.hash.replace("&"+f+"="+g[1],""),e):g[1])},processHash:function(a,b,c){for(var d,e,f,g,h=decodeURI(c||"").split(b.sort2Hash_separator),i=0,j=h.length,k=[];j>i;)e=h[i++],g=parseInt(e,10),(isNaN(g)||g>a.columns)&&(d=new RegExp("("+e+")","i"),e=a.$headers.filter(function(b,c){return d.test(a.$headers[b].textContent||"")}).attr("data-column")),f=h[i++],"undefined"!=typeof f&&(isNaN(f)&&(f=f.indexOf(b.sort2Hash_directionText[1])>-1?1:0),k.push([e,f]));k.length&&(a.sortList=k)},processSort:function(b,c){var d,e,f,g,h=[],i=b.sortList||[],j=i.length;for(d=0;j>d;d++)f=i[d][0],c.sort2Hash_useHeaderText&&(e=a.trim(b.$headerIndexed[f].text()),"function"==typeof c.sort2Hash_processHeaderText&&(e=c.sort2Hash_processHeaderText(e,b,f)),f=e),h.push(f),g=c.sort2Hash_directionText[i[d][1]],h.push(g);return h.join(c.sort2Hash_separator)},setHash:function(a,b){var d=c.processSort(a,b);d.length&&(c.getSort(a,b,!0),window.location.hash+=(window.location.hash.length?"":b.sort2Hash_hash)+"&"+c.getTableId(a,b)+"="+encodeURI(d))}};b.addWidget({id:"sort2Hash",priority:30,options:{sort2Hash_hash:"#",sort2Hash_separator:"-",sort2Hash_tableId:null,sort2Hash_useHeaderText:!1,sort2Hash_processHeaderText:null,sort2Hash_directionText:[0,1],sort2Hash_overrideSaveSort:!1},init:function(a,b,d,e){c.init(d,e)},remove:function(a,b){b.$table.off("sortEnd.sort2hash")}})}(jQuery); \ No newline at end of file +!function(a){"use strict";var b=a.tablesorter||{},c={init:function(a,d){var e=b.hasWidget(a.table,"saveSort"),f=c.getSort(a,d);(f&&!e||f&&e&&d.sort2Hash_overrideSaveSort)&&c.processHash(a,d,f),a.$table.on("sortEnd.sort2hash",function(){c.setHash(a,d)})},getTableId:function(b,c){return c.sort2Hash_tableId||b.table.id||"table"+a("table").index(b.$table)},getSort:function(a,b,d){var e,f=c.getTableId(a,b).replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"),g=new RegExp("[\\#&]"+f+"=([^&]*)").exec(window.location.hash);return null===g?"":(e=c.processSort(a,b,g[1]),d?(window.location.hash=window.location.hash.replace("&"+f+"="+g[1],""),e):g[1])},processHash:function(a,b,c){for(var d,e,f,g,h=decodeURI(c||"").split(b.sort2Hash_separator),i=0,j=h.length,k=[];j>i;)e=h[i++],g=parseInt(e,10),(isNaN(g)||g>a.columns)&&(d=new RegExp("("+e+")","i"),e=a.$headers.filter(function(b){return d.test(a.$headers[b].textContent||"")}).attr("data-column")),f=h[i++],"undefined"!=typeof f&&(isNaN(f)&&(f=f.indexOf(b.sort2Hash_directionText[1])>-1?1:0),k.push([e,f]));k.length&&(a.sortList=k)},processSort:function(b,c){var d,e,f,g,h=[],i=b.sortList||[],j=i.length;for(d=0;j>d;d++)f=i[d][0],c.sort2Hash_useHeaderText&&(e=a.trim(b.$headerIndexed[f].text()),"function"==typeof c.sort2Hash_processHeaderText&&(e=c.sort2Hash_processHeaderText(e,b,f)),f=e),h.push(f),g=c.sort2Hash_directionText[i[d][1]],h.push(g);return h.join(c.sort2Hash_separator)},setHash:function(a,b){var d=c.processSort(a,b);d.length&&(c.getSort(a,b,!0),window.location.hash+=(window.location.hash.length?"":b.sort2Hash_hash)+"&"+c.getTableId(a,b)+"="+encodeURI(d))}};b.addWidget({id:"sort2Hash",priority:30,options:{sort2Hash_hash:"#",sort2Hash_separator:"-",sort2Hash_tableId:null,sort2Hash_useHeaderText:!1,sort2Hash_processHeaderText:null,sort2Hash_directionText:[0,1],sort2Hash_overrideSaveSort:!1},init:function(a,b,d,e){c.init(d,e)},remove:function(a,b){b.$table.off("sortEnd.sort2hash")}})}(jQuery); \ No newline at end of file diff --git a/js/jquery.tablesorter.combined.js b/js/jquery.tablesorter.combined.js index 37ba3376..eef563c1 100644 --- a/js/jquery.tablesorter.combined.js +++ b/js/jquery.tablesorter.combined.js @@ -35,7 +35,7 @@ * @contributor Rob Garrison - https://github.com/Mottie/tablesorter */ /*jshint browser:true, jquery:true, unused:false, expr: true */ -/*global console:false, alert:false, require:false, define:false, module:false */ +/*global console:false */ ;(function($){ 'use strict'; $.extend({ @@ -2250,6 +2250,7 @@ })(jQuery); /*! Widget: storage - updated 3/26/2015 (v2.21.3) */ +/*global JSON:false */ ;(function ($, window, document) { 'use strict'; @@ -2711,7 +2712,7 @@ types: { or : function( c, data, vars ) { if ( /\|/.test( data.iFilter ) || ts.filter.regex.orSplit.test( data.filter ) ) { - var indx, filterMatched, txt, query, regex, + var indx, filterMatched, query, regex, // duplicate data but split filter data2 = $.extend( {}, data ), index = data.index, @@ -2746,7 +2747,7 @@ // Look for an AND or && operator ( logical and ) and : function( c, data, vars ) { if ( ts.filter.regex.andTest.test( data.filter ) ) { - var indx, filterMatched, result, txt, query, regex, + var indx, filterMatched, result, query, regex, // duplicate data but split filter data2 = $.extend( {}, data ), index = data.index, diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index a2eda6d1..b241b00e 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -17,7 +17,7 @@ * @contributor Rob Garrison - https://github.com/Mottie/tablesorter */ /*jshint browser:true, jquery:true, unused:false, expr: true */ -/*global console:false, alert:false, require:false, define:false, module:false */ +/*global console:false */ ;(function($){ 'use strict'; $.extend({ diff --git a/js/jquery.tablesorter.widgets.js b/js/jquery.tablesorter.widgets.js index 27e77529..225dee7c 100644 --- a/js/jquery.tablesorter.widgets.js +++ b/js/jquery.tablesorter.widgets.js @@ -17,6 +17,7 @@ }(function($) { /*! Widget: storage - updated 3/26/2015 (v2.21.3) */ +/*global JSON:false */ ;(function ($, window, document) { 'use strict'; @@ -478,7 +479,7 @@ types: { or : function( c, data, vars ) { if ( /\|/.test( data.iFilter ) || ts.filter.regex.orSplit.test( data.filter ) ) { - var indx, filterMatched, txt, query, regex, + var indx, filterMatched, query, regex, // duplicate data but split filter data2 = $.extend( {}, data ), index = data.index, @@ -513,7 +514,7 @@ // Look for an AND or && operator ( logical and ) and : function( c, data, vars ) { if ( ts.filter.regex.andTest.test( data.filter ) ) { - var indx, filterMatched, result, txt, query, regex, + var indx, filterMatched, result, query, regex, // duplicate data but split filter data2 = $.extend( {}, data ), index = data.index, diff --git a/js/parsers/parser-globalize.js b/js/parsers/parser-globalize.js index 24a08bda..aa64fc70 100644 --- a/js/parsers/parser-globalize.js +++ b/js/parsers/parser-globalize.js @@ -2,6 +2,7 @@ /* Extract localized data using jQuery's Globalize parsers; set Globalize.locale( 'xx' ) prior to initializing tablesorter! */ /*jshint jquery:true */ +/*global Globalize:false */ ;( function( $ ) { 'use strict'; diff --git a/js/parsers/parser-network.js b/js/parsers/parser-network.js index 53927e2e..a39de293 100644 --- a/js/parsers/parser-network.js +++ b/js/parsers/parser-network.js @@ -29,13 +29,14 @@ return ts.regex.ipv6Validate.test(s); }, format: function(address, table) { - // code modified from http://forrst.com/posts/JS_Expand_Abbreviated_IPv6_Addresses-1OR + // code modified from http://zurb.com/forrst/posts/JS_Expand_Abbreviated_IPv6_Addresses-1OR + // Saved to https://gist.github.com/Mottie/7018157 var i, t, sides, groups, groupsPresent, hex = table ? (typeof table === 'boolean' ? table : table && table.config.ipv6HexFormat || false) : false, fullAddress = '', expandedAddress = '', - validGroupCount = 8, - validGroupSize = 4; + validGroupCount = 8; + // validGroupSize = 4; <- removed while loop // remove any extra spaces address = address.replace(/\s*/g, ''); // look for embedded ipv4 @@ -112,7 +113,7 @@ */ ts.addParser({ id : 'MAC', - is : function( str ) { + is : function() { return false; }, format : function( str ) { diff --git a/js/widgets/widget-filter.js b/js/widgets/widget-filter.js index d83d433b..5ca182be 100644 --- a/js/widgets/widget-filter.js +++ b/js/widgets/widget-filter.js @@ -105,7 +105,7 @@ types: { or : function( c, data, vars ) { if ( /\|/.test( data.iFilter ) || ts.filter.regex.orSplit.test( data.filter ) ) { - var indx, filterMatched, txt, query, regex, + var indx, filterMatched, query, regex, // duplicate data but split filter data2 = $.extend( {}, data ), index = data.index, @@ -140,7 +140,7 @@ // Look for an AND or && operator ( logical and ) and : function( c, data, vars ) { if ( ts.filter.regex.andTest.test( data.filter ) ) { - var indx, filterMatched, result, txt, query, regex, + var indx, filterMatched, result, query, regex, // duplicate data but split filter data2 = $.extend( {}, data ), index = data.index, diff --git a/js/widgets/widget-math.js b/js/widgets/widget-math.js index 180188bd..b531faf9 100644 --- a/js/widgets/widget-math.js +++ b/js/widgets/widget-math.js @@ -40,8 +40,7 @@ // get all of the row numerical values in an arry getRow : function( c, $el ) { - var $t, txt, - wo = c.widgetOptions, + var wo = c.widgetOptions, arry = [], $row = $el.closest( 'tr' ), $cells = $row.children().not( '[' + wo.math_dataAttrib + '=ignore]' ); @@ -58,7 +57,7 @@ // get all of the column numerical values in an arry getColumn : function( c, $el, type ) { - var index, txt, $t, len, $mathRows, mathAbove, + var index, $t, len, $mathRows, mathAbove, arry = [], wo = c.widgetOptions, filtered = wo.filter_filteredRow || 'filtered', @@ -104,7 +103,7 @@ // get all of the column numerical values in an arry getAll : function( c ) { - var txt, $t, col, $row, rowIndex, rowLen, $cells, cellIndex, cellLen, + var $t, col, $row, rowIndex, rowLen, $cells, cellIndex, cellLen, arry = [], wo = c.widgetOptions, filtered = wo.filter_filteredRow || 'filtered', @@ -128,7 +127,7 @@ return arry; }, - recalculate : function(table, c, wo, init) { + recalculate : function(c, wo, init) { if ( c && ( !wo.math_isUpdating || init ) ) { // add data-column attributes to all table cells @@ -315,7 +314,7 @@ str += integer.charAt( index ); // ie6 only support charAt for sz. // -posSeparator so that won't trail separator on full length /*jshint -W018 */ - if ( !( ( index - offset + 1 ) % posSeparator ) && index < l - posSeparator ) { + if ( !( ( index - offset + 1 ) % posSeparator ) && index < len - posSeparator ) { str += group; } } @@ -456,7 +455,7 @@ // redo data-column indexes on update ts.computeColumnIndex( c.$table.children('tbody').children() ); } - math.recalculate( table, c, wo, init ); + math.recalculate( c, wo, init ); } }) .on( update + '.tsmath', function() { diff --git a/js/widgets/widget-output.js b/js/widgets/widget-output.js index 7fcd3249..cbe107b1 100644 --- a/js/widgets/widget-output.js +++ b/js/widgets/widget-output.js @@ -5,7 +5,7 @@ * Download-File-JS: https://github.com/PixelsCommander/Download-File-JS (http://www.apache.org/licenses/LICENSE-2.0) */ /*jshint browser:true, jquery:true, unused:false */ -/*global jQuery: false */ +/*global jQuery:false, alert:false */ ;(function($){ 'use strict'; diff --git a/js/widgets/widget-sort2Hash.js b/js/widgets/widget-sort2Hash.js index 8a35f638..86db9a16 100644 --- a/js/widgets/widget-sort2Hash.js +++ b/js/widgets/widget-sort2Hash.js @@ -50,7 +50,7 @@ // just see if column contains a number if ( isNaN( temp ) || temp > c.columns ) { regex = new RegExp( '(' + column + ')', 'i' ); - column = c.$headers.filter( function( index, cell ) { + column = c.$headers.filter( function( index ) { return regex.test( c.$headers[ index ].textContent || '' ); }).attr( 'data-column' ); } @@ -94,8 +94,7 @@ return sort.join( wo.sort2Hash_separator ); }, setHash : function( c, wo ) { - var arry = [], - sort = s2h.processSort( c, wo ); + var sort = s2h.processSort( c, wo ); if ( sort.length ) { // remove old hash s2h.getSort( c, wo, true ); diff --git a/js/widgets/widget-storage.js b/js/widgets/widget-storage.js index bfb9c745..6c482a34 100644 --- a/js/widgets/widget-storage.js +++ b/js/widgets/widget-storage.js @@ -1,4 +1,5 @@ /*! Widget: storage - updated 3/26/2015 (v2.21.3) */ +/*global JSON:false */ ;(function ($, window, document) { 'use strict';