From fb505c53d5e960f6e5fa2f33299985821d20db08 Mon Sep 17 00:00:00 2001 From: pongpon pitisuk Date: Thu, 17 Sep 2026 15:32:01 +0700 Subject: [PATCH] Support /meeting path alongside /survey and root paths --- js/admin.js | 2 +- js/app.js | 5 ++++- js/editor.js | 6 +++--- js/survey.js | 4 ++-- js/teacher.js | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/js/admin.js b/js/admin.js index 836a6c0..32092c6 100644 --- a/js/admin.js +++ b/js/admin.js @@ -798,7 +798,7 @@ async function changeStatus(id, status) { async function generateLink(id) { try { const data = await API.post('surveys.php?action=generateLink', { id }); - const basePath = window.location.pathname.includes('/survey') ? '/survey' : ''; + const basePath = getAppBasePath(); const fullUrl = data.full_url || `${window.location.origin}${basePath}/respond.php?link=${data.unique_link}`; // Find survey title diff --git a/js/app.js b/js/app.js index 5c7dcd1..ed75a55 100644 --- a/js/app.js +++ b/js/app.js @@ -4,7 +4,10 @@ */ const getAppBasePath = () => { - return window.location.pathname.includes('/survey') ? '/survey' : ''; + const p = window.location.pathname; + if (p.includes('/meeting')) return '/meeting'; + if (p.includes('/survey')) return '/survey'; + return ''; }; const API = { diff --git a/js/editor.js b/js/editor.js index d4505a1..639831f 100644 --- a/js/editor.js +++ b/js/editor.js @@ -76,7 +76,7 @@ function renderEditor() {
- +
@@ -479,7 +479,7 @@ function closeEditor() { function previewSurvey() { if (!currentSurvey) return; - const basePath = window.location.pathname.includes('/survey') ? '/survey' : ''; + const basePath = getAppBasePath(); window.open(`${basePath}/respond.php?link=${currentSurvey.unique_link}`, '_blank'); } @@ -519,7 +519,7 @@ async function uploadCertTemplate(input) { formData.append('template_image', file); try { - const basePath = window.location.pathname.includes('/survey') ? '/survey' : ''; + const basePath = getAppBasePath(); const res = await fetch(`${basePath}/api/surveys.php?action=uploadTemplate`, { method: 'POST', body: formData diff --git a/js/survey.js b/js/survey.js index 72b9164..95a2c2b 100644 --- a/js/survey.js +++ b/js/survey.js @@ -15,7 +15,7 @@ async function initSurvey() { } try { - const basePath = window.location.pathname.includes('/survey') ? '/survey' : ''; + const basePath = getAppBasePath(); const data = await fetch(`${basePath}/api/surveys.php?action=getByLink&link=${encodeURIComponent(link)}`).then(r => r.json()); if (data.error) { @@ -247,7 +247,7 @@ async function submitSurveyResponse(e) { const params = new URLSearchParams(window.location.search); try { - const basePath = window.location.pathname.includes('/survey') ? '/survey' : ''; + const basePath = getAppBasePath(); const res = await fetch(`${basePath}/api/responses.php?action=submit`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, diff --git a/js/teacher.js b/js/teacher.js index fc16d1b..b1e50dd 100644 --- a/js/teacher.js +++ b/js/teacher.js @@ -374,7 +374,7 @@ async function teacherDuplicateSurvey(id) { async function teacherGenerateLink(id) { try { const data = await API.post('surveys.php?action=generateLink', { id }); - const basePath = window.location.pathname.includes('/survey') ? '/survey' : ''; + const basePath = getAppBasePath(); const fullUrl = data.full_url || `${window.location.origin}${basePath}/respond.php?link=${data.unique_link}`; // Find survey title