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 +86 -31 1.6.101.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 ) {
@@ -119,12 +132,18 @@
119 132
120 133 function cpjs_content_type( value ) {
121 134 if ( value == 1 ) {
122 135 jQuery('#ct-1').slideDown();
136 + jQuery('#ct-3').slideUp();
123 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();
124 142 } else {
125 - jQuery('#ct-2').slideDown();
143 + jQuery('#ct-3').slideDown();
126 144 jQuery('#ct-1').slideUp();
145 + jQuery('#ct-2').slideUp();
127 146 }
128 147 }
129 148
130 149 function cpjs_isJSON( data ) {
@@ -140,8 +159,15 @@
140 159 return null;
141 160 }
142 161 }
143 162
163 +function cpjs_ismultiline( data ) {
164 + if ( data.match( /[\n\r]/) ) {
165 + return true;
166 + }
167 + return false;
168 +}
169 +
144 170 // =====================================================================
145 171 // Log page: filter and delete the log.
146 172
147 173 function cpjs_filter_log() {
@@ -182,9 +208,15 @@
182 208 // =====================================================================
183 209 // AJAX call to start the profiler.
184 210
185 211 function cpjs_start_profiler() {
212 +
186 213 'use strict';
214 +
215 + jQuery('html, body').animate( {
216 + scrollTop: jQuery('#button-adv-settings').offset().top
217 + }, 1000 );
218 +
187 219 // Get the nonce
188 220 var cp_nonce = jQuery('#cp_nonce').val();
189 221 if ( cp_nonce == '') {
190 222 alert( cpi18n.missing_nonce );
@@ -192,18 +224,25 @@
192 224 }
193 225
194 226 // Get the scan type (frontend/backend)
195 227 var post;
196 - var where = jQuery('input[name="where"]:checked').val();
197 - if ( where == 'frontend') {
228 + var x_end = jQuery('input[name="x_end"]:checked').val();
229 + if ( x_end == 'frontend') {
198 230 post = jQuery('#id-frontend').val();
199 231
200 - } else if ( where == 'backend') {
232 + } else if ( x_end == 'backend') {
201 233 post = jQuery('#id-backend').val();
202 234
203 - } else if ( where == 'custom') {
235 + } else if ( x_end == 'custom') {
204 236 post = jQuery('#id-custom').val().trim(); // Trim user input
205 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 +
206 245 } else {
207 246 alert( cpi18n.missing_frontbackend );
208 247 return;
209 248 }
@@ -219,16 +258,16 @@
219 258 jQuery('input[name="profile"]').focus();
220 259 return;
221 260 }
222 261
223 - var user = jQuery('input[name="user"]:checked').val();
224 - if ( user == '') {
262 + var x_auth = jQuery('input[name="x_auth"]:checked').val();
263 + if ( x_auth == '') {
225 264 alert( cpi18n.missing_userauth );
226 265 return;
227 266 }
228 267
229 268 var username = jQuery('#user-name').val().trim(); // Trim user input
230 - if ( user == 'authenticated') {
269 + if ( x_auth == 'authenticated') {
231 270 if ( username == '') {
232 271 alert( cpi18n.missing_username );
233 272 jQuery('#user-name').focus();
234 273 return;
@@ -234,11 +273,11 @@
234 273 return;
235 274 }
236 275 }
237 276
238 - var ua = jQuery('#ua-id').val();
239 - if ( ua == 'undefined') {
240 - ua = 'FireFox';
277 + var user_agent = jQuery('#ua-id').val();
278 + if ( user_agent == 'undefined') {
279 + user_agent = 'FireFox';
241 280 }
242 281
243 282 var theme = jQuery('#id-theme').val();
244 283
@@ -253,15 +292,22 @@
253 292 }
254 293
255 294 //Content type
256 295 var ct = jQuery('#id-content-type').val();
257 - // application/json
258 296 if ( ct == 2 ) {
297 + // application/json
259 298 if ( cpjs_isJSON( payload ) == null ) {
260 299 alert( cpi18n.missing_ajax );
261 300 jQuery('#user-name').focus();
262 301 return;
263 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 + }
264 310 }
265 311
266 312 var cookies = jQuery('#cp-cookies').val();
267 313 var headers = jQuery('#custom-headers').val();
@@ -277,13 +323,13 @@
277 323
278 324 var data = {
279 325 'action': 'codeprofiler_start_profiler',
280 326 'cp_nonce': cp_nonce,
281 - 'where': where,
327 + 'x_end': x_end,
282 328 'post': post,
283 329 'content_type': ct,
284 330 'profile': profile,
285 - 'user': user,
331 + 'x_auth': x_auth,
286 332 'username': username,
287 333 'cookies': cookies,
288 334 'custom_headers': headers,
289 335 'exclusions': exclusions,
@@ -288,9 +334,9 @@
288 334 'custom_headers': headers,
289 335 'exclusions': exclusions,
290 336 'method': method,
291 337 'payload': payload,
292 - 'ua': ua,
338 + 'user_agent': user_agent,
293 339 'theme': theme
294 340 };
295 341 // Send the request via AJAX
296 342 jQuery.ajax( {
@@ -552,11 +598,8 @@
552 598 type: 'bar',
553 599 options: {
554 600 animation: {
555 601 duration: 1000,
556 - onComplete: function() {
557 - document.getElementById('download-png-img').href = myChart.toBase64Image();
558 - }
559 602 },
560 603 indexAxis: _indexAxis,
561 604 plugins: chartPlugins
562 605 },
@@ -637,9 +680,8 @@
637 680 animation: {
638 681 duration: 700,
639 682 onComplete: function() {
640 683 jQuery('#cp-footer-buttons').slideDown(200);
641 - document.getElementById('download-png-img').href = myChart.toBase64Image();
642 684 }
643 685 },
644 686 indexAxis: _indexAxis,
645 687 plugins: chartPlugins
@@ -645,8 +687,15 @@
645 687 plugins: chartPlugins
646 688 },
647 689 plugins:[plugin]
648 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 + }
649 698 }
650 699
651 700 // =====================================================================
652 701 // File I/O chart.
@@ -666,11 +715,8 @@
666 715 type: 'line',
667 716 options: {
668 717 animation: {
669 718 duration: 1000,
670 - onComplete: function() {
671 - document.getElementById('download-png-img').href = myChart.toBase64Image();
672 - }
673 719 },
674 720 indexAxis: _indexAxis,
675 721 plugins: chartPlugins
676 722 },
@@ -738,9 +784,8 @@
738 784 animation: {
739 785 duration: 700,
740 786 onComplete: function() {
741 787 jQuery('#cp-footer-buttons').slideDown(200);
742 - document.getElementById('download-png-img').href = myChart.toBase64Image();
743 788 }
744 789 },
745 790 indexAxis: _indexAxis,
746 791 plugins: chartPlugins
@@ -747,8 +792,15 @@
747 792 },
748 793 plugins:[plugin]
749 794 });
750 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 +
751 803 }
752 804 // =====================================================================
753 805 // Disk I/O chart.
754 806
@@ -767,11 +819,8 @@
767 819 type: 'line',
768 820 options: {
769 821 animation: {
770 822 duration: 1000,
771 - onComplete: function() {
772 - document.getElementById('download-png-img').href = myChart.toBase64Image();
773 - }
774 823 },
775 824 indexAxis: _indexAxis,
776 825 plugins: chartPlugins
777 826 },
@@ -838,9 +887,8 @@
838 887 animation: {
839 888 duration: 700,
840 889 onComplete: function() {
841 890 jQuery('#cp-footer-buttons').slideDown(200);
842 - document.getElementById('download-png-img').href = myChart.toBase64Image();
843 891 }
844 892 },
845 893 indexAxis: _indexAxis,
846 894 plugins: chartPlugins
@@ -846,8 +894,15 @@
846 894 plugins: chartPlugins
847 895 },
848 896 plugins:[plugin]
849 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 + }
850 905 }
851 906
852 907 // =====================================================================
853 908 // Settings page