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() {
-
 ? '/survey/' : '/') + currentSurvey.certificate_template : ''})
+
@@ -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