-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Air Quality Index Calculator (#823)
- Loading branch information
1 parent
12cb18e
commit 709641c
Showing
5 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# <p align="center">Air Quality Index Calculator</p> | ||
|
||
## Description :- | ||
|
||
Calculates the level of the air quality using AQI index. | ||
|
||
## Tech Stacks :- | ||
|
||
- HTML | ||
- CSS | ||
- JavaScript | ||
|
||
## Screenshots :- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Air Quality Index Calculator</title> | ||
<link rel="icon" href="./assets/favicon.png"> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Air Quality Index(AQI) Calculator</h1> | ||
<br><br> | ||
<label for="aqi-idx" id="input-label">Enter AQI of your region : </label> | ||
<input type="number" id="input-id" min="1" max="500" step="any" oninput="validity.valid||(value='');" onchange="validateBaseInput(this)" placeholder="Enter AQI" required> | ||
<br><br> | ||
<button onclick="calculateAQI()">Calculate Level</button> | ||
<p id="result"></p> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function calculateAQI() { | ||
|
||
var aqiIndex = document.getElementById("input-id").value; | ||
var resultElement = document.getElementById("result"); | ||
|
||
if (aqiIndex <= 0 || aqiIndex > 500) { | ||
alert("Invalid input \nEnter AQI index from 1 to 500!"); | ||
resultElement.innerHTML = ""; | ||
resultElement.style.backgroundColor = ""; | ||
} else if (aqiIndex >= 1 && aqiIndex <= 50) { | ||
resultElement.innerHTML = `AQI: ${aqiIndex} - Good air quality`; | ||
resultElement.style.backgroundColor = "green"; | ||
} else if (aqiIndex >= 51 && aqiIndex <= 100) { | ||
resultElement.innerHTML = `AQI: ${aqiIndex} - Moderate air quality`; | ||
resultElement.style.backgroundColor = "yellow"; | ||
resultElement.style.color = "black"; | ||
} else if (aqiIndex >= 101 && aqiIndex <= 150) { | ||
resultElement.innerHTML = `AQI: ${aqiIndex} - Unhealthy for sensitive groups`; | ||
resultElement.style.backgroundColor = "orange"; | ||
} else if (aqiIndex >= 151 && aqiIndex <= 200) { | ||
resultElement.innerHTML = `AQI: ${aqiIndex} - Unhealthy`; | ||
resultElement.style.backgroundColor = "red"; | ||
} else if (aqiIndex >= 201 && aqiIndex <= 300) { | ||
resultElement.innerHTML = `AQI: ${aqiIndex} - Very unhealthy`; | ||
resultElement.style.backgroundColor = "purple"; | ||
} else if (aqiIndex >= 301 && aqiIndex <= 500) { | ||
resultElement.innerHTML = `AQI: ${aqiIndex} - Hazardous`; | ||
resultElement.style.backgroundColor = "maroon"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
* { | ||
padding: 0; | ||
margin: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
html { | ||
height: 100%; | ||
margin: 0; | ||
background-image: linear-gradient(to right, #72ff5f, #d3ef34, #f1543c); | ||
} | ||
|
||
body { | ||
display: flex; | ||
height: 100vh; | ||
margin: 0; | ||
background-image: url('./assets/background.png'); | ||
background-size: contain; | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.container { | ||
background-color: rgba(222, 133, 123, 0.5); | ||
padding: 20px; | ||
border-radius: 8px; | ||
color: rgb(10, 10, 10); | ||
text-align: center; | ||
max-width: 35%; | ||
height: 48%; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
#input-label { | ||
font-size: 18px; | ||
font-weight: 500; | ||
color: #000000; | ||
} | ||
|
||
#input-id { | ||
width: 100px; | ||
border: none; | ||
border-radius: 10px; | ||
padding: 10px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
button { | ||
cursor: pointer; | ||
border: none; | ||
border-radius: 10px; | ||
padding: 10px; | ||
background-image: linear-gradient(to right, #72ff5f, #d3ef34, #de361c); | ||
font-weight: bold; | ||
box-shadow: 0 4px 6px rgba(12, 162, 27, 0.3); | ||
transition: box-shadow 0.3s; | ||
} | ||
|
||
button:hover { | ||
box-shadow: 0 6px 8px rgba(176, 39, 29, 0.4); | ||
} | ||
|
||
#result { | ||
padding: 12px; | ||
margin-top: 25px; | ||
border-radius: 8px; | ||
color: white; | ||
text-align: center; | ||
justify-content: center; | ||
font-weight: bold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters