Small workaround if data is already parsed, fix #249
This commit is contained in:
parent
095c5d1f1b
commit
f6519073d0
1 changed files with 6 additions and 2 deletions
8
index.ts
8
index.ts
|
@ -84,13 +84,17 @@ if (layoutFromBase64.startsWith("http")) {
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(data);
|
console.log("Received ", data)
|
||||||
|
let parsed = data;
|
||||||
|
if(typeof parsed == "string"){
|
||||||
|
parsed = JSON.parse(data);
|
||||||
|
}
|
||||||
// Overwrite the id to the wiki:value
|
// Overwrite the id to the wiki:value
|
||||||
parsed.id = link;
|
parsed.id = link;
|
||||||
const layout = new LayoutConfig(parsed, false);
|
const layout = new LayoutConfig(parsed, false);
|
||||||
InitUiElements.InitAll(layout, layoutFromBase64, testing, layoutFromBase64, btoa(data));
|
InitUiElements.InitAll(layout, layoutFromBase64, testing, layoutFromBase64, btoa(data));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
new FixedUiElement(`<a href="${link}">${link}</a> is invalid:<br/>${e}<br/> <a href='https://${window.location.host}/'>Go back</a>")`)
|
new FixedUiElement(`<a href="${link}">${link}</a> is invalid:<br/>${e}<br/> <a href='https://${window.location.host}/'>Go back</a>`)
|
||||||
.SetClass("clickable")
|
.SetClass("clickable")
|
||||||
.AttachTo("centermessage");
|
.AttachTo("centermessage");
|
||||||
console.error("Could not parse the text", data)
|
console.error("Could not parse the text", data)
|
||||||
|
|
Loading…
Reference in a new issue