Remove alert() after password update. Replace it by button name update (2 seconds)

This commit is contained in:
Gregory Soutade 2022-09-26 20:28:22 +02:00
parent 54565f90b6
commit 2cb26d6d40

View File

@ -543,14 +543,14 @@ async function change_master_key(warning_unciphered)
update_button = document.createElement("input");
update_button.setAttribute("type", "button");
update_button.setAttribute("value", "Update");
update_button.setAttribute("onclick", "update_entry(\"unciph_entry_" + i + "\");");
update_button.setAttribute("onclick", "update_entry(this, \"unciph_entry_" + i + "\");");
div.appendChild(update_button);
clipboard_button = document.createElement("input");
clipboard_button.setAttribute("type", "button");
clipboard_button.setAttribute("name", "copy_button");
clipboard_button.setAttribute("value", "Copy password");
clipboard_button.setAttribute("onclick", "copy_clipboard(\"unciph_entry_" + i + "\");");
clipboard_button.setAttribute("onclick", "copy_clipboard(this, \"unciph_entry_" + i + "\");");
div.appendChild(clipboard_button);
clear_passwords.push(div);
@ -885,7 +885,7 @@ function delete_entry(entry_number)
update_stats();
}
function update_entry(entry_number)
function update_entry(button, entry_number)
{
var url = "";
var login = "";
@ -949,6 +949,13 @@ function update_entry(entry_number)
passwords[found] = pentry;
ciphered_login.setAttribute("login", pentry.ciphered_login);
if (button !== null)
{
old_value = button.value;
button.value = "Updated";
window.setTimeout(() => { button.value = old_value; }, 2000);
}
else
alert("Entry updated");
});
}
@ -1016,12 +1023,7 @@ async function update_masterkey()
}
}
function reset_copy_button_name(button)
{
button.value = "Copy password";
}
function copy_clipboard(entry_number)
function copy_clipboard(button, entry_number)
{
var password = "";
@ -1034,16 +1036,6 @@ function copy_clipboard(entry_number)
inputs = entry.getElementsByTagName("input");
var button = null;
for(i=0; i<inputs.length; i++)
{
if (inputs[i].getAttribute("name") == "copy_button")
{
button = inputs[i];
break;
}
}
for(i=0; i<inputs.length; i++)
{
if (inputs[i].getAttribute("name") == "password")
@ -1053,8 +1045,9 @@ function copy_clipboard(entry_number)
inputs[i].setSelectionRange(0,0); // Unselect
if (button !== null)
{
old_value = button.value;
button.value = "Copied";
window.setTimeout(reset_copy_button_name.bind(null, button), 2000);
window.setTimeout(() => { button.value = old_value; }, 2000);
}
else
alert('Password copied into clipboard');