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
16 changes: 13 additions & 3 deletions password-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous" />
<link rel="stylesheet" href="style.css" />
<style>
@import url('https://fonts.googleapis.com/css?family=Muli&display=swap');

</style>
<title>Password Generator</title>
<link rel="stylesheet" href="style.css">
<link rel="icon" type="image/png" href="padlock.png">
</head>
<body>
<div class="container">
Expand Down Expand Up @@ -42,7 +47,12 @@ <h2>Password Generator</h2>
<button class="btn btn-large" id="generate">
Generate Password
</button>
<button class="btn btn-large" id="clear">
Clear Password
</button>

</div>
<script src="script.js"></script>
<script src="script.js"></script>

</body>
</html>
</html>
15 changes: 13 additions & 2 deletions password-generator/script.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const resultEl = document.getElementById('result')
const resultEl = document.getElementById('result')
const lengthEl = document.getElementById('length')
const uppercaseEl = document.getElementById('uppercase')
const lowercaseEl = document.getElementById('lowercase')
const numbersEl = document.getElementById('numbers')
const symbolsEl = document.getElementById('symbols')
const generateEl = document.getElementById('generate')
const clipboardEl = document.getElementById('clipboard')
const clear = document.getElementById('clear');

const randomFunc = {
lower: getRandomLower,
Expand All @@ -20,7 +21,14 @@ clipboardEl.addEventListener('click', () => {
return;
}
navigator.clipboard.writeText(password);
alert('Password copied to clipboard!')

const icon = clipboardEl.querySelector("i");
icon.className = "fas fa-check";

setTimeout(() => {
icon.classList.remove("fa-check");
icon.classList.add("fa-clipboard");
}, 2000);
})

generateEl.addEventListener('click', () => {
Expand Down Expand Up @@ -54,6 +62,9 @@ function generatePassword(lower, upper, number, symbol, length) {
return finalPassword
}

clear.addEventListener('click' , ()=>{
resultEl.innerText = "";
});
function getRandomLower() {
return String.fromCharCode(Math.floor(Math.random() * 26) + 97)
}
Expand Down
11 changes: 9 additions & 2 deletions password-generator/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import url('https://fonts.googleapis.com/css?family=Muli&display=swap');

* {
box-sizing: border-box;
Expand Down Expand Up @@ -27,7 +26,8 @@ h2 {
background-color: #23235b;
box-shadow: 0px 2px 10px rgba(255, 255, 255, 0.2);
padding: 20px;
width: 350px;
width: 380px;
height: 460px;
max-width: 100%;
}

Expand Down Expand Up @@ -77,10 +77,17 @@ h2 {
display: block;
width: 100%;
}
.btn:hover{
background-color: #48489a;
}

.setting {
display: flex;
justify-content: space-between;
align-items: center;
margin: 15px 0;
}
#clear{
margin-top: 1rem;
}