forked from marva/sumorobot-web
remove blockly code from sumorobot object
This commit is contained in:
parent
44da136962
commit
1a8bbaf087
@ -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'));
|
||||
}
|
||||
|
||||
|
@ -166,12 +166,12 @@ window.addEventListener('load', function() {
|
||||
// Otherwise when we are in Blockly mode
|
||||
} else {
|
||||
// Get the code from the blocks
|
||||
parsedCode = sumorobot.getBlocklyCode().replace(/;;.{20}/g, '');
|
||||
parsedCode = Blockly.Python.workspaceToCode(workspace).replace(/;;.{20}/g, '');
|
||||
}
|
||||
// Escape the qoutes, replace new lines and send the code
|
||||
//sumorobot.send('code', parsedCode.replace(/"/g, '\\"').replace(/\n/g, ';;'));
|
||||
// Split into lines of code and filter empty lines
|
||||
lines = sumorobot.getBlocklyCode().split('\n').filter(Boolean);
|
||||
lines = Blockly.Python.workspaceToCode(workspace).split('\n').filter(Boolean);
|
||||
// Process the code starting from the first line
|
||||
processCode(0);
|
||||
});
|
||||
|
@ -102,13 +102,3 @@ Sumorobot.prototype.close = function() {
|
||||
// Close the WebSocket connection
|
||||
this.websocket.close();
|
||||
};
|
||||
|
||||
// Function to get SumoRobot Blockly code
|
||||
Sumorobot.prototype.getBlocklyCode = function() {
|
||||
return this.blocklyCode;
|
||||
};
|
||||
|
||||
// Function to set SumoRobot Blockly code
|
||||
Sumorobot.prototype.setBlocklyCode = function(blocklyCode) {
|
||||
this.blocklyCode = blocklyCode;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user