Created
October 11, 2017 15:10
-
-
Save muodov/9cf2ec922e26999a8026b5e9d5099a99 to your computer and use it in GitHub Desktop.
surfly session id approach
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head></head> | |
<body> | |
<div id="surfly-control" class="hidden">CLICK ME!</div> | |
<style> | |
.start-surfly { | |
cursor: pointer; | |
color: red; | |
} | |
.hidden { | |
display: none; | |
} | |
</style> | |
<script> | |
(function(s,u,r,f,l,y){s[f]=s[f]||{init:function(){s[f].q=arguments}}; | |
l=u.createElement(r);y=u.getElementsByTagName(r)[0];l.async=1; | |
l.src='https://surfly.com/surfly.js';y.parentNode.insertBefore(l,y);}) | |
(window,document,'script','Surfly'); | |
Surfly.init( | |
{ | |
widget_key: 'WIDGET_KEY_HERE', | |
hide_until_agent_joins: true | |
}, | |
function(initResult) { | |
if (initResult.success) { | |
var controlEl = document.querySelector('#surfly-control'); | |
if (!Surfly.isInsideSession) { | |
controlEl.className = 'start-surfly'; | |
controlEl.addEventListener('click', function(e) { | |
controlEl.textContent = 'session is starting...'; | |
Surfly.session() | |
.on('session_queued', function(session) { | |
controlEl.textContent = session.pin; | |
}) | |
.startLeader(); | |
}); | |
} | |
} | |
} | |
); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment