From 342d07ee582e539e58765b629f17a918b9f313ae Mon Sep 17 00:00:00 2001 From: Silver Kuusik Date: Wed, 15 Aug 2018 20:21:10 +0200 Subject: [PATCH] fix resuming blocks & code --- assets/js/blockly.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/assets/js/blockly.js b/assets/js/blockly.js index f3dcf1c..c93b548 100644 --- a/assets/js/blockly.js +++ b/assets/js/blockly.js @@ -186,13 +186,6 @@ window.addEventListener('load', function() { var xml = Blockly.Xml.textToDom(getLocalStorageItem('sumorobot.blockly')); // Resume the blocks Blockly.Xml.domToWorkspace(xml, workspace); - // Show the code in the ace editor, filter out block IDs - 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 (/controls_if/.test(xml)) { - workspace.updateToolbox(document.getElementById('toolbox_no_if')); - } // On Blockly code change function onCodeChanged(event) { @@ -221,11 +214,8 @@ window.addEventListener('load', function() { // Only process change and move commands if (event.type != Blockly.Events.CHANGE && event.type != Blockly.Events.MOVE) return; - // Generate code from the used blocks - 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(); // Save the code to the local storage