Skip to content

Commit 80f2254

Browse files
committed
Added type detection test, again based on globalization plugin.
1 parent df6ab87 commit 80f2254

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

grid-type/detection.html

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Grid: Type</title>
5+
<meta charset=utf-8 />
6+
<link rel="stylesheet" href="../themes/base/jquery.ui.all.css" title="ui-theme" />
7+
<script src="../jquery-1.4.4.js"></script>
8+
<script src="../external/jquery.global.js"></script>
9+
<script src="../external/jquery.global.de-DE.js"></script>
10+
<script src="../external/jquery.global.ja-JP.js"></script>
11+
<script type="text/javascript">
12+
$(function() {
13+
var table = $( "table" );
14+
thead = table.children( "thead" ),
15+
tbody = table.children( "tbody" );
16+
17+
thead.find( "th" ).each(function() {
18+
var index = this.cellIndex,
19+
type = "string";
20+
21+
tbody.children().each( function() {
22+
var cell = $( this.cells[index] ).text();
23+
if ($.global.parseDate(cell)) {
24+
type = "date";
25+
} else if ($.global.parseFloat(cell)) {
26+
// add check for currency symbol(s) to detecht currency
27+
type = "number"
28+
}
29+
});
30+
31+
$( this ).text( function( index, text ) {
32+
return text + " (" + type + ")";
33+
})
34+
});
35+
});
36+
</script>
37+
<style>
38+
body { font-size:62.5%; }
39+
table {
40+
border-collapse: collapse;
41+
}
42+
th, td {
43+
padding: 0.5em;
44+
border: 1px solid black;
45+
}
46+
</style>
47+
</head>
48+
<body>
49+
50+
<table>
51+
<thead>
52+
<tr>
53+
<th>Year</th>
54+
<th>US Revenue</th>
55+
<th>EU Revenue</th>
56+
<th>JP Revenue</th>
57+
<th>Peak Traffic</th>
58+
</tr>
59+
</thead>
60+
<tbody>
61+
<tr>
62+
<td>2005</td>
63+
<td>$0.00</td>
64+
<td>0,00 €</td>
65+
<td>¥0</td>
66+
<td>12/1/2005</td>
67+
</tr>
68+
<tr>
69+
<td>2006</td>
70+
<td>$0.50</td>
71+
<td>10.000,00 €</td>
72+
<td>¥1,500</td>
73+
<td>5/16/2006</td>
74+
</tr>
75+
<tr>
76+
<td>2007</td>
77+
<td>$10,000.00</td>
78+
<td>0,50 €</td>
79+
<td>-¥115</td>
80+
<td>6/3/2007</td>
81+
</tr>
82+
<tr>
83+
<td>2008</td>
84+
<td>$-10,000.00</td>
85+
<td>0,06 €</td>
86+
<td>¥10,000</td>
87+
<td>12/1/2008</td>
88+
</tr>
89+
<tr>
90+
<td>2009</td>
91+
<td>$-10.00</td>
92+
<td>-10,00 €</td>
93+
<td>-¥150</td>
94+
<td>12/30/2009</td>
95+
</tr>
96+
<tr>
97+
<td>2010</td>
98+
<td>$0.06</td>
99+
<td>-10.000,00 €</td>
100+
<td>¥15</td>
101+
<td>2/28/2010</td>
102+
</tr>
103+
</tbody>
104+
</table>
105+
106+
</body>
107+
</html>

0 commit comments

Comments
 (0)