initial
This commit is contained in:
30
src/App.svelte
Normal file
30
src/App.svelte
Normal file
@@ -0,0 +1,30 @@
|
||||
<script>
|
||||
// export let name;
|
||||
import Location from './Location.svelte';
|
||||
</script>
|
||||
|
||||
<main>
|
||||
<Location/>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
main {
|
||||
text-align: center;
|
||||
padding: 1em;
|
||||
max-width: 240px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #ff3e00;
|
||||
text-transform: uppercase;
|
||||
font-size: 4em;
|
||||
font-weight: 100;
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
main {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
</style>
|
49
src/Location.svelte
Normal file
49
src/Location.svelte
Normal file
@@ -0,0 +1,49 @@
|
||||
<script>
|
||||
|
||||
$: latitude = ""
|
||||
$: longitude = ""
|
||||
$: temp = ""
|
||||
$: weather = ""
|
||||
$: wind = ""
|
||||
$: answer = "???"
|
||||
|
||||
if (!navigator.geolocation) {
|
||||
alert("Geolocation is not supported in this browser.");
|
||||
answer = "\"Fuck it, this asshole didn't allow me to check\" "
|
||||
} else {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
(position) => {
|
||||
console.log(position.coords)
|
||||
latitude = position.coords.latitude
|
||||
longitude = position.coords.longitude
|
||||
fetch("http://www.7timer.info/bin/civil.php?lon="+longitude+"&lat="+latitude+"&unit=metric&output=json&tzshift=0").then(
|
||||
response => response.json()
|
||||
).then(
|
||||
data => {
|
||||
temp = data.dataseries[0].temp2m
|
||||
weather = data.dataseries[0].weather
|
||||
wind = data.dataseries[0].wind10m.speed
|
||||
if (temp < 17 || wind > 7){
|
||||
answer = "Pants"
|
||||
} else {
|
||||
answer = "Shorts"
|
||||
}
|
||||
})
|
||||
},
|
||||
(error) => {
|
||||
answer = "\"Fuck it, this asshole didn't allow me to check\" "
|
||||
console.log(error);
|
||||
}
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Location: {latitude} {longitude} <br>
|
||||
Temp : {temp} <br>
|
||||
Weather : {weather} <br>
|
||||
WindSpeed : {wind} <br> -->
|
||||
|
||||
<h1>It's {answer} Weather</h1> <br>
|
||||
|
||||
Nannal 2021
|
||||
|
10
src/main.js
Normal file
10
src/main.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import App from './App.svelte';
|
||||
|
||||
const app = new App({
|
||||
target: document.body,
|
||||
props: {
|
||||
name: 'world'
|
||||
}
|
||||
});
|
||||
|
||||
export default app;
|
Reference in New Issue
Block a user