mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
fix(selected unit coords): failsafe in case of absence of the navigator element
This commit is contained in:
@@ -116,6 +116,8 @@ export class MouseInfoPanel extends Panel {
|
|||||||
#listenForCopyableElements() {
|
#listenForCopyableElements() {
|
||||||
const copyableElements = document.getElementsByClassName('copyable');
|
const copyableElements = document.getElementsByClassName('copyable');
|
||||||
|
|
||||||
|
// TODO: copy all the coordinates and elevation instead of copying only lat, lng or elevation.
|
||||||
|
|
||||||
for (const element of copyableElements) {
|
for (const element of copyableElements) {
|
||||||
element.addEventListener('contextmenu', (ev) => {
|
element.addEventListener('contextmenu', (ev) => {
|
||||||
if (!ev.target) return;
|
if (!ev.target) return;
|
||||||
@@ -134,12 +136,14 @@ export class MouseInfoPanel extends Panel {
|
|||||||
|
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
|
|
||||||
|
if(!navigator || !navigator.clipboard) return;
|
||||||
|
|
||||||
navigator.clipboard.writeText(text)
|
navigator.clipboard.writeText(text)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
//console.log('Testo copiato negli appunti!');
|
// Text copied to clipboard. TODO: add a toast or alert for this event.
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error('Errore nel copiare:', err);
|
console.error('An error occurred while copying text to clipboard: ', err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user