Skip to content

Commit

Permalink
Added Air Quality Index Calculator (#823)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarzookhunger authored May 24, 2024
1 parent 12cb18e commit 709641c
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Calculators/Air-Quality-Index-Calculator/README.md
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 :-
22 changes: 22 additions & 0 deletions Calculators/Air-Quality-Index-Calculator/index.html
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>
30 changes: 30 additions & 0 deletions Calculators/Air-Quality-Index-Calculator/script.js
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";
}
}
73 changes: 73 additions & 0 deletions Calculators/Air-Quality-Index-Calculator/style.css
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;
}
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,20 @@ <h3>Calculates the person's age by taking in the date of birth as input.</h3>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Air Quality Index Calculator</h2>
<h3>Calculates the level of the air quality using AQI index as input.</h3>
<div class="card-footer">
<a href="./Calculators/Air-Quality-Index-Calculator/index.html" target="_blank">
<button>Try Now</button>
</a>
<a href="https://github.com/Rakesh9100/CalcDiverse/tree/main/Calculators/Air-Quality-Index-Calculator" title="Source Code" target="_blank">
<img src="./assets/images/github.png" alt="Source Code"></img>
</a>
</div>
</div>
</div>
<div class="box">
<div class="content">
<h2>Antilog Calculator</h2>
Expand Down

0 comments on commit 709641c

Please sign in to comment.