mirror of
https://github.com/anthonyaxenov/password-generator.git
synced 2024-11-22 05:14:43 +00:00
Removed shitty copyBtn
This commit is contained in:
parent
b36994fb91
commit
50ea227d91
28
js/script.js
28
js/script.js
@ -81,8 +81,6 @@ const symbolEl = document.getElementById("symbol");
|
||||
|
||||
// Button to generate the password
|
||||
const generateBtn = document.getElementById("generate");
|
||||
// Button to copy the text
|
||||
const copyBtn = document.getElementById("copy-btn");
|
||||
// Result viewbox container
|
||||
const resultContainer = document.querySelector(".result");
|
||||
// Text info showed after generate button is clicked
|
||||
@ -99,22 +97,6 @@ let resultContainerBound = {
|
||||
left: resultContainer.getBoundingClientRect().left,
|
||||
top: resultContainer.getBoundingClientRect().top,
|
||||
};
|
||||
// This will update the position of the copy button based on mouse Position
|
||||
resultContainer.addEventListener("mousemove", e => {
|
||||
resultContainerBound = {
|
||||
left: resultContainer.getBoundingClientRect().left,
|
||||
top: resultContainer.getBoundingClientRect().top,
|
||||
};
|
||||
if(generatedPassword){
|
||||
copyBtn.style.opacity = '1';
|
||||
copyBtn.style.pointerEvents = 'all';
|
||||
copyBtn.style.setProperty("--x", `${e.x - resultContainerBound.left}px`);
|
||||
copyBtn.style.setProperty("--y", `${e.y - resultContainerBound.top}px`);
|
||||
}else{
|
||||
copyBtn.style.opacity = '0';
|
||||
copyBtn.style.pointerEvents = 'none';
|
||||
}
|
||||
});
|
||||
window.addEventListener("resize", e => {
|
||||
resultContainerBound = {
|
||||
left: resultContainer.getBoundingClientRect().left,
|
||||
@ -123,10 +105,10 @@ window.addEventListener("resize", e => {
|
||||
});
|
||||
|
||||
// Copy Password in clipboard
|
||||
copyBtn.addEventListener("click", () => {
|
||||
resultContainer.addEventListener("click", () => {
|
||||
const textarea = document.createElement("textarea");
|
||||
const password = resultEl.innerText;
|
||||
if (!password || password == "CLICK GENERATE") {
|
||||
if (!password || password == "-") {
|
||||
return;
|
||||
}
|
||||
textarea.value = password;
|
||||
@ -177,11 +159,7 @@ function generatePassword(length, lower, upper, number, symbol) {
|
||||
function disableOnlyCheckbox(){
|
||||
let totalChecked = [uppercaseEl, lowercaseEl, numberEl, symbolEl].filter(el => el.checked)
|
||||
totalChecked.forEach(el => {
|
||||
if(totalChecked.length == 1){
|
||||
el.disabled = true;
|
||||
}else{
|
||||
el.disabled = false;
|
||||
}
|
||||
el.disabled = totalChecked.length == 1
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user