fix fullscreen button & add it to the main list

This commit is contained in:
Zhora Shalyapin 2025-03-10 09:53:54 +00:00
parent 061278ec0a
commit af84552e32

28
main.js
View File

@ -7,6 +7,9 @@
// @match https://rst.runcity.org/*/cp_mgmt* // @match https://rst.runcity.org/*/cp_mgmt*
// @icon https://www.google.com/s2/favicons?sz=64&domain=runcity.org // @icon https://www.google.com/s2/favicons?sz=64&domain=runcity.org
// @grant none // @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== // ==/UserScript==
(function () { (function () {
@ -115,6 +118,8 @@
document.head.appendChild(script) document.head.appendChild(script)
} }
const sleep = ms => new Promise(res => setTimeout(res, ms));
function isEditCpPage() { function isEditCpPage() {
let params = new URLSearchParams(document.location.search) let params = new URLSearchParams(document.location.search)
return params.get("action") === "edit" 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 = ` let styles = `
.large-menu { .large-menu {
position: sticky; position: sticky;
@ -1148,19 +1162,18 @@
return 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()) { if (!isEditCpPage()) {
return return
} }
/* action=edit HEAD */ /* 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://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") addCss("https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css")
/* NEW DEFALUT VALUES */ /* NEW DEFALUT VALUES */
@ -1427,9 +1440,6 @@
contentWrapper.appendChild(document.querySelector("form")) contentWrapper.appendChild(document.querySelector("form"))
contentWrapper.appendChild(document.querySelector("#map-wrapper")) contentWrapper.appendChild(document.querySelector("#map-wrapper"))
content.appendChild(contentWrapper) content.appendChild(contentWrapper)
$(() => {
map.addControl(new L.Control.Fullscreen())
})
let panToCenter = document.createElement("button") let panToCenter = document.createElement("button")
panToCenter.type = "button" panToCenter.type = "button"