add sensebox sensor blocks
This commit is contained in:
@@ -10,49 +10,49 @@ export const workspaceChange = () => (dispatch) => {
|
||||
|
||||
|
||||
export const onChangeWorkspace = (event) => (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: CHANGE_WORKSPACE,
|
||||
})
|
||||
const workspace = Blockly.getMainWorkspace();
|
||||
var code = getState().workspace.code;
|
||||
code.arduino = Blockly.Arduino.workspaceToCode(workspace);
|
||||
var xmlDom = Blockly.Xml.workspaceToDom(workspace);
|
||||
code.xml = Blockly.Xml.domToPrettyText(xmlDom);
|
||||
dispatch({
|
||||
type: NEW_CODE,
|
||||
payload: code
|
||||
});
|
||||
var stats = getState().workspace.stats;
|
||||
if (event.type === Blockly.Events.BLOCK_CREATE) {
|
||||
stats.create += event.ids.length;
|
||||
dispatch({
|
||||
type: CHANGE_WORKSPACE,
|
||||
})
|
||||
const workspace = Blockly.getMainWorkspace();
|
||||
var code = getState().workspace.code;
|
||||
code.arduino = Blockly.Arduino.workspaceToCode(workspace);
|
||||
var xmlDom = Blockly.Xml.workspaceToDom(workspace);
|
||||
code.xml = Blockly.Xml.domToPrettyText(xmlDom);
|
||||
dispatch({
|
||||
type: NEW_CODE,
|
||||
payload: code
|
||||
type: CREATE_BLOCK,
|
||||
payload: stats
|
||||
});
|
||||
var stats = getState().workspace.stats;
|
||||
if (event.type === Blockly.Events.BLOCK_CREATE){
|
||||
stats.create += event.ids.length;
|
||||
}
|
||||
else if (event.type === Blockly.Events.BLOCK_MOVE) {
|
||||
stats.move += 1;
|
||||
dispatch({
|
||||
type: MOVE_BLOCK,
|
||||
payload: stats
|
||||
});
|
||||
}
|
||||
else if (event.type === Blockly.Events.BLOCK_CHANGE) {
|
||||
stats.change += 1;
|
||||
dispatch({
|
||||
type: CHANGE_BLOCK,
|
||||
payload: stats
|
||||
});
|
||||
}
|
||||
else if (event.type === Blockly.Events.BLOCK_DELETE) {
|
||||
if (stats.create > 0) {
|
||||
stats.delete += event.ids.length;
|
||||
dispatch({
|
||||
type: CREATE_BLOCK,
|
||||
type: DELETE_BLOCK,
|
||||
payload: stats
|
||||
});
|
||||
}
|
||||
else if (event.type === Blockly.Events.BLOCK_MOVE){
|
||||
stats.move += 1;
|
||||
dispatch({
|
||||
type: MOVE_BLOCK,
|
||||
payload: stats
|
||||
});
|
||||
}
|
||||
else if (event.type === Blockly.Events.BLOCK_CHANGE){
|
||||
stats.change += 1;
|
||||
dispatch({
|
||||
type: CHANGE_BLOCK,
|
||||
payload: stats
|
||||
});
|
||||
}
|
||||
else if (event.type === Blockly.Events.BLOCK_DELETE){
|
||||
if(stats.create > 0){
|
||||
stats.delete += event.ids.length;
|
||||
dispatch({
|
||||
type: DELETE_BLOCK,
|
||||
payload: stats
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const clearStats = () => (dispatch) => {
|
||||
|
||||
Reference in New Issue
Block a user