Support /meeting path alongside /survey and root paths
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
+3
-3
@@ -76,7 +76,7 @@ function renderEditor() {
|
||||
<input type="hidden" id="edit-survey-cert-template-path" value="${escapeHtml(currentSurvey.certificate_template || '')}">
|
||||
|
||||
<div id="cert-preview-wrapper" style="margin-top:12px; display:${currentSurvey.certificate_template ? 'block' : 'none'};">
|
||||
<img id="cert-template-preview" src="${currentSurvey.certificate_template ? (window.location.pathname.includes('/survey') ? '/survey/' : '/') + currentSurvey.certificate_template : ''}" style="max-height:140px; width:auto; border-radius:8px; border:1px solid var(--border-color); box-shadow:var(--shadow-sm);">
|
||||
<img id="cert-template-preview" src="${currentSurvey.certificate_template ? getAppBasePath() + '/' + currentSurvey.certificate_template : ''}" style="max-height:140px; width:auto; border-radius:8px; border:1px solid var(--border-color); box-shadow:var(--shadow-sm);">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -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' },
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user