Skip to content

Instantly share code, notes, and snippets.

@alderg
Created July 11, 2014 21:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alderg/c0ad5ce81bfbab6875bb to your computer and use it in GitHub Desktop.
Save alderg/c0ad5ce81bfbab6875bb to your computer and use it in GitHub Desktop.
<html>
<head>
<script type="text/javascript">
function edit(xml, callback)
{
var editWindow = window.open('https://www.draw.io/?embed=1&ui=atlas');
var receive = function(evt)
{
if (evt.origin == 'https://www.draw.io')
{
if (evt.data == 'ready')
{
editWindow.postMessage(xml, 'https://www.draw.io');
}
else
{
window.removeEventListener('message', receive);
editWindow.close();
callback(evt.data);
}
}
};
window.addEventListener('message', receive);
}
</script>
</head>
<body>
<button onclick="edit('', function(xml) { console.log(xml); });">Edit</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment