forked from RubyLouvre/avalon
/
index26each.html
72 lines (70 loc) · 2.51 KB
/
index26each.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>ms-each</title>
<script src="avalon.js" type="text/javascript"></script>
<style>
.selected{
background: #01B4D2;
}
table{
width:99%;
border:1px solid #000;
border-collapse: collapse;
}
table td{
border:1px solid #000;
}
</style>
<script>
require("index26each,ready!", function(array) {
avalon.log(array.length)
avalon.define('bigdata', function(scope) {
scope.selected = "name"
scope.options = ["name", "resource_name", "service"]
scope.trend = 1
scope.data = array
scope.$watch("selected", function(v) {
var t = parseFloat(scope.trend)
var t1 = new Date
scope.data.sort(function(a, b) {
var ret = a[v] > b[v] ? 1 : -1
return t * ret
})
avalon.log(new Date - t1)
})
scope.$watch("trend", function(t) {
var v = scope.selected, t = parseFloat(t)
scope.data.sort(function(a, b) {
var ret = a[v] > b[v] ? 1 : -1
return t * ret
})
})
});
avalon.scan()
})
</script>
</head>
<body>
<fieldset ms-controller="bigdata">
<legend>大数据的测试例子</legend>
<p><select ms-each-el="options" ms-duplex="selected">
<option>{{el}}</option>
</select>
<select ms-duplex="trend">
<option value="1">up</option>
<option value="-1">down</option>
</select>
</p>
<table >
<tbody ms-each-el="data">
<tr ms-class-selected="el.selected">
<td> <input type="checkbox" ms-duplex-radio="el.selected" ></td> <td>{{el.name}}</td> <td>{{el.resource_name}}</td>
</tr>
</tbody>
</table>
</fieldset>
</body>
</html>