Last active
June 19, 2021 09:48
-
-
Save thinhbuzz/ebbacbe51f2b7d140ab025cb1ae2e03d to your computer and use it in GitHub Desktop.
moonani click to teleport
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.body.addEventListener('click', event => { | |
if (!event.target.matches('button[data-clipboard-text]')) { | |
return; | |
} | |
event.preventDefault(); | |
const href = event.target.getAttribute('data-clipboard-text'); | |
const location = href.split(','); | |
console.log(location); | |
fetch('http://localhost:4444/adb', { | |
method: 'POST', | |
body: JSON.stringify({"lat":location[0],"lng":location[1]}), | |
}) | |
.then(res => res.json()) | |
// .then(console.log) | |
.then(res => { | |
event.target.parentElement.removeChild(event.target); | |
console.log(res); | |
}) | |
.catch(console.error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment