Skip to content

Commit

Permalink
downloading of runs
Browse files Browse the repository at this point in the history
  • Loading branch information
vincens2005 committed Dec 16, 2021
1 parent f544911 commit df5fc85
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,18 @@ function jsonToRun(json: string): boolean {
}
}

function downloadRun(): void {
let run = runToJson(currentRun);
let file = new Blob([run], {
type: "application/json"
});
let url = URL.createObjectURL(file);
let link = document.createElement("a");
link.href = url;
link.download = "currentRun.runmap";
link.click();
}

function loadRun(): void {
// TODO
// we can check the reurn value of jsonToRun in order to check if the load was successful.
Expand All @@ -234,6 +246,7 @@ function setupUserControls(): void {
followRoadsElement.onclick = () => closeMenuAction(toggleFollowRoads);
clearRunElement.onclick = () => closeMenuAction(clearRun);
loadRunElement.onclick = () => closeMenuAction(loadRun);
saveRunElement.onclick = () => closeMenuAction(downloadRun);

const id = preferenceService.getMapStyle();
setSelectedMapToggleStyles(document.getElementById(id) as HTMLElement);
Expand Down

0 comments on commit df5fc85

Please sign in to comment.