Add files via upload
@@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Pogoda dla Twojej miejscowości!</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src="script.js" defer></script>
|
||||
<script src="https://kit.fontawesome.com/e4c3899c65.js" crossorigin="anonymous"></script>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" id="container">
|
||||
<div class="content">
|
||||
<h2 class="city-title" onclick="changeCity()"><span id="cityTitle">Łódź, Polnd</span></h2>
|
||||
<div class="row">
|
||||
<img src="" alt="" class="icon" id="icon">
|
||||
<div>
|
||||
<h2 class="temperature" id="temp">20°C</h2>
|
||||
<h4 class="description" id="desc">opis</h4>
|
||||
</div>
|
||||
</div>
|
||||
<h3 class="feel_temp" id="feel_temp">Odczuwalne: 4</h3>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p class="info" id="min_temp"></p>
|
||||
<p class="info" id="max_temp"></p>
|
||||
<p class="info" id="pressure"></p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p class="info right" id="humidity"></p>
|
||||
<p class="info right" id="wind"></p>
|
||||
<p class="info right" id="clouds"></p>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<h4 class="author">Stworzone przez <a href="https://www.smaga.me">Krzysztof Smaga</a><br>Wykorzystano: <a href="https://openweathermap.org">OpenWeatherMap API</a></h4>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,69 @@
|
||||
let api = "{ADD_YOUR_API_KEY}";
|
||||
let city = getCookie("city") != "" ? getCookie("city") : "3093133";
|
||||
let type = getCookie("type") != "" ? getCookie("type") : "id";
|
||||
|
||||
function call(){
|
||||
let api_call = `https://api.openweathermap.org/data/2.5/weather?${type}=${city}&appid=${api}&units=metric&lang=pl`;
|
||||
|
||||
const xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
if(this.readyState == 4 && this.status == 200){
|
||||
let data = JSON.parse(this.responseText);
|
||||
let temperature = data.main.temp;
|
||||
cityTitle.innerText = `${data.name}, ${data.sys.country}`;
|
||||
icon.setAttribute("src", `https://openweathermap.org/img/wn/${data.weather[0].icon}@4x.png`);
|
||||
icon.setAttribute("alt", `${data.weather[0].main}`)
|
||||
temp.innerText = `${temperature.toPrecision(2)}°C`;
|
||||
desc.innerText = `${data.weather[0].description}`
|
||||
feel_temp.innerText = `Odczuwalne: ${data.main.feels_like}°C`
|
||||
min_temp.innerHTML = `Najniższa temp: <b>${data.main.temp_min}°C</b>`
|
||||
max_temp.innerHTML = `Najwyższa temp: <b>${data.main.temp_max}°C</b>`
|
||||
pressure.innerHTML = `Ciśnienie: <b>${data.main.pressure} hPa</b>`
|
||||
humidity.innerHTML = `Wilgotność: <b>${data.main.humidity}%</b>`
|
||||
wind.innerHTML = `Wiatr: <b>${data.wind.speed} m/s, ${data.wind.deg}°</b>`
|
||||
clouds.innerHTML = `Pochmurzenie: <b>${data.clouds.all}%</b>`
|
||||
container.style.backgroundImage = `url(wallpapers/${data.weather[0].icon}.jpg)`
|
||||
}
|
||||
};
|
||||
xhttp.open("GET", api_call);
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
call();
|
||||
|
||||
function changeCity() {
|
||||
let temp_type = prompt("Co chcesz podać? (ID miasta - id; Nazwę miasta - q)");
|
||||
let temp_id = prompt("Podaj nowe miasto");
|
||||
|
||||
if(temp_type != null && temp_type != "")
|
||||
type = temp_type;
|
||||
if(temp_id != null && temp_id != "")
|
||||
city = temp_id;
|
||||
|
||||
setCookie("city", city);
|
||||
setCookie("type", type);
|
||||
|
||||
call();
|
||||
}
|
||||
|
||||
function setCookie(cname, cvalue) {
|
||||
const d = new Date();
|
||||
d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
|
||||
let expires = "expires="+d.toUTCString();
|
||||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
|
||||
}
|
||||
|
||||
function getCookie(cname) {
|
||||
let name = cname + "=";
|
||||
let ca = document.cookie.split(';');
|
||||
for(let i = 0; i < ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) == ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
if (c.indexOf(name) == 0) {
|
||||
return c.substring(name.length, c.length);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
font-family: "Open Sans", sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 16px;
|
||||
border-radius: 48px;
|
||||
color: white;
|
||||
box-shadow: 0 0 32px #000000;
|
||||
backdrop-filter: blur(3px) brightness(60%);
|
||||
}
|
||||
|
||||
.city-title {
|
||||
text-align: center;
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
.temperature {
|
||||
display: inline-block;
|
||||
margin: 16px;
|
||||
margin-bottom: 0;
|
||||
font-weight: 300;
|
||||
font-size: 600%;
|
||||
}
|
||||
|
||||
.description {
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.feel_temp {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: inline-block;
|
||||
height: 256px;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.col {
|
||||
text-align: center;
|
||||
flex: 1 0 0%;
|
||||
}
|
||||
|
||||
.info {
|
||||
text-align: left;
|
||||
margin: 4px 24px 0 24px;
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.info.right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.author {
|
||||
text-align: center;
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.author a {
|
||||
font-weight: 500;
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.author a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 133 KiB |
|
After Width: | Height: | Size: 829 KiB |
|
After Width: | Height: | Size: 706 KiB |
|
After Width: | Height: | Size: 540 KiB |
|
After Width: | Height: | Size: 956 KiB |
|
After Width: | Height: | Size: 492 KiB |
|
After Width: | Height: | Size: 648 KiB |
|
After Width: | Height: | Size: 578 KiB |
|
After Width: | Height: | Size: 403 KiB |
|
After Width: | Height: | Size: 589 KiB |
|
After Width: | Height: | Size: 570 KiB |
|
After Width: | Height: | Size: 922 KiB |
|
After Width: | Height: | Size: 209 KiB |
|
After Width: | Height: | Size: 731 KiB |
|
After Width: | Height: | Size: 554 KiB |
|
After Width: | Height: | Size: 593 KiB |
|
After Width: | Height: | Size: 408 KiB |