From 17bbac63a67fb729f4a97abc3c9c0c0490bcad1f Mon Sep 17 00:00:00 2001 From: MathiasDPX Date: Thu, 6 Mar 2025 20:08:25 +0100 Subject: [PATCH] fix: remove editor.js --- static/editor.js | 52 ------------------------------------------------ 1 file changed, 52 deletions(-) delete mode 100644 static/editor.js diff --git a/static/editor.js b/static/editor.js deleted file mode 100644 index c87db38..0000000 --- a/static/editor.js +++ /dev/null @@ -1,52 +0,0 @@ -const codeArea = document.getElementById('code') -const previewFrame = document.getElementById('preview') -const previewSwitch = document.getElementById('previewSwitch') -let lastCode = '' -let previewMode = false - -function forceUpdatePreview() { - const currentCode = codeArea.value - const encodedCode = btoa(currentCode) - let url = `http://127.0.0.1:5000/preview/${encodedCode}` - if (previewMode) { - url += "?website=True" - } - previewFrame.src = url -} - -function updatePreview() { - const currentCode = codeArea.value - if (currentCode !== lastCode) { - forceUpdatePreview(); - lastCode = currentCode - } -} - -function saveCode() { - const currentCode = codeArea.value - const blob = new Blob([currentCode], { type: 'text/plain' }) - const url = URL.createObjectURL(blob) - const a = document.createElement('a') - a.href = url - a.download = 'code.html' - a.style.display = 'none' - document.body.appendChild(a) - a.click() - document.body.removeChild(a) - URL.revokeObjectURL(url) -} - -setInterval(updatePreview, 1000) -updatePreview() - -document.addEventListener('keydown', function(event) { - if (event.ctrlKey && event.key === 's') { - event.preventDefault() - saveCode() - } -}) - -previewSwitch.addEventListener('change', function(event) { - previewMode = event.target.checked - forceUpdatePreview() -}) \ No newline at end of file