Move imageAttributionSources around, improve fixTheme script

This commit is contained in:
Pieter Vander Vennet 2021-06-22 14:21:32 +02:00
parent 8bca83d708
commit aaaf876257
15 changed files with 125 additions and 43 deletions

View file

@ -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