forked from doublerobotics/d3-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathd3.html
More file actions
71 lines (67 loc) · 1.41 KB
/
d3.html
File metadata and controls
71 lines (67 loc) · 1.41 KB
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
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html lang="en">
<head>
<title>Basic Example</title>
<meta charset="utf-8">
<style>
body {
color: white;
font-family: Sans-serif;
overflow: hidden;
}
#content {
background: rgba(0, 0, 0, 0.8);
border-radius: 10px;
bottom: 40px;
left: 40px;
overflow: auto;
padding: 20px;
position: absolute;
right: 40px;
top: 55%;
}
input[type=button] {
padding: 5px 10px;
}
</style>
</head>
<body>
<div id="content">
<input type="button" value="Send Hello" onclick="sendMessage({ text: 'Hello from D3' })">
<h3>From Sidebar:</h3>
<div id="log"></div>
</div>
<script>
function q(q) { return document.querySelector(q); }
var log = q("#log");
function sendMessage(message) {
DRDoubleSDK.sendCommand('endpoint.driverSidebar.sendMessage', {
message: message,
targetOrigin: '*'
});
}
function handleMesage(message) {
log.innerHTML += "<p>" + message.text + "</p>";
}
if ("DRDoubleSDK" in window) {
DRDoubleSDK.on("event", (message) => {
switch (message.class +"."+ message.key) {
case "DREndpointModule.messageFromDriverSidebar": {
if (message.data) {
handleMesage(message.data);
}
break;
}
}
});
DRDoubleSDK.on("connect", () => {
DRDoubleSDK.sendCommand("events.subscribe", {
events: [
"DREndpointModule.messageFromDriverSidebar"
]
});
});
}
</script>
</body>
</html>