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) {
|
async function generateLink(id) {
|
||||||
try {
|
try {
|
||||||
const data = await API.post('surveys.php?action=generateLink', { id });
|
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}`;
|
const fullUrl = data.full_url || `${window.location.origin}${basePath}/respond.php?link=${data.unique_link}`;
|
||||||
|
|
||||||
// Find survey title
|
// Find survey title
|
||||||
|
|||||||
@@ -4,7 +4,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const getAppBasePath = () => {
|
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 = {
|
const API = {
|
||||||
|
|||||||
+3
-3
@@ -76,7 +76,7 @@ function renderEditor() {
|
|||||||
<input type="hidden" id="edit-survey-cert-template-path" value="${escapeHtml(currentSurvey.certificate_template || '')}">
|
<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'};">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ function closeEditor() {
|
|||||||
|
|
||||||
function previewSurvey() {
|
function previewSurvey() {
|
||||||
if (!currentSurvey) return;
|
if (!currentSurvey) return;
|
||||||
const basePath = window.location.pathname.includes('/survey') ? '/survey' : '';
|
const basePath = getAppBasePath();
|
||||||
window.open(`${basePath}/respond.php?link=${currentSurvey.unique_link}`, '_blank');
|
window.open(`${basePath}/respond.php?link=${currentSurvey.unique_link}`, '_blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -519,7 +519,7 @@ async function uploadCertTemplate(input) {
|
|||||||
formData.append('template_image', file);
|
formData.append('template_image', file);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const basePath = window.location.pathname.includes('/survey') ? '/survey' : '';
|
const basePath = getAppBasePath();
|
||||||
const res = await fetch(`${basePath}/api/surveys.php?action=uploadTemplate`, {
|
const res = await fetch(`${basePath}/api/surveys.php?action=uploadTemplate`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
|
|||||||
+2
-2
@@ -15,7 +15,7 @@ async function initSurvey() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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());
|
const data = await fetch(`${basePath}/api/surveys.php?action=getByLink&link=${encodeURIComponent(link)}`).then(r => r.json());
|
||||||
|
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
@@ -247,7 +247,7 @@ async function submitSurveyResponse(e) {
|
|||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const basePath = window.location.pathname.includes('/survey') ? '/survey' : '';
|
const basePath = getAppBasePath();
|
||||||
const res = await fetch(`${basePath}/api/responses.php?action=submit`, {
|
const res = await fetch(`${basePath}/api/responses.php?action=submit`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
|||||||
+1
-1
@@ -374,7 +374,7 @@ async function teacherDuplicateSurvey(id) {
|
|||||||
async function teacherGenerateLink(id) {
|
async function teacherGenerateLink(id) {
|
||||||
try {
|
try {
|
||||||
const data = await API.post('surveys.php?action=generateLink', { id });
|
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}`;
|
const fullUrl = data.full_url || `${window.location.origin}${basePath}/respond.php?link=${data.unique_link}`;
|
||||||
|
|
||||||
// Find survey title
|
// Find survey title
|
||||||
|
|||||||
Reference in New Issue
Block a user