From 0dc2819b173dd67471367e97cbc64e6b50d0fb3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n?= <58742147+dip000@users.noreply.github.com> Date: Sun, 20 Feb 2022 16:46:28 -0600 Subject: [PATCH] final fixes to merge --- MapBuilderForWeb/MapBuilder.js | 17 +++++++++++------ MapBuilderForWeb/MultimapMechanics.js | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/MapBuilderForWeb/MapBuilder.js b/MapBuilderForWeb/MapBuilder.js index c494831..fb4d9a4 100644 --- a/MapBuilderForWeb/MapBuilder.js +++ b/MapBuilderForWeb/MapBuilder.js @@ -414,12 +414,17 @@ function Point(x, y){ /////////////////////////// UPLOAD ///////////////////////////////////////////////// function upload(uploadString){ - let mapsAndShapesString = uploadString.split("$"); - let mapsString = mapsAndShapesString[0].split("&"); - let shapesString = mapsAndShapesString[1].split("&"); - - uploadShapes(shapesString); - uploadMaps(mapsString); + let mapsAndShapesString, mapsString, shapesString; + try{ + mapsAndShapesString = uploadString.split("$"); + mapsString = mapsAndShapesString[0].split("&"); + shapesString = mapsAndShapesString[1].split("&"); + } catch{ alert("Couldn't parse. File corrupted"); return; } + + try{ uploadShapes(shapesString);} catch{ alert("Shapes couldn't be loaded"); return;} + + try{ uploadMaps(mapsString);} catch{ alert("Maps couldn't be loaded"); return;} + ChangeItem(0); } diff --git a/MapBuilderForWeb/MultimapMechanics.js b/MapBuilderForWeb/MultimapMechanics.js index fd9dd68..1f2074a 100644 --- a/MapBuilderForWeb/MultimapMechanics.js +++ b/MapBuilderForWeb/MultimapMechanics.js @@ -173,7 +173,9 @@ document.querySelector('input[type=file]').value = ""; } - try{ reader.readAsText( file ); } catch{} + if(file){ + try{ reader.readAsText( file ); } catch{ alert("This file Cannot be uploaded"); } + } } function downloadManager(){