diff --git a/StartServerWindows.bat b/StartServerWindows.bat index 2ea1bccdb..b81638194 100644 --- a/StartServerWindows.bat +++ b/StartServerWindows.bat @@ -1,2 +1,2 @@ @echo off -node_modules\.bin\webpack-dev-server --host 0.0.0.0 --port 80 --content-base .\ +node_modules\.bin\webpack-dev-server --host 0.0.0.0 --content-base . diff --git a/playground/index.html b/playground/index.html index 20b8db310..0492fac97 100644 --- a/playground/index.html +++ b/playground/index.html @@ -15,7 +15,8 @@ <p> <a id="renderexplorer-link" href="#">Renderer</a><br /> <a id="threadexplorer-link" href="#">VM Threads</a><br /> - <a id="blockexplorer-link" href="#">VM Block Representation</a> + <a id="blockexplorer-link" href="#">VM Block Representation</a><br /> + <a id="importexport-link" href="#">Import/Export XML</a> </p> <div id="tab-renderexplorer"> Render<br /> @@ -29,6 +30,16 @@ Block explorer <pre id="blockexplorer"></pre> </div> + <div id="tab-importexport"> + Import/Export XML + <p> + <input type="button" value="Export to XML" onclick="toXml()"> + + <input type="button" value="Import from XML" onclick="fromXml()" id="import"> + <br><br> + <textarea id="importExport" style="width: 480px; height: 360px"></textarea> + </p> + </div> </div> <div id="blocks"></div> @@ -741,5 +752,20 @@ <script src="../vm.worker.js"></script> <!-- Playground --> <script src="./playground.js"></script> + <script> + function toXml() { + var output = document.getElementById('importExport'); + var xml = Blockly.Xml.workspaceToDom(workspace); + output.value = Blockly.Xml.domToPrettyText(xml); + output.focus(); + output.select(); + } + + function fromXml() { + var input = document.getElementById('importExport'); + var xml = Blockly.Xml.textToDom(input.value); + Blockly.Xml.domToWorkspace(workspace, xml); + } + </script> </body> </html> diff --git a/playground/playground.css b/playground/playground.css index a15e1d81c..c2f65505a 100644 --- a/playground/playground.css +++ b/playground/playground.css @@ -20,7 +20,7 @@ a { bottom: 0; width: 35%; } -#blockexplorer, #threadexplorer { +#blockexplorer, #threadexplorer, #importexport { position: absolute; width: 100%; height: 75%; @@ -32,6 +32,6 @@ a { font-size: 10pt; } -#tab-blockexplorer, #tab-threadexplorer { +#tab-blockexplorer, #tab-threadexplorer, #tab-importexport { display: none; } diff --git a/playground/playground.js b/playground/playground.js index 2367d539c..03103e6ad 100644 --- a/playground/playground.js +++ b/playground/playground.js @@ -129,6 +129,7 @@ window.onload = function() { var tabBlockExplorer = document.getElementById('tab-blockexplorer'); var tabThreadExplorer = document.getElementById('tab-threadexplorer'); var tabRenderExplorer = document.getElementById('tab-renderexplorer'); + var tabImportExport = document.getElementById('tab-importexport'); // Handlers to show different explorers. document.getElementById('threadexplorer-link').addEventListener('click', @@ -138,6 +139,7 @@ window.onload = function() { tabBlockExplorer.style.display = 'none'; tabRenderExplorer.style.display = 'none'; tabThreadExplorer.style.display = 'block'; + tabImportExport.style.display = 'none'; }); document.getElementById('blockexplorer-link').addEventListener('click', function () { @@ -146,6 +148,7 @@ window.onload = function() { tabBlockExplorer.style.display = 'block'; tabRenderExplorer.style.display = 'none'; tabThreadExplorer.style.display = 'none'; + tabImportExport.style.display = 'none'; }); document.getElementById('renderexplorer-link').addEventListener('click', function () { @@ -153,5 +156,14 @@ window.onload = function() { tabBlockExplorer.style.display = 'none'; tabRenderExplorer.style.display = 'block'; tabThreadExplorer.style.display = 'none'; + tabImportExport.style.display = 'none'; + }); + document.getElementById('importexport-link').addEventListener('click', + function () { + window.exploreTabOpen = false; + tabBlockExplorer.style.display = 'none'; + tabRenderExplorer.style.display = 'none'; + tabThreadExplorer.style.display = 'none'; + tabImportExport.style.display = 'block'; }); };