Add button to copy generated code

This commit is contained in:
Jacob Strieb 2019-06-30 01:14:07 -07:00
parent ad4abcf43c
commit f67984d66b
2 changed files with 16 additions and 1 deletions

View File

@ -28,7 +28,8 @@ ${data["css"]}
<script type="text/javascript">
${data["js"]}
</scr` +
// This has to be broken up because otherwise it is recognized as the main document's end script tag
// This has to be broken up because otherwise it is recognized as the main
// document's end script tag
`ipt>
</head>
<body>
@ -65,3 +66,16 @@ function update() {
// Update the <iframe> to display the generated page
window.frames[0].location.replace(`data:text/html,${encodeURIComponent(html)}`);
}
/* Show a prompt with the HTML so the user can copy the code */
function showCopyCodePrompt() {
var data = {
"css" : document.getElementById("css").value,
"js" : document.getElementById("javascript").value,
"html" : document.getElementById("html").value
};
var html = getHTML(data);
window.prompt("Copy to clipboard: ", html)
}

View File

@ -15,6 +15,7 @@
<div id="buttons">
<button><a id="getLinkLink" href="" target="_blank">Get Link</a></button>
<button onclick="showCopyCodePrompt()">Copy Code</button>
</div>
<iframe></iframe>