add get param to load file on page load

merge-requests/1/head
Julien Veyssier 2016-12-08 18:27:50 +01:00
parent 099fd75385
commit b22bc070c0
2 changed files with 18 additions and 8 deletions

View File

@ -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

View File

@ -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);