/** * TPU Survey - Standalone Editor Logic * รองรับ Section -> Heading -> Question */ let currentSurvey = null; let isDirty = false; async function initEditor() { const urlParams = new URLSearchParams(window.location.search); const id = urlParams.get('id'); if (!id) { alert('ไม่ระบุ ID แบบสอบถาม'); window.close(); return; } try { const data = await API.get(`surveys.php?action=get&id=${id}`); currentSurvey = data.survey; renderEditor(); } catch (err) { Toast.error(err.message); document.getElementById('editorContent').innerHTML = `
${err.message}