📄

    ${bodyHtml} `; lastHtml = fullHtml; $('#downloadBtn').disabled = false; $('#copyBtn').disabled = false; } catch(e) { status.innerHTML = '' + t('error').replace('{msg}', e.message) + ''; } }); } // Wire up $('#drop').addEventListener('click', () => $('#file').click()); $('#file').addEventListener('change', e => { if (e.target.files[0]) convert(e.target.files[0]); }); $('#drop').addEventListener('dragover', e => { e.preventDefault(); $('#drop').classList.add('drag'); }); $('#drop').addEventListener('dragleave', () => $('#drop').classList.remove('drag')); $('#drop').addEventListener('drop', e => { e.preventDefault(); $('#drop').classList.remove('drag'); const f = e.dataTransfer.files[0]; if (f) convert(f); }); document.querySelectorAll('input[name="mode"]').forEach(r => r.addEventListener('change', () => { // Re-convert if we have a file if (lastHtml) { const f = $('#file').files[0]; if (f) convert(f); } })); $('#downloadBtn').addEventListener('click', () => { if (!lastHtml) return; const blob = new Blob([lastHtml], { type: 'text/html;charset=utf-8' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'converted.html'; a.click(); URL.revokeObjectURL(url); }); $('#copyBtn').addEventListener('click', () => { if (!lastHtml) { alert(t('empty')); return; } copyText(lastHtml); const btn = $('#copyBtn'); const orig = btn.textContent; btn.textContent = '✓'; setTimeout(() => { btn.textContent = orig; }, 1500); }); $('#clearBtn').addEventListener('click', () => { $('#preview').innerHTML = ''; $('#status').innerHTML = ''; $('#file').value = ''; lastHtml = ''; $('#downloadBtn').disabled = true; $('#copyBtn').disabled = true; }); // Labels $('#drop-title').textContent = t('dropTitle'); $('#drop-sub').textContent = t('dropSub'); $('#lbl-layout').textContent = t('lblLayout'); $('#lbl-flow').textContent = t('lblFlow'); $('#downloadBtn').textContent = '⬇ ' + t('download'); $('#copyBtn').textContent = t('copy'); $('#clearBtn').textContent = t('clear'); $('#note').textContent = t('note'); GZ.renderToolPage({ category: 'convert', titleKey: 'toolTitle', descKey: 'toolDesc', howToSteps: ['step1','step2','step3','step4'], related: [ {icon:'📝', href:'/convert/pdf-to-text.html', name:'PDF to Text'}, {icon:'🖼️', href:'/convert/pdf-to-image.html', name:'PDF to Image'}, {icon:'🖼️', href:'/convert/pdf-to-jpg.html', name:'PDF to JPG'}, {icon:'📑', href:'/convert/pdf-merger.html', name:'PDF Merger'}, ] });