save arduino code locally

zeedee
Stephen Gilardi 7 years ago
parent 7e43bd7469
commit 2ca42d0484
  1. 13
      blockly/apps/blocklyduino/blockly_helper.js
  2. 1
      blockly/apps/blocklyduino/index.html

@ -31,6 +31,19 @@ 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")
fileName = fileName + ".ino";
//doesn't save if the user quits the save prompt
if(fileName == "null"){
var blob = new Blob([Blockly.Arduino.workspaceToCode()], {type: "text/plain;charset=utf-8"});
saveAs(blob, fileName);
}
}
/**
* Save blocks to local file.
* better include Blob and FileSaver for browser compatibility

@ -294,6 +294,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