debug-bar.js
23 lines
| 1 | /* global jQuery, JSON */ |
| 2 | |
| 3 | ( function( $ ) { |
| 4 | $( document ).ready( function() { |
| 5 | $( '.jetpack-search-debug-bar .json-toggle-wrap .toggle' ).click( function() { |
| 6 | var t = $( this ), |
| 7 | wrap = t.closest( '.json-toggle-wrap' ), |
| 8 | pre = wrap.find( 'pre' ), |
| 9 | content = pre.text(), |
| 10 | isPretty = wrap.hasClass( 'pretty' ); |
| 11 | |
| 12 | if ( ! isPretty ) { |
| 13 | pre.text( JSON.stringify( JSON.parse( content ), null, 2 ) ); |
| 14 | } else { |
| 15 | content.replace( '\t', '' ).replace( '\n', '' ).replace( ' ', '' ); |
| 16 | pre.text( JSON.stringify( JSON.parse( content ) ) ); |
| 17 | } |
| 18 | |
| 19 | wrap.toggleClass( 'pretty' ); |
| 20 | } ); |
| 21 | } ); |
| 22 | } )( jQuery ); |
| 23 |