-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
49 lines (49 loc) · 1.57 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!-- HTML -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="/main.css"/>
</head>
<body>
<div class="container">
<div class="text">
Password Generator
</div>
<div class="input-data">
<div class="display">
<input type="text">
<span class="far fa-copy" onclick="copy()"></span>
<span class="fas fa-copy" onclick="copy()"></span>
</div>
<button>Generate</button>
</div>
</div>
<script>
const display = document.querySelector("input"),
button = document.querySelector("button"),
copyBtn = document.querySelector("span.far"),
copyActive = document.querySelector("span.fas");
let chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
button.onclick = ()=>{
let i,
randomPassword = "";
copyBtn.style.display = "block";
copyActive.style.display = "none";
for (i = 0; i < 16; i++) {
randomPassword = randomPassword + chars.charAt(
Math.floor(Math.random() * chars.length)
);
}
display.value = randomPassword;
}
function copy(){
copyBtn.style.display = "none";
copyActive.style.display = "block";
display.select();
document.execCommand("copy");
}
</script>
</body>
</html>