-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscript.js
111 lines (87 loc) · 2.46 KB
/
script.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const { remote } = require('electron');
const { ipcRenderer } = require('electron');
const mainProcess = remote.require('./index.js');
// mainProcess.furbies will return the list of furbies.
ipcRenderer.on('furby-connected', (evt, msg) => addFurbyToUI(msg));
function red() {
remote.getGlobal('furbies').red()
}
function green() {
remote.getGlobal('furbies').green()
}
function blue() {
remote.getGlobal('furbies').blue()
}
function ping() {
remote.getGlobal('furbies').ping()
}
function toggle() {
remote.getGlobal('furbies').toggle()
}
function prev() {
var action = remote.getGlobal('furbies').prev()
var el = document.getElementById("action")
el.innerHTML = action
}
function next() {
var action = remote.getGlobal('furbies').next()
var el = document.getElementById("action")
el.innerHTML = action
}
function play() {
remote.getGlobal('furbies').play()
}
function debug() {
remote.getGlobal('furbies').debug()
}
function deleteDlc() {
remote.getGlobal('furbies').deleteDlc()
}
function flashDlc() {
remote.getGlobal('furbies').flashDlc()
}
function loadDlc() {
remote.getGlobal('furbies').loadDlc()
}
function toggleDlc() {
remote.getGlobal('furbies').toggleDlc()
}
function test() {
remote.getGlobal('furbies').test(
parseInt(document.getElementById("action1").value),
parseInt(document.getElementById("action2").value),
parseInt(document.getElementById("action3").value),
parseInt(document.getElementById("action4").value),
)
}
function onPairClick(evt){
uuid = this.parentNode.id
ipcRenderer.send("pair", uuid)
}
function onUnpairClick(evt){
uuid = this.parentNode.id
ipcRenderer.send("unpair", uuid)
}
function addFurbyToUI(furby){
furbiesList = document.getElementById("furbies")
uuid = furby.uuid
var container = document.createElement("div")
container.classList.add("furby")
container.id = uuid
var uuidSpan = document.createElement("span")
uuidSpan.classList.add("uid")
uuidSpan.innerHTML = uuid
var pairButton = document.createElement("button")
pairButton.classList.add("button")
pairButton.innerHTML = "Pair"
pairButton.onclick = onPairClick
var unpairButton = document.createElement("button")
unpairButton.classList.add("button")
unpairButton.innerHTML = "Unpair"
unpairButton.onclick = onUnpairClick
unpairButton.style.display = "none"
container.appendChild(uuidSpan);
container.appendChild(pairButton);
container.appendChild(unpairButton);
furbiesList.appendChild(container);
}