-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
116 lines (93 loc) · 3.57 KB
/
index.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!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">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link type="text/css" rel="stylesheet" href="css/handsontable.full.min.css">
<link href="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css" rel="stylesheet">
<script type="text/javascript" src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<title>Interactive Grid</title>
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="icon" href="images/favicon.png">
</head>
<style>
body,td,th,table{font-family: 'Lato', sans-serif;font-size:12px;}
th {text-align:center;font-size:0.8em;font-weight:800;padding:3px;color:#444;}
td { text-align:center;font-size:10px;padding:2px;}
</style>
<body>
<table id="jtable" border="1">
</table>
</body>
<script>
var json;
function createHeaderRow(headerName,addToElement,cols) {
var para = document.createElement("tr");
var rtd = document.createElement("td");
rtd.setAttribute('colspan',cols);
rtd.setAttribute("style", "background-color: #efefef;text-align:left;font-size:12px;font-weight:bold");
rtd.appendChild(document.createTextNode(headerName));
para.appendChild(rtd);
addToElement.appendChild(para);
}
function createCell(str,row,split,elType) {
if (str == null) {
str = '';
}
var para = document.createElement(elType);
if (split) {
var items = str.split('|');
for (j=0;j<items.length;j++) {
para.appendChild(document.createTextNode(items[j]));
para.appendChild(document.createElement("br"));
}
}
else
{
para.appendChild(document.createTextNode(str));
}
row.appendChild(para);
}
var element = document.getElementById("jtable");
$.getJSON( "example.json", function( json ) {
var th = document.createElement("thead");
element.appendChild(th);
var tr = document.createElement("tr");
tr.setAttribute('id','header1');
createCell("",tr,true,"th");
for (i = 0 ; i < json.table[0].reqs.length;i++){
createCell(json.table[0].reqs[i].req +'|' +json.table[0].reqs[i].cd +' '+json.table[0].reqs[i].ct +"|" +json.table[0].reqs[i].stat,tr,true,"th");
console.log(json.table[0].reqs[i]);
}
th.appendChild(tr);
var tbody = document.createElement("tbody");
//for (h = 0 ; h < json.table.length;h++){
for (h = 0 ; h < 1;h++){
for (i = 0 ; i < json.table[h].group.length;i++){
createHeaderRow(json.table[h].group[i].name,tbody,json.table[h].reqs.length+1);
console.log(json.table[h].group[i].test);
console.log('#TESTS ' +json.table[h].group[i].test.length);
for (j = 0 ; j < json.table[h].group[i].test.length;j++) {
var trG = document.createElement("tr");
trG.setAttribute('id','group'+i);
testTD = document.createElement("td");
test_name = document.createTextNode(json.table[h].group[i].test[j].name);
testTD.appendChild(test_name);
trG.appendChild(testTD);
for (k = 0; k < json.table[h].group[i].test[j].reqs.length;k++){
//createCell(json.table[h].group[i].test[j].reqs[k].val,trG,false,"td");
ti = document.createElement("td")
ti.innerHTML = json.table[h].group[i].test[j].reqs[k].val;
tbody.appendChild(ti);
console.log('TEST - '+k +' - ' +json.table[h].group[i].test[j].name);
} // end of k loop
} // end of j loop
tbody.appendChild(trG);
} // end of i loop
}
element.appendChild(tbody);
});
</script>
</html>