Merge pull request #51 from stevoleeto/saveCode

Save generated Arduino code locally
zeedee
gasolin 7 years ago
commit c1be154c95
  1. 12
      blockly/apps/blocklyduino/blockly_helper.js
  2. 1
      blockly/apps/blocklyduino/index.html

@ -31,6 +31,18 @@ function restore_blocks() {
}
}
/**
* Save Arduino generated code to local file.
*/
function saveCode() {
var fileName = window.prompt('What would you like to name your file?', 'BlocklyDuino')
//doesn't save if the user quits the save prompt
if(fileName){
var blob = new Blob([Blockly.Arduino.workspaceToCode()], {type: 'text/plain;charset=utf-8'});
saveAs(blob, fileName + '.ino');
}
}
/**
* Save blocks to local file.
* better include Blob and FileSaver for browser compatibility

@ -300,6 +300,7 @@ function init() {
<button type="button" onclick="uploadClick()">Upload</button>
<button type="button" onclick="resetClick()">Reset</button>
<button onclick="discard()">Discard</button>
<button onclick="saveCode()">Save Arduino Code</button>
<button onclick="save()">Save XML</button>
<button id="fakeload">Load XML</button>
<input type="file" id="load" style="display: none;"/>

Loading…
Cancel
Save