-
Notifications
You must be signed in to change notification settings - Fork 1
/
block-xml-conversion.js
32 lines (30 loc) · 1.02 KB
/
block-xml-conversion.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use strict";
(function() {
document.getElementById("convert-to-ruby-text-btn")
.addEventListener("click", function() {
var workspace = workspace || Blockly.getMainWorkspace();
var xmlDom = Blockly.Xml.workspaceToDom(workspace);
var xmlText = Blockly.Xml.domToPrettyText(xmlDom);
document.getElementById('xml_data').value = xmlText;
});
document.getElementById("convertToXMLButton")
.addEventListener("click", function() {
var workspace = workspace || Blockly.getMainWorkspace();
var xmlText = document.getElementById('xml_data').value;
var xmlDom = null;
try {
xmlDom = Blockly.Xml.textToDom(xmlText);
} catch (e) {
var q =
window.confirm(MSG['badXml'].replace('%1', e));
if (!q) {
return;
}
}
if (xmlDom) {
workspace.clear();
Blockly.Xml.domToWorkspace(xmlDom, workspace);
}
Blockly.svgResize(workspace);
});
})();