summaryrefslogtreecommitdiff
path: root/data/script.js
blob: 997a02eee2ed79ad6d1bcc00bbe1b056654f9191 (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
$(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 (a > b) {
				return 1;
			} else if (a < b) {
				return -1;
			} else {
				return 0;
			}
		});
		protolist.append (items);
	}
	$('#sort').change (function () {
		sortproto ($(this).val ());
	});
	$('#filter').keyup (function () {
		var search = $(this).val ().toLowerCase ();
		var items = $('#protocols .protocol');
		for (var i = 0; i < items.length; i++) {
			var e = $(items[i]);
			if (e.data ('name').toLowerCase ().indexOf (search) >= 0) {
				e.show ();
			} else {
				e.hide ();
			}
		}
	});
	$('#protosort').show ();
	sortproto ('name');
});