Skip to content
Open
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
76 changes: 76 additions & 0 deletions Calc/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calc</title>
<link rel="stylesheet" href="./stylesheet.css">
<link rel="icon" href="https://icons-for-free.com/iconfiles/png/512/character+http+slash+icon-1320184998745278213.png" type="image/icon type">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">

<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> -->

<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> -->

<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script> -->
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.1/dist/umd/popper.min.js" integrity="sha384-SR1sx49pcuLnqZUnnPwx6FCym0wLsk5JZuNx2bPPENzswTNFaQU1RDvt3wT4gWFG" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.min.js" integrity="sha384-j0CNLUeiqtyaRmlzUHCPZ+Gy5fQu0dQ6eZ/xAww941Ai1SxSY+0EQqNXNE6DZiVc" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"
>
</head>
<body>
<header ><h1 class="fs-1 fw-bold text-center mt-2 animate__pulse">My Calc</h1></header>
<!-- d-flex flex-row align justify-content-md-center justify-content-sm-start -->
<div class=" container mt-2 mb-4 pb-2" >

<div class=" mt-4 pt-4 mb-4 pb-4 table-div">

<div class="calculator">

<input type="text" class="calculator-screen" value="" disabled />

<div class="calculator-keys">

<button type="button" class="operator" value="+"><p class="special">+</p></button>
<button type="button" class="operator" value="-"><p class="special">-</p></button>
<button type="button" class="operator" value="*"><p class="special">&times;</p></button>
<button type="button" class="operator" value="/"><p class="special">&divide;</p></button>

<button type="button" value="7"><p>7</p></button>
<button type="button" value="8"><p>8</p></button>
<button type="button" value="9"><p>9</p></button>


<button type="button" value="4"><p>4</p></button>
<button type="button" value="5"><p>5</p></button>
<button type="button" value="6"><p>6</p></button>


<button type="button" value="1"><p>1</p></button>
<button type="button" value="2"><p>2</p></button>
<button type="button" value="3"><p>3</p></button>


<button type="button" value="0"><p>0</p></button>
<button type="button" class="decimal" value="."><p>.</p></button>
<button type="button" class="all-clear" value="all-clear"><p>AC</p></button>

<button type="button" class="equal-sign operator" value="="><p class="special">=</p></button>

</div>
</div>

</div>
</div>
<script src="script.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>

</body>
</html>
122 changes: 122 additions & 0 deletions Calc/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
const calculator = {
displayValue: '0',
firstOperand: null,
waitingForSecondOperand: false,
operator: null,
};

function inputDigit(digit) {
const { displayValue, waitingForSecondOperand } = calculator;

if (waitingForSecondOperand === true) {
calculator.displayValue = digit;
calculator.waitingForSecondOperand = false;
} else {
calculator.displayValue = displayValue === '0' ? digit : displayValue + digit;
}
}

function inputDecimal(dot) {
if (calculator.waitingForSecondOperand === true) {
calculator.displayValue = "0."
calculator.waitingForSecondOperand = false;
return
}

if (!calculator.displayValue.includes(dot)) {
calculator.displayValue += dot;
}
}

function handleOperator(nextOperator) {
const { firstOperand, displayValue, operator } = calculator
const inputValue = parseFloat(displayValue);

if (operator && calculator.waitingForSecondOperand) {
calculator.operator = nextOperator;
return;
}


if (firstOperand == null && !isNaN(inputValue)) {
calculator.firstOperand = inputValue;
} else if (operator) {
const result = calculate(firstOperand, inputValue, operator);

calculator.displayValue = `${parseFloat(result.toFixed(7))}`;
calculator.firstOperand = result;
}

calculator.waitingForSecondOperand = true;
calculator.operator = nextOperator;
}

function calculate(firstOperand, secondOperand, operator) {
if (operator === '+') {
// console.log("ans" + firstOperand + secondOperand );
return firstOperand + secondOperand;
} else if (operator === '-') {
return firstOperand - secondOperand;
} else if (operator === '*') {
return firstOperand * secondOperand;
} else if (operator === '/') {
return firstOperand / secondOperand;
}

return secondOperand;
}

function resetCalculator() {
calculator.displayValue = '0';
calculator.firstOperand = null;
calculator.waitingForSecondOperand = false;
calculator.operator = null;
}

function updateDisplay() {
const display = document.querySelector('.calculator-screen');
display.value = calculator.displayValue;
}

updateDisplay();

const keys = document.querySelector('.calculator-keys');
keys.addEventListener('click', event => {
// console.log("call at-------------",event.target.firstChild.nodeValue)
// console.log("many1--- ",event.target," ----- evv");
// console.log('after changing',event.target)
// console.log("many2--- ",event.currentTarget," ----- evv");
// const target = event.target.parentElement;
// const { value } = target;

const target = event.target.parentElement;
const { value } = target;
console.log(target,value);
if (!target.matches('button')) {
console.log("exited somes")
return;
}

switch (value) {
case '+':
case '-':
case '*':
case '/':
case '=':
console.log("11111111"+target)
handleOperator(value);
break;
case '.':
inputDecimal(value);
break;
case 'all-clear':
resetCalculator();
break;
default:
if (Number.isInteger(parseFloat(value))) {
inputDigit(value);
}
}

updateDisplay();
});
91 changes: 91 additions & 0 deletions Calc/stylesheet.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
*{
margin: 0px;
padding: 0px;
font-family: 'Roboto Mono', monospace;
font-size: 2vw !important;
font-weight:300 ;
box-sizing: border-box;
}

.table-div{
position: relative;
vertical-align: center;
left:20vw;
height: 30vw;
width: 30vw;
}
p{
margin-bottom: 0px !important;
}
.operator > .special:hover{
transition: 0.7s;
transform: rotate(180deg);
}


.calculator {
border: 1px solid #ccc;
border-radius: 5px;

}

.calculator-screen {
width: 100%;

height: 80px;
border: none;
background-color: #252525;
color: #fff;
text-align: right;
padding-right: 20px;
padding-left: 10px;
}

button {
height: 60px;
background-color: #fff;
border-radius: 3px;
border: 1px solid #c4c4c4;
background-color: transparent;
color: #333;
background-image: linear-gradient(to bottom,transparent,transparent 50%,rgba(0,0,0,.04));
box-shadow: inset 0 0 0 1px rgba(255,255,255,.05), inset 0 1px 0 0 rgba(255,255,255,.45), inset 0 -1px 0 0 rgba(255,255,255,.15), 0 1px 0 0 rgba(255,255,255,.15);
text-shadow: 0 1px rgba(255,255,255,.4);
}

button:hover {
background-color: #eaeaea;
}

.operator {
color: #337cac;
}

.all-clear {
background-color: #f0595f;
border-color: #b0353a;
color: #fff;
}

.all-clear:hover {
background-color: #f17377;
}

.equal-sign {
background-color: #2e86c0;
border-color: #337cac;
color: #fff;
height: 100%;
grid-area: 2 / 4 / 6 / 5;
}

.equal-sign:hover {
background-color: #4e9ed4;
}

.calculator-keys {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 20px;
padding: 20px;
}
61 changes: 61 additions & 0 deletions Calendar/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="https://icons-for-free.com/iconfiles/png/512/character+http+slash+icon-1320184998745278213.png" type="image/icon type">

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">


<link rel="stylesheet" href="stylesheet.css">

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>

<title>Calendar</title>
</head>
<body>

<div id="root" >
<div class="calendar-bg">

<header class="pt-4 mb-4">
<h1 class="text-center fs-1">
Calendar 2021
</h1>
</header>
<div class="d-flex justify-content-around flex-sm-row ">
<button class="btn btn-sm btn-outline-dark mb-4" id="left"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-left" viewBox="0 0 16 16">
<path d="M10 12.796V3.204L4.519 8 10 12.796zm-.659.753-5.48-4.796a1 1 0 0 1 0-1.506l5.48-4.796A1 1 0 0 1 11 3.204v9.592a1 1 0 0 1-1.659.753z"/>
</svg></button>
<!-- Example single danger button -->

<select name="ab" id="select-box" class="btn btn-sm btn-dark-outline fs-4 mb-4" onchange="if (this.selectedIndex) myCall();">
<option value="-1">Month</option>
<option value="0">January</option>
<option value="1">February</option>
<option value="2">March</option>
<option value="3">April</option>
<option value="4">May</option>
<option value="5">June</option>
<option value="6">July</option>
<option value="7">August</option>
<option value="8">September</option>
<option value="9">October</option>
<option value="10">November</option>
<option value="11">December</option>
</select>

<button class="btn btn-sm btn-outline-dark mb-4" id="right"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-right" viewBox="0 0 16 16">
<path d="M6 12.796V3.204L11.481 8 6 12.796zm.659.753 5.48-4.796a1 1 0 0 0 0-1.506L6.66 2.451C6.011 1.885 5 2.345 5 3.204v9.592a1 1 0 0 0 1.659.753z"/>
</svg></button>

</div>
</div>


</div>
<script src="script.js"></script>
</body>
</html>
Loading