Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frequency Calculator is added #2298

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Frequency Calcullator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!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>Frequency Calculator</title>
</head>
<body>
<div class="container">
<h1>Frequency Calculator</h1>
<div class="calculator">
<div class="input-group">
<label for="period">Period (T) in seconds:</label>
<input type="number" id="period" placeholder="Enter period">
<button onclick="calculateFrequencyByPeriod()">Calculate</button>
</div>
<div class="input-group">
<label for="wavelength">Wavelength (λ) in meters:</label>
<input type="number" id="wavelength" placeholder="Enter wavelength">
</div>
<div class="input-group">
<label for="waveSpeed">Wave Speed (v) in m/s:</label>
<input type="number" id="waveSpeed" placeholder="Enter wave speed">
<button onclick="calculateFrequencyByWavelength()">Calculate</button>
</div>
<div class="input-group">
<label for="angularFrequency">Angular Frequency (ω) in rad/s:</label>
<input type="number" id="angularFrequency" placeholder="Enter angular frequency">
<button onclick="calculateFrequencyByAngularFrequency()">Calculate</button>
</div>
<div class="output-group">
<h2>Frequency (f): <span id="frequencyOutput">--</span> Hz</h2>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
9 changes: 9 additions & 0 deletions Frequency Calcullator/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"manifest_version": 3,
"name": "Frequency Calculator",
"version": "1.0",
"action": {
"default_popup": "index.html"
},
"permissions": []
}
30 changes: 30 additions & 0 deletions Frequency Calcullator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function calculateFrequencyByPeriod() {
const period = document.getElementById('period').value;
if (period > 0) {
const frequency = 1 / period;
document.getElementById('frequencyOutput').textContent = frequency.toFixed(2);
} else {
alert("Please enter a valid period.");
}
}

function calculateFrequencyByWavelength() {
const wavelength = document.getElementById('wavelength').value;
const waveSpeed = document.getElementById('waveSpeed').value;
if (wavelength > 0 && waveSpeed > 0) {
const frequency = waveSpeed / wavelength;
document.getElementById('frequencyOutput').textContent = frequency.toFixed(2);
} else {
alert("Please enter valid values for wavelength and wave speed.");
}
}

function calculateFrequencyByAngularFrequency() {
const angularFrequency = document.getElementById('angularFrequency').value;
if (angularFrequency > 0) {
const frequency = angularFrequency / (2 * Math.PI);
document.getElementById('frequencyOutput').textContent = frequency.toFixed(2);
} else {
alert("Please enter a valid angular frequency.");
}
}
76 changes: 76 additions & 0 deletions Frequency Calcullator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}

.container {
max-width: 800px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
text-align: center;
color: #007BFF;
}

.calculator {
background-color: #f8f9fa;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.input-group {
margin-bottom: 15px;
}

.input-group label {
display: block;
margin-bottom: 8px;
color: #555;
}

.input-group input[type="number"] {
width: calc(100% - 80px);
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 16px;
}

.input-group button {
padding: 8px 12px;
margin-top: 20px;
background-color: #007BFF;
color: #fff;
border: none;
cursor: pointer;
border-radius: 4px;
font-size: 16px;
transition: background-color 0.3s ease;
}

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

.output-group {
margin-top: 20px;
}

.output-group h2 {
font-size: 1.5rem;
color: #333;
}

.output-group #frequencyOutput {
font-weight: bold;
font-size: 1.8rem;
color: #007BFF;
}
Loading