From 472b5e2ef4b43d0a79ee49eb27629cfd2dd3cf8f Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Wed, 22 Feb 2023 20:05:13 -0800 Subject: [PATCH] Refactor view logic into its own function --- index.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 0a7f3c4..0b118ec 100644 --- a/index.html +++ b/index.html @@ -139,6 +139,11 @@ import encrypt from '/encrypt.js'; import decrypt from '/decrypt.js'; + function setOutput(ciphertext) { + document.querySelector('#output').style.display = 'block'; + document.querySelector('#ciphertext').textContent = ciphertext; + } + function downloadHtml(htmlString, fileName) { const encodedHtml = new TextEncoder().encode(htmlString); const file = new File([encodedHtml], fileName, { type: 'text/html' }); @@ -157,8 +162,7 @@ const password = data.get('password'); const encrypted = await encrypt(content, password); - document.querySelector('#output').style.display = 'block'; - document.querySelector('#ciphertext').textContent = encrypted; + setOutput(encrypted); }); document.querySelector('#download').addEventListener('click', e => { -- 2.47.3