| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>jQuery tablesorter - Named Numbers Parser</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 |
<style> |
| 16 |
th { width: 33%; } |
| 17 |
</style> |
| 18 |
|
| 19 |
<link href="../css/theme.blue.css" rel="stylesheet"> |
| 20 |
<script src="../js/jquery.tablesorter.js"></script> |
| 21 |
|
| 22 |
|
| 23 |
<script src="../js/parsers/parser-named-numbers.js"></script> |
| 24 |
<script src="../js/parsers/parser-huge-numbers.js"></script> |
| 25 |
|
| 26 |
<script id="js">$(function() { |
| 27 |
|
| 28 |
$("table").tablesorter({ |
| 29 |
theme : 'blue', |
| 30 |
widgets : ["zebra"] |
| 31 |
}); |
| 32 |
|
| 33 |
});</script> |
| 34 |
</head> |
| 35 |
<body> |
| 36 |
<div id="banner"> |
| 37 |
<h1>table<em>sorter</em></h1> |
| 38 |
<h2>Named Numbers Parser</h2> |
| 39 |
<h3>Flexible client-side table sorting</h3> |
| 40 |
<a href="index.html">Back to documentation</a> |
| 41 |
</div> |
| 42 |
<div id="main"> |
| 43 |
|
| 44 |
<p class="tip"> |
| 45 |
<em>NOTE!</em> |
| 46 |
</p> |
| 47 |
<ul> |
| 48 |
<li>In <span class="version">v2.25.5</span>, added an example that uses the huge number parser. |
| 49 |
<ul> |
| 50 |
<li>The largest number (<code>MAX_SAFE_INTEGER</code>) that javascript can handle is <code>9,007,199,254,740,991</code>.</li> |
| 51 |
<li>Anything larger and the number gets rounded off, so that's why this parser was created.</li> |
| 52 |
</ul> |
| 53 |
</li> |
| 54 |
<li>In <span class="version updated">v2.22.0</span>, this parser will now ignore commas, periods and quotes adjacent to the named number word (e.g. "10 million, three...").</li> |
| 55 |
<li>This parser will convert named numbers into appropriate values so they are sorted correctly.</li> |
| 56 |
<li>Named numbers include values: |
| 57 |
<ul> |
| 58 |
<li>zero to twenty; by one ("one", "two", "three", ..., "nineteen", "twenty")</li> |
| 59 |
<li>twenty to hundred; by ten ("twenty", "thirty", "forty", ... "ninety", "hundred")</li> |
| 60 |
<li>thousand (1e3) to duotrigintillion (1e99); by 10^(3n+3) value ("thousand", "million", "billion", ... "untrigintillion", "duotrigintillion")</li> |
| 61 |
<li>googl (1e100)</li> |
| 62 |
</ul> |
| 63 |
</li> |
| 64 |
<li>Even bigger named values will need to be manually added to the parser code; see <a href="http://en.wikipedia.org/wiki/Names_of_large_numbers">this wikipedia page</a> for more names.</li> |
| 65 |
</ul> |
| 66 |
|
| 67 |
<h1>Demo</h1> |
| 68 |
<button type="button" class="toggleparsedvalue">Toggle parsed values</button> |
| 69 |
<div id="demo"><table class="tablesorter"> |
| 70 |
<thead> |
| 71 |
<tr> |
| 72 |
<th class="sorter-namedNumbers">Numbers</th> |
| 73 |
<th class="sorter-namedNumbers">Large Numbers</th> |
| 74 |
<th class="sorter-hugeNumbers">Huge Numbers</th> |
| 75 |
</tr> |
| 76 |
</thead> |
| 77 |
<tbody> |
| 78 |
<tr> |
| 79 |
<td>5 hundred</td> |
| 80 |
<td>one hundred and fifty two million</td> |
| 81 |
<td>110,000,000,000,000,001</td> |
| 82 |
</tr> |
| 83 |
<tr> |
| 84 |
<td>four hundred thousand five hundred fourty three</td> |
| 85 |
<td>710,231,000</td> |
| 86 |
<td>110,000,000,000,000,000</td> |
| 87 |
</tr> |
| 88 |
<tr> |
| 89 |
<td>one hundred and fifty five</td> |
| 90 |
<td>10 million, three hundred sixty five thousand, four hundred and ninety one</td> |
| 91 |
<td>110,000,000,000,000,005</td> |
| 92 |
</tr> |
| 93 |
<tr> |
| 94 |
<td>negative twelve</td> |
| 95 |
<td>10 million and three</td> |
| 96 |
<td>110,000,000,000,000,003</td> |
| 97 |
</tr> |
| 98 |
<tr> |
| 99 |
<td>minus three hundred and fifty seven thousand four hundred and two</td> |
| 100 |
<td>6 billion eight thousand</td> |
| 101 |
<td>110,000,000,000,000,012</td> |
| 102 |
</tr> |
| 103 |
<tr> |
| 104 |
<td>zero</td> |
| 105 |
<td>3 hundred quadrillion</td> |
| 106 |
<td>110,000,000,000,000,002</td> |
| 107 |
</tr> |
| 108 |
<tr> |
| 109 |
<td>three hundred twenty</td> |
| 110 |
<td>145 decillion</td> |
| 111 |
<td>110,000,000,000,000,010</td> |
| 112 |
</tr> |
| 113 |
<tr> |
| 114 |
<td>forty-two</td> |
| 115 |
<td>700 thousand</td> |
| 116 |
<td>110,000,000,000,000,007</td> |
| 117 |
</tr> |
| 118 |
<tr> |
| 119 |
<td>ninety-nine thousand nine hundred and ninety-nine</td> |
| 120 |
<td>2.3 million</td> |
| 121 |
<td>110,000,000,000,000,009</td> |
| 122 |
</tr> |
| 123 |
<tr> |
| 124 |
<td>2.3 thousand</td> |
| 125 |
<td>2.3 googl</td> |
| 126 |
<td>110,000,000,000,000,008</td> |
| 127 |
</tr> |
| 128 |
<tr> |
| 129 |
<td>minus one</td> |
| 130 |
<td>8 hundred thousand</td> |
| 131 |
<td>110,000,000,000,000,021</td> |
| 132 |
</tr> |
| 133 |
<tr> |
| 134 |
<td>seven hundred fifty two</td> |
| 135 |
<td>9 hundred-million</td> |
| 136 |
<td>110,000,000,000,000,011</td> |
| 137 |
</tr> |
| 138 |
<tr> |
| 139 |
<td>one hundred and thirty-three</td> |
| 140 |
<td>Twenty-three trillion</td> |
| 141 |
<td>110,000,000,000,000,100</td> |
| 142 |
</tr> |
| 143 |
</tbody> |
| 144 |
</table></div> |
| 145 |
|
| 146 |
<h1>Page Header</h1> |
| 147 |
<div> |
| 148 |
<pre class="prettyprint lang-html"><!-- blue theme stylesheet with additional css styles added in v2.0.17 --> |
| 149 |
<link rel="stylesheet" href="../css/theme.blue.css"> |
| 150 |
<!-- tablesorter plugin --> |
| 151 |
<script src="../js/jquery.tablesorter.js"></script> |
| 152 |
|
| 153 |
<!-- load metric parser --> |
| 154 |
<script src="../js/parsers/parser-named-numbers.js"></script></pre> |
| 155 |
</div> |
| 156 |
|
| 157 |
<h1>Javascript</h1> |
| 158 |
<div id="javascript"> |
| 159 |
<pre class="prettyprint lang-javascript"></pre> |
| 160 |
</div> |
| 161 |
|
| 162 |
<h1>HTML</h1> |
| 163 |
<div id="html"> |
| 164 |
<pre class="prettyprint lang-html"></pre> |
| 165 |
</div> |
| 166 |
|
| 167 |
</div> |
| 168 |
|
| 169 |
<script> |
| 170 |
$(function() { |
| 171 |
// add parsed values to columns [0,1] |
| 172 |
addParsedValues($('table'), [0,1]); |
| 173 |
}); |
| 174 |
</script> |
| 175 |
|
| 176 |
</body> |
| 177 |
</html> |