From b20bac443e97b38a342d928eae3b7766df55b3fd Mon Sep 17 00:00:00 2001 From: Weslei Miranda Date: Thu, 25 Jan 2024 20:35:10 -0300 Subject: [PATCH] feat: creates invalid decoding notification --- README.md | 3 ++- script.js | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1f41f21..fe06505 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,9 @@ Uma ferramenta simples e eficiente para mensagens codificadas. Este projeto foi ## Funcionalidades -- **Decodificação Simples:** É possível criptografar e descriptografar mensagens de maneira rápida e fácil. +- **Decodificação Simples:** É possível converter uma palavra para a versão criptografada e retornar para a versão original de maneira rápida e fácil. - **Interface Intuitiva:** Navegue por uma interface limpa e intuitiva, projetada para ser direto ao ponto. +- **Restrição:** Aceita apenas letras minúsculas sem acentos nem caracteres especiais. ## Como Usar diff --git a/script.js b/script.js index 9401e74..5203f7f 100644 --- a/script.js +++ b/script.js @@ -44,7 +44,7 @@ const action = { checkText: (text) => { const regex = /^[a-z\s]+$/; - return regex.test(text) + return regex.test(text); }, decodeText: (operation) => { @@ -53,6 +53,8 @@ const action = { if (action.checkText(sendField.trim())) { receiveField.innerHTML = operation(sendField.trim()); + } else { + notification.invalidDecode(); } }, @@ -80,4 +82,26 @@ const notification = { copyButton.innerHTML = 'Copiar'; }, 500); }, + + invalidDecode: () => { + let notifyField = document.getElementById('main__input__warning__text'); + let notifyIcon = document.getElementById('main__input__warning__icon'); + let count = 0; + + const interval = setInterval(() => { + if(count % 2 === 0) { + notifyField.style.color = '#FF0000'; + notifyIcon.style.backgroundColor = '#FF0000'; + } else { + notifyField.style.color = 'transparent'; + notifyIcon.style.backgroundColor = 'transparent'; + } + + if (++count === 20) { + clearInterval(interval); + notifyField.style.color = '#110F0F'; + notifyIcon.style.backgroundColor = '#008CDB'; + } + }, 100); + }, }