mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-03-07 20:58:35 -05:00
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
export function inEmbeddedApp() {
|
|
try {
|
|
const params = new URL(globalThis.location.href).searchParams;
|
|
const mode = params.get('mode');
|
|
|
|
if (mode === 'lms_embed_mode') {
|
|
sessionStorage.setItem('lms_embed_mode', 'true');
|
|
return true;
|
|
}
|
|
|
|
if (mode === 'standard') {
|
|
sessionStorage.removeItem('lms_embed_mode');
|
|
return false;
|
|
}
|
|
|
|
return sessionStorage.getItem('lms_embed_mode') === 'true';
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function isSelectMediaMode() {
|
|
try {
|
|
const params = new URL(globalThis.location.href).searchParams;
|
|
const action = params.get('action');
|
|
|
|
return action === 'select_media';
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export function inSelectMediaEmbedMode() {
|
|
return inEmbeddedApp() && isSelectMediaMode();
|
|
}
|
|
|
|
export function getLtiContextId(): string | null {
|
|
try {
|
|
const params = new URL(globalThis.location.href).searchParams;
|
|
const contextId = params.get('lti_context_id');
|
|
|
|
if (contextId) {
|
|
sessionStorage.setItem('lti_context_id', contextId);
|
|
return contextId;
|
|
}
|
|
|
|
return sessionStorage.getItem('lti_context_id');
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
}
|