-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
55 lines (51 loc) · 1.78 KB
/
example.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
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Kona Converstaions Widget Test</title>
</head>
<body>
<form name="form">
<select name="space_id" id="spaceIdChanger">
<option value="">My Kona</option>
<option value="1">Space 1</option>
<option value="2">Space 2</option>
</select>
</form>
<div id="myContainer" style="width: 700px; height: 600px;"></div>
<script>
(function() {
window._konaWidgetConfig = {
id: "conversationsiFrame",
key: 'clientID',
domain: 'io.kona.com',
oauth_token: 'access_token',
container_id: 'myContainer'
};
var spaceChange = function(){
document.getElementById("spaceIdChanger").onchange = function() {
var win = document.getElementById(window._konaWidgetConfig.id).contentWindow;
win.postMessage(
this.value,
"https://" + window._konaWidgetConfig.domain
);
return false;
}
};
var script = document.createElement('script');
script.src = 'https://' + window._konaWidgetConfig.domain + '/kona/widgets/kona_widget_loader.js?conversations';
var insertLocation = document.getElementsByTagName('script')[0];
insertLocation.parentNode.insertBefore(script, insertLocation);
if (script.addEventListener) {
return script.addEventListener('load', spaceChange, false);
} else {
return script.attachEvent('onreadystatechange', function() {
if (/complete|loaded/.test(script.readyState)) {
return spaceChange();
}
});
}
})();
</script>
</body>
</html>