forked from marva/sumorobot-web
fix resuming blocks & code
This commit is contained in:
parent
1a8bbaf087
commit
342d07ee58
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user