Skip to content

Commit

Permalink
Merge pull request #2148 from Archiesachin/Pet_age_calculator
Browse files Browse the repository at this point in the history
Pet age calculator Extension added
  • Loading branch information
Sulagna-Dutta-Roy authored Jul 5, 2024
2 parents 29ebd2d + f805e34 commit e9bc92d
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Pet Age Calculator/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"manifest_version": 3,
"name": "Pet Age Caclulator",
"description": "Pet Age Caclulator",
"version": "1.0",
"permissions": [
"storage"
],
"host_permissions": ["*://*/*"],
"action": {
"default_popup": "popup.html"
}
}
30 changes: 30 additions & 0 deletions Pet Age Calculator/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pet Age Calculator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Pet Age Calculator</h1>
<form id="ageForm">
<label for="petType">Select Pet:</label>
<select id="petType" required>
<option value="dog">Dog</option>
<option value="cat">Cat</option>
<option value="rabbit">Rabbit</option>
<option value="fish">Fish</option>
</select>

<label for="humanYears">Enter Human Years:</label>
<input type="number" id="humanYears" step="0.1" min="0" required>

<button type="submit">Calculate Pet Age</button>
</form>
<div id="result"></div>
</div>
<script src="script.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions Pet Age Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
document.getElementById('ageForm').addEventListener('submit', function(event) {
event.preventDefault();

const petType = document.getElementById('petType').value;
const humanYears = parseFloat(document.getElementById('humanYears').value);
let petYears = 0;

switch(petType) {
case 'dog':
petYears = humanYears * 7;
break;
case 'cat':
petYears = humanYears * 6;
break;
case 'rabbit':
petYears = humanYears * 12;
break;
case 'fish':
petYears = humanYears * 5;
break;
default:
petYears = 0;
}

document.getElementById('result').textContent = `Your ${petType} is ${petYears.toFixed(1)} years old in pet years.`;
});
59 changes: 59 additions & 0 deletions Pet Age Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: lightblue;
margin: 0;
}

.container {
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
width: 50vw;
}

h1 {
margin-bottom: 20px;
}

form {
display: flex;
flex-direction: column;
align-items: flex-start;
}

label {
margin: 10px 0 5px;
font-size: 20px;
}

input, select, button {
margin-bottom: 10px;
padding: 8px;
width: 100%;
box-sizing: border-box;
font-size: 18px;
}

button {
background-color: #007BFF;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}

#result {
margin-top: 20px;
font-size: 1.2em;
color: #333;
}

0 comments on commit e9bc92d

Please sign in to comment.