UNPKG

@gobistories/gobi-web-integration

Version:

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

128 lines (105 loc) 3.75 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="Story Bubbles" 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="Story Bubbles" 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 - Story Bubbles</title> <script type="text/javascript" src="/dist/run-config.js"></script> <!--URLSearchParams Polyfill for IE --> <script src="https://cdnjs.cloudflare.com/ajax/libs/url-search-params/1.1.0/url-search-params.js"></script> <style> html, body { height: 100%; } body { display: flex; justify-content: center; align-items: center; margin: 0; padding: 0; background: none transparent; } #bubbles { width: 100%; } </style> <script> function displayBubbles() { const params = new URLSearchParams(location.search); const pageOptions = { color: 'black', backgroundColor: null, }; const options = { color: '#156cea', animatedBubble: true, bubbleSize: '200px', playerOptions: { autoStartWithSound: true, checkViewPort: true, apiBaseUrl: runConfig.apiBaseUrl, }, stories: params.getAll("stories").map(function (story) { return { id: story }; }), }; params.delete('stories'); const usePlayerPage = params.get('usePlayerPage'); params.delete('usePlayerPage'); if (!options.stories.length) { return console.warn("gobi: No story ids specified."); } params.forEach(function (value, key) { if ('false' === value) { value = false; } else if (value == parseInt(value)) { value = parseInt(value); } if (match = key.match(/^page\-(.*)/)) { pageOptions[match[1]] = value; } else if (match = key.match(/^playerOptions\-(.*)/)) { options['playerOptions'][match[1]] = value; } else { options[key] = value; } }); if (usePlayerPage) { options.on = { open: function (storyId) { const params = new URLSearchParams(); for (key in options.playerOptions) { params.set(key, options.playerOptions[key]); } for (key in pageOptions) { params.set('page-' + key, pageOptions[key]); } location.href = 'player-page.html?storyId=' + storyId + '&backOnComplete=true&' + params.toString(); return false; } }; } const body = document.querySelector("body"); for (key in pageOptions) { if (pageOptions[key]) { body.style[key] = pageOptions[key]; } } const gobiBubbles = new gobi.Bubbles(Object.assign(options, { container: "#bubbles" })); } document.addEventListener('DOMContentLoaded', displayBubbles); </script> <script type="text/javascript" src="index.js?v=d85e77"></script></head> <body> <div id="bubbles"></div> </body> </html>