Add analytics
[bus.git] / busui / owa / includes / pqp / pqp.tpl
maxious 1 <!-- JavaScript -->
2 {literal}
3 <script type="text/javascript">
4 var PQP_DETAILS = true;
5 var PQP_HEIGHT = "short";
6
7 addEvent(window, 'load', loadCSS);
8
9 function changeTab(tab) {
10 var pQp = document.getElementById('pQp');
11 hideAllTabs();
12 addClassName(pQp, tab, true);
13 }
14
15 function hideAllTabs() {
16 var pQp = document.getElementById('pQp');
17 removeClassName(pQp, 'console');
18 removeClassName(pQp, 'speed');
19 removeClassName(pQp, 'queries');
20 removeClassName(pQp, 'memory');
21 removeClassName(pQp, 'files');
22 }
23
24 function toggleDetails(){
25 var container = document.getElementById('pqp-container');
26
27 if(PQP_DETAILS){
28 addClassName(container, 'hideDetails', true);
29 PQP_DETAILS = false;
30 }
31 else{
32 removeClassName(container, 'hideDetails');
33 PQP_DETAILS = true;
34 }
35 }
36 function toggleHeight(){
37 var container = document.getElementById('pqp-container');
38
39 if(PQP_HEIGHT == "short"){
40 addClassName(container, 'tallDetails', true);
41 PQP_HEIGHT = "tall";
42 }
43 else{
44 removeClassName(container, 'tallDetails');
45 PQP_HEIGHT = "short";
46 }
47 }
48
49 function loadCSS() {
50 var sheet = document.createElement("link");
51 sheet.setAttribute("rel", "stylesheet");
52 sheet.setAttribute("type", "text/css");
53 sheet.setAttribute("href", "/pqp/css/pQp.css");
54 document.getElementsByTagName("head")[0].appendChild(sheet);
55 setTimeout(function(){document.getElementById("pqp-container").style.display = "block"}, 10);
56 }
57
58
59 //http://www.bigbold.com/snippets/posts/show/2630
60 function addClassName(objElement, strClass, blnMayAlreadyExist){
61 if ( objElement.className ){
62 var arrList = objElement.className.split(' ');
63 if ( blnMayAlreadyExist ){
64 var strClassUpper = strClass.toUpperCase();
65 for ( var i = 0; i < arrList.length; i++ ){
66 if ( arrList[i].toUpperCase() == strClassUpper ){
67 arrList.splice(i, 1);
68 i--;
69 }
70 }
71 }
72 arrList[arrList.length] = strClass;
73 objElement.className = arrList.join(' ');
74 }
75 else{
76 objElement.className = strClass;
77 }
78 }
79
80 //http://www.bigbold.com/snippets/posts/show/2630
81 function removeClassName(objElement, strClass){
82 if ( objElement.className ){
83 var arrList = objElement.className.split(' ');
84 var strClassUpper = strClass.toUpperCase();
85 for ( var i = 0; i < arrList.length; i++ ){
86 if ( arrList[i].toUpperCase() == strClassUpper ){
87 arrList.splice(i, 1);
88 i--;
89 }
90 }
91 objElement.className = arrList.join(' ');
92 }
93 }
94
95 //http://ejohn.org/projects/flexible-javascript-events/
96 function addEvent( obj, type, fn ) {
97 if ( obj.attachEvent ) {
98 obj["e"+type+fn] = fn;
99 obj[type+fn] = function() { obj["e"+type+fn]( window.event ) };
100 obj.attachEvent( "on"+type, obj[type+fn] );
101 }
102 else{
103 obj.addEventListener( type, fn, false );
104 }
105 }
106 </script>
107 {/literal}
108
109 <div id="pqp-container" class="pQp" style="display:none">
110 <div id="pQp" class="console">
111 <table id="pqp-metrics" cellspacing="0">
112 <tr>
113 <td class="green" onclick="changeTab('console');">
114 <var>{$logs.console|@count}</var>
115 <h4>Console</h4>
116 </td>
117 <td class="blue" onclick="changeTab('speed');">
118 <var>{$speedTotals.total}</var>
119 <h4>Load Time</h4>
120 </td>
121 <td class="purple" onclick="changeTab('queries');">
122 <var>{$queryTotals.count} Queries</var>
123 <h4>Database</h4>
124 </td>
125 <td class="orange" onclick="changeTab('memory');">
126 <var>{$memoryTotals.used}</var>
127 <h4>Memory Used</h4>
128 </td>
129 <td class="red" onclick="changeTab('files');">
130 <var>{$files|@count} Files</var>
131 <h4>Included</h4>
132 </td>
133 </tr>
134 </table>
135
136 <div id='pqp-console' class='pqp-box'>
137 {if $logs.console|@count == 0}
138 <h3>This panel has no log items.</h3>
139 {else}
140 <table class='side' cellspacing='0'>
141 <tr>
142 <td class='alt1'><var>{$logs.logCount}</var><h4>Logs</h4></td>
143 <td class='alt2'><var>{$logs.errorCount}</var> <h4>Errors</h4></td>
144 </tr>
145 <tr>
146 <td class='alt3'><var>{$logs.memoryCount}</var> <h4>Memory</h4></td>
147 <td class='alt4'><var>{$logs.speedCount}</var> <h4>Speed</h4></td>
148 </tr>
149 </table>
150 <table class='main' cellspacing='0'>
151 {foreach from=$logs.console item=log}
152 <tr class='log-{$log.type}'>
153 <td class='type'>{$log.type}</td>
154 <td class="{cycle values="alt,"}">
155 {if $log.type == 'log'}
156 <div><pre>{$log.data}</pre></div>
157 {elseif $log.type == 'memory'}
158 <div><pre>{$log.data}</pre> <em>{$log.dataType}</em>: {$log.name} </div>
159 {elseif $log.type == 'speed'}
160 <div><pre>{$log.data}</pre> <em>{$log.name}</em></div>
161 {elseif $log.type == 'error'}
162 <div><em>Line {$log.line}</em> : {$log.data} <pre>{$log.file}</pre></div>
163 {/if}
164 </td>
165 </tr>
166 {/foreach}
167 </table>
168 {/if}
169 </div>
170
171 <div id="pqp-speed" class="pqp-box">
172 {if $logs.speedCount == 0}
173 <h3>This panel has no log items.</h3>
174 {else}
175 <table class='side' cellspacing='0'>
176 <tr><td><var>{$speedTotals.total}</var><h4>Load Time</h4></td></tr>
177 <tr><td class='alt'><var>{$speedTotals.allowed} s</var> <h4>Max Execution Time</h4></td></tr>
178 </table>
179
180 <table class='main' cellspacing='0'>
181 {foreach from=$logs.console item=log}
182 {if $log.type == 'speed'}
183 <tr class='log-{$log.type}'>
184 <td class="{cycle values="alt,"}"><b>{$log.data}</b> {$log.name}</td>
185 </tr>
186 {/if}
187 {/foreach}
188 </table>
189 {/if}
190 </div>
191
192 <div id='pqp-queries' class='pqp-box'>
193 {if $queryTotals.count == 0}
194 <h3>This panel has no log items.</h3>
195 {else}
196 <table class='side' cellspacing='0'>
197 <tr><td><var>{$queryTotals.count}</var><h4>Total Queries</h4></td></tr>
198 <tr><td class='alt'><var>{$queryTotals.time}</var> <h4>Total Time</h4></td></tr>
199 <tr><td><var>0</var> <h4>Duplicates</h4></td></tr>
200 </table>
201
202 <table class='main' cellspacing='0'>
203 {foreach from=$queries item=query}
204 <tr>
205 <td class="{cycle values="alt,"}">
206 {$query.sql}
207 {if $query.explain}
208 <em>
209 Possible keys: <b>{$query.explain.possible_keys}</b> &middot;
210 Key Used: <b>{$query.explain.key}</b> &middot;
211 Type: <b>{$query.explain.type}</b> &middot;
212 Rows: <b>{$query.explain.rows}</b> &middot;
213 Speed: <b>{$query.time}</b>
214 </em>
215 {/if}
216 </td>
217 </tr>
218 {/foreach}
219 </table>
220 {/if}
221 </div>
222
223 <div id="pqp-memory" class="pqp-box">
224 {if $logs.memoryCount == 0}
225 <h3>This panel has no log items.</h3>
226 {else}
227 <table class='side' cellspacing='0'>
228 <tr><td><var>{$memoryTotals.used}</var><h4>Used Memory</h4></td></tr>
229 <tr><td class='alt'><var>{$memoryTotals.total}</var> <h4>Total Available</h4></td></tr>
230 </table>
231
232 <table class='main' cellspacing='0'>
233 {foreach from=$logs.console item=log}
234 {if $log.type == 'memory'}
235 <tr class='log-{$log.type}'>
236 <td class="{cycle values="alt,"}"><b>{$log.data}</b> <em>{$log.dataType}</em>: {$log.name}</td>
237 </tr>
238 {/if}
239 {/foreach}
240 </table>
241 {/if}
242 </div>
243
244 <div id='pqp-files' class='pqp-box'>
245 <table class='side' cellspacing='0'>
246 <tr><td><var>{$fileTotals.count}</var><h4>Total Files</h4></td></tr>
247 <tr><td class='alt'><var>{$fileTotals.size}</var> <h4>Total Size</h4></td></tr>
248 <tr><td><var>{$fileTotals.largest}</var> <h4>Largest</h4></td></tr>
249 </table>
250 <table class='main' cellspacing='0'>
251 {foreach from=$files item=file}
252 <tr><td class="{cycle values="alt,"}"><b>{$file.size}</b> {$file.name}</td></tr>
253 {/foreach}
254 </table>
255 </div>
256
257 <table id="pqp-footer" cellspacing="0">
258 <tr>
259 <td class="credit">
260 <a href="http://particletree.com/features/php-quick-profiler/" target="_blank">
261 <strong>PHP</strong>
262 <b class="green">Q</b><b class="blue">u</b><b class="purple">i</b><b class="orange">c</b><b class="red">k</b>
263 Profiler</a></td>
264 <td class="actions">
265 <a href="#" onclick="toggleDetails();return false">Details</a>
266 <a class="heightToggle" href="#" onclick="toggleHeight();return false">Height</a>
267 </td>
268 </tr>
269 </table>
270 </div>
271 </div>