Debian Codegraph @

docs/example-parsers-metric.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter - Metric Parser</title>
6
7 <!-- jQuery -->
8 <script src="js/jquery-latest.min.js"></script>
9
10 <!-- Demo stuff -->
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: 20%; }
17 </style>
18
19 <link href="../css/theme.blue.css" rel="stylesheet">
20 <script src="../js/jquery.tablesorter.js"></script>
21
22 <!-- load metric parser -->
23 <script src="../js/parsers/parser-metric.js"></script>
24
25 <script id="js">$(function() {
26
27 $("table").tablesorter({
28 theme : 'blue',
29 widgets : ["zebra"]
30 });
31
32 });</script>
33 </head>
34 <body>
35 <div id="banner">
36 <h1>table<em>sorter</em></h1>
37 <h2>Metric parser</h2>
38 <h3>Flexible client-side table sorting</h3>
39 <a href="index.html">Back to documentation</a>
40 </div>
41 <div id="main">
42
43 <p class="tip">
44 <em>NOTE!</em>
45 </p>
46 <ul>
47 <li>In <span class="version update">v2.22.2</span>,
48 <ul>
49 <li>Added header data-attribute <code>data-metric-name-full</code> which will contain the full base unit name, e.g. <code>"byte|Byte|BYTE"</code>. This change should allow for different capitalizations of the base unit name.</li>
50 <li>Added header data-attribute <code>data-metric-name-abbr</code> which will contain the abbreviated base unit name, e.g. <code>"b|B"</code>. This change also should allow for different capitalizations of the base unit name.</li>
51 <li>Each name is separated by a pipe, or vertical bar, ("<code>|</code>") without spaces, because it will eventually be used in a regular expression - the vertical bar signifies an "OR" operator.</li>
52 <li>When using these new data-attributes, the value in <code>data-metric-name</code> (now deprecated) will be ignored; eventually <code>data-metric-name</code> support will be removed.</li>
53 <li>These additions were made because of <em>common misuse</em> of abbreviated capitalization in the metric units, i.e. "kB" versus "kb". The lower case "b" is for "bit", and upper case "B" is for "byte". I am guilty of this too!</li>
54 </ul>
55 </li>
56 <li>This parser will convert numbers with metric prefixes ("Mega", "Giga", etc) into appropriate values so they are sorted correctly.</li>
57 <li>The base name must be included in the header:
58 <ul>
59 <li>The base is the unit of measure, such as "byte", "meter", "liter", etc.</li>
60 <li><span class="label alert">deprecated</span> When saving the base, include both the abbreviation and full name of the base separated by a vertical bar (shift-\) <code>b|byte</code>.</li>
61 <li><span class="label alert">deprecated</span> Store this information within the header's data-attribute (<code>data-metric-name="b|byte"</code>) - this data-attribute should be considered deprecated as of v2.22.2, use <code>data-metric-name-full</code> &amp; <code>data-metric-name-abbr</code> instead.</li>
62 <li>If no base information is found, it will default to <code>m|meter</code>.</li>
63 </ul>
64 </li>
65 <li>Because metric prefixes can be applied to binary values, the parser will calculate the cached value based on the binary multiple, i.e. <code>"1 kB"</code> is actually <code>"1024 bytes"</code>. See <a href="http://en.wikipedia.org/wiki/Unit_prefix#Binary_prefixes">this article</a> for more details.</li>
66 <li>This parser does not (yet) support the IEC recommendations for binary prefixes (i.e. "kibibyte (KiB)", "mebibyte (MiB)", etc).</li>
67 <li>Supported prefixes include: Yotta (10<sup>24</sup>), Zetta (10<sup>21</sup>), Exa (10<sup>18</sup>), Peta (10<sup>15</sup>), Tera (10<sup>12</sup>), Giga (10<sup>9</sup>), Mega (10<sup>6</sup>), kilo (10<sup>3</sup>), hecto (10<sup>2</sup>), deka (10<sup>1</sup>), deci (10<sup>-1</sup>), centi (10<sup>-2</sup>), milli (10<sup>-3</sup>), micro (10<sup>-6</sup>), nano (10<sup>-9</sup>), pico (10<sup>-12</sup>), femto (10<sup>-15</sup>), atto (10<sup>-18</sup>), zepto (10<sup>-21</sup>) and yocto (10<sup>-24</sup>).</li>
68 <li>This demo includes the stored metric values within the table cells, toggle the view using the button below.</li>
69 </ul>
70
71 <h1>Demo</h1>
72 <button type="button" class="toggleparsedvalue">Toggle parsed values</button>
73 <div id="demo"><table class="tablesorter">
74 <thead>
75 <tr>
76 <th class="sorter-metric" data-metric-name-full="byte|Byte|BYTE" data-metric-name-abbr="b|B">Metric (binary) Size</th>
77 <!-- "data-metric-name" is deprecated in v2.22.2, use "data-metric-name-full" and "data-metric-name-abbr" instead -->
78 <th class="sorter-metric" data-metric-name="m|meter">Metric Length</th>
79 </tr>
80 </thead>
81 <tbody>
82 <tr><td>1 byte</td><td>1 nm</td></tr>
83 <tr><td>1 kB</td><td>1 kilometer</td></tr>
84 <tr><td>1 Gigabyte</td><td>1 Gm</td></tr>
85 <tr><td>10 MB</td><td>1 Tm</td></tr>
86 <tr><td>1 MB</td><td>1,000 mm</td></tr>
87 <tr><td>1 TB</td><td>1 meter</td></tr>
88 <tr><td>1 Petabyte</td><td>1 hm</td></tr>
89 <tr><td>1 ZB</td><td>1 dam</td></tr>
90 <tr><td>1 ZettaB</td><td>1 millimeter</td></tr>
91 <tr><td>1,025 MB</td><td>1 Mm</td></tr>
92 <tr><td>1,000 kilobytes</td><td>1 dm</td></tr>
93 <tr><td>1 EB</td><td>1 µm</td></tr>
94 <tr><td>1023 MB</td><td>1 pm</td></tr>
95 </tbody>
96 </table></div>
97
98 <h1>Page Header</h1>
99 <div>
100 <pre class="prettyprint lang-html">&lt;!-- blue theme stylesheet with additional css styles added in v2.0.17 --&gt;
101 &lt;link rel=&quot;stylesheet&quot; href=&quot;../css/theme.blue.css&quot;&gt;
102 &lt;!-- tablesorter plugin --&gt;
103 &lt;script src=&quot;../js/jquery.tablesorter.js&quot;&gt;&lt;/script&gt;
104
105 &lt;!-- load metric parser --&gt;
106 &lt;script src=&quot;../js/parsers/parser-metric.js&quot;&gt;&lt;/script&gt;</pre>
107 </div>
108
109 <h1>Javascript</h1>
110 <div id="javascript">
111 <pre class="prettyprint lang-javascript"></pre>
112 </div>
113
114 <h1>HTML</h1>
115 <div id="html">
116 <pre class="prettyprint lang-html"></pre>
117 </div>
118
119 <div class="next-up">
120 <hr />
121 Next up: <a href="example-widget-filter.html">Applying the filter widget &rsaquo;&rsaquo;</a>
122 </div>
123
124 </div>
125
126 <script>
127 $(function() {
128 // add parsed values to columns [0,1]
129 addParsedValues($('table'), [0,1], function(num) { return num.toExponential(); });
130 });
131 </script>
132
133 </body>
134 </html>