Skip to content

Instantly share code, notes, and snippets.

@dshaw
Created March 3, 2010 17:49
Show Gist options
  • Save dshaw/320807 to your computer and use it in GitHub Desktop.
Save dshaw/320807 to your computer and use it in GitHub Desktop.
/*
* TableSorter 2.0 Parsers
* Version 1.0.0
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
/**
* @description html parser - Sorts the *content* of a cell which contains
* additional html of no semantic value to the sort.
*
* @author Daniel D. Shaw (js@dshaw.com)
*/
// add parser to handle sorting of text enclosed in html
$.tablesorter.addParser({
id: "html",
is: function(s) {
// return false so this parser is not auto detected
// TODO: might actually want to auto detect this.
return false;
},
format: function(s) {
return $.trim(s.toLowerCase().replace(/<.*?>/g, ''));
},
type: "text"
});
// add parser to handle sorting of text enclosed in html
$.tablesorter.addParser({
id: "htmlDigit",
is: function(s) {
// return false so this parser is not auto detected
// TODO: might actually want to auto detect this.
return false;
},
format: function(s) {
return $.trim(s.toLowerCase().replace(/<.*?>/g, ''));
},
type: "numeric"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment