forked from MapComplete/MapComplete
Add a download utility (currently unused)
This commit is contained in:
parent
6423957d33
commit
06ddf37817
1 changed files with 6 additions and 0 deletions
6
Utils.ts
6
Utils.ts
|
@ -291,6 +291,11 @@ export class Utils {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a 'download file' popup which will download the contents
|
||||
* @param contents
|
||||
* @param fileName
|
||||
*/
|
||||
public static downloadTxtFile (contents: string, fileName: string = "download.txt") {
|
||||
const element = document.createElement("a");
|
||||
const file = new Blob([contents], {type: 'text/plain'});
|
||||
|
@ -299,6 +304,7 @@ export class Utils {
|
|||
document.body.appendChild(element); // Required for this to work in FireFox
|
||||
element.click();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface TileRange{
|
||||
|
|
Loading…
Reference in a new issue