update blockly

This commit is contained in:
Silver Kuusik
2018-08-17 15:32:56 +02:00
parent c588d70009
commit 0842926b35
21 changed files with 1239 additions and 1067 deletions

View File

@@ -183,10 +183,14 @@ window.addEventListener('load', function() {
Blockly.svgResize(workspace);
// Retrieve the blocks
var xml = Blockly.Xml.textToDom(getLocalStorageItem('sumorobot.blockly'));
// Resume the blocks
Blockly.Xml.domToWorkspace(xml, workspace);
var code = getLocalStorageItem('sumorobot.blockly');
// When there is code
if (code) {
// Convert it to XML
var xml = Blockly.Xml.textToDom(code);
// Resume the blocks from the XML
Blockly.Xml.domToWorkspace(xml, workspace);
}
// On Blockly code change
function onCodeChanged(event) {
// When the if condition block was created
@@ -229,13 +233,13 @@ window.addEventListener('load', function() {
}
}
// Add a change listener to Blockly
// Add the change listener to Blockly
workspace.addChangeListener(onCodeChanged);
// Set a click listener on the document
$(document).click(function(e) {
// Get the event target
var target = e.target;
// When control_if block is in use
if (controlBlockId != '') {
// When the user clicks anywhere outside the mutator and not on the mutator icon