add copy button
This commit is contained in:
parent
f9e9f75838
commit
ec9a6098aa
31
main.js
31
main.js
@ -110,6 +110,26 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function copyCoordinates() {
|
||||||
|
let copyButton = document.createElement("button")
|
||||||
|
copyButton.addEventListener("click", async event => {
|
||||||
|
event.preventDefault();
|
||||||
|
let lat = document.querySelector(`input[name="cp[lattitude]"]`).value
|
||||||
|
let lon = document.querySelector(`input[name="cp[longitude]"]`).value
|
||||||
|
|
||||||
|
const text = new Blob([`(${lat}, ${lon})`], { type: "text/plain" });
|
||||||
|
const data = new ClipboardItem({ "text/plain": text });
|
||||||
|
await navigator.clipboard.write([data]);
|
||||||
|
})
|
||||||
|
copyButton.classList.add("copy-button")
|
||||||
|
|
||||||
|
let copyImage = document.createElement("img")
|
||||||
|
copyImage.src = "https://upload.wikimedia.org/wikipedia/commons/a/aa/Bw_copy_icon_320x320.svg"
|
||||||
|
copyButton.appendChild(copyImage)
|
||||||
|
|
||||||
|
return copyButton
|
||||||
|
}
|
||||||
|
|
||||||
function yandexMaps(lat, lon, zoom) {
|
function yandexMaps(lat, lon, zoom) {
|
||||||
return `https://yandex.ru/maps/213/moscow/?ll=${lon}%2C${lat}&z=${zoom}`
|
return `https://yandex.ru/maps/213/moscow/?ll=${lon}%2C${lat}&z=${zoom}`
|
||||||
}
|
}
|
||||||
@ -149,6 +169,7 @@
|
|||||||
let lon = document.querySelector(`input[name="cp[longitude]"]`).value
|
let lon = document.querySelector(`input[name="cp[longitude]"]`).value
|
||||||
let linksContainer = document.createElement("div")
|
let linksContainer = document.createElement("div")
|
||||||
|
|
||||||
|
linksContainer.appendChild(copyCoordinates())
|
||||||
linksContainer.appendChild(makeRef(yandexMaps, "https://upload.wikimedia.org/wikipedia/commons/7/72/Yandex_Maps_icon.svg", lat, lon, ZOOM))
|
linksContainer.appendChild(makeRef(yandexMaps, "https://upload.wikimedia.org/wikipedia/commons/7/72/Yandex_Maps_icon.svg", lat, lon, ZOOM))
|
||||||
linksContainer.appendChild(makeRef(googleMaps, "https://upload.wikimedia.org/wikipedia/commons/a/aa/Google_Maps_icon_%282020%29.svg", lat, lon, METERS))
|
linksContainer.appendChild(makeRef(googleMaps, "https://upload.wikimedia.org/wikipedia/commons/a/aa/Google_Maps_icon_%282020%29.svg", lat, lon, METERS))
|
||||||
linksContainer.appendChild(makeRef(pastvu, "https://pastvu.com/coast-icon.png", lat, lon, ZOOM))
|
linksContainer.appendChild(makeRef(pastvu, "https://pastvu.com/coast-icon.png", lat, lon, ZOOM))
|
||||||
@ -701,6 +722,16 @@
|
|||||||
height: 15px;
|
height: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#new .copy-button {
|
||||||
|
all: unset;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#new .copy-button img {
|
||||||
|
width: 15px;
|
||||||
|
heigth: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
input[type=submit] {
|
input[type=submit] {
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user