FSWD Glob
FSWD Glob
THE DEGREE OF
R. Ravikumar(22241A66B5)
P. Harshavardhan Reddy(22241A66B1)
V. Nikhil (22241A66C5)
UNDER THE GUIDANCE OF:
Asst. professor
DEPARTMENT OF
(Bachupally, Hyderabad,500090
1 Introduction 3
● Problem Statement
● Goal of the Project
2 Weather UI 3
● Description
● Why HTML, CSS and JS ?
JS source code
OpenWeatherMap API
API key
6 Testing Weather UI 14
7 Limitations 15
2. Weather UI
Description
The project Weather UI is a web application that displays the weather
information of a location. The user can enter the location in the search box, and
the app will retrieve the weather data using an API and display it in a visually
appealing way. The app includes a weather image, temperature, humidity, and
wind speed. The UI is built using HTML, CSS, and JavaScript.
Features
User-Friendly Interface:
Create a responsive and intuitive user interface that is easy to
navigate, ensuring a positive and seamless user experience for
individuals of all technical backgrounds.
Real-Time Weather Information:
Integrate with a reliable weather API to fetch and display up-to-
date weather information, including temperature, humidity, wind
speed, and conditions for a specified location.
Visual Appeal:
Design visually appealing layouts using HTML and CSS to present
weather data in a clear and aesthetically pleasing manner,
enhancing user engagement and comprehension.
Customization Options:
Provide users with the ability to customize the displayed weather
information based on their preferences, such as choosing between
Celsius and Fahrenheit, or selecting preferred units for wind speed.
Geolocation Integration:
Implement geolocation features using JavaScript to automatically
detect and display weather information for the user's current
location, offering a personalized experience.
Forecasting:
Include a forecast section that allows users to view weather
predictions for the upcoming days, giving them a comprehensive
overview of the weather conditions.
Cross-Browser Compatibility:
Ensure compatibility with major web browsers to reach a wide
audience, minimizing issues related to inconsistent rendering and
functionality.
Accessibility
Implement accessibility features to ensure the application is usable
by individuals with disabilities, adhering to web standards and best
practices.
Why HTML, CSS and JS ?
HTML (Hypertext Markup Language):
Structure and Semantics: HTML provides a structured and
semantic markup language, making it easy to organize and present
content on the web.
Cross-browser Compatibility: HTML is supported by all major
browsers, ensuring consistency in displaying content across
different platforms.
Accessibility: HTML supports the creation of accessible web
content, allowing developers to implement features that cater to
users with disabilities.
CSS (Cascading Style Sheets):
Separation of Concerns: CSS allows the separation of design and
structure, making it easier to maintain and update the visual aspects
of a website without altering its underlying structure.
Consistent Styling: With CSS, you can apply consistent styles to
multiple pages, ensuring a cohesive and professional appearance
for the entire website.
Responsive Design: CSS supports responsive design, enabling
websites to adapt to different screen sizes and devices, enhancing
the user experience.
JavaScript (JS):
Interactivity: JavaScript adds interactivity to web pages, allowing
developers to create dynamic and engaging user experiences.
Client-Side Processing: JavaScript reduces the load on the server
by enabling client-side processing, leading to faster response times
and improved performance.
Extensibility: JavaScript can be used to extend the functionality of
a website through the use of libraries and frameworks, such as
jQuery, React, or Angular.
<div class="location-not-found">
<h1>Sorry, Location not found!!!</h1>
<img src="/assets/404.png" alt="404 Error">
</div>
<div class="weather-body">
<img src="/assets/cloud.png" alt="Weather Image" class="weather-img">
<div class="weather-box">
<p class="temperature">0 <sup>°C</sup></p>
<p class="description">light rain</p>
</div>
<div class="weather-details">
<div class="humidity">
<i class="fa-sharp fa-solid fa-droplet"></i>
<div class="text">
<span id="humidity">45%</span>
<p>Humidity</p>
</div>
</div>
<div class="wind">
<i class="fa-solid fa-wind"></i>
<div class="text">
<span id="wind-speed">12Km/H</span>
<p>Wind Speed</p>
</div>
</div>
</div>
</div>
</div>
<script src="script.js"></script>
<script src="https://kit.fontawesome.com/9b6998f11d.js"
crossorigin="anonymous"></script>
</body>
</html>
body{
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: #25d8d2;
}
.container{
width: 400px;
height: min-content;
background-color: #fff;
border-radius: 12px;
padding: 28px;
}
.search-box{
width: 100%;
height: min-content;
display: flex;
justify-content: space-between;
align-items: center;
}
.search-box input{
width: 84%;
font-size: 20px;
text-transform: capitalize;
color: #000;
background-color: #e6f5fb;
padding: 12px 16px;
border-radius: 14px;
}
.search-box input::placeholder{
color: #000;
}
.search-box button{
width: 46px;
height: 46px;
background-color: #e6f5fb;
border-radius: 50%;
cursor: pointer;
font-size: 20px;
}
.search-box button:hover{
color: #fff;
background-color: #ababab;
}
.weather-body{
justify-content: center;
align-items: center;
flex-direction: column;
margin-block: 20px;
display: none;
}
.weather-body img{
width: 60%;
}
.weather-box{
margin-block: 20px;
text-align: center;
}
.weather-box .temperature{
font-size: 40px;
font-weight: 800;
position: relative;
}
.weather-box .description{
font-size: 20px;
font-weight: 700;
text-transform: capitalize;
}
.weather-details{
width: 100%;
display: flex;
justify-content: space-between;
margin-top: 30px;
}
.humidity, .wind{
display: flex;
align-items: center;
}
.humidity{
margin-left: 20px;
}
.wind{
margin-right: 20px;
}
.weather-details i{
font-size: 36px;
}
.weather-details .text{
margin-left: 10px;
font-size: 16px;
}
.text span{
font-size: 20px;
font-weight: 700;
}
.location-not-found{
margin-top: 20px;
display: none;
align-items: center;
justify-content: center;
flex-direction: column;
}
.location-not-found h1{
font-size: 20px;
color: #6b6b6b;
margin-block-end: 15px;
}
.location-not-found img{
width: 80%;
}
5. Fetching Weather Data with JavaScript
JS source code
const inputBox = document.querySelector('.input-box');
const searchBtn = document.getElementById('searchBtn');
const weather_img = document.querySelector('.weather-img');
const temperature = document.querySelector('.temperature');
const description = document.querySelector('.description');
const humidity = document.getElementById('humidity');
const wind_speed = document.getElementById('wind-speed');
const location_not_found = document.querySelector('.location-not-found');
const weather_body = document.querySelector('.weather-body');
async function checkWeather(city){
const api_key = "2ce5171d854cc7408ed95e791ab31e78";
const url = `https://api.openweathermap.org/data/2.5/weather?q=${city}&appid=$
{api_key}`;
const weather_data = await fetch(`${url}`).then(response => response.json());
if(weather_data.cod === `404`){
location_not_found.style.display = "flex";
weather_body.style.display = "none";
console.log("error");
return;
}
console.log("run");
location_not_found.style.display = "none";
weather_body.style.display = "flex";
temperature.innerHTML = `${Math.round(weather_data.main.temp - 273.15)}°C`;
description.innerHTML = `${weather_data.weather[0].description}`;
humidity.innerHTML = `${weather_data.main.humidity}%`;
wind_speed.innerHTML = `${weather_data.wind.speed}Kmph`;
switch(weather_data.weather[0].main){
case 'Clouds':
weather_img.src = "/assets/cloud.png";
break;
case 'Clear':
weather_img.src = "/assets/clear.png";
break;
case 'Rain':
weather_img.src = "/assets/rain.png";
break;
case 'Mist':
weather_img.src = "/assets/mist.png";
break;
case 'Snow':
weather_img.src = "/assets/snow.png";
break;
}
console.log(weather_data);
}
searchBtn.addEventListener('click', ()=>{
checkWeather(inputBox.value);
});
Open weather Map Api
6. Testing Weather UI
7. Limitations
HTML:
Limited Dynamic Functionality: HTML is primarily a markup language
for creating static content. While it provides structure, it lacks the ability
to create dynamic and interactive elements without the help
of JavaScript.
Limited Styling Options: HTML has limited styling capabilities, and for
more complex visual designs, CSS is required.
CSS:
Browser Compatibility: Achieving consistent styling across different
browsers can be challenging due to variations in how browsers interpret
CSS rules.
Learning Curve: CSS can be complex, and mastering advanced
techniques, such as responsive design or CSS animations, may require a
significant learning curve.
JavaScript:
Security Concerns: JavaScript executing on the client side can be
vulnerable to security issues, and developers need to be cautious about
potential security risks like cross-site scripting (XSS).
Dependency on Client-Side Processing: Relying too heavily on
JavaScript for essential functionalities can lead to usability issues if users
have JavaScript disabled or if there are network latency problems.