PluginProbe
Code Profiler – WordPress Performance Profiling and Debugging Made Easy / 1.7.4
Code Profiler – WordPress Performance Profiling and Debugging Made Easy v1.7.4
1.9.5 1.9.4 1.9.3 trunk 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.6 1.6.1 1.6.10 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 All 40 releases
← All changes | static/code-profiler.js +30 -85 trunk1.7.4 View file →
@@ -68,41 +68,28 @@
68 68 function cpjs_front_or_backend( item ) {
69 69 'use strict';
70 70 // Enable/disable frontend/backend select box
71 71 // depending on user's choice
72 - if ( item == 'frontend') {
72 + if ( item == 1 ) {
73 73 jQuery('#p-frontend').show();
74 74 jQuery('#p-backend').hide();
75 75 jQuery('#p-custom').hide();
76 - jQuery('#p-wpcron').hide();
77 76 jQuery('#id-frontend').focus();
78 77 jQuery('#user-unauthenticated').prop('disabled', false);
79 - jQuery('#user-authenticated').prop('disabled', false);
80 - } else if ( item == 'backend') {
78 + } else if ( item == 2 ) {
81 79 jQuery('#p-backend').show();
82 80 jQuery('#p-frontend').hide();
83 81 jQuery('#p-custom').hide();
84 - jQuery('#p-wpcron').hide();
85 82 jQuery('#id-backend').focus();
86 83 jQuery('#user-unauthenticated').prop('disabled', true);
87 - jQuery('#user-authenticated').prop('disabled', false);
88 84 jQuery('#user-authenticated').prop('checked', true);
89 85 jQuery('#user-name').prop('disabled', false);
90 - } else if ( item == 'custom') {
86 + } else {
91 87 jQuery('#p-custom').show();
92 88 jQuery('#p-frontend').hide();
93 89 jQuery('#p-backend').hide();
94 - jQuery('#p-wpcron').hide();
95 90 jQuery('#id-custom').focus();
96 91 jQuery('#user-unauthenticated').prop('disabled', false);
97 - jQuery('#user-authenticated').prop('disabled', false);
98 - } else {
99 - jQuery('#p-wpcron').show();
100 - jQuery('#p-custom').hide();
101 - jQuery('#p-frontend').hide();
102 - jQuery('#p-backend').hide();
103 - jQuery('#id-wpcron').focus();
104 - jQuery('#user-unauthenticated').prop('disabled', false);
105 92 }
106 93 }
107 94
108 95 function cpjs_authenticated( id ) {
@@ -132,18 +119,12 @@
132 119
133 120 function cpjs_content_type( value ) {
134 121 if ( value == 1 ) {
135 122 jQuery('#ct-1').slideDown();
136 - jQuery('#ct-3').slideUp();
137 123 jQuery('#ct-2').slideUp();
138 - } else if ( value == 2 ) {
124 + } else {
139 125 jQuery('#ct-2').slideDown();
140 - jQuery('#ct-3').slideUp();
141 126 jQuery('#ct-1').slideUp();
142 - } else {
143 - jQuery('#ct-3').slideDown();
144 - jQuery('#ct-1').slideUp();
145 - jQuery('#ct-2').slideUp();
146 127 }
147 128 }
148 129
149 130 function cpjs_isJSON( data ) {
@@ -159,15 +140,8 @@
159 140 return null;
160 141 }
161 142 }
162 143
163 -function cpjs_ismultiline( data ) {
164 - if ( data.match( /[\n\r]/) ) {
165 - return true;
166 - }
167 - return false;
168 -}
169 -
170 144 // =====================================================================
171 145 // Log page: filter and delete the log.
172 146
173 147 function cpjs_filter_log() {
@@ -208,15 +182,9 @@
208 182 // =====================================================================
209 183 // AJAX call to start the profiler.
210 184
211 185 function cpjs_start_profiler() {
212 -
213 186 'use strict';
214 -
215 - jQuery('html, body').animate( {
216 - scrollTop: jQuery('#button-adv-settings').offset().top
217 - }, 1000 );
218 -
219 187 // Get the nonce
220 188 var cp_nonce = jQuery('#cp_nonce').val();
221 189 if ( cp_nonce == '') {
222 190 alert( cpi18n.missing_nonce );
@@ -224,25 +192,18 @@
224 192 }
225 193
226 194 // Get the scan type (frontend/backend)
227 195 var post;
228 - var x_end = jQuery('input[name="x_end"]:checked').val();
229 - if ( x_end == 'frontend') {
196 + var where = jQuery('input[name="where"]:checked').val();
197 + if ( where == 'frontend') {
230 198 post = jQuery('#id-frontend').val();
231 199
232 - } else if ( x_end == 'backend') {
200 + } else if ( where == 'backend') {
233 201 post = jQuery('#id-backend').val();
234 202
235 - } else if ( x_end == 'custom') {
203 + } else if ( where == 'custom') {
236 204 post = jQuery('#id-custom').val().trim(); // Trim user input
237 205
238 - } else if ( x_end == 'wpcron') {
239 - post = jQuery('#id-wpcron').val();
240 - if ( post == 0 ) {
241 - alert( cpi18n.missing_wpcron );
242 - return;
243 - }
244 -
245 206 } else {
246 207 alert( cpi18n.missing_frontbackend );
247 208 return;
248 209 }
@@ -258,16 +219,16 @@
258 219 jQuery('input[name="profile"]').focus();
259 220 return;
260 221 }
261 222
262 - var x_auth = jQuery('input[name="x_auth"]:checked').val();
263 - if ( x_auth == '') {
223 + var user = jQuery('input[name="user"]:checked').val();
224 + if ( user == '') {
264 225 alert( cpi18n.missing_userauth );
265 226 return;
266 227 }
267 228
268 229 var username = jQuery('#user-name').val().trim(); // Trim user input
269 - if ( x_auth == 'authenticated') {
230 + if ( user == 'authenticated') {
270 231 if ( username == '') {
271 232 alert( cpi18n.missing_username );
272 233 jQuery('#user-name').focus();
273 234 return;
@@ -273,11 +234,11 @@
273 234 return;
274 235 }
275 236 }
276 237
277 - var user_agent = jQuery('#ua-id').val();
278 - if ( user_agent == 'undefined') {
279 - user_agent = 'FireFox';
238 + var ua = jQuery('#ua-id').val();
239 + if ( ua == 'undefined') {
240 + ua = 'FireFox';
280 241 }
281 242
282 243 var theme = jQuery('#id-theme').val();
283 244
@@ -292,22 +253,15 @@
292 253 }
293 254
294 255 //Content type
295 256 var ct = jQuery('#id-content-type').val();
257 + // application/json
296 258 if ( ct == 2 ) {
297 - // application/json
298 259 if ( cpjs_isJSON( payload ) == null ) {
299 260 alert( cpi18n.missing_ajax );
300 261 jQuery('#user-name').focus();
301 262 return;
302 263 }
303 - } else if ( ct == 3 ) {
304 - // Raw format must be on one single line
305 - if ( cpjs_ismultiline( payload.trim() ) == true ) {
306 - alert( cpi18n.multiline_raw );
307 - jQuery('#post-value').focus();
308 - return;
309 - }
310 264 }
311 265
312 266 var cookies = jQuery('#cp-cookies').val();
313 267 var headers = jQuery('#custom-headers').val();
@@ -323,13 +277,13 @@
323 277
324 278 var data = {
325 279 'action': 'codeprofiler_start_profiler',
326 280 'cp_nonce': cp_nonce,
327 - 'x_end': x_end,
281 + 'where': where,
328 282 'post': post,
329 283 'content_type': ct,
330 284 'profile': profile,
331 - 'x_auth': x_auth,
285 + 'user': user,
332 286 'username': username,
333 287 'cookies': cookies,
334 288 'custom_headers': headers,
335 289 'exclusions': exclusions,
@@ -334,9 +288,9 @@
334 288 'custom_headers': headers,
335 289 'exclusions': exclusions,
336 290 'method': method,
337 291 'payload': payload,
338 - 'user_agent': user_agent,
292 + 'ua': ua,
339 293 'theme': theme
340 294 };
341 295 // Send the request via AJAX
342 296 jQuery.ajax( {
@@ -598,8 +552,11 @@
598 552 type: 'bar',
599 553 options: {
600 554 animation: {
601 555 duration: 1000,
556 + onComplete: function() {
557 + document.getElementById('download-png-img').href = myChart.toBase64Image();
558 + }
602 559 },
603 560 indexAxis: _indexAxis,
604 561 plugins: chartPlugins
605 562 },
@@ -680,8 +637,9 @@
680 637 animation: {
681 638 duration: 700,
682 639 onComplete: function() {
683 640 jQuery('#cp-footer-buttons').slideDown(200);
641 + document.getElementById('download-png-img').href = myChart.toBase64Image();
684 642 }
685 643 },
686 644 indexAxis: _indexAxis,
687 645 plugins: chartPlugins
@@ -687,15 +645,8 @@
687 645 plugins: chartPlugins
688 646 },
689 647 plugins:[plugin]
690 648 });
691 -
692 - document.getElementById('download-png-img').onclick = function() {
693 - var a = document.createElement('a');
694 - a.href = myChart.toBase64Image();
695 - a.download = jQuery('#download-png-img').attr('download');
696 - a.click();
697 - }
698 649 }
699 650
700 651 // =====================================================================
701 652 // File I/O chart.
@@ -715,8 +666,11 @@
715 666 type: 'line',
716 667 options: {
717 668 animation: {
718 669 duration: 1000,
670 + onComplete: function() {
671 + document.getElementById('download-png-img').href = myChart.toBase64Image();
672 + }
719 673 },
720 674 indexAxis: _indexAxis,
721 675 plugins: chartPlugins
722 676 },
@@ -784,8 +738,9 @@
784 738 animation: {
785 739 duration: 700,
786 740 onComplete: function() {
787 741 jQuery('#cp-footer-buttons').slideDown(200);
742 + document.getElementById('download-png-img').href = myChart.toBase64Image();
788 743 }
789 744 },
790 745 indexAxis: _indexAxis,
791 746 plugins: chartPlugins
@@ -792,15 +747,8 @@
792 747 },
793 748 plugins:[plugin]
794 749 });
795 750
796 - document.getElementById('download-png-img').onclick = function() {
797 - var a = document.createElement('a');
798 - a.href = myChart.toBase64Image();
799 - a.download = jQuery('#download-png-img').attr('download');
800 - a.click();
801 - }
802 -
803 751 }
804 752 // =====================================================================
805 753 // Disk I/O chart.
806 754
@@ -819,8 +767,11 @@
819 767 type: 'line',
820 768 options: {
821 769 animation: {
822 770 duration: 1000,
771 + onComplete: function() {
772 + document.getElementById('download-png-img').href = myChart.toBase64Image();
773 + }
823 774 },
824 775 indexAxis: _indexAxis,
825 776 plugins: chartPlugins
826 777 },
@@ -887,8 +838,9 @@
887 838 animation: {
888 839 duration: 700,
889 840 onComplete: function() {
890 841 jQuery('#cp-footer-buttons').slideDown(200);
842 + document.getElementById('download-png-img').href = myChart.toBase64Image();
891 843 }
892 844 },
893 845 indexAxis: _indexAxis,
894 846 plugins: chartPlugins
@@ -894,15 +846,8 @@
894 846 plugins: chartPlugins
895 847 },
896 848 plugins:[plugin]
897 849 });
898 -
899 - document.getElementById('download-png-img').onclick = function() {
900 - var a = document.createElement('a');
901 - a.href = myChart.toBase64Image();
902 - a.download = jQuery('#download-png-img').attr('download');
903 - a.click();
904 - }
905 850 }
906 851
907 852 // =====================================================================
908 853 // Settings page