PluginProbe
Code Profiler – WordPress Performance Profiling and Debugging Made Easy / 1.9.6
Code Profiler – WordPress Performance Profiling and Debugging Made Easy v1.9.6
1.9.6 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 All 41 releases
← All changes | static/code-profiler.js +130 -30 1.6.11.9.6 View file →
@@ -5,9 +5,9 @@
5 5 | | | / _ \ / _` |/ _ \ | |_) | '__/ _ \| |_| | |/ _ \ '__| |
6 6 | | |__| (_) | (_| | __/ | __/| | | (_) | _| | | __/ | |
7 7 | \____\___/ \__,_|\___| |_| |_| \___/|_| |_|_|\___|_| |
8 8 | |
9 - | (c) Jerome Bruandet ~ https://code-profiler.com/ |
9 + | (c) Jerome Bruandet ~ https://nintechnet.com/codeprofiler/ |
10 10 +=====================================================================+
11 11 */
12 12
13 13 // =====================================================================
@@ -68,28 +68,41 @@
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 == 1 ) {
72 + if ( item == 'frontend') {
73 73 jQuery('#p-frontend').show();
74 74 jQuery('#p-backend').hide();
75 75 jQuery('#p-custom').hide();
76 + jQuery('#p-wpcron').hide();
76 77 jQuery('#id-frontend').focus();
77 78 jQuery('#user-unauthenticated').prop('disabled', false);
78 - } else if ( item == 2 ) {
79 + jQuery('#user-authenticated').prop('disabled', false);
80 + } else if ( item == 'backend') {
79 81 jQuery('#p-backend').show();
80 82 jQuery('#p-frontend').hide();
81 83 jQuery('#p-custom').hide();
84 + jQuery('#p-wpcron').hide();
82 85 jQuery('#id-backend').focus();
83 86 jQuery('#user-unauthenticated').prop('disabled', true);
87 + jQuery('#user-authenticated').prop('disabled', false);
84 88 jQuery('#user-authenticated').prop('checked', true);
85 89 jQuery('#user-name').prop('disabled', false);
86 - } else {
90 + } else if ( item == 'custom') {
87 91 jQuery('#p-custom').show();
88 92 jQuery('#p-frontend').hide();
89 93 jQuery('#p-backend').hide();
94 + jQuery('#p-wpcron').hide();
90 95 jQuery('#id-custom').focus();
91 96 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);
92 105 }
93 106 }
94 107
95 108 function cpjs_authenticated( id ) {
@@ -108,14 +121,53 @@
108 121
109 122 function cpjs_get_post( id ) {
110 123 if ( id == 1 ) {
111 124 jQuery('#post-value').prop('disabled', false);
125 + jQuery('#id-content-type').prop('disabled', false);
112 126 jQuery('#post-value').focus();
113 127 } else {
114 128 jQuery('#post-value').prop('disabled', true);
129 + jQuery('#id-content-type').prop('disabled', true);
115 130 }
116 131 }
117 132
133 +function cpjs_content_type( value ) {
134 + if ( value == 1 ) {
135 + jQuery('#ct-1').slideDown();
136 + jQuery('#ct-3').slideUp();
137 + jQuery('#ct-2').slideUp();
138 + } else if ( value == 2 ) {
139 + jQuery('#ct-2').slideDown();
140 + jQuery('#ct-3').slideUp();
141 + jQuery('#ct-1').slideUp();
142 + } else {
143 + jQuery('#ct-3').slideDown();
144 + jQuery('#ct-1').slideUp();
145 + jQuery('#ct-2').slideUp();
146 + }
147 +}
148 +
149 +function cpjs_isJSON( data ) {
150 +
151 + if ( jQuery('#id-content-type').val() == 1 || jQuery('#get-method').prop('checked') == true ) {
152 + // Ignore
153 + return 1;
154 + }
155 + try {
156 + return JSON.parse( data );
157 + } catch (e) {
158 + // Not a JSON-encoded string
159 + return null;
160 + }
161 +}
162 +
163 +function cpjs_ismultiline( data ) {
164 + if ( data.match( /[\n\r]/) ) {
165 + return true;
166 + }
167 + return false;
168 +}
169 +
118 170 // =====================================================================
119 171 // Log page: filter and delete the log.
120 172
121 173 function cpjs_filter_log() {
@@ -156,9 +208,15 @@
156 208 // =====================================================================
157 209 // AJAX call to start the profiler.
158 210
159 211 function cpjs_start_profiler() {
212 +
160 213 'use strict';
214 +
215 + jQuery('html, body').animate( {
216 + scrollTop: jQuery('#button-adv-settings').offset().top
217 + }, 1000 );
218 +
161 219 // Get the nonce
162 220 var cp_nonce = jQuery('#cp_nonce').val();
163 221 if ( cp_nonce == '') {
164 222 alert( cpi18n.missing_nonce );
@@ -166,18 +224,25 @@
166 224 }
167 225
168 226 // Get the scan type (frontend/backend)
169 227 var post;
170 - var where = jQuery('input[name="where"]:checked').val();
171 - if ( where == 'frontend') {
228 + var x_end = jQuery('input[name="x_end"]:checked').val();
229 + if ( x_end == 'frontend') {
172 230 post = jQuery('#id-frontend').val();
173 231
174 - } else if ( where == 'backend') {
232 + } else if ( x_end == 'backend') {
175 233 post = jQuery('#id-backend').val();
176 234
177 - } else if ( where == 'custom') {
235 + } else if ( x_end == 'custom') {
178 236 post = jQuery('#id-custom').val().trim(); // Trim user input
179 237
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 +
180 245 } else {
181 246 alert( cpi18n.missing_frontbackend );
182 247 return;
183 248 }
@@ -193,16 +258,16 @@
193 258 jQuery('input[name="profile"]').focus();
194 259 return;
195 260 }
196 261
197 - var user = jQuery('input[name="user"]:checked').val();
198 - if ( user == '') {
262 + var x_auth = jQuery('input[name="x_auth"]:checked').val();
263 + if ( x_auth == '') {
199 264 alert( cpi18n.missing_userauth );
200 265 return;
201 266 }
202 267
203 268 var username = jQuery('#user-name').val().trim(); // Trim user input
204 - if ( user == 'authenticated') {
269 + if ( x_auth == 'authenticated') {
205 270 if ( username == '') {
206 271 alert( cpi18n.missing_username );
207 272 jQuery('#user-name').focus();
208 273 return;
@@ -208,13 +273,15 @@
208 273 return;
209 274 }
210 275 }
211 276
212 - var ua = jQuery('#ua-id').val();
213 - if ( ua == 'undefined') {
214 - ua = 'FireFox';
277 + var user_agent = jQuery('#ua-id').val();
278 + if ( user_agent == 'undefined') {
279 + user_agent = 'FireFox';
215 280 }
216 281
282 + var theme = jQuery('#id-theme').val();
283 +
217 284 // GET or POST
218 285 var method = jQuery('input[name="method"]:checked').val();
219 286 var payload = '';
220 287 if ( method == 'post') {
@@ -223,10 +290,30 @@
223 290 } else {
224 291 method = 'get';
225 292 }
226 293
227 - var cookies = jQuery('#cp-cookies').val();
294 + //Content type
295 + var ct = jQuery('#id-content-type').val();
296 + if ( ct == 2 ) {
297 + // application/json
298 + if ( cpjs_isJSON( payload ) == null ) {
299 + alert( cpi18n.missing_ajax );
300 + jQuery('#user-name').focus();
301 + return;
302 + }
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 + }
228 311
312 + var cookies = jQuery('#cp-cookies').val();
313 + var headers = jQuery('#custom-headers').val();
314 + var exclusions = jQuery('#exclusions').val();
315 +
229 316 // Change buttons status and add animated image with status message
230 317 jQuery('#start-profile').prop('disabled', true);
231 318 jQuery('#cp-progress-div').slideDown();
232 319 jQuery('#progress-gif').slideDown();
@@ -236,17 +323,21 @@
236 323
237 324 var data = {
238 325 'action': 'codeprofiler_start_profiler',
239 326 'cp_nonce': cp_nonce,
240 - 'where': where,
327 + 'x_end': x_end,
241 328 'post': post,
329 + 'content_type': ct,
242 330 'profile': profile,
243 - 'user': user,
331 + 'x_auth': x_auth,
244 332 'username': username,
245 333 'cookies': cookies,
334 + 'custom_headers': headers,
335 + 'exclusions': exclusions,
246 336 'method': method,
247 337 'payload': payload,
248 - 'ua': ua
338 + 'user_agent': user_agent,
339 + 'theme': theme
249 340 };
250 341 // Send the request via AJAX
251 342 jQuery.ajax( {
252 343 type: 'POST',
@@ -507,11 +598,8 @@
507 598 type: 'bar',
508 599 options: {
509 600 animation: {
510 601 duration: 1000,
511 - onComplete: function() {
512 - document.getElementById('download-png-img').href = myChart.toBase64Image();
513 - }
514 602 },
515 603 indexAxis: _indexAxis,
516 604 plugins: chartPlugins
517 605 },
@@ -592,9 +680,8 @@
592 680 animation: {
593 681 duration: 700,
594 682 onComplete: function() {
595 683 jQuery('#cp-footer-buttons').slideDown(200);
596 - document.getElementById('download-png-img').href = myChart.toBase64Image();
597 684 }
598 685 },
599 686 indexAxis: _indexAxis,
600 687 plugins: chartPlugins
@@ -600,8 +687,15 @@
600 687 plugins: chartPlugins
601 688 },
602 689 plugins:[plugin]
603 690 });
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 + }
604 698 }
605 699
606 700 // =====================================================================
607 701 // File I/O chart.
@@ -621,11 +715,8 @@
621 715 type: 'line',
622 716 options: {
623 717 animation: {
624 718 duration: 1000,
625 - onComplete: function() {
626 - document.getElementById('download-png-img').href = myChart.toBase64Image();
627 - }
628 719 },
629 720 indexAxis: _indexAxis,
630 721 plugins: chartPlugins
631 722 },
@@ -693,9 +784,8 @@
693 784 animation: {
694 785 duration: 700,
695 786 onComplete: function() {
696 787 jQuery('#cp-footer-buttons').slideDown(200);
697 - document.getElementById('download-png-img').href = myChart.toBase64Image();
698 788 }
699 789 },
700 790 indexAxis: _indexAxis,
701 791 plugins: chartPlugins
@@ -702,8 +792,15 @@
702 792 },
703 793 plugins:[plugin]
704 794 });
705 795
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 +
706 803 }
707 804 // =====================================================================
708 805 // Disk I/O chart.
709 806
@@ -722,11 +819,8 @@
722 819 type: 'line',
723 820 options: {
724 821 animation: {
725 822 duration: 1000,
726 - onComplete: function() {
727 - document.getElementById('download-png-img').href = myChart.toBase64Image();
728 - }
729 823 },
730 824 indexAxis: _indexAxis,
731 825 plugins: chartPlugins
732 826 },
@@ -793,9 +887,8 @@
793 887 animation: {
794 888 duration: 700,
795 889 onComplete: function() {
796 890 jQuery('#cp-footer-buttons').slideDown(200);
797 - document.getElementById('download-png-img').href = myChart.toBase64Image();
798 891 }
799 892 },
800 893 indexAxis: _indexAxis,
801 894 plugins: chartPlugins
@@ -801,8 +894,15 @@
801 894 plugins: chartPlugins
802 895 },
803 896 plugins:[plugin]
804 897 });
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 + }
805 905 }
806 906
807 907 // =====================================================================
808 908 // Settings page