forked from MapComplete/MapComplete
Move imageAttributionSources around, improve fixTheme script
This commit is contained in:
parent
8bca83d708
commit
aaaf876257
15 changed files with 125 additions and 43 deletions
29
Utils.ts
29
Utils.ts
|
@ -1,5 +1,4 @@
|
|||
import * as colors from "./assets/colors.json"
|
||||
import {Util} from "leaflet";
|
||||
|
||||
export class Utils {
|
||||
|
||||
|
@ -324,6 +323,34 @@ export class Utils {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static externalDownloadFunction: (url: string) => Promise<any>;
|
||||
|
||||
public static downloadJson(url: string): Promise<any>{
|
||||
if(this.externalDownloadFunction !== undefined){
|
||||
return this.externalDownloadFunction(url)
|
||||
}
|
||||
|
||||
return new Promise(
|
||||
(resolve, reject) => {
|
||||
try{
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.onload = () => {
|
||||
if (xhr.status == 200) {
|
||||
resolve(JSON.parse(xhr.response))
|
||||
} else {
|
||||
reject(xhr.statusText)
|
||||
}
|
||||
};
|
||||
xhr.open('GET', url);
|
||||
xhr.send();
|
||||
}catch(e){
|
||||
reject(e)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a 'download file' popup which will download the contents
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue