From 07540659c955c3706140a3023a595790789eac3a Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Thu, 15 Dec 2016 04:07:29 +0100 Subject: [PATCH] error dialog if try to load anything else than gpx,kml,csv,jpg --- js/gpxedit.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/gpxedit.js b/js/gpxedit.js index 9c062a9..ad52dde 100644 --- a/js/gpxedit.js +++ b/js/gpxedit.js @@ -171,6 +171,10 @@ var defaultStyle = { weight: 7 }; +function endsWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; +} + function load_map() { var layer = getUrlParameter('layer'); console.log('layer '+layer); @@ -821,6 +825,14 @@ function hideSaveSuccessAnimation(){ } function loadAction(file){ + if (!endsWith(file, '.gpx') || + !endsWith(file, '.kml') || + !endsWith(file, '.jpg') || + !endsWith(file, '.csv')){ + OC.dialogs.alert(t('gpxedit', 'This file cannot be loaded'),t('gpxedit', 'Load error')); + return; + } + loadFile(file); // set save name var spl = file.split('/');