| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>jQuery tablesorter 2.0 - IP address parsers</title> |
| 6 |
|
| 7 |
|
| 8 |
<script src="js/jquery-latest.min.js"></script> |
| 9 |
|
| 10 |
|
| 11 |
<link rel="stylesheet" href="css/jq.css"> |
| 12 |
<link href="css/prettify.css" rel="stylesheet"> |
| 13 |
<script src="js/prettify.js"></script> |
| 14 |
<script src="js/docs.js"></script> |
| 15 |
|
| 16 |
|
| 17 |
<link rel="stylesheet" href="../css/theme.blue.css"> |
| 18 |
<script src="../js/jquery.tablesorter.js"></script> |
| 19 |
|
| 20 |
<script src="../js/parsers/parser-network.js"></script> |
| 21 |
|
| 22 |
<script id="js">$(function() { |
| 23 |
|
| 24 |
$('table').tablesorter({ |
| 25 |
theme: 'blue', |
| 26 |
widthFixed: true, |
| 27 |
widgets: ['zebra'], |
| 28 |
sortList: [[2, 0]], |
| 29 |
headers: { |
| 30 |
1: { sorter: 'MAC' }, |
| 31 |
3: { sorter: 'ipv6Address' } |
| 32 |
} |
| 33 |
}); |
| 34 |
|
| 35 |
});</script> |
| 36 |
|
| 37 |
</head> |
| 38 |
<body> |
| 39 |
<div id="banner"> |
| 40 |
<h1>table<em>sorter</em></h1> |
| 41 |
<h2>IPv4 & IPv6 address parsers</h2> |
| 42 |
<h3>Flexible client-side table sorting</h3> |
| 43 |
<a href="index.html">Back to documentation</a> |
| 44 |
</div> |
| 45 |
<div id="main"> |
| 46 |
|
| 47 |
<p class="tip"> |
| 48 |
<em>NOTE!</em> |
| 49 |
</p> |
| 50 |
<ul> |
| 51 |
<li><span class="label warning">NOTE</span> The default "ipAddress" parser (also named "ipv4Address") is included with the original tablesorter; it was moved to the <code>parser-network.js</code> file in <span class="version">v2.18.0</span>.<br><br></li> |
| 52 |
|
| 53 |
<li>In <span class="version">v2.29.3</span>, all included parsers were changed to return a text representation of the network address. The specific issue was that the parsed IPv6 numerical values were too large for javascript to properly recognize the number.</li> |
| 54 |
<li>A parser for IPv6 was added in <span class="version">v2.12</span> and named "ipv6Address": |
| 55 |
<ul> |
| 56 |
<li>Unlike some other custom parsers, this one will auto-detect & check for a valid IPv6 address since the same address can be represented in many different ways. Some examples are shown in the demo table below.</li> |
| 57 |
<li>IPv6 addresses are stored in the cache in their canonical decimal form, for faster & easier numerical sorting.</li> |
| 58 |
<li><a href="../test.html">Extensive unit tests</a> are included with this parser.</li> |
| 59 |
</ul> |
| 60 |
</li> |
| 61 |
<li>If the parser doesn't auto-detect which column has IPv6 addresses, use the headers sorter option to set it: |
| 62 |
<pre class="prettyprint lang-javascript">$(function() { |
| 63 |
$('table').tablesorter({ |
| 64 |
headers: { |
| 65 |
1: { sorter: 'MAC' }, |
| 66 |
// 2: { sorter: 'ipAddress' }, this parser is auto-detected |
| 67 |
3: { sorter: 'ipv6Address' } |
| 68 |
} |
| 69 |
}); |
| 70 |
});</pre> |
| 71 |
</li> |
| 72 |
<li>These parsers may also be used with the original tablesorter plugin.</li> |
| 73 |
</ul> |
| 74 |
|
| 75 |
|
| 76 |
<h1>Demo</h1> |
| 77 |
<button type="button" class="toggleparsedvalue">Toggle parsed values</button> |
| 78 |
<br> |
| 79 |
<div id="demo"> |
| 80 |
<table> |
| 81 |
<thead> |
| 82 |
<tr> |
| 83 |
<th>Name</th> |
| 84 |
<th>MAC</th> |
| 85 |
<th>IPv4</th> |
| 86 |
<th>IPv6</th> |
| 87 |
</tr> |
| 88 |
</thead> |
| 89 |
<tbody> |
| 90 |
<tr><td>Fred</td><td>12:06:D2:8E:56:BF</td><td>1.2.3.4</td><td>f0f0::1</td></tr> |
| 91 |
<tr><td>Ginger</td><td>546F.5903.3C9B</td><td>1.1.1.1</td><td>f0::1</td></tr> |
| 92 |
<tr><td>Mike</td><td>3c-cf-44-cd-6e-d6</td><td>2.222.33.44</td><td>1:2:3:4:5::7:8</td></tr> |
| 93 |
<tr><td>George</td><td>ff-68-3d-e8-b4-0d</td><td>255.255.255.255</td><td>::2:3:4</td></tr> |
| 94 |
<tr><td>Harry</td><td>f566.6dfd.2df2</td><td>251.2.33.4</td><td>f0f0:f::1</td></tr> |
| 95 |
<tr><td>Frank</td><td>12:69:13:D8:FA:61</td><td>251.002.31.4</td><td>::</td></tr> |
| 96 |
<tr><td>Kristy</td><td>A031.5FED.43BC</td><td>2.221.003.4</td><td>0:0:0:0:0:0:0:0</td></tr> |
| 97 |
<tr><td>Lily</td><td>82-2D-FF-FA-CD-6C</td><td>251.02.32.4</td><td>f0f0::f:1</td></tr> |
| 98 |
<tr><td>Maria</td><td>125c395f08f2</td><td>1.2.3.44</td><td>1:2:3:4:5:6:1.2.3.4</td></tr> |
| 99 |
</tbody> |
| 100 |
</table> |
| 101 |
|
| 102 |
</div> |
| 103 |
|
| 104 |
<h1>Page Header</h1> |
| 105 |
<div> |
| 106 |
<pre class="prettyprint lang-html"><!-- tablesorter --> |
| 107 |
<link rel="stylesheet" href="../css/theme.blue.css"> |
| 108 |
<script src="../js/jquery.tablesorter.js"></script> |
| 109 |
|
| 110 |
<!-- load mac, ipv4 and ipv6 parsers --> |
| 111 |
<script src="../js/parsers/parser-network.js"></script> |
| 112 |
<script> |
| 113 |
$(function() { |
| 114 |
|
| 115 |
$('table').tablesorter({ |
| 116 |
theme: 'blue', |
| 117 |
widgets: ['zebra'], |
| 118 |
sortList: [[1, 0]], |
| 119 |
headers: { |
| 120 |
1: { sorter: 'MAC' }, |
| 121 |
// 2: { sorter: 'ipAddress' }, this parser is auto-detected (alias for 'ipv4Address') |
| 122 |
3: { sorter: 'ipv6Address' } // this parser is also auto-detected |
| 123 |
} |
| 124 |
}); |
| 125 |
|
| 126 |
}); |
| 127 |
</script></pre> |
| 128 |
</div> |
| 129 |
|
| 130 |
</div> |
| 131 |
|
| 132 |
<script> |
| 133 |
$(function() { |
| 134 |
// add parsed values to columns [0,1] |
| 135 |
addParsedValues($('table'), [1,2,3]); |
| 136 |
}); |
| 137 |
</script> |
| 138 |
|
| 139 |
|
| 140 |
</body></html> |