| Current Path : /home/jeromecohp/www/aesecure/third/tablesorter/js/parsers/ |
| Current File : /home/jeromecohp/www/aesecure/third/tablesorter/js/parsers/parser-named-numbers.js |
// @file : /third/tablesorter/js/parsers/parser-named-numbers.js
// @version : 2.0.2
// @author : AVONTURE Christophe - christophe@aesecure.com
// @copyright : (C) 2013-2015 - Christophe Avonture - all right reserved.
// @url : http://www.aesecure.com/
// @package : 2015-02-14 13:37:55
// @license : This program is a commercial software. You CAN'T redistribute it and/or modify it.
// Source code is the property of Christophe Avonture and can't be reused, in whole or in part, in any programs.
;(function($){
"use strict";var named={
negative: [ 'negative','minus' ],
numbers:{
'zero':0,'one':1,'two':2,'three':3,'four':4,'five':5,'six':6,'seven':7,'eight':8,'nine':9,'ten':10,'eleven':11,'twelve':12,'thirteen':13,'fourteen':14,'fifteen':15,'sixteen':16,'seventeen':17,'eighteen':18,'nineteen':19,'twenty':20,'thirty':30,'forty':40,'fourty':40,'fifty':50,'sixty':60,'seventy':70,'eighty':80,'ninety':90
},
hundred:'hundred',
powers:{
'thousand':1e3,'million':1e6,'billion':1e9,'trillion':1e12,'quadrillion':1e15,'quintillion':1e18,'sextillion':1e21,'septillion':1e24,'octillion':1e27,'nonillion':1e30,'decillion':1e33,'undecillion':1e36,'duodecillion':1e39,'tredecillion':1e42,'quattuordecillion':1e45,'quindecillion':1e48,'sexdecillion':1e51,'septendecillion':1e54,'octodecillion':1e57,'novemdecillion':1e60,'vigintillion':1e63,'unvigintillion':1e66,'duovigintillion':1e69,'trevigintillion':1e72,'quattuorvigintillion':1e75,'quinvigintillion':1e78,'sexvigintillion':1e81,'septenvigintillion':1e84,'octovigintillion':1e87,'novemvigintillion':1e90,'trigintillion':1e93,'untrigintillion':1e96,'duotrigintillion':1e99,'googl':1e100
}},
result, group,
negativeRegex=new RegExp('(' + named.negative.join('|') + ')'),
calc=function ( word, table ){
var num=named.numbers.hasOwnProperty( word )?named.numbers[ word ]:null,
power=named.powers.hasOwnProperty( word )?named.powers[ word ]:null;
if( !num && !isNaN( word ) ){
num=$.tablesorter.formatFloat( word || '', table );}
if( num !==null ){
group +=num;} else if( word===named.hundred ){
group *=100;} else if( power !==null ){
result +=group * power;
group=0;}};
$.tablesorter.addParser({
id: "namedNumbers",
is: function (){
return false;},
format: function ( str, table ){
result=0;
group=0;var indx,
arry=( str || '' ).split( /[\s-]+/ ),
len=arry.length;
for ( indx=0; indx < len; indx++ ){
calc( arry[ indx ].toLowerCase(), table );}
result=( result + group ) * ( str.match( negativeRegex )?-1:1 );
return result || named.numbers.hasOwnProperty( str )?result:$.tablesorter.formatFloat( str || '', table );},
type: "numeric"
});})( jQuery );