Skip to content

Commit

Permalink
Added Midpoint Calculator Extension: Sulagna-Dutta-Roy#2153
Browse files Browse the repository at this point in the history
  • Loading branch information
Anshika14528 committed Jul 6, 2024
1 parent e426f34 commit c868d00
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Midpoint Calculator Extension/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"manifest_version": 3,
"name": "Midpoint Calculator",
"version": "1.0",
"description": "Midpoint Calculator.",
"permissions": [],
"action": {
"default_popup": "popup.html"
}
}
29 changes: 29 additions & 0 deletions Midpoint Calculator Extension/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Midpoint Calculator</title>
</head>

<body>
<div class="main">
<div class="cal">
<h1>Midpoint Calculator</h1>
<label for="point1">Enter Point 1 (x1, y1):</label>
<input type="text" id="point1" placeholder="Enter x1, y1" />

<label for="point2">Enter Point 2 (x2, y2):</label>
<input type="text" id="point2" placeholder="Enter x2, y2" />

<button id="myButton">Calculate</button>
<div id="result"></div>
</div>
<div id="answer"></div>
</div>
<script src="script.js"></script>
</body>

</html>
22 changes: 22 additions & 0 deletions Midpoint Calculator Extension/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
document.getElementById('myButton').addEventListener('click', function() {
const point1 = document.getElementById('point1').value.split(',');
const point2 = document.getElementById('point2').value.split(',');

if (point1.length === 2 && point2.length === 2) {
const x1 = parseFloat(point1[0]);
const y1 = parseFloat(point1[1]);
const x2 = parseFloat(point2[0]);
const y2 = parseFloat(point2[1]);

if (!isNaN(x1) && !isNaN(y1) && !isNaN(x2) && !isNaN(y2)) {
const midX = (x1 + x2) / 2;
const midY = (y1 + y2) / 2;

document.getElementById('result').innerText = `Midpoint: (${midX}, ${midY})`;
} else {
document.getElementById('result').innerText = 'Please enter valid numbers.';
}
} else {
document.getElementById('result').innerText = 'Please enter two points in the format x,y.';
}
});
93 changes: 93 additions & 0 deletions Midpoint Calculator Extension/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
body {
font-family: "Arial", sans-serif;
background: linear-gradient(50deg, #136f74, #087f9d);
margin: 0;
padding: 0;
list-style: 1.6;
height: 400px;
width: 400px;
}

.main {
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
}

@media screen and (max-width:400px) {
#formula {
font-size: 1.3rem;
font-weight: 600;
}
}

.cal {
text-align: center;
color: #ddd;
}

h1 {
margin: 40px 0;
}

input {
width: calc(100% - 100px);
padding: 10px;
margin: 10px 0 20px 0;
box-sizing: border-box;
font-size: 16px;
border: 1px solid #ddd;
border-radius: 5px;
}

#result {
margin: 1.4rem 0;
font-size: 1.5rem;
color: #000000;
}


.gcd {
font-size: 12px;
font-weight: 600;
margin-top: 0;
}

abel {
font-weight: bold;
display: block;
margin-bottom: 8px;
color: #333333;
}

input,
select {
width: 100%;
padding: 10px;
margin-bottom: 16px;
box-sizing: border-box;
border-radius: 10px;
}

button {
width: 100%;
height: 40px;
font-size: 16px;
cursor: pointer;
background-color: #6f0150;
color: #ffffff;
border: none;
border-radius: 9px;
transition: background-color 0.3s;
}

button:hover {
background-color: #45a09e;
}

#result {
margin-top: 16px;
font-weight: bold;
color: #020101;
}

0 comments on commit c868d00

Please sign in to comment.