-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
47 lines (42 loc) · 1.88 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
const display = document.querySelector("input"),
button = document.querySelector("button"),
copyBtn = document.querySelector("span.far"),
copyActive = document.querySelector("span.fas");
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+~`|}{[]:;?><,./-=";
let copyText = document.querySelector(".copy");
button.onclick = ()=>{
let i,
randomPassword = "";
copyBtn.style.display = "block";
copyActive.style.display = "none";
if (document.getElementById('sayisal').checked == true) {
var chars = "0123456789";
}
else if(document.getElementById('harf').checked == true){
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
}
else if(document.getElementById('harfsayi').checked==true){
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
}
else{
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+~`|}{[]:;?><,./-=";
}
for (i = 0; i < 15; i++) {
randomPassword = randomPassword + chars.charAt(
Math.floor(Math.random() * chars.length)
);
}
display.value = randomPassword;
}
function copy(){
copyText.innerHTML ="Kopyalandı!";
setTimeout(function(){ copyText.innerHTML =""; }, 1500);
copyBtn.style.display = "none";
copyActive.style.display = "block";
setTimeout(function(){copyBtn.style.display = "block";},1500);
setTimeout(function(){copyActive.style.display = "none";},1500);
display.select();
document.execCommand("copy");
document.getElementById("kopyala").innerHTML.replace("Kopyalandı");
// alert("Kopyalandı!")
}