Add To Playground

This commit is contained in:
TheBrokenRail 2016-12-03 13:25:15 -05:00 committed by GitHub
parent 05a827c0ea
commit 39e71aa4f4

View file

@ -52,9 +52,9 @@
<button id="projectLoadButton">Load</button>
<button id="createEmptyProject">New Project</button><br />
<p>
<input type="button" value="Export to XML" onclick="toXml()">
<input type="button" value="Export to JSON" onclick="toJson()">
&nbsp;
<input type="button" value="Import from XML" onclick="fromXml()" id="import">
<input type="button" value="Import from JSON" onclick="fromJson()" id="import">
<br /><br />
<textarea id="importExport"></textarea>
</p>
@ -70,18 +70,17 @@
<!-- Playground -->
<script src="./playground.js"></script>
<script>
function toXml() {
function toJson() {
var output = document.getElementById('importExport');
var xml = Blockly.Xml.workspaceToDom(workspace);
output.value = Blockly.Xml.domToPrettyText(xml);
var json = window.vm.toJSON(workspace);
output.value = json;
output.focus();
output.select();
}
function fromXml() {
function fromJson() {
var input = document.getElementById('importExport');
var xml = Blockly.Xml.textToDom(input.value);
Blockly.Xml.domToWorkspace(workspace, xml);
window.vm.fromJSON(input.value);
}
</script>
</body>