mirror of
https://github.com/maputnik/editor.git
synced 2026-08-28 07:57:28 +00:00
cd7d607f13
It's apparently forced now to use the eslint.config.js instead of .eslintrc It got more strict with requiring the underscore on unused vars like `catch(_err)` , but that was all Closes #1012 Closes #995 Closes #992 ## Launch Checklist <!-- Thanks for the PR! Feel free to add or remove items from the checklist. --> - [ ] Briefly describe the changes in this PR. - [ ] Link to related issues. - [ ] Include before/after visuals or gifs if this PR includes visual changes. - [ ] Write tests for all new functionality. - [ ] Add an entry to `CHANGELOG.md` under the `## main` section.
31 lines
841 B
TypeScript
31 lines
841 B
TypeScript
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())
|
|
}
|