Skip to content

Commit

Permalink
Merge pull request #550 from PVillarmarzo/pvill/customViz
Browse files Browse the repository at this point in the history
Added new message
  • Loading branch information
brianlagunas authored Dec 10, 2024
2 parents 1f597ea + 962fa65 commit 8564627
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
24 changes: 1 addition & 23 deletions docs/web/custom-visualizations.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,12 @@ As mentioned earlier, to consume data from the SDK, you must define the bridge.
var host;
window.revealBridge = {
sendMessageToHost: function (data) {
try {
var iframe = document.createElement("IFRAME");
var message = encodeURIComponent(JSON.stringify(data));
iframe.setAttribute("src", "js-frame:" + message);
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
}
catch (e) {
// The frame couldn't be created.
// This could happen in web environments when the host is not in the same domain than the custom view webpage.
// Is not a problem as we are using window.postMessage for the communication in this case.
}

try {
if (window.parent && window.parent.location) {
window.parent.postMessage(data, "*");
}
} catch (e) {
// window.top.postMessage couldn't be executed.
// window.parent.postMessage couldn't be executed.
// This sould never happen but...
}
},
Expand All @@ -46,14 +32,6 @@ window.revealBridge = {
this.sendMessageToHost({ message: "ready" });
}
},

runAction: function (actionName, data) {
this.sendMessageToHost({ message: "runAction", action: actionName, rowData: data });
},

openUrl: function (url) {
this.sendMessageToHost({ message: "openURL", URL: url });
},
}

function processMessageFromHost(message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,12 @@ Reveal SDK は、アプリケーションにシームレスに統合される、
var host;
window.revealBridge = {
sendMessageToHost: function (data) {
try {
var iframe = document.createElement("IFRAME");
var message = encodeURIComponent(JSON.stringify(data));
iframe.setAttribute("src", "js-frame:" + message);
document.documentElement.appendChild(iframe);
iframe.parentNode.removeChild(iframe);
iframe = null;
}
catch (e) {
// The frame couldn't be created.
// This could happen in web environments when the host is not in the same domain than the custom view webpage.
// Is not a problem as we are using window.postMessage for the communication in this case.
}

try {
if (window.parent && window.parent.location) {
window.parent.postMessage(data, "*");
}
} catch (e) {
// window.top.postMessage couldn't be executed.
// window.parent.postMessage couldn't be executed.
// This sould never happen but...
}
},
Expand All @@ -46,14 +32,6 @@ window.revealBridge = {
this.sendMessageToHost({ message: "ready" });
}
},

runAction: function (actionName, data) {
this.sendMessageToHost({ message: "runAction", action: actionName, rowData: data });
},

openUrl: function (url) {
this.sendMessageToHost({ message: "openURL", URL: url });
},
}

function processMessageFromHost(message) {
Expand Down

0 comments on commit 8564627

Please sign in to comment.