Skip to content

Commit f4f0fb2

Browse files
committed
Display unmodified content json in ips demo tab
1 parent 329d53e commit f4f0fb2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

static/ips/assets/js/renderIPS.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ let sectionCount = 0;
1111
let mode = "Entries";
1212

1313
let shlContents;
14+
let originalShlContents;
1415

1516
// Sqrl setting. See https://v7--squirrellyjs.netlify.app/docs/v7/auto-escaping
1617
Sqrl.autoEscaping(false);
@@ -51,7 +52,7 @@ function updateDisplayMode(displayMode) {
5152
update(e, (shlContents.length === 1 ? "" : i));
5253
});
5354
if (config.show_demo) {
54-
$('#ipsInput').val(JSON.stringify(shlContents[0], null, 2));
55+
$('#ipsInput').val(JSON.stringify(originalShlContents[0], null, 2));
5556
updateFromText();
5657
}
5758
};
@@ -180,14 +181,13 @@ function loadBase64EncodedPDF(base64Data) {
180181
}
181182

182183
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();
187186
var jqxh = $.get(new URL(`../templates/IPS.html`, import.meta.url).href, function () { })
188187
.done(function (template) {
189188
shlContents.forEach((e, i) => {
190189
let data = { index: i };
190+
// Create tabs at the top if more than 1 IPS or if in demo mode
191191
if (shlContents.length > (config.show_demo ? 0 : 1)) {
192192
addTab(`IPS ${i+1}`, i);
193193
} else {
@@ -204,7 +204,7 @@ function prepareSHLContents(contents) {
204204
addTab("IPS Demo", "Demo");
205205
$(Sqrl.Render(template, {index: "Demo"}))
206206
.appendTo('#rendered-ips');
207-
$('#ipsInput').val(JSON.stringify(shlContents[0], null, 2));
207+
$('#ipsInput').val(JSON.stringify(originalShlContents[0], null, 2));
208208
updateFromText();
209209
$("#submit").on('click', updateFromText);
210210
$('#clearSample').on('click', clearData);

0 commit comments

Comments
 (0)