Skip to content

Instantly share code, notes, and snippets.

@thinhbuzz
Last active June 19, 2021 09:48
Show Gist options
  • Save thinhbuzz/ebbacbe51f2b7d140ab025cb1ae2e03d to your computer and use it in GitHub Desktop.
Save thinhbuzz/ebbacbe51f2b7d140ab025cb1ae2e03d to your computer and use it in GitHub Desktop.
moonani click to teleport
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