-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInstrumentPanel.js
More file actions
40 lines (32 loc) · 1.46 KB
/
InstrumentPanel.js
File metadata and controls
40 lines (32 loc) · 1.46 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
const plugin = ({widgets, simulator}) => {
const container = document.createElement("div")
container.setAttribute("style", `display:flex; height: 100%; width: 100%;`)
container.innerHTML = (`
<div style="max-width: fit-content; margin: 0 auto; position: relative; margin: auto 0;">
<img src="https://firebasestorage.googleapis.com/v0/b/digital-auto.appspot.com/o/media%2FDashboardSpeed.jpg?alt=media&token=44b42de9-12a7-4cb1-b525-94e8fc077141" style="height: fit-content; width: 100%; object-fit: contain;">
<div class="speedometer-status" style="position: absolute;color: white;font-family: 'Lato';width: 100%;top: 0;height: 100%;box-sizing: border-box;display: flex;padding-top: 10px;padding-left: 10px;"></div>
</div>
`)
let boxGlobal = null
widgets.register("Speedometer", (box) => {
boxGlobal = box
box.injectNode(container)
return () => {
boxGlobal = null
// Deactivation function for clearing intervals or such.
}
})
let currentValue = ""
simulator("Vehicle.Cabin.InstrumentPanel.Status", "get", async ({args}) => {
return currentValue
})
simulator("Vehicle.Cabin.InstrumentPanel.Status", "set", async ({args}) => {
currentValue = args[0]
if (boxGlobal !== null) {
container.querySelector(".speedometer-status").textContent = currentValue
}
return null
})
return {}
}
export default plugin