version 0.3
This commit is contained in:
parent
3fb2db279f
commit
8eed835aa2
@ -1,5 +1,4 @@
|
|||||||
# SAC Route Portal GPX Downloader
|
# SAC Route Portal GPX Downloader
|
||||||
|
|
||||||
The [Swiss Alpine Club](https://www.sac-cas.ch/en/) has a great
|
The [Swiss Alpine Club](https://www.sac-cas.ch/en/) has a great
|
||||||
[route portal](https://www.sac-cas.ch/en/huts-and-tours/sac-route-portal/)
|
[route portal](https://www.sac-cas.ch/en/huts-and-tours/sac-route-portal/)
|
||||||
for finding interesting hiking routes.
|
for finding interesting hiking routes.
|
||||||
|
@ -129,11 +129,14 @@ function listener(details) {
|
|||||||
let buffer = await blob.arrayBuffer();
|
let buffer = await blob.arrayBuffer();
|
||||||
let str = decoder.decode(buffer);
|
let str = decoder.decode(buffer);
|
||||||
|
|
||||||
gpxTrack = JSON.parse(str);
|
|
||||||
updateActiveTab(browser.tabs);
|
updateActiveTab(browser.tabs);
|
||||||
|
|
||||||
filter.write(encoder.encode(str));
|
filter.write(encoder.encode(str));
|
||||||
filter.close();
|
filter.close();
|
||||||
|
|
||||||
|
let geoJson = JSON.parse(str);
|
||||||
|
const routeTitle = trackTitle(geoJson);
|
||||||
|
gpxTrack = {title: routeTitle, data: toGpx(geoJson)};
|
||||||
};
|
};
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
@ -162,14 +165,12 @@ function handleClick(tab) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let blob = new Blob([toGpx(gpxTrack)], {type: "application/gpx+xml"});
|
let blob = new Blob([gpxTrack.data], {type: "application/gpx+xml"});
|
||||||
let objectURL = URL.createObjectURL(blob);
|
let objectURL = URL.createObjectURL(blob);
|
||||||
|
|
||||||
const routeTitle = trackTitle(gpxTrack);
|
|
||||||
|
|
||||||
let downloading = browser.downloads.download({
|
let downloading = browser.downloads.download({
|
||||||
url : objectURL,
|
url : objectURL,
|
||||||
filename : `track-${routeTitle}.gpx`,
|
filename : `track-${gpxTrack.title}.gpx`,
|
||||||
saveAs: true,
|
saveAs: true,
|
||||||
conflictAction : 'uniquify'
|
conflictAction : 'uniquify'
|
||||||
});
|
});
|
||||||
@ -209,7 +210,7 @@ function updateIcon(tab) {
|
|||||||
tabId: tab.id
|
tabId: tab.id
|
||||||
});
|
});
|
||||||
browser.browserAction.setTitle({
|
browser.browserAction.setTitle({
|
||||||
title: hasTrack ? `Download track ${trackTitle(gpxTrack)}` : 'No track selected',
|
title: hasTrack ? `Download track ${gpxTrack.title}` : 'No track selected',
|
||||||
tabId: tab.id
|
tabId: tab.id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "SAC Route Portal GPX Downloader",
|
"name": "SAC Route Portal GPX Downloader",
|
||||||
"version": "0.2",
|
"version": "0.3",
|
||||||
"developer": {
|
"developer": {
|
||||||
"name": "Sebastian Hugentobler",
|
"name": "Sebastian Hugentobler",
|
||||||
"url": "https://code.vanwa.ch/sebastian/sac-route-portal-gpx-fx"
|
"url": "https://code.vanwa.ch/sebastian/sac-route-portal-gpx-fx"
|
||||||
|
Loading…
Reference in New Issue
Block a user