-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
67 lines (61 loc) · 1.89 KB
/
main.js
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
function reenable() {
$('#reset').prop('disabled', false);
$('#submit').prop('disabled', false);
$('#submit_spinner').hide();
}
$(document).ready(function () {
$('#submit_spinner').hide();
$('#example1').on('click', function () {
$('#reset').trigger('click');
$('#chromosome').val('chr16');
$('#start_min').val(31180139);
$('#end_max').val(31191605);
$('#strand').val('+');
});
$('#example2').on('click', function () {
$('#example1').trigger('click');
$('#protein_name').val('FUS');
});
$('#reset').on('click', function () {
$('#results').DataTable().clear().draw();
});
let table = $('#results').DataTable({
dom: 'frtipB',
searching: false,
AutoWidth: false,
scrollX: true,
scrollY: true,
columnDefs: [
{
targets: [1, 2],
className: 'dt-body-right'
},
{
targets: [3],
className: 'dt-body-right',
render: function (data, type, row) {
if (typeof data === 'number') {
return (type === 'display' || type === 'filter') ? data.toFixed(2) : data;
}
return data;
}
}
],
buttons: [{
extend: 'csvHtml5',
text: 'Download results (CSV)',
}
],
headerCallback: function (thead, data, start, end, display) {
$(thead).find('th').css('white-space', 'nowrap');
}
});
$('#search').submit(function (e) {
e.preventDefault();
let form = $(this);
table.ajax.url('/get_results?' + form.serialize()).load(reenable);
$('#reset').prop('disabled', true);
$('#submit').prop('disabled', true);
$('#submit_spinner').show();
});
});