-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdev-example-view.html
63 lines (54 loc) · 1.92 KB
/
dev-example-view.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
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example to view an interactive component</title>
<style>
* {
margin: 0;
box-sizing: inherit;
}
body {
box-sizing: border-box;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
background-color: rgba(236, 151, 31, 0.1);
overflow: hidden; /* hide scrollbars when resizing. */
}
</style>
<script type="application/javascript" src="../sdk/int-comp-sdk-v1.js"></script>
<script type="application/javascript">
// Called when page is ready
function _onLoad() {
// Log communication messages for develop purposes.
IntCompSdk.logMessages(true);
// Start listening to messages from ContentStation
IntCompSdk.listen(_onMessage);
// Notify ContentStation this page is ready to receive data
IntCompSdk.readyForData();
// Let the SDK manage the height of the component in ContentStation editor.
IntCompSdk.autoHeight();
}
// Handle the messages from ContentStation
function _onMessage(message) {
switch (message.id) {
case 'useData':
// Handle initial data or data change in ContentStation editor.
_updateContent(message.data);
break;
default:
break;
}
}
// Update the content in page
function _updateContent(content) {
// Put content in this page body
document.body.innerText = JSON.stringify(content, null, '․․');
// Ensure the correct height of the component in ContentStation editor.
IntCompSdk.fitHeight();
}
</script>
</head>
<body onload="_onLoad()">
</body>
</html>