diff --git a/CHANGELOG.md b/CHANGELOG.md index a2a463d..77e1589 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - symbol selects include icons [#6](https://gitlab.com/eneiluj/gpxedit-oc/issues/6) @eneiluj - gpx route parsing, save it as route +- GET param to load file on page load ### Changed - detach marker and tooltip styling option diff --git a/js/gpxedit.js b/js/gpxedit.js index 27c1bb9..6824a03 100644 --- a/js/gpxedit.js +++ b/js/gpxedit.js @@ -736,6 +736,16 @@ function hideSaveSuccessAnimation(){ $('#saved').fadeOut(); } +function loadAction(file){ + loadFile(file); + // set save name + var spl = file.split('/'); + var basename = spl[spl.length-1]; + $('input#saveName').val( + basename.replace(/\.jpg$/, '.gpx').replace(/\.kml$/, '.gpx').replace(/\.csv$/, '.gpx') + ); +} + function loadFile(file){ var req = { path : file @@ -1032,14 +1042,7 @@ $(document).ready(function(){ var treeurl = OC.generateUrl('/apps/gpxedit/getdircontent'); $('#loadtree').fileTree({root: '/', script: treeurl, multiFolder: false }, function(file) { - gpxedit.fileToLoad = file; - loadFile(file); - // set save name - var spl = file.split('/'); - var basename = spl[spl.length-1]; - $('input#saveName').val( - basename.replace(/\.jpg$/, '.gpx').replace(/\.kml$/, '.gpx').replace(/\.csv$/, '.gpx') - ); + loadAction(file); }); var savetreeurl = OC.generateUrl('/apps/gpxedit/getdircontentdir'); @@ -1093,6 +1096,12 @@ $(document).ready(function(){ $(this).addClass(symbolSelectClasses[$(this).val()]); }); + // load a file if 'file' GET url parameter was given + var fileparam = getUrlParameter('file'); + if (fileparam){ + loadAction(fileparam); + } + }); })(jQuery, OC);