debug-bar.js 624 B

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