forked from snxraven/p2ns
E2EE syntax highlight peer.paste
This commit is contained in:
@@ -678,6 +678,8 @@ function renderPastePage(paste) {
|
||||
${attachments.length ? `<p class="meta">Attachments: ${attachments.map((a) => a.name).join(', ')}</p>` : ''}
|
||||
<p><a href="/">Create another paste</a></p>
|
||||
</div>
|
||||
<script src="/api/vendor/marked.min.js"></script>
|
||||
<script src="/api/vendor/highlight.min.js"></script>
|
||||
<script>
|
||||
const payload = ${JSON.stringify(encryptedPayload)};
|
||||
function b64uToBytes(s) {
|
||||
@@ -726,25 +728,30 @@ function renderPastePage(paste) {
|
||||
out.textContent = 'Failed to decrypt paste: ' + (err && err.message ? err.message : 'unknown error');
|
||||
}
|
||||
}
|
||||
const btn = document.getElementById('decrypt-btn');
|
||||
const input = document.getElementById('manual-key');
|
||||
const keyRow = document.getElementById('key-row');
|
||||
btn.addEventListener('click', () => decryptAndRender(input.value));
|
||||
input.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') decryptAndRender(input.value);
|
||||
});
|
||||
const initial = readKeyFromHash();
|
||||
if (initial) {
|
||||
input.value = initial;
|
||||
keyRow.classList.add('hidden');
|
||||
decryptAndRender(initial);
|
||||
function initDecryptView() {
|
||||
const btn = document.getElementById('decrypt-btn');
|
||||
const input = document.getElementById('manual-key');
|
||||
const keyRow = document.getElementById('key-row');
|
||||
btn.addEventListener('click', () => decryptAndRender(input.value));
|
||||
input.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') decryptAndRender(input.value);
|
||||
});
|
||||
const initial = readKeyFromHash();
|
||||
if (initial) {
|
||||
input.value = initial;
|
||||
keyRow.classList.add('hidden');
|
||||
decryptAndRender(initial);
|
||||
} else {
|
||||
keyRow.classList.remove('hidden');
|
||||
decryptAndRender('');
|
||||
}
|
||||
}
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', initDecryptView);
|
||||
} else {
|
||||
keyRow.classList.remove('hidden');
|
||||
decryptAndRender('');
|
||||
initDecryptView();
|
||||
}
|
||||
</script>
|
||||
<script src="/api/vendor/marked.min.js"></script>
|
||||
<script src="/api/vendor/highlight.min.js"></script>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user