Skip to content

Instantly share code, notes, and snippets.

@vipulgupta2048
Created April 8, 2021 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vipulgupta2048/6c742e74e86399acdeb575ee37e00054 to your computer and use it in GitHub Desktop.
Save vipulgupta2048/6c742e74e86399acdeb575ee37e00054 to your computer and use it in GitHub Desktop.
Token Fetcher, Immersive Reader Launcher
tokenGetOverHereandLaunch() {
fetch(tokenURL, { credentials: `include`, cache: "no-store" })
.then(response => response.json())
.then(body => {
// https://docs.microsoft.com/en-us/azure/cognitive-services/immersive-reader/reference#chunk
const data = {
chunks: [{
content: htmlContent,
lang: "en-us",
mimeType: "text/html"
}]
};
// https://docs.microsoft.com/en-us/azure/cognitive-services/immersive-reader/reference#options
const options = {
uiLang: "en-us",
timeout: 90,
uiZIndex: 5,
useWebview: true,
onExit: () => console.log("Closing Immersive Reader"),
allowFullscreen: false,
hideExitButton: false,
cookiePolicy: CookiePolicy,
disableFirstRun: false,
readAloudOptions: ReadAloudOptions,
translationOptions: TranslationOptions,
displayOptions: DisplayOptions,
}
// The backend service needs to be configured to fetch the token from the authentication directory
launchAsync(body.token, body.subdomain, data, options)
.catch(function (error) {
console.log(`Error in launching the Immersive Reader: ${error}`);
});
})
.catch((error) => {
console.error(`Error: ${error}`);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment