-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxul.js
229 lines (186 loc) · 6.09 KB
/
xul.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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
window.onload = initStatViewer;
function initStatViewer()
{
getDiagramList();
window.onload = null;
}
function getFilterAndSettingsURLString()
{
return 'filter='
+ escape(document.getElementById('filtertext').value)
+ '&'
+ 'width='
+ escape(document.getElementById('setting_chart_x').value)
+ '&'
+ 'height='
+ escape(document.getElementById('setting_chart_y').value)
+ '&'
+ 'pie_threshold='
+ escape(document.getElementById('setting_chart_pie_threshold').value)
+ '&'
+ 'timeline_steps='
+ escape(document.getElementById('setting_timeline_steps').value);
}
function doXHRequest(url, success)
{
var httpRequest = new XMLHttpRequest();
document.getElementById("statmainwindow").setAttribute("wait-cursor", "true");
document.getElementById("filterbutton").setAttribute("disabled", "true");
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState == 4) {
if (httpRequest.status == 200) {
try {
success(httpRequest.responseText);
} catch(e) {
}
document.getElementById("filterbutton").setAttribute("disabled", "false");
document.getElementById("statmainwindow").removeAttribute("wait-cursor");
} else {
alert('There was a problem with the request.');
}
}
};
httpRequest.open('GET', url, true);
httpRequest.send(null);
}
function addToFilter(newcondition)
{
var element = document.getElementById('filtertext');
element.value = (element.value == "") ? newcondition : "("+element.value+") AND "+newcondition;
}
function applyFilter()
{
showSVGFromSelection(document.getElementById("diagramlist"));
if (document.getElementById('dumptab') == document.getElementById("maintabbox").selectedTab) {
getDump(true);
} else {
var list = document.getElementById('dumptree');
while (list.hasChildNodes()) {
list.removeChild(list.firstChild);
}
}
}
function exportChart(format, obj)
{
if (!document.getElementById("diagramlist").selectedItem) {
return;
}
var url = document.getElementById("diagramlist").selectedItem.value;
showSVG(url, format);
}
function loadedDigramList(json)
{
var all, diagrams;
var list = document.getElementById("diagramlist");
eval("all = "+json);
diagrams = all['dat'];
while (list.hasChildNodes()) {
list.removeChild(list.firstChild);
}
for (var key in diagrams) {
var li = document.createElement('listitem');
li.setAttribute('label', diagrams[key][0]);
li.setAttribute('value', key);
li.setAttribute('tooltiptext', diagrams[key][1]);
li.setAttribute('context', 'svgmenu');
list.appendChild(li);
}
}
function getDiagramList()
{
doXHRequest('json.php?action=chartlist', loadedDigramList);
}
function exportDump(format, sender)
{
var url = 'dump.php?export=1&mode=' + escape(format) +'&'+getFilterAndSettingsURLString();
document.getElementById('diagramframe').setAttribute('src', url);
}
function showSVG(chart, exportformat)
{
var url = 'chart.php?d='+escape(chart)+'&'+getFilterAndSettingsURLString();
if (exportformat != null) {
url += "&export=1&format=" + escape(exportformat);
} else {
url += "&format=" + escape(document.getElementById("setting_chart_format").getAttribute('label'));
}
document.getElementById('diagramframe').setAttribute('src', url);
}
function showSVGFromSelection(obj)
{
if (!obj.selectedItem) {
return;
}
var url = obj.selectedItem.value;
showSVG(url, null);
}
function loadedDump(dat)
{
var d;
var tree = document.getElementById('dumptree');
var cols = document.createElement('treecols');
var children = document.createElement('treechildren');
while (tree.hasChildNodes()) {
tree.removeChild(tree.firstChild);
}
eval('d = '+dat);
for (var key in d.header) {
var tmp = document.createElement('treecol');
var splitter = document.createElement('splitter');
splitter.setAttribute('class', 'tree-splitter');
tmp.setAttribute('label', d.header[key]);
tmp.setAttribute('flex', '1');
cols.appendChild(tmp);
cols.appendChild(splitter);
}
tree.appendChild(cols);
for (var key in d.data) {
var item = document.createElement('treeitem');
var row = document.createElement('treerow');
for (var content in d.data[key]) {
var tmp = document.createElement('treecell');
tmp.setAttribute('label', d.data[key][content]);
row.appendChild(tmp);
}
item.appendChild(row);
children.appendChild(item);
}
tree.appendChild(children);
document.getElementById("filterbutton").setAttribute("disabled", "false");
document.getElementById("statmainwindow").removeAttribute("wait-cursor"); //, "true");
}
function getDump(force)
{
if (!force && document.getElementById('dumptree').hasChildNodes()) {
return;
}
if (document.getElementById('filtertext').value == "") {
var c = confirm("No Filter set, dump too most likely too large. Are you sure you want to do this?");
if (!c) {
return;
}
}
doXHRequest('json.php?action=dump&filter='+escape(document.getElementById('filtertext').value), loadedDump);
}
function exportToServer(format, event)
{
var url = 'chart.php?' + 'format=' + escape(format) + '&export=server&d=' + escape(document.getElementById("diagramlist").selectedItem.value) + '&' + getFilterAndSettingsURLString();
doXHRequest(url, window.open);
}
function showSVGFromSelection(obj)
{
if (!obj.selectedItem) {
return;
}
var url = obj.selectedItem.value;
showSVG(url, null);
}
function loadedQueryList(text)
{
var tmp;
eval('tmp='+text);
document.getElementById("querybox").value = tmp;
}
function getQueryList()
{
doXHRequest('json.php?action=querylist', loadedQueryList);
}