diff options
| -rwxr-xr-x | history.txt | 4 | ||||
| -rw-r--r-- | objects.js | 27 |
2 files changed, 23 insertions, 8 deletions
diff --git a/history.txt b/history.txt index 5fb2b40..bcf8e5c 100755 --- a/history.txt +++ b/history.txt @@ -2120,3 +2120,7 @@ ______ * text-encoding fix for exporting variable contents, thanks, Blob! * set turbo mode block fix, thanks, Michael and Nathan! * enable storage and retrieval of first-class costumes in both file formats + +140502 +------ +* error message when trying to import a non-text file into a variable, thanks, Nate! @@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2014-April-30'; +modules.objects = '2014-May-02'; var SpriteMorph; var StageMorph; @@ -6450,7 +6450,17 @@ WatcherMorph.prototype.userMenu = function () { inp.addEventListener( "change", function () { - var file, i; + var file; + + function txtOnlyMsg(ftype) { + ide.inform( + 'Unable to import', + 'Snap! can only import "text" files.\n' + + 'You selected a file of type "' + + ftype + + '".' + ); + } function readText(aFile) { var frd = new FileReader(); @@ -6460,18 +6470,19 @@ WatcherMorph.prototype.userMenu = function () { e.target.result ); }; - frd.readAsText(aFile); + + if (aFile.type.indexOf("text") === 0) { + frd.readAsText(aFile); + } else { + txtOnlyMsg(aFile.type); + } } document.body.removeChild(inp); ide.filePicker = null; if (inp.files.length > 0) { file = inp.files[inp.files.length - 1]; - if (file.type.indexOf("text") === 0) { - readText(file); - } else { - ide.inform("Unable to import", "Snap! can only import \"text\" files.\n You selected a file of type \"" + file.type + "\"."); - } + readText(file); } }, false |
