UNPKG

@gobistories/gobi-web-integration

Version:

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

109 lines (92 loc) 2.89 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> html, body { height: 100%; } body { display: flex; justify-content: center; align-items: center; margin: 0; padding: 0; background: none transparent; } </style> <script> function displayBubbles() { const params = new URLSearchParams(location.search); const pageOptions = { color: 'black', backgroundColor: null, }; const options = { color: '#156cea', bubbleSize: '180px', animatedBubble: true, playerOptions: { autoStartWithSound: true, checkViewPort: true, apiBaseUrl: runConfig.apiBaseUrl, }, stories: params.getAll("stories").map((story) => ({ 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."); } 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 if (match = key.match(/^playerOptions\-(.*)/)) { options['playerOptions'][match[1]] = value; } else { options[key] = value; } } if (usePlayerPage) { options.on = { open: (storyId) => { const params = new URLSearchParams(); for (const key in options.playerOptions) { params.set(key, options.playerOptions[key]); } for (const 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 (const key in pageOptions) { if (pageOptions[key]) { body.style[key] = pageOptions[key]; } } const gobiBubbles = new gobi.Bubbles(Object.assign(options, { container: "#bubbles" })); } </script> <script type="text/javascript" src="../index.js?v=d85e77"></script></head> <body> <div id="bubbles"></div> <script> document.addEventListener('DOMContentLoaded', displayBubbles); </script> </body> </html>