Copy words to clipboard on click
This commit is contained in:
parent
d570d1b525
commit
635b00bd3b
18
index.html
18
index.html
@ -73,6 +73,9 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
}
|
}
|
||||||
|
.copyonclick {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
.clicktext {
|
.clicktext {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@ -165,6 +168,21 @@
|
|||||||
];
|
];
|
||||||
var bgimg = bgs[Math.floor(Math.random() * bgs.length)];
|
var bgimg = bgs[Math.floor(Math.random() * bgs.length)];
|
||||||
$("body").css("background-image", "url(./img/bg/" + bgimg + ")");
|
$("body").css("background-image", "url(./img/bg/" + bgimg + ")");
|
||||||
|
|
||||||
|
$("body").on("click", ".copyonclick", function () {
|
||||||
|
var copyitem = $(this);
|
||||||
|
var copytext = copyitem.text();
|
||||||
|
if (copytext == "Copied to clipboard!") {
|
||||||
|
// prevent copying copied text if double-clicked
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
navigator.clipboard.writeText(copytext).then(() => {
|
||||||
|
copyitem.text("Copied to clipboard!");
|
||||||
|
setTimeout(function () {
|
||||||
|
copyitem.text(copytext);
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function dolookup(words) {
|
function dolookup(words) {
|
||||||
|
@ -53,15 +53,12 @@ var FixPhrase = {
|
|||||||
(Number(lon.substring(4, 7)) + 6610),
|
(Number(lon.substring(4, 7)) + 6610),
|
||||||
];
|
];
|
||||||
|
|
||||||
console.log(groups);
|
|
||||||
|
|
||||||
return this.wordlist[groups[0]] + " " + this.wordlist[groups[1]] + " " + this.wordlist[groups[2]] + " " + this.wordlist[groups[3]];
|
return this.wordlist[groups[0]] + " " + this.wordlist[groups[1]] + " " + this.wordlist[groups[2]] + " " + this.wordlist[groups[3]];
|
||||||
},
|
},
|
||||||
decode: function (words) {
|
decode: function (words) {
|
||||||
var indexes = [-1, -1, -1, -1];
|
var indexes = [-1, -1, -1, -1];
|
||||||
words = words.toLowerCase();
|
words = words.toLowerCase();
|
||||||
words = words.split(" ");
|
words = words.split(" ");
|
||||||
console.log(words);
|
|
||||||
|
|
||||||
if (words.length < 2) {
|
if (words.length < 2) {
|
||||||
throw "Not enough words!";
|
throw "Not enough words!";
|
||||||
|
@ -36,7 +36,7 @@ function maplibreMap() {
|
|||||||
var words = FixPhrase.encode(coordinates.lat, coordinates.lng);
|
var words = FixPhrase.encode(coordinates.lat, coordinates.lng);
|
||||||
var popup = new mapboxgl.Popup();
|
var popup = new mapboxgl.Popup();
|
||||||
popup.setLngLat(e.lngLat);
|
popup.setLngLat(e.lngLat);
|
||||||
popup.setHTML("<b class='copyonclick'>" + words + "</b><br>" + (Math.round(coordinates.lat * 10000) / 10000) + ", " + (Math.round(coordinates.lng * 10000) / 10000));
|
popup.setHTML("<b><span class='copyonclick'>" + words + "</span></b><br>" + (Math.round(coordinates.lat * 10000) / 10000) + ", " + (Math.round(coordinates.lng * 10000) / 10000));
|
||||||
popup.addTo(map);
|
popup.addTo(map);
|
||||||
map.flyTo({
|
map.flyTo({
|
||||||
center: e.lngLat,
|
center: e.lngLat,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user