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
79 changes: 79 additions & 0 deletions JS/CurrencyConverter/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// let url='https://api.frankfurter.app/latest?amount=1&from=USD&to=EUR';
// let url='https://api.frankfurter.app/latest?amount=';

// let url='https://api.exchangerate.host/convert?from=INR&to=PKR&amount=1';
// let url='https://api.exchangerate.host/convert?';

// let url='https://currency-rate-exchange-api.onrender.com/inr';
let url='https://currency-rate-exchange-api.onrender.com/';

// let url2='https://restcountries.com/v3.1/name/india?fullText=true';
let url2='https://restcountries.com/v3.1/name/';


let amt=document.querySelector('#amt');
let fromc=document.querySelector('#fromc');
let toc=document.querySelector('#toc');



let btn=document.querySelector('button');
btn.addEventListener('click',async function(){
let amount=amt.value;
let value1=fromc.value;
let value2=toc.value;

let send1=value1+'?fullText=true';
let send2=value2+'?fullText=true';



let from=await getConvert2(send1);
let to= await getConvert2(send2);

// let queryString='from='+from+'&to='+to+'&amount='+amount;
let queryString=from;
let result=await getConvert(queryString,to);
let p=document.querySelector('p');
p.innerHTML=`${amount}${from} of ${fromc.value} is equal to <b>${result}</b> ${to} of ${toc.value}`



});


async function getConvert(add,to){
try {
url='https://currency-rate-exchange-api.onrender.com/';
add=add.toLowerCase();
to=to.toLowerCase();
let res= await axios.get(url+add);
let rate=res.data.rates[add.toLowerCase()];
let resul=rate[to.toLowerCase()];
console.log(resul);
return resul;

} catch (error) {
console.log( "Error :",error);
}

};

async function getConvert2(add){
try {
url2='https://restcountries.com/v3.1/name/';
let res= await axios.get(url2+add);
let currencies=res.data[0].currencies;
let currenciesCode=Object.keys(currencies);
console.log(currenciesCode[0]);

return currenciesCode[0];
} catch (error) {
console.log( "Error :",error);

}

};



27 changes: 27 additions & 0 deletions JS/CurrencyConverter/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Currency Converter</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

<h1>Currency Converter</h1>


<input type="number" id="amt" placeholder="Enter Amount">
<input type="text" id="fromc" placeholder="From Country">
<input type="text" id="toc" placeholder="TO Country">
<button id="convert">Convert</button>

<p></p>




<script src="app.js"> </script>
</body>
</html>
11 changes: 11 additions & 0 deletions JS/CurrencyConverter/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
body{
text-align: center;
background-color: rgba(12, 12, 115, 0.705);
}
h1{
text-decoration: overline;
}
button{
color: red;
font-weight: 700;
}
152 changes: 152 additions & 0 deletions JS/TicTOE/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
let startboolean=false;
let start=document.querySelector('#start');
let p=document.querySelector('p');


start.addEventListener('click',function () {
if (startboolean==false){
console.log('start');
startboolean=true;
userCall();

}

});






let array=[['one','two','three'],['four','five','six'],['seven','eight','nine']];
function userCall() {
let users=document.querySelectorAll('.fone');
for (const user of users) {
user.addEventListener('click' ,function () {
console.log(user);
let checkans=add(user);

if(checkans=='red'){
p.innerText="Red WIN";
return;

}
else if(checkans=='green'){
p.innerText="GREEN WIN";
return;
}
});
}



}

// add();
let set=0;
function add(user){
let userid=user.id;
for(let i=0;i<array.length;i++){
for(let j=0;j<array[i].length;j++){

if(userid==array[i][j] && set==0){
user.style.backgroundColor='red';
array[i][j]=0;
let ans=check(i,j);
if(ans==1){
return 'red';
}
set=1;
}
else if(userid==array[i][j] && set==1){
user.style.backgroundColor='green';
array[i][j]=1;
let ans=check(i,j);
if(ans==1){
return 'green';
}
set=0;
}
}
}

// draw();

}



// check()
function check(i,j) {


// Horizontal
if((array[0][0]==array[i][j])&&(array[0][1]==array[i][j])&&(array[0][2]==array[i][j])){
return 1;

}
else if((array[1][0]==array[i][j])&&(array[1][1]==array[i][j])&&(array[1][2]==array[i][j])){
return 1;

}
else if((array[2][0]==array[i][j])&&(array[2][1]==array[i][j])&&(array[2][2]==array[i][j])){
return 1;

}

// Vertical
else if((array[0][0]==array[i][j])&&(array[1][0]==array[i][j])&&(array[2][0]==array[i][j])){
return 1;
}
else if((array[0][1]==array[i][j])&&(array[1][1]==array[i][j])&&(array[2][1]==array[i][j])){
return 1;
}
else if((array[0][2]==array[i][j])&&(array[1][2]==array[i][j])&&(array[2][2]==array[i][j])){
return 1;
}

// Diagonal
else if((array[0][0]==array[i][j])&&(array[1][1]==array[i][j])&&(array[2][2]==array[i][j])){
return 1;
}
else if((array[0][2]==array[i][j])&&(array[1][1]==array[i][j])&&(array[2][0]==array[i][j])){
return 1;
}
else{
let count=0;
for (let m = 0; m < array.length; m++) {
for (let n = 0; n< array.length; n++) {
if(array[m][n]==0 || array[m][n]==1){
count++;
}
}
}
if(count==9){
p.innerText="DRAW";
}
}

return 0;


}





let restart=document.querySelector('#restart');
restart.addEventListener('click',function() {
startboolean=false;
array=[['one','two','three'],['four','five','six'],['seven','eight','nine']];
let fones=document.querySelectorAll('.fone');
for (let fone of fones) {
fone.style.backgroundColor='';
p.innerText='';
fone.classList.add('white');

}
set=0;


});
38 changes: 38 additions & 0 deletions JS/TicTOE/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tic Toe</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Welcome To TIC TOE</h1>
<p></p>


<div class="box" id="mainbox">
<div class="first">
<div class="fone" id="one" type="button">1</div>
<div class="fone" id="four" type="button">4</div>
<div class="fone" id="seven" type="button">7</div>
</div>
<div class="Second">
<div class="fone" id="two" type="button">2</div>
<div class="fone" id="five" type="button">5</div>
<div class="fone" id="eight" type="button">8</div>
</div>
<div class="Third">
<div class="fone" id="three" type="button">3</div>
<div class="fone" id="six" type="button">6</div>
<div class="fone" id="nine" type="button">9</div>
</div>
</div>

<button id="start">Start </button>
<button id="restart">ReStart </button>


<script src="app.js"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions JS/TicTOE/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
body{
text-align: center;
background-color: rgb(33, 77, 111);


}

.box{
display: flex;
justify-content: center;

}
.box .fone{
height: 50px;
width: 50px;
border: 2px solid black;
margin: 0.3rem;
}

.red{
background-color: red;
}
.green{
background-color: green;
}
.white{
background-color: white;
}