mapcomplete/UI/Img.ts

17 lines
358 B
TypeScript
Raw Normal View History

export class Img {
2020-11-06 02:17:27 +00:00
public static runningFromConsole = false;
2020-11-05 11:28:02 +00:00
static AsData(source:string){
2020-11-06 02:17:27 +00:00
if(this.runningFromConsole){
return source;
}
2020-11-05 11:28:02 +00:00
return `data:image/svg+xml;base64,${(btoa(source))}`;
}
static AsImageElement(source: string): string{
2020-11-05 11:28:02 +00:00
return `<img src="${Img.AsData(source)}">`;
}
}