| 1 |
/* |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
;(function($) { |
| 7 |
'use strict'; |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
$.tablesorter.fileTypes = { |
| 13 |
|
| 14 |
separator : '|', |
| 15 |
equivalents : { |
| 16 |
'3D Image' : '3dm|3ds|dwg|max|obj', |
| 17 |
'Audio' : 'aif|aac|ape|flac|la|m4a|mid|midi|mp2|mp3|ogg|ra|raw|rm|wav|wma', |
| 18 |
'Compressed' : '7z|bin|cab|cbr|gz|gzip|iso|lha|lz|rar|tar|tgz|zip|zipx|zoo', |
| 19 |
'Database' : 'csv|dat|db|dbf|json|ldb|mdb|myd|pdb|sql|tsv|wdb|wmdb|xlr|xls|xlsx|xml', |
| 20 |
'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', |
| 21 |
'Document' : 'doc|docx|odt|ott|pages|pdf|rtf|tex|wpd|wps|wrd|wri', |
| 22 |
'Executable' : 'apk|app|com|exe|gadget|lnk|msi', |
| 23 |
'Fonts' : 'eot|fnt|fon|otf|ttf|woff', |
| 24 |
'Icons' : 'ani|cur|icns|ico', |
| 25 |
'Images' : 'bmp|gif|jpg|jpeg|jpe|jp2|pic|png|psd|tga|tif|tiff|wmf|webp', |
| 26 |
'Presentation' : 'pps|ppt', |
| 27 |
'Published' : 'chp|epub|lit|pub|ppp|fm|mobi', |
| 28 |
'Script' : 'as|bat|cgi|cmd|jar|js|lua|scpt|scptd|sh|vbs|vb|wsf', |
| 29 |
'Styles' : 'css|less|sass', |
| 30 |
'Text' : 'info|log|md|markdown|nfo|tex|text|txt', |
| 31 |
'Vectors' : 'awg|ai|eps|cdr|ps|svg', |
| 32 |
'Video' : 'asf|avi|flv|m4v|mkv|mov|mp4|mpe|mpeg|mpg|ogg|rm|rv|swf|vob|wmv', |
| 33 |
'Web' : 'asp|aspx|cer|cfm|htm|html|php|url|xhtml' |
| 34 |
} |
| 35 |
}; |
| 36 |
|
| 37 |
$.tablesorter.addParser({ |
| 38 |
id: 'filetype', |
| 39 |
is: function() { |
| 40 |
return false; |
| 41 |
}, |
| 42 |
format: function(s, table) { |
| 43 |
var t, |
| 44 |
c = table.config, |
| 45 |
wo = c.widgetOptions, |
| 46 |
groupSeparator = wo.group_separator || '-', |
| 47 |
i = s.lastIndexOf('.'), |
| 48 |
sep = $.tablesorter.fileTypes.separator, |
| 49 |
m = $.tablesorter.fileTypes.matching, |
| 50 |
types = $.tablesorter.fileTypes.equivalents; |
| 51 |
if (!m) { |
| 52 |
|
| 53 |
t = []; |
| 54 |
$.each(types, function(i, v) { |
| 55 |
t.push(v); |
| 56 |
}); |
| 57 |
m = $.tablesorter.fileTypes.matching = sep + t.join(sep) + sep; |
| 58 |
} |
| 59 |
if (i >= 0) { |
| 60 |
t = sep + s.substring(i + 1, s.length) + sep; |
| 61 |
if (m.indexOf(t) >= 0) { |
| 62 |
for (i in types) { |
| 63 |
if ((sep + types[i] + sep).indexOf(t) >= 0) { |
| 64 |
|
| 65 |
return i + ( groupSeparator.toString().charAt(0) !== '/' ? wo.group_separator : '-' ) + s; |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
return s; |
| 71 |
}, |
| 72 |
type: 'text' |
| 73 |
}); |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
$.tablesorter.addParser({ |
| 78 |
id: 'file-extension', |
| 79 |
is: function() { |
| 80 |
return false; |
| 81 |
}, |
| 82 |
format: function( str ) { |
| 83 |
var ext, |
| 84 |
parts = str.split( '.' ); |
| 85 |
if ( parts.length ) { |
| 86 |
ext = parts.pop(); |
| 87 |
parts.unshift( ext ); |
| 88 |
return parts.join( '.' ); |
| 89 |
} |
| 90 |
return str; |
| 91 |
}, |
| 92 |
type: 'text' |
| 93 |
}); |
| 94 |
|
| 95 |
})(jQuery); |