1
1
( function ( $ ) {
2
2
"use strict" ;
3
3
4
- let fullHeight = function ( ) {
4
+ const fullHeight = function ( ) {
5
5
$ ( ".js-fullheight" ) . css ( "height" , $ ( window ) . height ( ) ) ;
6
6
$ ( window ) . resize ( function ( ) {
7
7
$ ( ".js-fullheight" ) . css ( "height" , $ ( window ) . height ( ) ) ;
16
16
$ ( ".page-link" ) . on ( "click" , function ( e ) {
17
17
e . preventDefault ( ) ;
18
18
$ ( "#page" ) . val ( $ ( this ) . attr ( "data-val" ) ) ;
19
- $ ( "form" ) . submit ( )
19
+ $ ( "form" ) . submit ( ) ;
20
20
} ) ;
21
21
22
22
$ ( "#logCount" ) . on ( "change" , function ( ) {
23
23
$ ( "#page" ) . val ( "1" ) ;
24
- $ ( "form" ) . submit ( )
24
+ $ ( "form" ) . submit ( ) ;
25
25
} ) ;
26
26
27
27
$ ( "#logFilter" ) . on ( "change" , function ( ) {
28
28
$ ( "#page" ) . val ( "1" ) ;
29
- $ ( "form" ) . submit ( )
29
+ $ ( "form" ) . submit ( ) ;
30
30
} ) ;
31
31
32
32
$ ( "#search" ) . on ( "keypress" , function ( e ) {
38
38
39
39
$ ( ".modal-trigger" ) . on ( "click" , function ( e ) {
40
40
e . preventDefault ( ) ;
41
+
42
+ const modal = $ ( "#messageModal" ) ;
43
+ const modalBody = modal . find ( '.modal-body' ) ;
44
+ const dataType = $ ( this ) . attr ( "data-type" ) ;
41
45
let message = $ ( this ) . find ( "span" ) . text ( ) ;
42
- const isXml = $ ( this ) . attr ( "data-type" ) === "xml" ;
43
- if ( isXml )
46
+
47
+ if ( dataType === "xml" ) {
44
48
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
+ }
45
57
46
- const modal = $ ( "#messageModal" ) ;
47
- modal . find ( '.modal-body pre' ) . text ( message ) ;
58
+ modalBody . find ( 'pre' ) . text ( message ) ;
48
59
modal . modal ( "show" ) ;
49
60
} ) ;
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
- }
75
61
} ) ( jQuery ) ;
0 commit comments