-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
88 lines (78 loc) · 2.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!doctype html>
<html>
<head>
<title>Trillion</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script src="http://cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/react/0.14.3/react-dom.js"></script>
</head>
<body style="margin: 40px">
<div class="container">
<div class="row"><div class="col-xs-12">
<main>Loading…</main>
</div></div>
</div>
<script src="dist/trillion.js"></script>
<script src="dist/trillion-react.js"></script>
<script>
function randomDate() {
var year = 31557600000;
return new Date(Math.floor((Math.random() * 31557600000) + Math.floor(Math.random() * 45 * year)));
}
function testTable () {
var carMakes = ['Mercedes-Benz', 'BMW', 'Ford', 'Chevrolet', 'Toyota', 'Nissan', 'Lamborghini', 'Ferrari'];
var data = [];
for (var i = 0; i < 250000; i++ ) {
var price = 50000 + ((Math.random() * 60000) - 30000);
var date = randomDate();
var brand = carMakes[Math.floor(carMakes.length * Math.random())];
data.push({
'name': brand + ' ' + (100 + Math.floor(Math.random() * 800)),
'price': Number(price).toFixed(2),
'release': date,
'brand': brand
});
}
var headers = [
{
'label': 'Name',
'field': 'name',
'type': 'text'
},
{
'label': 'Price',
'field': 'price',
'type': 'number'
},
{
'label': 'Release date',
'field': 'release',
'type': 'date'
},
{
'label': 'Brand',
'visible': false,
'field': 'brand',
'type': 'text'
}
];
return {
'data': data,
'indices': headers
};
}
var test = testTable();
var trillion = Trillion(test.data, test.indices, {
'lazy': true,
'pageSize': 25
});
trillion.addFilter(trillion.createFilter('match', 'name', 'BMW'));
//trillion.addFilter(trillion.createFilter('fuzzy', 'name', 'mecr benz'))
ReactDOM.render(
React.createElement(TrillionReact, {
'Trillion': trillion
}),
document.querySelector('main'));
</script>
</body>
</html>