Skip to content

Commit

Permalink
Merge pull request #501 from artoonie/support-multiple-iframes
Browse files Browse the repository at this point in the history
support multiple iframes
  • Loading branch information
artoonie authored Jul 23, 2024
2 parents 39ccdf2 + f3b1f4c commit 3499791
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion static/visualizer/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ function makeEmbeddedIframeTag(iframeUrl) {
allowfullscreen="allowfullscreen"
onload="
var iframe = this;
var key = '${iframeUrl}' + Math.floor(Math.random() * 10000);
window.addEventListener('message', function(event) {
if (isNaN(event.data.rcvisHeight)) return;
if (event.data.key != key) return;
var height = parseInt(event.data.rcvisHeight);
iframe.height = height + 'px';
}, false);
contentWindow.postMessage({getSize: true}, '*');
contentWindow.postMessage({getSize: true, key: key}, '*');
">
`;
return text;
Expand Down
3 changes: 2 additions & 1 deletion static/visualizer/visualize-nonblocking.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ function setUpIframeMessageListener() {
window.addEventListener('message', function(event) {
if (event.data.getSize == true) {
if (parent == null) return;
var key = event.data.key;

var height = document.getElementById("embedded-content").scrollHeight
+ document.getElementById("embedded-footer").scrollHeight
+ 10;
parent.postMessage({rcvisHeight: height}, "*");
parent.postMessage({rcvisHeight: height, key: key}, "*");
}
});
}
Expand Down

0 comments on commit 3499791

Please sign in to comment.