tablesorter/dist/js/parsers/parser-network.min.js
Rob Garrison 7f082fa019 v2.28.10
2017-05-16 15:33:15 -05:00

5 lines
2.7 KiB
JavaScript

/*! Parser: network - updated 5/17/2015 (v2.22.0) */
!function(d){"use strict";var e,r,t=d.tablesorter;/*! IPv6 Address parser (WIP) */
d.extend(t.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}),t.addParser({id:"ipv6Address",is:function(d){return t.regex.ipv6Validate.test(d)},format:function(d,e){var r,a,i,f,n,s=!!e&&("boolean"==typeof e?e:e&&e.config.ipv6HexFormat||!1),c="",p="";if(d=d.replace(/\s*/g,""),t.regex.ipv4Validate.test(d)){for(f=d.match(t.regex.ipv4Extract),a="",r=1;r<f.length;r++)a+=("00"+parseInt(f[r],10).toString(16)).slice(-2)+(2===r?":":"");d=d.replace(t.regex.ipv4Extract,a)}if(-1==d.indexOf("::"))c=d;else{for(i=d.split("::"),n=0,r=0;r<i.length;r++)n+=i[r].split(":").length;for(c+=i[0]+":",r=0;r<8-n;r++)c+="0000:";c+=i[1]}for(f=c.split(":"),r=0;r<8;r++)f[r]=s?("0000"+f[r]).slice(-4):("00000"+(parseInt(f[r],16)||0)).slice(-5),p+=7!=r?f[r]+":":f[r];return s?p:p.replace(/:/g,"")},type:"numeric"}),r=function(d){return/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/.test(d)},e=function(d,e){var r,a=d?d.split("."):"",i="",f=a.length;for(r=0;r<f;r++)i+=("000"+a[r]).slice(-3);return d?t.formatFloat(i,e):d},/*! Parser: ipv4Address (a.k.a. ipAddress) */
t.addParser({id:"ipAddress",is:r,format:e,type:"numeric"}),t.addParser({id:"ipv4Address",is:r,format:e,type:"numeric"}),/*! Parser: MAC address */
t.addParser({id:"MAC",is:function(){return!1},format:function(d){var e,r,t="",a=(d||"").replace(/[:.-]/g,"").match(/\w{2}/g);if(a){for(r=a.length,e=0;e<r;e++)t+=("000"+parseInt(a[e],16)).slice(-3);return t}return d},type:"numeric"})}(jQuery);