✏️ Editor HTML — MixarMedia Credit System
Código fuente
Vista previa en vivo
0 caracteres 1 líneas
`; editor.value = originalCode; updateStats(); runCode(); let debounceTimer; function runCode() { const doc = frame.contentDocument || frame.contentWindow.document; doc.open(); doc.write(editor.value); doc.close(); const now = new Date(); lastRunEl.textContent = 'Actualizado ' + now.toLocaleTimeString('es'); } function updateStats() { const val = editor.value; charCountEl.textContent = val.length.toLocaleString() + ' caracteres'; lineCountEl.textContent = val.split('\n').length.toLocaleString() + ' líneas'; } function copyCode() { navigator.clipboard.writeText(editor.value).then(() => { lastRunEl.textContent = '¡Copiado!'; setTimeout(() => lastRunEl.textContent = '', 2000); }); } function saveFile() { const blob = new Blob([editor.value], {type: 'text/html;charset=utf-8'}); const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'tools_modified_v3.html'; a.click(); URL.revokeObjectURL(a.href); lastRunEl.textContent = 'Guardado como tools_modified_v3.html'; setTimeout(() => lastRunEl.textContent = '', 3000); } editor.addEventListener('input', () => { updateStats(); if (autoCheck.checked) { clearTimeout(debounceTimer); debounceTimer = setTimeout(runCode, 600); } }); editor.addEventListener('keydown', e => { if (e.key === 'Tab') { e.preventDefault(); const s = editor.selectionStart; editor.value = editor.value.substring(0, s) + ' ' + editor.value.substring(editor.selectionEnd); editor.selectionStart = editor.selectionEnd = s + 2; } if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') runCode(); if ((e.ctrlKey || e.metaKey) && e.key === 's') { e.preventDefault(); saveFile(); } });