forked from kerminal/vehicleDebug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (55 loc) · 1.24 KB
/
index.js
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
window.addEventListener("message", function (event) {
const data = event.data;
const callback = data.callback;
if (callback != undefined) {
const func = window[callback.type];
if (func != undefined) {
func(callback.data);
}
}
});
function post(type, data) {
try {
fetch(`https://${GetParentResourceName()}/${type}`, {
method: "POST",
headers: {
"Content-Type": "application/json; charset=UTF-8",
},
body: JSON.stringify(data),
});
} catch { }
}
function toggle(value) {
document.querySelector("#content").style.display = value ? "block" : "none";
}
function setFocus(value) {
document.querySelector("#handling").style.display = value
? "block"
: "none";
}
function updateText(data) {
for (var x in data) {
const val = data[x];
const element = document.querySelector(`#${x}`);
if (element != undefined) {
element.innerHTML = val;
}
}
}
function copyText(text) {
var element = document.querySelector("#clipboard");
element.value = text;
element.select();
element.setSelectionRange(0, 99999);
document.execCommand("copy");
element.value = undefined;
}
function copyHandling() {
post("copyHandling");
}
function updateHandling(key, value) {
post("updateHandling", {
key: key,
value: value,
});
}