Skip to content

Commit

Permalink
weather
Browse files Browse the repository at this point in the history
  • Loading branch information
Ningoje committed Nov 6, 2023
1 parent 16ef9c1 commit 4c505ce
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 11 deletions.
4 changes: 2 additions & 2 deletions 404.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- 404 -->
<!-- 404 page -->
<div class="container">
<div class="row">
<div class="row error-page">
<div class="col-md-12">
<h1 class="text-center">404</h1>
<h3 class="text-center">Page not found</h3>
Expand Down
10 changes: 10 additions & 0 deletions calculator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h2 class="page-header text-center">Calculator</h2>
<!-- embed calculator from online-->

<div class="row ">
<div class="col-md-2"></div>
<div class="col-md-8">
<iframe src="https://www.calculator.net/" width="100%" height="1000px" frameborder="0"></iframe>
</div>
<div class="col-md-2"></div>
</div>
2 changes: 1 addition & 1 deletion home.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="text-center col-md-12 border border-success">
<div class="wrapper">
<br>
<div class="typing-demo">
<div class="card">
Hi friend👋👋, WELCOME!!!!!!
</div>
</div>
Expand Down
37 changes: 33 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css"
integrity="sha384-Bfad6CLCknfcloXFOyFnlgtENryhrpZCe29RTifKEixXQZ38WheV+i/6YWSzkz3V" crossorigin="anonymous">
<!-- jquery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<title>NINGOJE</title>

</head>
Expand All @@ -30,6 +33,32 @@
<li class="nav-item"><a class="nav-link" href="./index.php?mod=dictionary">Dictionary</a></li>
<li class="nav-item"><a class="nav-link" href="./index.php?mod=randomImages">Random Images</a></li>
<li class="nav-item"><a class="nav-link" href="./index.php?mod=qr">Generate Qr</a></li>
<!-- converter dropdown (currency,unit) -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Converter
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="./index.php?mod=currency">Currency</a></li>
<li><a class="dropdown-item" href="./index.php?mod=unit">Unit</a></li>
</ul>
</li>
<!-- /converter dropdown (currency,unit) -->
<li class="nav-item"><a class="nav-link" href="./index.php?mod=weather">Weather</a></li>
<li class="nav-item"><a class="nav-link" href="./index.php?mod=calculator">Calculator</a></li>
<!-- other enterainment(jokes,quotes,) dropdown -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Entertainment
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li><a class="dropdown-item" href="./index.php?mod=jokes">Jokes</a></li>
<li><a class="dropdown-item" href="./index.php?mod=quotes">Quotes</a></li>
</ul>
</li>
<!-- /other enterainment(jokes,quotes,) dropdown -->
<li class="nav-item"><a class="nav-link" href="./index.php?mod=contact">Contact</a></li>
<li class="nav-item"><a class="nav-link" href="./index.php?mod=about">About</a></li>
<!-- /ITEMS -->
Expand All @@ -48,7 +77,7 @@
include($mod);
} else {

include("404.php");
include("404.php");
}
?>

Expand All @@ -71,9 +100,9 @@
<!-- location -->
<div class="col-md-4">
<h3><i class="fa fa-map-marker"></i></h3>
<div class="gmap_canvas"><iframe width="300" height="200" id="gmap_canvas"
src="https://maps.google.com/maps?q=nairobi&t=&z=13&ie=UTF8&iwloc=&output=embed"
frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe></div>
<div class="gmap_canvas"><iframe width="300" height="200" id="gmap_canvas"
src="https://maps.google.com/maps?q=nairobi&t=&z=13&ie=UTF8&iwloc=&output=embed" frameborder="0"
scrolling="no" marginheight="0" marginwidth="0"></iframe></div>
</div>

<div class="col-md-4">
Expand Down
2 changes: 2 additions & 0 deletions jokes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!-- jokes section -->
<h2 class="page-header text-center">Jokes</h2>
21 changes: 17 additions & 4 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,28 @@
}
.search-card {
/* Replace 'red', 'green', and 'blue' with actual integer values */
box-shadow: 0 0 10px rgba(255, 0, 0, 0.5); /* Example shadow with red color */
box-shadow: 0 0 10px rgba(255, 0, 0, 0.5); /* shadow with red color */
}
.results-card{
box-shadow: 0 0 10px rgba(0, 255, 0, 0.5); /* Example shadow with red color */
box-shadow: 0 0 10px rgba(0, 255, 0, 0.5); /* shadow with red color */
min-height: 300px;
}
/* glowing card */
.glowing-card {
/* Replace 'red', 'green', and 'blue' with actual integer values */
box-shadow: 0 0 10px rgba(115, 0, 255, 0.5); /* Example shadow with red color */

box-shadow: 0 0 10px rgba(115, 0, 255, 0.5);
animation: glow 1s ease-in-out infinite alternate;
}
/* 404 page */
.error-page{
background-image: -webkit-gradient(linear, left top, left bottom, from(#1e5799), to(#2989d8));

/* add shaking animation */
animation: shake 0.5s linear infinite !important;
/* glowing border */
border: 1px solid #fff;
box-shadow: 0 0 10px #fff;



}
87 changes: 87 additions & 0 deletions weather.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<!-- weather find by city -->
<h2 class="page-header text-center">weather</h2>

<!-- textfiled to enter city -->
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<input type="text" id="city" class="form-control" placeholder="Enter city name">
</div>
<div class="col-md-4">
<!-- button to search -->
<button id="searchW" class="btn btn-primary" onclick="fetchData()">Search</button>
</div>
</div>
<!-- card to display weather -->
<div class="card weather-card m-2 p-2">
<div class="row m-3 p-3">
<div class="col-md-2"></div>
<div class="col-md-8" id="weather-results">
<!-- info -->
<p class="text-center">Enter city name to get weather information</p>
</div>
<div class="col-md-2">
</div>
</div>
</div>
<!-- use php to fetch -->
<script>
const url = 'https://api.api-ninjas.com/v1/weather?city=';
const api_key = 'pVu+077nJZLR5aSU3rT4Uw==Mjk3lCw4PETJptdl';
//use ajax to fetch data
async function fetchData() {
//show loading
document.getElementById('weather-results').innerHTML = modal_content
const city = document.getElementById('city').value;
//get counntry
const country = await fetch('https://api.api-ninjas.com/v1/city?name=' + city, {
headers: { 'X-Api-Key': api_key },
})
.then(res => res.json())
.then(data => data[0].country);
$.ajax({
method: 'GET',
url: 'https://api.api-ninjas.com/v1/weather?city=' + city,
headers: { 'X-Api-Key': api_key },
contentType: 'application/json',
success: function (result) {
//set icon
$('#icon').attr('src', `https://flagsapi.com/${country}/flat/64.png`);
src_ = `https://flagsapi.com/${country}/flat/64.png`
document.getElementById('weather-results').innerHTML = `
<div class="card m-2 p-2" style="width: 18rem;">
<img src="${src_}" class="card-img-top" alt="${country}">
<div class="card-body text-center">
<h5 class="card-title">${city}</h5>
<p class="card-text">Temperature: ${result.temp}°C</p>
<p class="card-text">Feels like: ${result.feels_like}°C</p>
<p class="card-text">Humidity: ${result.humidity}%</p>
<p class="card-text">Min Temperature: ${result.min_temp}°C</p>
<p class="card-text">Max Temperature: ${result.max_temp}°C</p>
<p class="card-text">Wind Speed: ${result.wind_speed}km/h</p>
<p class="card-text">Wind Degrees: ${result.wind_degrees}°</p>
<p class="card-text">Sunrise: ${result.sunrise}</p>
<p class="card-text">Sunset: ${result.sunset}</p>
</div>
</div>
`;
},
error: function ajaxError(jqXHR) {
console.error('Error: ', jqXHR.responseText);
}
});
}
</script>
<!--
{"cloud_pct":100,"temp":22,"feels_like":22,"humidity":75,"min_temp":22,"max_temp":22,"wind_speed":1.93,"wind_degrees":99,"sunrise":1699240151,"sunset":1699283811}
-->

0 comments on commit 4c505ce

Please sign in to comment.