-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
74 lines (66 loc) · 1.87 KB
/
app.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
let input = document.querySelectorAll(".one") ;
const copy = document.getElementById("copy") ;
let content = document.getElementById("content") ;
let upperletter = "ABCDEFGHIJKLMNOPQSXYZ"
let lowerletter = "abcdefghijklmnopqsxyz"
let number = "123456789" ;
let symbol = "!@$#$%^&*()_+-" ;
let list = [];
let numberLetter = document.getElementById("numletter") ;
console.log(numberLetter.value) ;
function splitthing(arg) {
for(i=0 ; i<arg.length ; i++) {
list.push(arg[i])
}
}
let btn = document.getElementById("li") ;
btn.addEventListener("click",() => {
for(e of input) {
if(e.checked) {
if(e.id === "a") {
splitthing(upperletter)
}
else if(e.id === "b") {
splitthing(lowerletter)
}
else if(e.id === "c") {
splitthing(number)
}
else if(e.id === "d") {
splitthing(symbol)
}
else {
content.innerText = '' ;
}
}
}
showRandomCode() ;
list = []
}
)
function showRandomCode() {
let nubContent = '' ;
if(numberLetter.value <= 20 && numberLetter.value > 5){
for(t=0 ; t < numberLetter.value ; t++ ) {
let randNumb = Math.floor(Math.random() * list.length)
nubContent += list[randNumb] ;
}
content.innerText = `${nubContent}` ;
}
else {
alert("please enter a number between 6 and 20")
}
}
let body = document.body
copy.addEventListener("click" , () => {
const textarea = document.createElement("textarea") ;
const password = content.innerText ;
if(!password) {
return
}
textarea.value = password ;
body.append(textarea) ;
textarea.select() ;
document.execCommand('copy') ;
textarea.remove() ;
})