]> git.ardis.lu - static-encrypt/commitdiff
Refactor view logic into its own function
authorArdis Lu <ardisglu@gmail.com>
Thu, 23 Feb 2023 04:05:13 +0000 (20:05 -0800)
committerArdis Lu <ardisglu@gmail.com>
Thu, 23 Feb 2023 04:05:13 +0000 (20:05 -0800)
index.html

index 0a7f3c43c060d0782c0fde99017a306d7e04abff..0b118ecafa1b8a6fde5146d9203d745ccb35bbe5 100644 (file)
     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' });
       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 => {
This page took 0.036526 seconds and 4 git commands to generate.