-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathidioms.js
More file actions
37 lines (34 loc) · 1.13 KB
/
idioms.js
File metadata and controls
37 lines (34 loc) · 1.13 KB
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
function filter_idiom_table(by_tag) {
if (by_tag === "None") {
$("#idiom-table > tbody > tr").show();
} else {
$("#idiom-table > tbody > tr:has('span[data-tag=\"" + by_tag + "\"]')").show();
$("#idiom-table > tbody > tr:not(:has('span[data-tag=\"" + by_tag + "\"]'))").hide();
}
}
$(document).ready(function() {
$("button[data-toggle='popover']").popover()
$("#tag-filterer > li > a.tag-filter").click(function() {
var label = this.textContent.trim();
filter_idiom_table(label);
})
var idiom_table = $("#idiom-table");
var rows = $(idiom_table).find('tbody > tr').get();
rows.sort(function(a, b) {
var keyA = $(a).find("td > h4 > a").text();
var keyB = $(b).find("td > h4 > a").text();
if (keyA > keyB) {
return 1;
} else if (keyA < keyB) {
return -1;
} else {
return 0;
}
});
$.each(rows, function(index, row) {
$(idiom_table).children('tbody').append(row);
});
if (window.location.hash) {
filter_idiom_table(window.location.hash.substring(1));
}
});