From 2cb26d6d40bc436673cbca999cd40cbb445b229d Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Mon, 26 Sep 2022 20:28:22 +0200 Subject: [PATCH] Remove alert() after password update. Replace it by button name update (2 seconds) --- server/resources/gpass.js | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/server/resources/gpass.js b/server/resources/gpass.js index 3b56e8a..c2fd0fd 100755 --- a/server/resources/gpass.js +++ b/server/resources/gpass.js @@ -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,7 +949,14 @@ function update_entry(entry_number) passwords[found] = pentry; ciphered_login.setAttribute("login", pentry.ciphered_login); - alert("Entry updated"); + 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 { button.value = old_value; }, 2000); } else alert('Password copied into clipboard');