annotate DataTables-1.9.4/media/src/ext/ext.types.js @ 3:4a6ebda2a3ae draft

fixed tool dependency issue
author saskia-hiltemann
date Tue, 30 Sep 2014 09:56:12 -0400
parents ac5f9272033b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3 $.extend( DataTable.ext.aTypes, [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5 * Function: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 * Purpose: Check to see if a string is numeric
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 * Returns: string:'numeric' or null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 * Inputs: mixed:sText - string to check
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 function ( sData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 /* Allow zero length strings as a number */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 if ( typeof sData === 'number' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 return 'numeric';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17 else if ( typeof sData !== 'string' )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 var sValidFirstChars = "0123456789-";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 var sValidChars = "0123456789.";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24 var Char;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 var bDecimal = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 /* Check for a valid first char (no period and allow negatives) */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 Char = sData.charAt(0);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 if (sValidFirstChars.indexOf(Char) == -1)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 /* Check all the other characters are valid */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 for ( var i=1 ; i<sData.length ; i++ )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37 Char = sData.charAt(i);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 if (sValidChars.indexOf(Char) == -1)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43 /* Only allowed one decimal place... */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 if ( Char == "." )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 if ( bDecimal )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50 bDecimal = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 return 'numeric';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
57 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 * Function: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 * Purpose: Check to see if a string is actually a formatted date
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 * Returns: string:'date' or null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61 * Inputs: string:sText - string to check
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 function ( sData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
65 var iParse = Date.parse(sData);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
66 if ( (iParse !== null && !isNaN(iParse)) || (typeof sData === 'string' && sData.length === 0) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68 return 'date';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
69 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
70 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
71 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74 * Function: -
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75 * Purpose: Check to see if a string should be treated as an HTML string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76 * Returns: string:'html' or null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77 * Inputs: string:sText - string to check
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79 function ( sData )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81 if ( typeof sData === 'string' && sData.indexOf('<') != -1 && sData.indexOf('>') != -1 )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83 return 'html';
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
87 ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
88