blob: 7e8bef371874e2e63a4a8bd66d9f6e48baedafe4 (
plain)
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
|
$(document).ready (function () {
function sortproto (by) {
var protolist = $('#protocols');
var items = protolist.children ('.protocol');
items.detach ().sort (function (nodeA, nodeB) {
var a = $(nodeA).data (by);
var b = $(nodeB).data (by);
if (typeof a == 'number' || typeof b == 'number') {
return a > b ? 1 : (a < b ? -1 : 0);
} else {
return a.localeCompare (b);
}
});
protolist.append (items);
}
function filterproto (search) {
search = search.toLowerCase ()
var items = $('#protocols .protocol');
for (var i = 0; i < items.length; i++) {
var e = $(items[i]);
var val = e.data ('name') + ' ' + e.data ('longname') + ' ' + e.data ('author');
if (val.toLowerCase ().indexOf (search) >= 0) {
e.show ();
} else {
e.hide ();
}
}
}
$('#sort').change (function () {
sortproto ($(this).val ());
});
$('#filter').keyup (function () {
filterproto ($(this).val ());
});
$('#protosort').show ();
sortproto ($('#sort').val ());
filterproto ($('#filter').val ());
});
|