Skip to content

Commit

Permalink
Merge branch 'main' into norm
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakesh9100 authored Aug 10, 2024
2 parents 35caef1 + 3335a9f commit f7e925c
Show file tree
Hide file tree
Showing 145 changed files with 303,673 additions and 411 deletions.
50 changes: 38 additions & 12 deletions Calculators/3D-Distance-Calculator/style.css
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

*{
* {
margin: 0;
padding: 0;
font-family: "Poppins", sans-serif;
font-weight: 400;
box-sizing: border-box;
}

.container{
html, body {
height: 100%;
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
overflow: auto;
background: linear-gradient(315deg, rgba(101, 0, 94, 1) 3%, rgba(60, 132, 206, 1) 38%, rgba(48, 238, 226, 1) 68%, rgba(255, 25, 25, 1) 98%);
animation: gradient 15s ease infinite;
background-size: 400% 400%;
background-attachment: fixed;
}

@keyframes gradient {
0% {
background-position: 0% 0%;
}

50% {
background-position: 100% 100%;
}

100% {
background-position: 0% 0%;
}
}

.container {
width: 100%;
height: 100dvh;
background-color: #e3f9ff;
height: 100vh; /* Use vh instead of dvh for compatibility */
display: flex;
align-items: center;
justify-content: center;
}

.calc{
.calc {
padding: 20px;
border-radius: 10px;
background-color: #3a4452;
Expand All @@ -29,7 +54,7 @@
justify-content: center;
}

.display{
.display {
height: 50px;
width: 250px;
border-radius: 10px;
Expand All @@ -38,30 +63,31 @@
color: black;
}

.display{
.display {
font-size: 20px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 5px;
}

form{
form {
display: flex;
gap: 30px;
margin: 20px 0;
}
form input{

form input {
border-radius: 10px;
height: 30px;
width: 150px;
margin: 5px 5px;
padding: 5px;
cursor: pointer;
font-size:20px;
font-size: 20px;
}

button{
button {
height: 50px;
width: 150px;
border: 0;
Expand All @@ -70,4 +96,4 @@ button{
color: white;
cursor: pointer;
background: transparent;
}
}
5 changes: 4 additions & 1 deletion Calculators/5-Band-Resistance-Calculator/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ body {
text-align: center;
justify-content: center;
align-items: center;
height: 120vh;
min-height: 100vh;
margin: 0;
padding: 0;
}

.title {
Expand All @@ -16,6 +18,7 @@ body {

.container {
display: flex;
margin-bottom: 45px;
}

.value_inp {
Expand Down
20 changes: 20 additions & 0 deletions Calculators/6-Band-Resistance-Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# <p align="center">6 Band Resistance Calculator</p>

## Description :-

This is a calculator that will help you calculate the resistance value by inputting the 6 color bands present on the resistor and it will return the resistance value for it including the tolerance value.

## Tech Stacks :-

- HTML
- CSS
- JavaScript

## Features :-

- Gives the theoretical resistance value of a given resistor.
- The calculator is responsive also and can be viewed on any device.

## Screenshots :-

![image](https://github.com/user-attachments/assets/bf49c92f-34e4-4ab3-a5c2-ef2b6edd62ae)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions Calculators/6-Band-Resistance-Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!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">
<link rel="shortcut icon" href="./assets/resistor.png" type="image/x-icon">
<title>6 Band Resistance Calculator</title>
</head>

<body>
<h1 class="title">Resistance <br> <img src="./assets/resistor2.png" alt="Resistor Image"> <br> Calculator</h1>
<div id="container">
<div class="value_inp">
<div class="1stcol">
<label for="band1">Select Band 1 colour:</label>
<select id="band1"></select>
</div>
<div class="2ndcol">
<label for="band2">Select Band 2 colour:</label>
<select id="band2"></select>
</div>
<div class="3rdcol">
<label for="band3">Select Band 3 colour:</label>
<select id="band3"></select>
</div>
<div class="4thcol">
<label for="band4">Select Band 4 (Multiplier):</label>
<select id="band4"></select>
</div>
<div class="tolr">
<label for="band5">Select Tolerance:</label>
<select id="band5"></select>
</div>
<div class="temp-coeff">
<label for="band6">Select Temperature Coefficient:</label>
<select id="band6"></select>
</div>
<button class="btn" onclick="calculateResistance()">Calculate</button>
</div>
<div id="popup" class="popup">
<div class="popup-content">
<h2 id="result">Resistance Result</h2>
<p id="popup-result"></p>
<button id="closebtn" onclick="closePopup()">Close</button>
</div>
</div>
</div>
<script src="./script.js"></script>
</body>

</html>
101 changes: 101 additions & 0 deletions Calculators/6-Band-Resistance-Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
const band1 = document.getElementById('band1');
const band2 = document.getElementById('band2');
const band3 = document.getElementById('band3');
const band4 = document.getElementById('band4');
const band5 = document.getElementById('band5');
const band6 = document.getElementById('band6');
const calcBtn = document.querySelector('.btn');

// Define color options for each band
const colorOptions = {
band1: ['Black', 'Brown', 'Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Violet', 'Gray', 'White'],
band2: ['Black', 'Brown', 'Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Violet', 'Gray', 'White'],
band3: ['Black', 'Brown', 'Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Violet', 'Gray', 'White'],
band4: ['Black', 'Brown', 'Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Violet', 'Gray', 'White'],
band5: ['Black', 'Brown', 'Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Violet', 'Gray', 'White', 'Gold', 'Silver'],
band6: ['Brown', 'Red', 'Green', 'Blue', 'Violet', 'Gray']
};

function updateDropdownOptions(dropdown, options) {
dropdown.innerHTML = ''; // Clear existing options

for (let i = 0; i < options.length; i++) {
const option = document.createElement('option');
option.value = options[i].toLowerCase();
option.text = options[i];
option.style.backgroundColor = options[i];
dropdown.appendChild(option);
}
}

// Update dropdown options initially and on change
updateDropdownOptions(band1, colorOptions.band1);
updateDropdownOptions(band2, colorOptions.band2);
updateDropdownOptions(band3, colorOptions.band3);
updateDropdownOptions(band4, colorOptions.band4);
updateDropdownOptions(band5, colorOptions.band5);
updateDropdownOptions(band6, colorOptions.band6);

// Adding event listener to the button to calculate the resistance
calcBtn.addEventListener('click', calcResistance);

// Resistance calculating function
function calcResistance() {
const band1Value = band1.value.toLowerCase();
const band2Value = band2.value.toLowerCase();
const band3Value = band3.value.toLowerCase();
const band4Value = band4.value.toLowerCase();
const band5Value = band5.value.toLowerCase();
const band6Value = band6.value.toLowerCase();

const resistorValues = {
black: 0,
brown: 1,
red: 2,
orange: 3,
yellow: 4,
green: 5,
blue: 6,
violet: 7,
gray: 8,
white: 9,
gold: -1,
silver: -2
};

const temperatureCoefficientValues = {
brown: 100,
red: 50,
green: 20,
blue: 10,
violet: 5,
gray: 1
};

const resistanceValue = (resistorValues[band1Value] * 100 + resistorValues[band2Value] * 10 + resistorValues[band3Value]) * Math.pow(10, resistorValues[band4Value]);

let tolerancePercentage = '';

if (band5Value === 'gold') {
tolerancePercentage = '5%';
} else if (band5Value === 'silver') {
tolerancePercentage = '10%';
} else {
tolerancePercentage = `${resistorValues[band5Value]}%`;
}

const temperatureCoefficient = temperatureCoefficientValues[band6Value];

// Open the popup for the resistance result
const popup = document.getElementById('popup');
const popupResult = document.getElementById('popup-result');
popupResult.textContent = `The value of Resistance is ${resistanceValue} Ω ± ${tolerancePercentage} tolerance, with a temperature coefficient of ${temperatureCoefficient} ppm/K`;
popup.style.display = 'flex';
}

// Hide the popup when the Close button is clicked
const closeButton = document.getElementById('closebtn');
closeButton.addEventListener('click', () => {
const popup = document.getElementById('popup');
popup.style.display = 'none';
});
Loading

0 comments on commit f7e925c

Please sign in to comment.