Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -144,27 +144,34 @@
designer.attachTo(document.getElementById("designerRootHost"));
designer.monacoModuleLoaded();

var cardUrl = getParameterByName("card", null);
var dataUrl = getParameterByName("data", null);

if (dataUrl) {
var dataXhttp = new XMLHttpRequest();
dataXhttp.onload = function () {
if (dataXhttp.responseText && dataXhttp.responseText != "") {
var sampleData = JSON.parse(dataXhttp.responseText);
designer.sampleData = sampleData;
}
};

// TODO: when the designer has an addError API we should log that we failed to load the requested card
// xhttp.onerror = function() {
// designer.
// };
var cardParam = getParameterByName("card", null);
var dataParam = getParameterByName("data", null);

if (dataParam) {
try {
dataXhttp.open("GET", dataUrl, true);
var dataUrl = new URL(dataParam);
var dataXhttp = new XMLHttpRequest();
dataXhttp.onload = function () {
if (dataXhttp.responseText && dataXhttp.responseText != "") {
var sampleData = JSON.parse(dataXhttp.responseText);
designer.sampleData = sampleData;
}
};

// TODO: when the designer has an addError API we should log that we failed to load the requested card
// xhttp.onerror = function() {
// designer.
// };

dataXhttp.open("GET", dataParam, true);
dataXhttp.send();
} catch (e) {
// Check if the data is a valid JSON
try {
var sampleData = JSON.parse(dataParam);
designer.sampleData = sampleData;
} catch (e) {
}
}
} else {
// Add sample data
Expand All @@ -188,25 +195,31 @@
designer.sampleData = sampleData;
}

if (cardUrl) {
var cardXhttp = new XMLHttpRequest();
cardXhttp.onload = function () {
if (cardXhttp.responseText && cardXhttp.responseText != "") {
designer.setCard(JSON.parse(cardXhttp.responseText));
}

history.replaceState(null, null, "<%- config.root %>designer");
};

// TODO: when the designer has an addError API we should log that we failed to load the requested card
// xhttp.onerror = function() {
// designer.
// };

try {
cardXhttp.open("GET", cardUrl, true);
if (cardParam) {
try{
var cardUrl = new URL(cardParam);
var cardXhttp = new XMLHttpRequest();
cardXhttp.onload = function () {
if (cardXhttp.responseText && cardXhttp.responseText != "") {
designer.setCard(JSON.parse(cardXhttp.responseText));
}

history.replaceState(null, null, "<%- config.root %>designer");
};

// TODO: when the designer has an addError API we should log that we failed to load the requested card
// xhttp.onerror = function() {
// designer.
// };

cardXhttp.open("GET", cardParam, true);
cardXhttp.send();
} catch (e) {
// Check if the card is a valid JSON
try {
designer.setCard(JSON.parse(cardParam));
} catch (e) {
}
}
} else {
designer.setCard({
Expand Down