YuJa Panorama LMS Accessibility Platform
@@ -119,3 +119,3 @@ const ULTRA_HOME_TAB_ELEMENT_MAP = { | ||
| let {currIframeDom, currIframe} = await getIframeDomForNewBlackboard(); | ||
| injectVisualizerToMainPageWhenCourseClosed(); | ||
| injectVisualizerToMainPageWhenCourseClosed(false); | ||
@@ -138,3 +138,3 @@ if (!currIframe) { | ||
| async function injectVisualizerToMainPageWhenCourseClosed() { | ||
| async function injectVisualizerToMainPageWhenCourseClosed(isUltra) { | ||
| callbackOnDomElementsLoaded( | ||
@@ -149,2 +149,5 @@ document, | ||
| async function () { | ||
| if (isUltra) { | ||
| destroyWA(); | ||
| } | ||
| callBackOnPageURLChange(function () { | ||
@@ -162,3 +165,3 @@ return !isCourseOpenForNewBB(); | ||
| async function injectForUltraNewBB() { | ||
| injectVisualizerToMainPageWhenCourseClosed(); | ||
| injectVisualizerToMainPageWhenCourseClosed(true); | ||
@@ -178,34 +181,2 @@ await sleep(1500); | ||
| async function newTabLoaded() { | ||
| const maxTries = 20; | ||
| let tryCount = 0; | ||
| let pause = false; | ||
| let tabLoadedChecker = setInterval(async () => { | ||
| if (!pause) { | ||
| pause = true; | ||
| let {currIframeDom} = await getIframeDomForNewBlackboard(); | ||
| let contentLinks; | ||
| if (currIframeDom) { | ||
| contentLinks = currIframeDom.querySelectorAll( | ||
| '#courseMenuPalette_contents li > a', | ||
| ); | ||
| } | ||
| pause = false; | ||
| if (contentLinks && contentLinks.length > 0) { | ||
| clearInterval(tabLoadedChecker); | ||
| injectForNewBlackboard(currIframeDom); | ||
| } | ||
| } | ||
| tryCount++; | ||
| if (tryCount > maxTries) { | ||
| clearInterval(tabLoadedChecker); | ||
| injectForNewBlackboard(currIframeDom); | ||
| } | ||
| }, 1000); | ||
| } | ||
| async function getIframeDomForNewBlackboard() { | ||
@@ -263,53 +234,2 @@ await sleep(1000); | ||
| async function injectForNewBlackboard(currIframeDom) { | ||
| function injectInFrame() { | ||
| const OriginalViewReloadElementMap = { | ||
| navLinksQuery: '#courseMenuPalette_contents li > a', | ||
| pageRootLinkQuery: '#globalNavPageContentArea ol li.root a', | ||
| bcMenu: '#bcMenu li > a', | ||
| assignmentMenu: '#evaMenu li > a', | ||
| toolMenu: '#aitMenu li > a', | ||
| partnerContentMenu: '.actionMenu li > a', | ||
| taskButtons: '.taskbuttondiv input', | ||
| contentList: '.contentList .liItem .item h3 a', | ||
| }; | ||
| let contentLinksQuery = formDomQueryStringFromMap( | ||
| OriginalViewReloadElementMap, | ||
| ); | ||
| let contentLinks = currIframeDom.querySelectorAll(contentLinksQuery); | ||
| injectCallbackOnClickEventsToElements(contentLinks, async (element) => { | ||
| await sleep(1000); | ||
| newTabLoaded(currIframeDom); | ||
| }); | ||
| let contentItemDownArrowQuery = | ||
| '.contentList .liItem .contextMenuContainer a'; | ||
| let contentItemDownArrow = currIframeDom.querySelectorAll( | ||
| contentItemDownArrowQuery, | ||
| ); | ||
| injectCallbackOnClickEventsToElements( | ||
| contentItemDownArrow, | ||
| async (element) => { | ||
| await sleep(500); | ||
| let contentItemDownArrowQuery = | ||
| '#' + element.id.replace('cmlink', 'cmdiv'); | ||
| let contentItemDown = currIframeDom.querySelectorAll( | ||
| contentItemDownArrowQuery, | ||
| ); | ||
| injectCallbackOnClickEventsToElements( | ||
| contentItemDown, | ||
| async (element) => { | ||
| await sleep(1000); | ||
| newTabLoaded(currIframeDom); | ||
| }, | ||
| ); | ||
| }, | ||
| ); | ||
| } | ||
| injectInFrame(); | ||
| load(currIframeDom); | ||
@@ -316,0 +236,0 @@ } |
+0
-1
@@ -216,3 +216,2 @@ /** | ||
| 'panorama-key', | ||
| 'panorama-region', | ||
| 'institute-domain', | ||
@@ -219,0 +218,0 @@ 'lms-type', |
+1
-1
@@ -5,3 +5,3 @@ { | ||
| "author": "YuJa Panorama", | ||
| "version": "4.1.0", | ||
| "version": "4.2.0", | ||
| "description": "Enables YuJa Panorama visualizations for end users. This includes alternative formats, analytics gauges and accessibility reports.", | ||
@@ -8,0 +8,0 @@ "content_scripts": [ |
| const localOrigins = ['localhost.yuja.com', 'localhost']; | ||
| const stagingOrigins = [ | ||
| 'staging-panorama.yuja.com', | ||
| 'staging-panorama-api.yuja.com', | ||
| ]; | ||
| const USOrigins = ['panorama.yuja.com', 'panorama-api.yuja.com']; | ||
| const CAOrigins = ['panorama-cz.yuja.com', 'panorama-api-cz.yuja.com']; | ||
| const EUOrigins = ['panorama-ez.yuja.com', 'panorama-api-ez.yuja.com']; | ||
| const validOrigins = [ | ||
| ...localOrigins, | ||
| ...stagingOrigins, | ||
| ...USOrigins, | ||
| ...CAOrigins, | ||
| ...EUOrigins, | ||
| ]; | ||
| function validateEventOrigin(reqUrl) { | ||
| const originHostname = new URL(reqUrl).hostname; | ||
| return validOrigins.includes(originHostname); | ||
| return ( | ||
| localOrigins.includes(originHostname) || | ||
| originHostname.endsWith('.yuja.com') | ||
| ); | ||
| } | ||
@@ -43,5 +26,2 @@ | ||
| visualize(); | ||
| } else if (requestType === 'panorama-plugin:updateCredentials') { | ||
| await updateCredentials(data, event.source, event.origin); | ||
| visualize(); | ||
| } | ||
@@ -53,32 +33,7 @@ } | ||
| async function storeCredentials(data, source, origin) { | ||
| function getRegion(origin) { | ||
| try { | ||
| const originHostname = new URL(origin).hostname; | ||
| if (stagingOrigins.includes(originHostname)) { | ||
| return 'staging'; | ||
| } else if (CAOrigins.includes(originHostname)) { | ||
| return 'canada'; | ||
| } else if (EUOrigins.includes(originHostname)) { | ||
| return 'europe'; | ||
| } else if (USOrigins.includes(originHostname)) { | ||
| return 'us'; | ||
| } else if (localOrigins.includes(originHostname)) { | ||
| return 'local'; | ||
| } else { | ||
| console.error(`Unable to get region from ${origin}`); | ||
| return ''; | ||
| } | ||
| } catch (e) { | ||
| console.error( | ||
| `Panorama Browser Extension: Error getting region from ${origin}. Error: ${e}`, | ||
| ); | ||
| return ''; | ||
| } | ||
| } | ||
| const region = getRegion(origin); | ||
| const { | ||
| extensionToken, | ||
| panoramaServerUrl, | ||
| panoramaCDNUrl, | ||
| portalServerUrl, | ||
| identifierKey, | ||
@@ -93,4 +48,2 @@ lmsType, | ||
| if ( | ||
| region && | ||
| region.length > 0 && | ||
| extensionToken && | ||
@@ -104,3 +57,2 @@ extensionToken.length > 0 && | ||
| 'panorama-key': identifierKey, | ||
| 'panorama-region': region, | ||
| 'institute-domain': domain, | ||
@@ -111,2 +63,5 @@ 'lms-type': lmsType, | ||
| userId, | ||
| panoramaServerUrl, | ||
| panoramaCDNUrl, | ||
| portalServerUrl, | ||
| }); | ||
@@ -126,23 +81,4 @@ | ||
| async function updateCredentials(data, source, origin) { | ||
| const {extensionToken, panoramaServerUrl, panoramaCDNUrl, portalServerUrl} = | ||
| data; | ||
| if (extensionToken && extensionToken.length > 0) { | ||
| await setObjectToGoogleStorage({ | ||
| panoramaServerUrl, | ||
| panoramaCDNUrl, | ||
| portalServerUrl, | ||
| }); | ||
| source.postMessage('panorama-plugin:update-successful', origin); | ||
| } else { | ||
| console.error( | ||
| 'Panorama Browser Extension: Unable to update - invalid extensionToken', | ||
| ); | ||
| source.postMessage('panorama-plugin:update-failed', origin); | ||
| } | ||
| } | ||
| function requestForLogin(source, origin) { | ||
| source.postMessage('panorama-plugin:request', origin); | ||
| } |
@@ -65,2 +65,4 @@ const INJECT_VISUALIZER_LMS_MAP = [ | ||
| scriptId = 'panoWAVisualizerScript'; | ||
| } else if (lms == LMS_TYPES.BLACKBOARD) { | ||
| scriptId = 'panoWAVisualizerScript'; | ||
| } | ||
@@ -94,12 +96,29 @@ | ||
| 'panorama-key', | ||
| 'panoramaServerUrl', | ||
| 'panoramaCDNUrl', | ||
| 'panorama-region', | ||
| ]); | ||
| const region = result['panorama-region']; | ||
| const apiKey = result['panorama-key']; | ||
| const token = result['panorama-token']; | ||
| const region = result['panorama-region']; | ||
| let serverUrl = result['panoramaServerUrl']; | ||
| let cdnUrl = result['panoramaCDNUrl']; | ||
| if (!region || !apiKey || !token) { | ||
| return null; | ||
| if ((!serverUrl || !cdnUrl) && region) { | ||
| const urls = getServerUrlForBackwardCompatibility(region); | ||
| if (urls) { | ||
| ({serverUrl, cdnUrl} = urls); | ||
| } | ||
| } | ||
| return { | ||
| serverUrl, | ||
| cdnUrl, | ||
| apiKey, | ||
| token, | ||
| }; | ||
| } | ||
| function getServerUrlForBackwardCompatibility(region) { | ||
| const regionUrls = { | ||
@@ -119,3 +138,2 @@ us: ['https://panorama-api.yuja.com', 'https://cdn-panorama.yuja.com'], | ||
| ], | ||
| local: ['https://localhost.yuja.com', 'https://localhost.yuja.com'], | ||
| }; | ||
@@ -126,5 +144,6 @@ | ||
| const [serverUrl, cdnUrl] = urls; | ||
| return {serverUrl, cdnUrl, apiKey, token}; | ||
| return {serverUrl, cdnUrl}; | ||
| } | ||
| return null; | ||
| } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet