Removed shitty copyBtn

This commit is contained in:
Антон Аксенов 2022-02-09 15:39:18 +08:00
parent b36994fb91
commit 50ea227d91
No known key found for this signature in database
GPG Key ID: 2B5A252645C3E670

View File

@ -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
})
}