mirror of
https://github.com/maputnik/editor.git
synced 2026-09-02 02:17:26 +00:00
a22476cab2
Adds lint to CI and fixes errors. I'm not sure I'm fully proud of all the solutions there. But there's no lint issues and the lint is being checked as part of the CI. --------- Co-authored-by: Yuri Astrakhan <yuriastrakhan@gmail.com>
32 lines
855 B
TypeScript
32 lines
855 B
TypeScript
// @ts-ignore
|
|
import style from './style'
|
|
|
|
export function initialStyleUrl() {
|
|
const initialUrl = new URL(window.location.href);
|
|
return initialUrl.searchParams.get('style');
|
|
}
|
|
|
|
export function loadStyleUrl(styleUrl: string, cb: (...args: any[]) => void) {
|
|
console.log('Loading style', styleUrl)
|
|
fetch(styleUrl, {
|
|
mode: 'cors',
|
|
credentials: "same-origin"
|
|
})
|
|
.then(function(response) {
|
|
return response.json();
|
|
})
|
|
.then(function(body) {
|
|
cb(style.ensureStyleValidity(body))
|
|
})
|
|
.catch(function() {
|
|
console.warn('Could not fetch default style', styleUrl)
|
|
cb(style.emptyStyle)
|
|
})
|
|
}
|
|
|
|
export function removeStyleQuerystring() {
|
|
const initialUrl = new URL(window.location.href);
|
|
initialUrl.searchParams.delete('style');
|
|
window.history.replaceState({}, document.title, initialUrl.toString())
|
|
}
|