/
page.html
93 lines (77 loc) · 3.73 KB
/
page.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
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<!-- DataTables -->
<link href="https://cdn.datatables.net/1.10.7/css/jquery.dataTables.min.css" rel="stylesheet">
</head>
<body>
{% include navbar.html %}
<div class="container">
{{ content }}
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
function renderDownload(data, type, full) {
if (type != 'display') {return data};
// return '<a href="' + data + '" target="_blank">link</a>';
return '<a href="' + data + '" class="btn btn-sm btn-default" download>Download</a>';
}
function renderTaxId(data, type, full) {
if (type != 'display') {return data};
return '<a href="//www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id=' + data + '" target="_blank">' + data + '</a>';
}
function renderItalic(data, type, full) {
if (type != 'display') {return data};
return '<i>' + data + '</i>';
}
function numberWithCommas(data, type, full) {
if (type != 'display') {return data};
return data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
var aoColumns = [
{'aTargets': ['TaxId'], 'mRender': renderTaxId, 'sType': 'numeric'},
{'aTargets': ['Scientific Name'], 'mRender': renderItalic},
{'aTargets': ['Terms'], 'mRender': numberWithCommas, 'sType': 'numeric'},
{'aTargets': ['Annotations'], 'mRender': numberWithCommas, 'sType': 'numeric'},
{'aTargets': ['Download'], 'mRender': renderDownload}];
function renderTable() {
var evidence = $('input[name=evidence]').filter(':checked').val();
var annotation_type = $('input[name=annotation_type]').filter(':checked').val();
//var coding = $('input[name=coding]').filter(':checked').val();
console.log([annotation_type, evidence]);
var table_id = evidence + '-' + annotation_type;
var path = 'summaries/summary-' + table_id +'.json'
var table_html = '<table cellpadding="0" cellspacing="0" border="0" class="display" width="100%" id="table_' + table_id + '"><thead><th>TaxId</th><th>Scientific Name</th><th>Terms</th><th>Annotations</th><th>Download</th></thead><tbody></tbody></table>';
$('#dynamic-table').fadeOut(1).html(table_html).fadeIn(900);
$('#table_' + table_id).dataTable({
'ajax': path, 'bProcessing': true, 'aoColumns': aoColumns, 'order': [[ 3, 'desc' ]]
})
}
renderTable()
$('body').on('mousedown', '#evidence_button .btn', function(event) {
event.stopPropagation(); // prevent default bootstrap behavior
if ($(this).attr('data-toggle') != 'button') { // don't toggle if data-toggle="button"
$(this).button('toggle')
}
renderTable()
});
$('body').on('mousedown', '#annotation_type_button .btn', function(event) {
event.stopPropagation(); // prevent default bootstrap behavior
if ($(this).attr('data-toggle') != 'button') { // don't toggle if data-toggle="button"
$(this).button('toggle')
}
renderTable()
});
</script>
{% include piwik.html %}
</body>
</html>