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;
|
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") {
|
public static downloadTxtFile (contents: string, fileName: string = "download.txt") {
|
||||||
const element = document.createElement("a");
|
const element = document.createElement("a");
|
||||||
const file = new Blob([contents], {type: 'text/plain'});
|
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
|
document.body.appendChild(element); // Required for this to work in FireFox
|
||||||
element.click();
|
element.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TileRange{
|
export interface TileRange{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue