-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathhubigraph_tile.groovy
More file actions
58 lines (49 loc) · 1.78 KB
/
Copy pathhubigraph_tile.groovy
File metadata and controls
58 lines (49 loc) · 1.78 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
metadata{
definition( name: "Hubigraph Tile Device", namespace: "tchoward", author: "Thomas Howard") {
// Indicate what capabilities the device should be capable of
capability "Actuator"
attribute "Graph", "string"
attribute "Graph_No_Title", "string"
command "setGraph", ["String"]
}
preferences{
}
}
def setGraph(str) {
name = device.getDisplayName();
iframe_html = """
<iframe style="width: 100%; height: 100%;" src="${str}" data-fs="false" onload="(() => {
const body = this.contentDocument.body;
const start = () => {
if(this.dataset.fs == 'false') {
this.style = 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 999;';
this.dataset.fs = 'true';
} else {
this.style = 'width: 100%; height: 100%;';
this.dataset.fs = 'false';
}
}
body.addEventListener('dblclick', start);
})()"></iframe>
"""
def event = createEvent(name: "Graph", value: iframe_html);
sendEvent(event);
iframe_html = """
<iframe style="width: 100%; height: 100%;" src="${str}" data-fs="false" onload="(() => {
const body = this.contentDocument.body;
const start = () => {
if(this.dataset.fs == 'false') {
this.style = 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 999;';
this.dataset.fs = 'true';
} else {
this.style = 'width: 100%; height: 100%;';
this.dataset.fs = 'false';
}
}
body.addEventListener('dblclick', start);
this.parentElement.parentElement.parentElement.querySelector('.tile-title').style='display: none;';
})()"></iframe>
"""
event = createEvent(name: "Graph_No_Title", value: iframe_html);
sendEvent(event);
}