Skip to content

Commit

Permalink
flag emoji!
Browse files Browse the repository at this point in the history
  • Loading branch information
cwmoriarty authored Jul 10, 2024
1 parent 426dec6 commit ddfdbaa
Showing 1 changed file with 57 additions and 49 deletions.
106 changes: 57 additions & 49 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,64 +1,72 @@
<body>
<div class="centered">
<h2>Christopher W Moriarty</h2>
<div class="centered">
<h2>Christopher W Moriarty</h2>

<body>
<div class="centered">
<h2>Christopher W Moriarty</h2>
<a href="Chris%20Moriarty%20-%20Resume.pdf">resume</a><br>
<a href="https://github.com/cwmoriarty">github</a><br>
<a href="https://www.linkedin.com/in/cwmoriarty/">linkedin</a><br>
<br>
email: <tt>cwmⓐcwmoriarty.com</tt>
</div>

<div class="libleft">
<small>🌎 <span id="distance">0</span> miles away</small>
</div>
<div class="centered">
<h2>Christopher W Moriarty</h2>
<a href="Chris%20Moriarty%20-%20Resume.pdf">resume</a><br>
<a href="https://github.com/cwmoriarty">github</a><br>
<a href="https://www.linkedin.com/in/cwmoriarty/">linkedin</a><br>
<br>
email: <tt>cwmⓐcwmoriarty.com</tt>
</div>

<div class="libleft">
<small><span id="flag">🌎</span> <span id="distance">0</span> miles away</small>
</div>

</body>



<script type="text/javascript">
R = 3959 // Radius of Earth in miles
fetch('https://ipapi.co/json').then(response => response.json()).then(data => {
dLat = (atob("NDIuNTU=") - data.latitude) * Math.PI / 180 // Radians keep me safe.
dLon = (atob("LTcwLjg3") - data.longitude) * Math.PI / 180

a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(data.latitude * Math.PI / 180) * Math.cos(42.55 * Math.PI / 180) *
Math.sin(dLon / 2) * Math.sin(dLon / 2);
c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
distance = (R * c).toFixed(1); // Distance in miles
<script type="text/javascript">
//Distance calculation
R = 3959
fetch('https://ipapi.co/json').then(response => response.json()).then(data => {
dLat = (atob("NDIuNTU=") - data.latitude) * Math.PI / 180 // Radians keep me safe.
dLon = (atob("LTcwLjg3") - data.longitude) * Math.PI / 180

a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(data.latitude * Math.PI / 180) * Math.cos(42.55 * Math.PI / 180) *
Math.sin(dLon / 2) * Math.sin(dLon / 2)
c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
distance = (R * c).toFixed(0);


//Flag Emoji
codePoints = data.country_code.toUpperCase().split('').map(char => 127397 + char.charCodeAt())
flagEmoji= String.fromCodePoint(...codePoints)


document.getElementById("distance").innerHTML = distance;
document.getElementById("flag").innerHTML = flagEmoji;

//distance=42;
console.log(data.latitude);
document.getElementById("distance").innerHTML = distance;
})
.catch(error => {
console.error("Error fetching IP data:", error);
});
</script>
console.log(flagEmoji)
})
.catch(error => {
console.error("Error fetching IP data:", error);
});
</script>




<style type="text/css">
body { font-family: Helvetica, Geneva, sans-serif; }
a { color: black; }
.centered {
position: fixed;
top: 50%;
left: 50%;
margin-top: -125px;
margin-left: -87px;
}
.libleft {
position: fixed;
left:30;
bottom:0;
}
</style>
body { font-family: Helvetica, Geneva, sans-serif; }
a { color: black; }
.centered {
position: fixed;
top: 50%;
left: 50%;
margin-top: -125px;
margin-left: -87px;
} .libleft {
position: fixed;
left:30;
bottom:0;
}
</style>


0 comments on commit ddfdbaa

Please sign in to comment.