Debian Codegraph @

docs/example-parsers-file-type.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - File Type 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
16 <style id="css">tr.group-header td {
17 background: #eee;
18 }
19 .group-name {
20 text-transform: uppercase;
21 font-weight: bold;
22 }
23 .group-count {
24 color: #999;
25 }
26 .group-hidden {
27 display: none;
28 }
29 .group-header, .group-header td {
30 user-select: none;
31 -moz-user-select: none;
32 }
33 /* collapsed arrow */
34 tr.group-header td i {
35 display: inline-block;
36 width: 0;
37 height: 0;
38 border-top: 4px solid transparent;
39 border-bottom: 4px solid #888;
40 border-right: 4px solid #888;
41 border-left: 4px solid transparent;
42 margin-right: 7px;
43 user-select: none;
44 -moz-user-select: none;
45 }
46 tr.group-header.collapsed td i {
47 border-top: 5px solid transparent;
48 border-bottom: 5px solid transparent;
49 border-left: 5px solid #888;
50 border-right: 0;
51 margin-right: 10px;
52 }</style>
53
54 <!-- Tablesorter: required -->
55 <link rel="stylesheet" href="../css/theme.blue.css">
56 <script src="../js/jquery.tablesorter.js"></script>
57 <script src="../js/jquery.tablesorter.widgets.js"></script>
58
59 <!-- grouping widget -->
60 <script src="../js/parsers/parser-file-type.js"></script>
61 <script src="../js/widgets/widget-grouping.js"></script>
62
63 <script id="js">$(function() {
64
65 // basic list from http://en.wikipedia.org/wiki/List_of_file_formats
66 // there is no need to include this unless you plan on replacing the
67 // default settings completely
68 $.tablesorter.fileTypes = {
69 // divides filetype extensions in the equivalent list below
70 separator : '|',
71 equivalents : {
72 "3D Image" : "3dm|3ds|dwg|max|obj",
73 "Audio" : "aif|aac|ape|flac|la|m4a|mid|midi|mp2|mp3|ogg|ra|raw|rm|wav|wma",
74 "Compressed" : "7z|bin|cab|cbr|gz|gzip|iso|lha|lz|rar|tar|tgz|zip|zipx|zoo",
75 "Database" : "csv|dat|db|dbf|json|ldb|mdb|myd|pdb|sql|tsv|wdb|wmdb|xlr|xls|xlsx|xml",
76 "Development" : "asm|c|class|cls|cpp|cc|cs|cxx|cbp|cs|dba|fla|h|java|lua|pl|py|pyc|pyo|sh|sln|r|rb|vb",
77 "Document" : "doc|docx|odt|ott|pages|pdf|rtf|tex|wpd|wps|wrd|wri",
78 "Executable" : "apk|app|com|exe|gadget|lnk|msi",
79 "Fonts" : "eot|fnt|fon|otf|ttf|woff",
80 "Icons" : "ani|cur|icns|ico",
81 "Images" : "bmp|gif|jpg|jpeg|jpe|jp2|pic|png|psd|tga|tif|tiff|wmf|webp",
82 "Presentation" : "pps|ppt",
83 "Published" : "chp|epub|lit|pub|ppp|fm|mobi",
84 "Script" : "as|bat|cgi|cmd|jar|js|lua|scpt|scptd|sh|vbs|vb|wsf",
85 "Styles" : "css|less|sass",
86 "Text" : "info|log|md|markdown|nfo|tex|text|txt",
87 "Vectors" : "awg|ai|eps|cdr|ps|svg",
88 "Video" : "asf|avi|flv|m4v|mkv|mov|mp4|mpe|mpeg|mpg|ogg|rm|rv|swf|vob|wmv",
89 "Web" : "asp|aspx|cer|cfm|htm|html|php|url|xhtml"
90 }
91 };
92
93 // To add a custom equivalent, define:
94 // $.tablesorter.fileTypes.equivalents['xx'] = "A|B|C";
95
96 // This demo uses the group widget to organize the file type equivalents
97 $("table").tablesorter({
98 theme: 'blue',
99 widgets : [ 'group', 'zebra', 'columns' ],
100 widgetOptions: {
101 group_separator : /[-.]/
102 }
103 });
104
105 });</script>
106 </head>
107 <body>
108 <div id="banner">
109 <h1>table<em>sorter</em></h1>
110 <h2>File Type Parser</h2>
111 <h3>Flexible client-side table sorting</h3>
112 <a href="index.html">Back to documentation</a>
113 </div>
114 <div id="main">
115
116 <ul>
117 <li>In <span class="version">v2.24.4</span>, added a "file-extension" parser.</li>
118 <li>If this parser finds the file type extension within the equivalents list, it will add the equivalents group name to the beginning of the file so that during sorting, those file names will sort by the group they are in.</li>
119 <li>Please look in the javascript code section below for a full list of default equivalents. This list is by no means extensive, but it can be easily modified or extended as needed.</li>
120 <li>To add a new group to the equivalents list, just define a new group, <em>before initializing tablesorter</em>, as follows:
121 <pre class="prettyprint lang-javascript">$.tablesorter.fileTypes.equivalents['xx'] = "A|B|C"</pre>
122 </li>
123 <li>But lets say your table is primarily being used to sort font file names, but you notice "svg" is listed under "vectors" (graphics) so you want to modify the equivalents list. Do it as follows:
124 <pre class="prettyprint lang-javascript">$.tablesorter.fileTypes.equivalents["Vectors"] = "awg|ai|eps|cdr"; // redefine vectors without "svg"
125 $.tablesorter.fileTypes.equivalents["Fonts"] += '|svg'; // just add it to the end (but first include the vertical bar = shift+\; above the enter key)!</pre>
126 </li>
127 <li>This parser only looks to see if an extension exists within the equivalents list, so any separator can be used (spaces, commas or vertical bars).</li>
128 </ul>
129
130 <h1>Demo</h1>
131 <div id="demo">
132
133 <button type="button">Switch</button> (switch media column between "group-separator-1" &amp; "group-separator-2")
134
135 <table class="tablesorter">
136 <thead>
137 <tr>
138 <th class="sorter-filetype group-separator">Desktop Files</th>
139 <th class="sorter-filetype group-separator-1">Tablesorter Files</th>
140 <th class="sorter-file-extension group-separator-1">Extensions</th>
141 <th id="media" class="group-separator-2">Media</th>
142 <th class="sorter-filetype group-separator-1">Media Files</th>
143 </tr>
144 </thead>
145 <tbody>
146 <tr><td>github.url</td><td>package.json</td><td>readme.md</td><td>Music Disc #1 - Green Day - Boulevard of Broken Dreams</td><td>Muse - Supermassive Black Hole.mp3</td></tr>
147 <tr><td>tablesorter.zip</td><td>readme.md</td><td>license.md</td><td>Music Disc #1 - Green Day - Holiday</td><td>Gorillaz - Feel Good Inc.mp3</td></tr>
148 <tr><td>learn-git.pdf</td><td>index.html</td><td>contributions.md</td><td>Music Disc #1 - M83 - Midnight City</td><td>M83 - Midnight City.mp4</td></tr>
149 <tr><td>pancake-cat.jpg</td><td>jquery.tablesorter.js</td><td>logo.png</td><td>Music Disc #1 - Bob Marley - Everything is Gonna Be Alright</td><td>Radiohead - Creep.ogg</td></tr>
150 <tr><td>to-do-list.txt</td><td>theme.blue.css</td><td>emote.png</td><td>Music Disc #1 - Bob Marley - Jamming</td><td>Ellie Goulding - Lights.flv</td></tr>
151 <tr><td>css-tips.docx</td><td>theme.less</td><td>script.js</td><td>Music Disc #1 - Bob Marley - Oh, Baby I Love Your Way</td><td>Imagine Dragons - Radioactive.avi</td></tr>
152 <tr><td>frisbee-cat.png</td><td>black-asc.gif</td><td>symbols.png</td><td>Music Disc #1 - Bob Marley - Red Red Wine</td><td>Muse - Supermassive Black Hole.avi</td></tr>
153 <tr><td>Diablo.lnk</td><td>green-unsorted.psd</td><td>jquery.js</td><td>Music Disc #1 - Bob Marley - No Woman No Cry</td><td>Alex Clare - Too Close.wma</td></tr>
154 <tr><td>Warcraft.lnk</td><td>jquery.tablesorter.widgets.js</td><td>jquery-ui.css</td><td>Music Disc #2 - Sublime - Santeria</td><td>The XX - Intro.mp3</td></tr>
155 <tr><td>google.url</td><td>glyphicons-halflings.png</td><td>tooltip.js</td><td>Music Disc #2 - Sublime - What I Got</td><td>AWOLNATION - Sail.wmv</td></tr>
156 <tr><td>swimming-cat.gif</td><td>component.json</td><td>style.css</td><td>Music Disc #2 - Massive Attack - Teardrop</td><td>Of Monsters and Men - Little Talks.m4a</td></tr>
157 <tr><td>photo-album.zip</td><td>themes.html</td><td>jquery-ui.js</td><td>Music Disc #2 - Massive Attack - Dissolved Girl</td><td>Nina Simone - Feeling Good.flac</td></tr>
158 </tbody>
159 </table>
160 </div>
161
162 <h1>Javascript</h1>
163 <div id="javascript">
164 <pre class="prettyprint lang-javascript"></pre>
165 </div>
166 <h1>HTML</h1>
167 <div id="html">
168 <pre class="prettyprint lang-html"></pre>
169 </div>
170
171 <script>
172 /* DEMO ONLY CODE */
173 $(function() {
174 $('button').click(function() {
175 $('#media').toggleClass('group-separator-1 group-separator-2');
176 $('table').trigger('sorton', [ [[3,0]] ]);
177 });
178 });
179 </script>
180
181 <div class="next-up">
182 <hr />
183 Next up: <a href="example-option-sort-force.html">Force a default sorting order &rsaquo;&rsaquo;</a>
184 </div>
185
186 </div>
187
188 </body>
189 </html>