UNPKG

@gobistories/gobi-web-integration

Version:

This library will let you put your Gobi stories on your site.

96 lines (78 loc) 2.33 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <title>Gobi Stories</title> <link rel="shortcut icon" href="bubbles-favicon.ico" /> <script type="text/javascript" src="/dist/run-config.js"></script> <style> body { display: flex; justify-content: center; margin: 0; padding: 0; height: 100vh; width: 100vw; background: none transparent; } #player { height: 100%; width: 100%; } </style> <script> function displayPlayer() { const params = new URLSearchParams(location.search); if (!params.get('storyId')) { return console.warn("gobi: No story id specified."); } const pageOptions = { backgroundColor: null, }; const options = { autoStartWithSound: true, checkViewPort: true, apiBaseUrl: runConfig.apiBaseUrl, }; if (params.has('backOnComplete')) { if (params.get('backOnComplete')) { options['on'] = { videoComplete: () => history.back(), }; const playerElement = document.querySelector('#player'); playerElement.addEventListener('click', (event) => event.target != playerElement || window.history.back()); } params.delete('backOnComplete'); } for (var [key, value] of params.entries()) { if ('false' === value) { value = false; } else if (value == parseInt(value)) { value = parseInt(value); } if (match = key.match(/^page\-(.*)/)) { pageOptions[match[1]] = value; } else { options[key] = value; } } options['container'] = '#player'; const body = document.querySelector("body"); for (const key in pageOptions) { if (pageOptions[key]) { body.style[key] = pageOptions[key]; } } options['autoStartWithSound'] = false; const gobiPlayer = new gobi.Player(options); } </script> <script type="text/javascript" src="../index.js?v=d85e77"></script></head> <body> <div id="player"></div> <script> document.addEventListener('DOMContentLoaded', displayPlayer); </script> </body> </html>