-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
45 lines (36 loc) · 1.31 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<html>
<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');
var settings = {
// Surfly session options can be set here, or at the Company/Plan levels.
widget_key: '513065a5492743e6a6340aec09b7e4d1',
};
Surfly.init(settings, function(initResult) {
if (initResult.success) {
// API calls can now be made!
if (!Surfly.isInsideSession) {
Surfly.button();
}
}
else{
console.log("Surfly was unable to initialize properly.")
}
Surfly.on("session_started", ()=> {
Surfly.listSessions()[0].on('message', function(session, event) {
console.log("HELLO: "+event.data.message);
});
Surfly.on("session_restored", ()=> {
Surfly.listSessions()[0].on('message', function(session, event) {
console.log("HELLO: "+event.data.message);
});
});
function myFunction()
{
Surfly.listSessions()[0].sendMessage({message: 'ALL good'}, window.location.origin);
}
</script>
<button id="btn-end-queued-session" type="button" onclick="myFunction()">Click Me!</button>
</html>