11( function ( $ ) {
22 "use strict" ;
33
4- let fullHeight = function ( ) {
4+ const fullHeight = function ( ) {
55 $ ( ".js-fullheight" ) . css ( "height" , $ ( window ) . height ( ) ) ;
66 $ ( window ) . resize ( function ( ) {
77 $ ( ".js-fullheight" ) . css ( "height" , $ ( window ) . height ( ) ) ;
1616 $ ( ".page-link" ) . on ( "click" , function ( e ) {
1717 e . preventDefault ( ) ;
1818 $ ( "#page" ) . val ( $ ( this ) . attr ( "data-val" ) ) ;
19- $ ( "form" ) . submit ( )
19+ $ ( "form" ) . submit ( ) ;
2020 } ) ;
2121
2222 $ ( "#logCount" ) . on ( "change" , function ( ) {
2323 $ ( "#page" ) . val ( "1" ) ;
24- $ ( "form" ) . submit ( )
24+ $ ( "form" ) . submit ( ) ;
2525 } ) ;
2626
2727 $ ( "#logFilter" ) . on ( "change" , function ( ) {
2828 $ ( "#page" ) . val ( "1" ) ;
29- $ ( "form" ) . submit ( )
29+ $ ( "form" ) . submit ( ) ;
3030 } ) ;
3131
3232 $ ( "#search" ) . on ( "keypress" , function ( e ) {
3838
3939 $ ( ".modal-trigger" ) . on ( "click" , function ( e ) {
4040 e . preventDefault ( ) ;
41+
42+ const modal = $ ( "#messageModal" ) ;
43+ const modalBody = modal . find ( '.modal-body' ) ;
44+ const dataType = $ ( this ) . attr ( "data-type" ) ;
4145 let message = $ ( this ) . find ( "span" ) . text ( ) ;
42- const isXml = $ ( this ) . attr ( "data-type" ) === "xml" ;
43- if ( isXml )
46+
47+ if ( dataType === "xml" ) {
4448 message = formatXml ( message ) ;
49+ $ ( modalBody ) . removeClass ( 'wrapped' ) ;
50+ } else if ( dataType === "json" ) {
51+ const prop = JSON . parse ( message ) ;
52+ message = JSON . stringify ( prop , null , 2 ) ;
53+ $ ( modalBody ) . removeClass ( 'wrapped' ) ;
54+ } else {
55+ $ ( modalBody ) . addClass ( 'wrapped' ) ;
56+ }
4557
46- const modal = $ ( "#messageModal" ) ;
47- modal . find ( '.modal-body pre' ) . text ( message ) ;
58+ modalBody . find ( 'pre' ) . text ( message ) ;
4859 modal . modal ( "show" ) ;
4960 } ) ;
50-
51- function formatXml ( xml ) {
52- const xmlDoc = new DOMParser ( ) . parseFromString ( xml , 'application/xml' ) ;
53- const xsltDoc = new DOMParser ( ) . parseFromString ( [
54- // describes how we want to modify the XML - indent everything
55- '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">' ,
56- ' <xsl:strip-space elements="*"/>' ,
57- ' <xsl:template match="para[content-style][not(text())]">' , // change to just text() to strip space in text nodes
58- ' <xsl:value-of select="normalize-space(.)"/>' ,
59- ' </xsl:template>' ,
60- ' <xsl:template match="node()|@*">' ,
61- ' <xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy>' ,
62- ' </xsl:template>' ,
63- ' <xsl:output indent="yes"/>' ,
64- '</xsl:stylesheet>' ,
65- ] . join ( '\n' ) , 'application/xml' ) ;
66-
67- const xsltProcessor = new XSLTProcessor ( ) ;
68- xsltProcessor . importStylesheet ( xsltDoc ) ;
69-
70- const resultDoc = xsltProcessor . transformToDocument ( xmlDoc ) ;
71- const resultXml = new XMLSerializer ( ) . serializeToString ( resultDoc ) ;
72-
73- return resultXml ;
74- }
7561} ) ( jQuery ) ;
0 commit comments