-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.js
More file actions
148 lines (137 loc) · 5.58 KB
/
Copy pathreport.js
File metadata and controls
148 lines (137 loc) · 5.58 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
* Called from the boilerplate html when a new main tab is selected.
*/
function onSelectMainTab(node, newMainIndex) {
highlightMainTab(node);
showMain(newMainIndex);
}
/*
* Called from the boilerplate html when a new child tab is selected.
*/
function onSelectChildTab(node, newChildIndex) {
highlightChildTab(node);
showChild(newChildIndex, rowIndex);
}
/*
* Called from the report specific code when a new master row is selected.
*/
function onSelectRowIndex(rowIndex) {
showChild(childIndex, rowIndex);
}
/**********************************************************************************************************************
Implementation code
***********************************************************************************************************************/
var mainIndex = 0;
var childIndex = 0;
var rowIndex = 0;
var selectedChildReport;
/*
* Modifies the UI by highlighting the selected main tab and unhighlighting the rest.
*/
function highlightMainTab(node) {
if (node.className != "currentmaintab") {
var tabNodes = document.getElementById("maintabs").children;
for (var t = 0;t < tabNodes.length;t++) {
var tabNode = tabNodes[t];
if (tabNode.className == "currentmaintab") {
tabNode.className = "maintab";
}
}
node.className = "currentmaintab";
}
}
/*
* Modifies the UI by highlighting the selected child tab and unhighlighting the rest.
*/
function highlightChildTab(node) {
if (node.className != "currentchildtab") {
var tabNodes = document.getElementById("ChildTabs." + mainIndex).children;
for (var t = 0;t < tabNodes.length;t++) {
var tabNode = tabNodes[t];
if (tabNode.className == "currentchildtab") {
tabNode.className = "childtab";
}
}
node.className = "currentchildtab";
}
}
/*
* Modifies the UI by showing the selected main report and hiding the rest.
*/
function showMain(newMainIndex) {
if (newMainIndex != mainIndex) {
var newMainId = "Master." + newMainIndex;
var mainElements = document.getElementById("masterreports").children;
for (var m = 0;m < mainElements.length;m++) {
var mainElement = mainElements[m];
if (mainElement.id == newMainId) {
mainElement.children[0].className = "currentmasterreport";
var childReportElement = document.getElementById("ChildReports." + newMainIndex);
if (childReportElement != null) {
var childElements = childReportElement.children;
for (var c = 0;c < childElements.length;c++) {
var childElement = childElements[c];
if (childElement.children[0].className == "currentchildreport") {
var childReportId = childElement.id;
var firstDot = childReportId.indexOf(".");
var secondDot = childReportId.indexOf(".", firstDot + 1);
var thirdDot = childReportId.indexOf(".", secondDot + 1);
selectedChildReport = childElement;
rowIndex = parseInt(childReportId.substring(secondDot + 1, thirdDot));
childIndex = parseInt(childReportId.substring(firstDot + 1, secondDot));
}
}
}
mainIndex = newMainIndex;
}
else {
var firstChildElement = mainElement.children[0];
if (firstChildElement.className == "currentmasterreport") {
firstChildElement.className = "masterreport";
}
}
}
}
}
/*
* Modifies the UI by showing the selected child report and hiding the rest.
*/
function showChild(newChildIndex, newRowIndex) {
if (newRowIndex != rowIndex || newChildIndex != childIndex) {
if (selectedChildReport == null) {
selectedChildReport = document.getElementById("ChildReports." + mainIndex).children[0];
}
selectedChildReport.children[0].className = "childreport";
var newChildId = "Child." + newChildIndex + "." + newRowIndex + "." + mainIndex;
selectedChildReport = document.getElementById(newChildId);
selectedChildReport.children[0].className = "currentchildreport";
childIndex = newChildIndex;
rowIndex = newRowIndex;
}
}/**********************************************************************************************************************
Table report code
***********************************************************************************************************************/
var table_selectedRows = new Array();
function table_onSelectMasterRow(node, tableNo, newMasterIndex) {
table_onSelectRow(node, tableNo);
onSelectRowIndex(newMasterIndex);
}
function table_onSelectRow(node, tableNo) {
if (node.className != "currentrow") {
previousRow = table_selectedRows[tableNo];
if (previousRow == null) {
previousRow = node.parentNode.children[1];
}
previousRow.className = "";
var previousCells = previousRow.children;
for (var pc = 0;pc < previousCells.length;pc++) {
previousCells[pc].className = "";
}
node.className = "currentrow";
var nodeCells = node.children;
for (var nc = 0;nc < nodeCells.length;nc++) {
nodeCells[nc].className = "currentcell";
}
table_selectedRows[tableNo] = node;
}
}