1
|
|
|
/** global: appSettings */ |
2
|
|
|
var whois = require('../../common/whoiswrapper.js'), |
3
|
|
|
conversions = require('../../common/conversions.js'), |
4
|
|
|
fs = require('fs'), |
5
|
|
|
Papa = require('papaparse'), |
6
|
|
|
dt = require('datatables')(), |
7
|
|
|
bwaFileContents; |
8
|
|
|
|
9
|
|
|
const { |
10
|
|
|
ipcRenderer |
11
|
|
|
} = require('electron'); |
12
|
|
|
|
13
|
|
|
ipcRenderer.on('bwa:analyser.tablegen', function(event, contents) { |
14
|
|
|
bwaFileContents = contents; |
15
|
|
|
showTable(); |
16
|
|
|
}); |
17
|
|
|
|
18
|
|
|
$('#bwaAnalyserButtonClose').click(function() { |
19
|
|
|
$('#bwaAnalyserModalClose').addClass('is-active'); |
20
|
|
|
}); |
21
|
|
|
|
22
|
|
|
$('#bwaAnalyserModalCloseButtonYes').click(function() { |
23
|
|
|
$('#bwaAnalyser').addClass('is-hidden'); |
24
|
|
|
$('#bwaAnalyserModalClose').removeClass('is-active'); |
25
|
|
|
$('#bwaEntry').removeClass('is-hidden'); |
26
|
|
|
}); |
27
|
|
|
|
28
|
|
|
$('#bwaAnalyserModalCloseButtonNo').click(function() { |
29
|
|
|
$('#bwaAnalyserModalClose').removeClass('is-active'); |
30
|
|
|
}); |
31
|
|
|
|
32
|
|
|
function showTable() { |
33
|
|
|
var header = {}, |
34
|
|
|
body = {}; |
35
|
|
|
header.columns = Object.keys(bwaFileContents.data[0]); |
36
|
|
|
console.log(header.columns); |
|
|
|
|
37
|
|
|
body.records = bwaFileContents.data; |
38
|
|
|
|
39
|
|
|
// Generate header column content |
40
|
|
|
header.content = '<tr>\n'; |
41
|
|
|
for (column in header.columns) { |
|
|
|
|
42
|
|
|
header.content += '\t<th><abbr title="{0}">{1}</abbr></th>\n'.format(header.columns[column], getInitials(header.columns[column])); |
43
|
|
|
} |
44
|
|
|
header.content += '</tr>'; |
45
|
|
|
|
46
|
|
|
$('#bwaAnalyserTableThead').html(header.content); |
47
|
|
|
//console.log(header.content); |
48
|
|
|
|
49
|
|
|
// Generate record fields |
50
|
|
|
body.content = ''; |
51
|
|
|
for (record in body.records) { |
|
|
|
|
52
|
|
|
body.content += '<tr>\n'; |
53
|
|
|
//console.log(body.content); |
54
|
|
|
//console.log(body.records[record]); |
55
|
|
|
|
56
|
|
|
for (field in body.records[record]) { |
|
|
|
|
57
|
|
|
body.content += '\t<td>{0}</td>\n'.format(body.records[record][field]); |
58
|
|
|
} |
59
|
|
|
body.content += '</tr>\n'; |
60
|
|
|
} |
61
|
|
|
//console.log(body.content); |
62
|
|
|
$('#bwaAnalyserTableTbody').html(body.content); |
63
|
|
|
basetable = $('#bwaAnalyserTable').dataTable(); |
|
|
|
|
64
|
|
|
//$('#bwaAnalyserTable_paginate > a').addClass('button is-small') |
65
|
|
|
|
66
|
|
|
$('#bwaFileinputconfirm').addClass('is-hidden'); |
67
|
|
|
$('#bwaAnalyser').removeClass('is-hidden'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
function getInitials(string, threshold = 1) { |
71
|
|
|
initials = string.match(/\b\w/g); |
|
|
|
|
72
|
|
|
|
73
|
|
|
(initials.length > threshold) ? |
74
|
|
|
initials = initials.join("").toString() : |
75
|
|
|
initials = string.substring(0, threshold + 1); |
76
|
|
|
|
77
|
|
|
return initials; |
78
|
|
|
} |
79
|
|
|
|