remove blockly code from sumorobot object

This commit is contained in:
Silver Kuusik
2018-08-15 20:18:56 +02:00
parent 44da136962
commit 1a8bbaf087
3 changed files with 4 additions and 16 deletions

View File

@@ -186,13 +186,11 @@ window.addEventListener('load', function() {
var xml = Blockly.Xml.textToDom(getLocalStorageItem('sumorobot.blockly'));
// Resume the blocks
Blockly.Xml.domToWorkspace(xml, workspace);
// For the code processor
sumorobot.setBlocklyCode(Blockly.Python.workspaceToCode(workspace));
// Show the code in the ace editor, filter out block IDs
readOnlyCodingEditor.setValue('\n' + sumorobot.getBlocklyCode().replace(/;;.{20}/g, ''));
readOnlyCodingEditor.setValue('\n' + Blockly.Python.workspaceToCode(workspace).replace(/;;.{20}/g, ''));
readOnlyCodingEditor.clearSelection();
// Disable the if condition block in the toolbox if it's already used
if (/if/.test(sumorobot.getBlocklyCode())) {
if (/controls_if/.test(xml)) {
workspace.updateToolbox(document.getElementById('toolbox_no_if'));
}