Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ <h2><i class="fa fa-unlock-alt"></i> <strong>{{ title }}</strong></h2>
'download': 'Safari has a bug that means your work will be downloaded as an un-named file. Please rename it to something ending in .hex. Alternatively, use a browser such as Firefox or Chrome. They do not suffer from this bug.',
'save': 'Safari has a bug that means your work will be downloaded as an un-named file. Please rename it to something ending in .py. Alternatively, use a browser such as Firefox or Chrome. They do not suffer from this bug.',
'length': 'Oops! Your script is too long given the limited memory on the device.',
'unrecognised_hex': "Sorry, we couldn't recognise this file",
'snippets': 'Snippets are disabled when blockly is enabled.'
},
'confirms': {
Expand Down
25 changes: 20 additions & 5 deletions python-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,16 @@ function web_editor(config) {
setName(f.name.replace('.hex', ''));
setDescription(config.translate.drop.hex);
reader.onload = function(e) {
var code = upyhex.extractPyStrFromIntelHex(
e.target.result);
if(code.length < 8192) {
var code = '';
var showAlert = false;
try {
code = upyhex.extractPyStrFromIntelHex(e.target.result);
} catch(e) {
showAlert = true;
}
if (showAlert || code.length === 0) {
return alert(config.translate.alerts.unrecognised_hex);
} else {
EDITOR.setCode(code);
}
};
Expand Down Expand Up @@ -579,8 +586,16 @@ function web_editor(config) {
setName(file.name.replace('.hex', ''));
setDescription(config.translate.drop.hex);
reader.onload = function(e) {
var code = upyhex.extractPyStrFromIntelHex(e.target.result);
if (code.length < 8192) {
var code = '';
var showAlert = false;
try {
code = upyhex.extractPyStrFromIntelHex(e.target.result);
} catch(e) {
showAlert = true;
}
if (showAlert || code.length === 0) {
return alert(config.translate.alerts.unrecognised_hex);
} else {
EDITOR.setCode(code);
}
};
Expand Down