fix fullscreen button & add it to the main list
This commit is contained in:
parent
061278ec0a
commit
af84552e32
28
main.js
28
main.js
@ -7,6 +7,9 @@
|
||||
// @match https://rst.runcity.org/*/cp_mgmt*
|
||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=runcity.org
|
||||
// @grant none
|
||||
// @require https://code.jquery.com/jquery-3.7.1.min.js
|
||||
// @require https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js
|
||||
// @require https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js
|
||||
// ==/UserScript==
|
||||
|
||||
(function () {
|
||||
@ -115,6 +118,8 @@
|
||||
document.head.appendChild(script)
|
||||
}
|
||||
|
||||
const sleep = ms => new Promise(res => setTimeout(res, ms));
|
||||
|
||||
function isEditCpPage() {
|
||||
let params = new URLSearchParams(document.location.search)
|
||||
return params.get("action") === "edit"
|
||||
@ -751,6 +756,15 @@
|
||||
|
||||
}
|
||||
|
||||
function addFullscreenButton() {
|
||||
$(async () => {
|
||||
while (L.Control.Fullscreen === undefined) {
|
||||
await sleep(500)
|
||||
}
|
||||
map.addControl(new L.Control.Fullscreen())
|
||||
})
|
||||
}
|
||||
|
||||
let styles = `
|
||||
.large-menu {
|
||||
position: sticky;
|
||||
@ -1148,19 +1162,18 @@
|
||||
return
|
||||
}
|
||||
|
||||
addJs('https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js')
|
||||
addCss('https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css')
|
||||
|
||||
addFullscreenButton()
|
||||
|
||||
if (!isEditCpPage()) {
|
||||
return
|
||||
}
|
||||
|
||||
/* action=edit HEAD */
|
||||
|
||||
addJs("https://code.jquery.com/jquery-3.7.1.min.js")
|
||||
addJs("https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js")
|
||||
addJs("https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js")
|
||||
addJs('https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js')
|
||||
|
||||
addCss("https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css")
|
||||
addCss('https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css')
|
||||
addCss("https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css")
|
||||
|
||||
/* NEW DEFALUT VALUES */
|
||||
@ -1427,9 +1440,6 @@
|
||||
contentWrapper.appendChild(document.querySelector("form"))
|
||||
contentWrapper.appendChild(document.querySelector("#map-wrapper"))
|
||||
content.appendChild(contentWrapper)
|
||||
$(() => {
|
||||
map.addControl(new L.Control.Fullscreen())
|
||||
})
|
||||
|
||||
let panToCenter = document.createElement("button")
|
||||
panToCenter.type = "button"
|
||||
|
Loading…
Reference in New Issue
Block a user