0
|
1 function tsvToTable(data){
|
|
2 var lines = data.split("\n");
|
|
3 var tbl = document.createElement('table');
|
|
4 tbl.className = "result_table";
|
|
5 tbl.border="1"
|
|
6 var thead = document.createElement('thead');
|
|
7 var tr = document.createElement('tr');
|
|
8 tr.className = "evenrowcolor";
|
|
9 var cells = lines[0].split("\t");
|
|
10 for(var a = 0;a < cells.length;++a){
|
|
11 var td = document.createElement('td');
|
|
12 td.appendChild(document.createTextNode(cells[a]));
|
|
13 tr.appendChild(td);
|
|
14 }
|
|
15 thead.appendChild(tr);
|
|
16 tbl.appendChild(thead);
|
|
17 var tbdy = document.createElement('tbody');
|
|
18
|
|
19
|
|
20 for(var a = 1;a < lines.length;++a){
|
|
21 tr = document.createElement('tr');
|
|
22 var cells = lines[a].split("\t");
|
|
23 if(cells.length == 1){
|
|
24 continue;
|
|
25 }
|
|
26 for(var b = 0;b < cells.length;++b){
|
|
27 td = document.createElement('td');
|
|
28 td.appendChild(document.createTextNode(cells[b]));
|
|
29 tr.appendChild(td)
|
|
30 }
|
|
31 if(a % 2 == 0){
|
|
32 tr.className = "evenrowcolor";
|
|
33 } else {
|
|
34 tr.className = "oddrowcolor";
|
|
35 }
|
|
36 tbdy.appendChild(tr);
|
|
37 }
|
|
38 tbl.appendChild(tbdy);
|
|
39 return tbl;
|
|
40 }
|
|
41
|
|
42 function loadfile(file, patient, type){
|
|
43 $('#hidden_div').load(file, function(){
|
|
44 $('#result_div_' + patient + '_' + type).html(tsvToTable($('#hidden_div').html()));
|
|
45 $('#result_div_' + patient + '_' + type + ' tr').hover(function() {
|
|
46 $(this).addClass('hover');
|
|
47 }, function() {
|
|
48 $(this).removeClass('hover');
|
|
49 });
|
|
50 $('#result_div_' + patient + '_' + type + ' table').addClass('result_table');
|
|
51 //$('#result_div_' + patient + ' tr:odd').addClass("oddrowcolor");
|
|
52 //$('#result_div_' + patient + ' tr:even').addClass("evenrowcolor");
|
|
53 $('#result_div_' + patient + '_' + type + ' table').before( "<a href='" + file + "'>Download " + file.replace(".txt", "") + "</a>" );
|
|
54 });
|
|
55 }
|
|
56
|
|
57 var currentTD = new Array();
|
|
58
|
|
59 $( document ).ready(function() {
|
|
60 $('.summary_table tr').hover(function() {
|
|
61 $(this).addClass('hover');
|
|
62 }, function() {
|
|
63 $(this).removeClass('hover');
|
|
64 });
|
|
65
|
|
66 $('.summary_table tr:odd').addClass("oddrowcolor");
|
|
67 $('.summary_table tr:even').addClass("evenrowcolor");
|
|
68
|
|
69 $('.summary_table td[data-patient]').click(function() {
|
|
70 var tmp = $(this);
|
|
71 if(currentTD[tmp.attr("data-patient")] != null){
|
|
72 currentTD[tmp.attr("data-patient")].removeClass("clicked_summary");
|
|
73 }
|
|
74 currentTD[tmp.attr("data-patient")] = tmp;
|
|
75 currentTD[tmp.attr("data-patient")].addClass("clicked_summary");
|
|
76 });
|
|
77 }); |