From: Ardis Lu Date: Wed, 22 Feb 2023 05:08:21 +0000 (-0800) Subject: Expand output section X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=a78e1d412989a30dea962952730917a049802206;p=static-encrypt Expand output section --- diff --git a/index.html b/index.html index 642078b..e681414 100644 --- a/index.html +++ b/index.html @@ -50,8 +50,8 @@ margin-block-end: 16px; } - textarea { - block-size: 20rem; + output { + display: none; } button { @@ -93,7 +93,11 @@ - + + +

+        
+      
@@ -157,6 +161,16 @@ return content; } + function downloadHtml(htmlString, fileName) { + const encodedHtml = new TextEncoder().encode(htmlString); + const file = new File([encodedHtml], fileName, { type: 'text/html' }); + + const a = document.createElement('a'); + a.href = URL.createObjectURL(file); + a.download = file.name; + a.click(); + } + const { default: decrypt } = await import('/decrypt.js'); const template = await fetch('/template.html').then(r => r.text()); document.querySelector('form').addEventListener('submit', async e => { @@ -167,10 +181,16 @@ const password = data.get('password'); const encrypted = await encrypt(content, password); + document.querySelector('#output').style.display = 'block'; + document.querySelector('#ciphertext').textContent = encrypted; + }); + + document.querySelector('#download').addEventListener('click', e => { + const encrypted = document.querySelector('#ciphertext').textContent; const scriptInjection = `