-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2148 from Archiesachin/Pet_age_calculator
Pet age calculator Extension added
- Loading branch information
Showing
4 changed files
with
128 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 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Pet Age Caclulator", | ||
"description": "Pet Age Caclulator", | ||
"version": "1.0", | ||
"permissions": [ | ||
"storage" | ||
], | ||
"host_permissions": ["*://*/*"], | ||
"action": { | ||
"default_popup": "popup.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 @@ | ||
<!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> |
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,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.`; | ||
}); |
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,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; | ||
} |