Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Load polyfills required for IE11
import "@babel/polyfill";
import "custom-event-polyfill/polyfill.js";
import "url-polyfill";
import { Client } from "iframe-coordinator/client";
document.getElementById("path").innerHTML = window.location.hash;
window.onhashchange = function() {
document.getElementById("path").innerHTML = window.location.hash;
};
// Start intercepting link click events for routing
let iframeClient = new Client();
iframeClient.addListener("environmentalData", envData => {
document.getElementById("client-data").value = JSON.stringify(envData);
});
iframeClient.messaging.addListener("host.topic", publication => {
console.log("Got Publish event:", publication);
});
iframeClient.start();
document.getElementById("do-publish").addEventListener("click", () => {
//Get the topic and the data to publish from the form
let topic = document.getElementById("pub-topic").value;
let data = JSON.parse(document.getElementById("pub-data").value);
//Publish the data