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

added js to calculator #24

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion Abhishek-Singh-Tanwar/Bootstrap Practice/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
<script src="./script.js"></script>
</body>
</html>
56 changes: 56 additions & 0 deletions Abhishek-Singh-Tanwar/JS-Assignment/Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!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">
<title>Calculator</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>
<body>

<div class="container my-4">

<div class="calculator card">

<input type="text" class="calculator-screen z-depth-1" value="" />

<div class="calculator-keys">

<button type="button" class=" btn btn-info" value="+">+</button>
<button type="button" class=" btn btn-info" value="-">-</button>
<button type="button" class=" btn btn-info" value="*">&times;</button>
<button type="button" class=" btn btn-info" value="/">&divide;</button>

<button type="button" value="7" class="btn btn-light waves-effect">7</button>
<button type="button" value="8" class="btn btn-light waves-effect">8</button>
<button type="button" value="9" class="btn btn-light waves-effect">9</button>


<button type="button" value="4" class="btn btn-light waves-effect">4</button>
<button type="button" value="5" class="btn btn-light waves-effect">5</button>
<button type="button" value="6" class="btn btn-light waves-effect">6</button>


<button type="button" value="1" class="btn btn-light waves-effect">1</button>
<button type="button" value="2" class="btn btn-light waves-effect">2</button>
<button type="button" value="3" class="btn btn-light waves-effect">3</button>


<button type="button" value="0" class="btn btn-light waves-effect">0</button>
<button type="button" class="decimal btn btn-secondary" value=".">.</button>
<button type="button" class="all-clear btn btn-danger btn-sm" value="all-clear">AC</button>

<button style="background-color: #2bbbad;" type="button" class="equal-sign operator btn btn-default" value="=">=</button>

</div>
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous"></script>
<script src="./script.js"></script>
</body>
</html>
54 changes: 54 additions & 0 deletions Abhishek-Singh-Tanwar/JS-Assignment/Calculator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var output="";
let equalBtn=document.querySelector('.equal-sign');
let keyPad=document.querySelector('.calculator-keys');
let outputScreen=document.querySelector('.calculator-screen');


keyPad.addEventListener('click',function(e){

if(e.target.value =='+'){

output+='+';
outputScreen.value=output;

}else if(e.target.value == '-'){

output+='-';
outputScreen.value=output;

}else if(e.target.value =='*'){

output+='*';
outputScreen.value=output;

}else if(e.target.value == '/'){

output+='/';
outputScreen.value=output;

}
else if(e.target.value == 'all-clear'){

output='';
outputScreen.value=output;

}else{
if(e.target.value!='='){
output+=e.target.value;
outputScreen.value=output;
}

}
})

equalBtn.addEventListener('click',function(e){


let result=eval(output);
console.log(result);
output=result;


outputScreen.value=output;

})
49 changes: 49 additions & 0 deletions Abhishek-Singh-Tanwar/JS-Assignment/Calculator/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
html {
font-size: 62.5%;
box-sizing: border-box;
}



.calculator {
border: 1px solid #ccc;
border-radius: 7px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

}

.calculator-screen {
width: 100%;
height: 80px;
border: none;
background-color: #252525;
color: #fff;
text-align: right;
padding-right: 20px;
padding-left: 10px;
font-size: 4rem;
}

button {
height: 60px;
font-size: 2rem!important;
}

.equal-sign {
height: 98%;
grid-area: 2 / 4 / 6 / 5;
}

.calculator-keys {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 20px;
padding: 20px;
}
.btn{
box-shadow:0 2px 5px 0 rgb(0 0 0 / 16%), 0 2px 10px 0 rgb(0 0 0 /12%);
padding: 0.84rem 2.14rem;
}
52 changes: 52 additions & 0 deletions Abhishek-Singh-Tanwar/JS-Assignment/Tic-Tac-Toe/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!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">
<title>Tic-Tac-Toe</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="container">

<div class="rules">


<h1>TIC TAC TOE</h1>
<p id="ins">Game starts by just Tap on
box<br><br>First Player starts as
<b>Player 1</b><br>And<br>Second
Player as <b>Player 2</b>
</p>

<button id="reset" onclick="resetGameBoard()" style="margin-top: 20px;background: blueviolet; color: antiquewhite; font-size: 40px;">
RESET
</button>




</div>
<div class="tic-tac-toe">

<div class="game-board">
<div id="c-1" contenteditable="true" onclick="func1()"></div>
<div id="c-2" contenteditable="true" onclick="func2()"></div>
<div id="c-3" contenteditable="true"onclick="func3()"></div>
<div id="c-4" contenteditable="true"onclick="func4()"></div>
<div id="c-5" contenteditable="true"onclick="func5()"></div>
<div id="c-6" contenteditable="true"onclick="func6()"></div>
<div id="c-7" contenteditable="true"onclick="func7()"></div>
<div id="c-8" contenteditable="true"onclick="func8()"></div>
<div id="c-9"contenteditable="true"onclick="func9()"></div>

</div>
</div>


</div>

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