dev tools
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / evergreen / util / filter_console.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: About -->
4
5 <!-- Stylesheets -->
6 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
7 <?xml-stylesheet href="chrome://evergreen/skin/evergreen.css" type="text/css"?>
8
9 <window id="filter_console_win" 
10         onload="try { my_init(); } catch(E) { alert(E); }"
11         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
12
13         <script>mw.sdump('D_TRACE','Loading filter_console.xul\n');</script>
14
15         <script>
16         <![CDATA[
17
18                 var rows; var containing; var not_containing;
19
20                 function my_init() {
21
22                         rows = document.getElementById('filter_console_grid_rows');
23                         containing = document.getElementById('filter_console_containing');
24                         not_containing = document.getElementById('filter_console_not_containing');
25                         
26                         mw.filter_console_init( {'observe_msg':observe_msg} );
27                         build_sdump_menu();
28                 }
29
30                 function build_sdump_menu() {
31                         try {
32                                 var mp = document.getElementById('fcmp');
33                                 for (var i in mw.sdump_levels) {
34                                         var m = document.createElement( 'menuitem' );
35                                         mp.appendChild(m);
36                                         m.setAttribute('type','checkbox');
37                                         m.setAttribute('label',i);
38                                         m.setAttribute('checked',mw.sdump_levels[i]);
39                                         m.setAttribute('oncommand',
40                                                 "mw.sdump_levels."+i+"=!mw.sdump_levels."+i+
41                                                 "; this.setAttribute('checked',mw.sdump_levels."+i+");");
42                                 }
43                         } catch(E) {
44                                 alert(E);
45                         }
46                 }
47
48                 function observe_msg(msg) {
49
50                         try {
51                                 var row = document.createElement('row');
52                                 rows.appendChild(row);
53
54                                 var hbox = document.createElement('hbox');
55                                 row.appendChild(hbox);
56                                 hbox.flex = 1;
57
58                                 var tb = document.createElement('textbox');
59                                 hbox.appendChild(tb);
60                                 tb.setAttribute('multiline','true');
61                                 tb.setAttribute('readonly','true');
62                                 tb.setAttribute('rows','5');
63                                 tb.setAttribute('flex','1');
64                                 tb.setAttribute('value',msg.message);
65
66                         } catch(E) { dump(E) }
67                 }
68
69                 function test_filter(msg) {
70                         var pass = true;
71                         var c_array = containing.value.split(' ');
72                         var nc_array = not_containing.value.split(' ');
73                         for (var i = 0; i < c_array.length; i++) {
74                                 var term = c_array[i];
75                                 if (term != '' && term != null && term != undefined)
76                                         if (! msg.match( term ) )
77                                                 pass = false;
78                         }
79                         for (var i = 0; i < nc_array.length; i++) {
80                                 var term = nc_array[i];
81                                 if (term != '' && term != null && term != undefined)
82                                         if (msg.match( term ) )
83                                                 pass = false;
84                         }
85                         return pass;
86                 }
87
88                 function clear_rows(prune) {
89                         var delete_these = [];
90                         for (var i = 0; i < rows.childNodes.length; i++) {
91                                 var row = rows.childNodes[i];
92                                 var tb = row.firstChild.firstChild;
93                                 var delete_me = ! test_filter(tb.value);
94                                 if (!prune) delete_me = true;
95                                 if (delete_me) delete_these.push( row ); 
96                         }
97                         var row; while (row = delete_these.pop()) { rows.removeChild(row); }
98                 }
99
100                 function hide_rows() {
101                         for (var i = 0; i < rows.childNodes.length; i++) {
102                                 var row = rows.childNodes[i];
103                                 var tb = row.firstChild.firstChild;
104                                 row.hidden = ! test_filter(tb.value);
105                         }
106                 }
107
108                 function calc_delta() {
109                         var first;
110                         var last;
111                         for (var i = 0; i < rows.childNodes.length; i++) {
112                                 var row = rows.childNodes[i];
113                                 if (! row.hidden ) {
114                                         var tb = row.firstChild.firstChild;
115                                         if (!first) first = parseInt( tb.value.split(' ')[0] );
116                                         last = parseInt( tb.value.split(' ')[0] );
117                                 }
118                         }
119                         document.getElementById('fc_calc_delta_label').setAttribute('value',last-first);
120                 }
121
122         ]]>
123         </script>
124
125         <popupset>
126                 <menupopup id="fcmp" position="after_start">
127                 </menupopup>
128         </popupset>
129
130         <vbox id="filter_console_vbox" flex="1">
131                 <groupbox id="filter_console_groupbox" orient="vertical" flex="1">
132                         <caption id="fcgbc" label="Filterable Javascript Console"/>
133                         <grid id="filter_console_nav_grid">
134                                 <columns id="fcnvc"><column id="fcnvc1"/><column id="fcnvc2" flex="1"/></columns>
135                                 <rows id="fcnvr">
136                                         <row id="fcnvr1">
137                                                 <label id="fcgbhb1l" value="Containing:" class="text_right" accesskey="o" control="filter_console_containing"/>
138                                                 <textbox id="filter_console_containing" flex="1"/>
139                                         </row>
140                                         <row id="fcnvr2">
141                                                 <label id="fcgbhb1l" value="Not Containing:" class="text_right" accesskey="N" control="filter_console_not_containing"/>
142                                                 <textbox id="filter_console_not_containing" flex="1"/>
143                                         </row>
144                                         <row id="fcnvr3">
145                                                 <spacer id="fcnvr3s1"/>
146                                                 <hbox id="fcnvr3hb1" flex="1">
147                                                         <button id="fc_sdump_levels" popup="fcmp" label="Set SDUMP Logging" accesskey="S"/>
148                                                         <button id="fc_filter_view" label="View with Filters" accesskey="V" oncommand="hide_rows();"/>
149                                                         <button id="fc_calc_delta" label="Delta (Last-1st sdump)" accesskey="D" oncommand="calc_delta();"/>
150                                                         <label id="fc_calc_delta_label" />
151                                                         <spacer id="fcnvr3hb1s1" flex="1"/>
152                                                         <button id="fc_filter_prune" label="Prune Hidden" accesskey="P" oncommand="clear_rows(true);"/>
153                                                         <button id="fc_clear" label="Clear" accesskey="C" oncommand="clear_rows(false);"/>
154                                                 </hbox>
155                                         </row>
156                                 </rows>
157                         </grid>
158                         <grid id="filter_console_grid" flex="1" style="overflow: auto;">
159                                 <columns id="fcgc"><column id="fcgc1" flex="1"/></columns>
160                                 <rows id="filter_console_grid_rows"/>
161                         </grid>
162                 </groupbox>
163         </vbox>
164
165 </window>
166