@@ -11,6 +11,7 @@ let sectionCount = 0;
11
11
let mode = "Entries" ;
12
12
13
13
let shlContents ;
14
+ let originalShlContents ;
14
15
15
16
// Sqrl setting. See https://v7--squirrellyjs.netlify.app/docs/v7/auto-escaping
16
17
Sqrl . autoEscaping ( false ) ;
@@ -51,7 +52,7 @@ function updateDisplayMode(displayMode) {
51
52
update ( e , ( shlContents . length === 1 ? "" : i ) ) ;
52
53
} ) ;
53
54
if ( config . show_demo ) {
54
- $ ( '#ipsInput' ) . val ( JSON . stringify ( shlContents [ 0 ] , null , 2 ) ) ;
55
+ $ ( '#ipsInput' ) . val ( JSON . stringify ( originalShlContents [ 0 ] , null , 2 ) ) ;
55
56
updateFromText ( ) ;
56
57
}
57
58
} ;
@@ -180,14 +181,13 @@ function loadBase64EncodedPDF(base64Data) {
180
181
}
181
182
182
183
function prepareSHLContents ( contents ) {
183
- if ( ! Array . isArray ( contents ) ) {
184
- contents = [ contents ] ;
185
- }
186
- shlContents = contents . reverse ( ) ;
184
+ originalShlContents = Array . isArray ( contents ) ? contents : [ contents ] ;
185
+ shlContents = JSON . parse ( JSON . stringify ( originalShlContents ) ) . reverse ( ) ;
187
186
var jqxh = $ . get ( new URL ( `../templates/IPS.html` , import . meta. url ) . href , function ( ) { } )
188
187
. done ( function ( template ) {
189
188
shlContents . forEach ( ( e , i ) => {
190
189
let data = { index : i } ;
190
+ // Create tabs at the top if more than 1 IPS or if in demo mode
191
191
if ( shlContents . length > ( config . show_demo ? 0 : 1 ) ) {
192
192
addTab ( `IPS ${ i + 1 } ` , i ) ;
193
193
} else {
@@ -204,7 +204,7 @@ function prepareSHLContents(contents) {
204
204
addTab ( "IPS Demo" , "Demo" ) ;
205
205
$ ( Sqrl . Render ( template , { index : "Demo" } ) )
206
206
. appendTo ( '#rendered-ips' ) ;
207
- $ ( '#ipsInput' ) . val ( JSON . stringify ( shlContents [ 0 ] , null , 2 ) ) ;
207
+ $ ( '#ipsInput' ) . val ( JSON . stringify ( originalShlContents [ 0 ] , null , 2 ) ) ;
208
208
updateFromText ( ) ;
209
209
$ ( "#submit" ) . on ( 'click' , updateFromText ) ;
210
210
$ ( '#clearSample' ) . on ( 'click' , clearData ) ;
0 commit comments