From ac2b8e774505d679835f8ff05980dada1db96877 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 28 Nov 2018 09:27:03 +0100 Subject: [PATCH] added special checks to make imporing text-based files into vars easier in Windows --- HISTORY.md | 3 +++ snap.html | 2 +- src/objects.js | 21 ++++++++++++++++----- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 206f376c..46c417e5 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,9 @@ # Snap! (BYOB) History ## in development +### 2018-11-28 +* Objects: added special checks to make imporing text-based files into vars easier in Windows + ### 2018-11-27 * Objects: Cache stage>>penTrailsMorph to optimize collision detection * Objects: Fixed a collision detection errror when objects are sub-pixel sized diff --git a/snap.html b/snap.html index f36bfcf2..33cf6887 100755 --- a/snap.html +++ b/snap.html @@ -8,7 +8,7 @@ - + diff --git a/src/objects.js b/src/objects.js index 60734351..4a00b3f3 100644 --- a/src/objects.js +++ b/src/objects.js @@ -83,7 +83,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize, TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph, AlignmentMorph, Process, XML_Element, VectorPaintEditorMorph*/ -modules.objects = '2018-November-27'; +modules.objects = '2018-November-28'; var SpriteMorph; var StageMorph; @@ -9639,10 +9639,21 @@ WatcherMorph.prototype.userMenu = function () { }; if (aFile.type.indexOf("text") === -1) { - txtOnlyMsg( - aFile.type, - function () {frd.readAsText(aFile); } - ); + // special cases for Windows + // check the file extension for text-like-ness + if (contains( + ['txt', 'csv', 'xml', 'json', 'tsv'], + aFile.name.split('.').pop().toLowerCase() + )) { + frd.readAsText(aFile); + } else { + // show a warning and an option + // letting the user load the file anyway + txtOnlyMsg( + aFile.type, + function () {frd.readAsText(aFile); } + ); + } } else { frd.readAsText(aFile); }