UNPKG

@gobistories/gobi-web-integration

Version:

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

120 lines (98 loc) 3.32 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta content="Watch Story" property="og:title" /> <meta property="og:type" content="website" /> <meta content="https://res.cloudinary.com/gobi-static/image/upload/v1649667490/shared/gobi-share-preview.png" property="og:image" /> <link href="https://res.cloudinary.com/gobi-static/image/upload/v1649667629/shared/favicon.png" rel="shortcut icon" /> <link href="https://res.cloudinary.com/gobi-static/image/upload/v1649667629/shared/touchicon.png" rel="apple-touch-icon" /> <meta content="Watch Story" property="twitter:title" /> <meta content="https://res.cloudinary.com/gobi-static/image/upload/v1649667490/shared/gobi-share-preview.png" property="twitter:image" /> <meta content="summary_large_image" name="twitter:card" /> <title>Gobi Stories - Watch Story</title> <script type="text/javascript" src="/dist/run-config.js"></script> <style> body { display: flex; justify-content: center; margin: 0; padding: 0; height: 100vh; height: -webkit-fill-available; width: 100vw; background: black; } #player { position: absolute; top: 0; right: 0; bottom: 0; left: 0; height: 100%; width: 100%; } </style> <script> function displayPlayer() { const pathMatch = /\/story\/id\/(.*)/.exec(location.pathname); const storyId = pathMatch && pathMatch[1]; const params = new URLSearchParams(location.search); if (storyId) { params.set('storyId', storyId); params.set('page-backgroundColor', 'black'); } if (!params.get('storyId')) { return console.warn("gobi: No story id specified."); } const pageOptions = { backgroundColor: null, }; const options = { 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]; } } 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>