Removed shitty copyBtn

pull/1/head
Антон Аксенов 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
1 changed files with 3 additions and 25 deletions

View File

@ -81,8 +81,6 @@ const symbolEl = document.getElementById("symbol");
// Button to generate the password // Button to generate the password
const generateBtn = document.getElementById("generate"); const generateBtn = document.getElementById("generate");
// Button to copy the text
const copyBtn = document.getElementById("copy-btn");
// Result viewbox container // Result viewbox container
const resultContainer = document.querySelector(".result"); const resultContainer = document.querySelector(".result");
// Text info showed after generate button is clicked // Text info showed after generate button is clicked
@ -99,22 +97,6 @@ let resultContainerBound = {
left: resultContainer.getBoundingClientRect().left, left: resultContainer.getBoundingClientRect().left,
top: resultContainer.getBoundingClientRect().top, 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 => { window.addEventListener("resize", e => {
resultContainerBound = { resultContainerBound = {
left: resultContainer.getBoundingClientRect().left, left: resultContainer.getBoundingClientRect().left,
@ -123,10 +105,10 @@ window.addEventListener("resize", e => {
}); });
// Copy Password in clipboard // Copy Password in clipboard
copyBtn.addEventListener("click", () => { resultContainer.addEventListener("click", () => {
const textarea = document.createElement("textarea"); const textarea = document.createElement("textarea");
const password = resultEl.innerText; const password = resultEl.innerText;
if (!password || password == "CLICK GENERATE") { if (!password || password == "-") {
return; return;
} }
textarea.value = password; textarea.value = password;
@ -177,11 +159,7 @@ function generatePassword(length, lower, upper, number, symbol) {
function disableOnlyCheckbox(){ function disableOnlyCheckbox(){
let totalChecked = [uppercaseEl, lowercaseEl, numberEl, symbolEl].filter(el => el.checked) let totalChecked = [uppercaseEl, lowercaseEl, numberEl, symbolEl].filter(el => el.checked)
totalChecked.forEach(el => { totalChecked.forEach(el => {
if(totalChecked.length == 1){ el.disabled = totalChecked.length == 1
el.disabled = true;
}else{
el.disabled = false;
}
}) })
} }