-
Notifications
You must be signed in to change notification settings - Fork 173
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 #2634 from Archiesachin/Roi-calculator
ROI Calculator Extension added
- Loading branch information
Showing
4 changed files
with
127 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,31 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>ROI Calculator</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h2>ROI Calculator</h2> | ||
<form id="roiForm"> | ||
<div class="form-group"> | ||
<label for="initialInvestment">Initial Investment (Rs):</label> | ||
<input type="number" id="initialInvestment" required> | ||
</div> | ||
<div class="form-group"> | ||
<label for="finalValue">Final Value (Rs):</label> | ||
<input type="number" id="finalValue" required> | ||
</div> | ||
<div class="form-group"> | ||
<label for="investmentPeriod">Investment Period (Years):</label> | ||
<input type="number" id="investmentPeriod" required> | ||
</div> | ||
<button type="button" onclick="calculateROI()">Calculate ROI</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,13 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "ROI Calculator", | ||
"version": "1.0", | ||
"permissions": [ | ||
"activeTab" | ||
], | ||
"browser_action": { | ||
"default_popup": "index.html" | ||
}, | ||
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'" | ||
} | ||
|
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,18 @@ | ||
function calculateROI() { | ||
const initialInvestment = parseFloat(document.getElementById('initialInvestment').value); | ||
const finalValue = parseFloat(document.getElementById('finalValue').value); | ||
const investmentPeriod = parseFloat(document.getElementById('investmentPeriod').value); | ||
|
||
if (isNaN(initialInvestment) || isNaN(finalValue) || isNaN(investmentPeriod) || initialInvestment <= 0 || investmentPeriod <= 0) { | ||
document.getElementById('result').textContent = 'Please enter valid values.'; | ||
return; | ||
} | ||
|
||
const roi = ((finalValue - initialInvestment) / initialInvestment) * 100; | ||
const annualizedROI = (Math.pow((finalValue / initialInvestment), (1 / investmentPeriod)) - 1) * 100; | ||
|
||
document.getElementById('result').innerHTML = ` | ||
<p>Total ROI: ${roi.toFixed(2)}%</p> | ||
<p>Annualized ROI: ${annualizedROI.toFixed(2)}%</p> | ||
`; | ||
} |
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,65 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
.container { | ||
background-color: #fff; | ||
padding: 20px; | ||
border-radius: 5px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
max-width: 400px; | ||
width: 100%; | ||
} | ||
|
||
h2 { | ||
margin-bottom: 20px; | ||
text-align: center; | ||
color: #333; | ||
} | ||
|
||
.form-group { | ||
margin-bottom: 15px; | ||
} | ||
|
||
label { | ||
display: block; | ||
margin-bottom: 5px; | ||
color: #555; | ||
} | ||
|
||
input { | ||
width: 100%; | ||
padding: 8px; | ||
box-sizing: border-box; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
} | ||
|
||
button { | ||
width: 100%; | ||
padding: 10px; | ||
background-color: #28a745; | ||
border: none; | ||
color: white; | ||
font-size: 16px; | ||
cursor: pointer; | ||
border-radius: 4px; | ||
margin-top: 10px; | ||
} | ||
|
||
button:hover { | ||
background-color: #218838; | ||
} | ||
|
||
#result { | ||
margin-top: 20px; | ||
font-size: 18px; | ||
text-align: center; | ||
color: #333; | ||
} |