Skip to content

Commit

Permalink
change the event listener on the 'load' event to avoid unnecessary nu…
Browse files Browse the repository at this point in the history
…ll checking
  • Loading branch information
sergeiown committed Jul 2, 2024
1 parent 41c12ce commit 7869716
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@ const clearButton = document.getElementById('clearButton');
const copyButton = document.getElementById('copyButton');

window.addEventListener('load', () => {
const storedText = getFromLocalStorage('storedText');
const storedMethod = getFromLocalStorage('encryptionMethod');
const storedText = getFromLocalStorage('storedText') || '';
const storedMethod = getFromLocalStorage('encryptionMethod') || '';

if (storedMethod) {
encryptionMethodSelect.value = storedMethod;
}
encryptionMethodSelect.value = storedMethod;
textInput.value = storedText;

if (storedText) {
textInput.value = storedText;
processText(textInput, encryptionMethodSelect, outputTextarea);
}
processText(textInput, encryptionMethodSelect, outputTextarea);
});

textInput.addEventListener('input', () => {
Expand Down

0 comments on commit 7869716

Please sign in to comment.