-
Notifications
You must be signed in to change notification settings - Fork 2
/
preload.js
151 lines (125 loc) · 4.46 KB
/
preload.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//'use strict'
const { ipcRenderer } = require('electron')
function window.sendEvent(event){
ipcRenderer.send(event);
}
/*
ipcRenderer.on('GoXlrPluginExecutableButton-selected', function(event, response) {
document.querySelector(`input[name="GoXlrPluginExecutable"]`).value = response.filePaths[0];
});
ipcRenderer.on('GoXlrExecutableButton-selected', function(event, response) {
document.querySelector(`input[name="GoXlrExecutable"]`).value = response.filePaths[0];
});
ipcRenderer.on('routing-save', function(event){
updateButtonLabels();
});
let inputs = ['Mic', 'Chat', 'Music', 'Game', 'Console', 'Line In', 'System', 'Samples'];
let outputs = ['Headphones', 'Broadcast Mix', 'Line Out', 'Chat Mic', 'Sampler'];
let thead = document.querySelector("#routingTable");
let row = thead.insertRow();
row.appendChild(document.createElement("td"));
row.appendChild(document.createElement("td"));
let th = document.createElement("th");
th.appendChild(document.createTextNode("Inputs"));
th.colSpan=8;
th.classList.add("caption");
row.appendChild(th);
function updateButtonLabels(){
(async() => {
let routingTable = await ipcRenderer.invoke('getStoreValue', 'GoXlrRouting');
for(const input in routingTable){
for(const output in routingTable[input]){
let nHotkeys = 0;
let nEvents = 0;
for(const action in routingTable[input][output]){
if(routingTable[input][output][action]['hotkey'] !== undefined){
nHotkeys++;
}
}
let element = document.getElementById("routingbutton-"+btoa(output+"-"+input));
element.innerHTML = '';
if(nHotkeys > 0){
let multiplicity = (nHotkeys != 1) ? 's' : '';
element.appendChild(document.createTextNode(nHotkeys+ " Hotkey" + multiplicity ));
}
}
}
})();
}
function createRoutingTable(){
row = thead.insertRow();
row.appendChild(document.createElement("td"));
row.appendChild(document.createElement("td"));
for(let input in inputs){
let th = document.createElement("th");
let text = document.createTextNode(inputs[input]);
th.appendChild(text);
row.appendChild(th);
}
for(let i in outputs){
let output = outputs[i];
let row = thead.insertRow();
if(i == 0){
let th = document.createElement("th");
let text = document.createTextNode("Outputs");
th.appendChild(text);
th.rowSpan=8;
th.classList.add("caption");
row.appendChild(th);
}
let th = document.createElement("th");
let text = document.createTextNode(output);
th.appendChild(text);
row.appendChild(th);
for(let j in inputs){
let input = inputs[j]
let td = document.createElement("td");
td.classList.add("config");
let btn = document.createElement("button");
btn.id = "routingbutton-"+btoa(output+"-"+input);
let span = document.createElement("span");
td.appendChild(btn);
row.appendChild(td);
btn.addEventListener('click', () => {
ipcRenderer.send('button-configureRouting', {input: input, output: output});
});
}
}
updateButtonLabels();
}
createRoutingTable();
(async() => {
document.querySelector(`input[name="GoXlrPluginExecutable"]`).value = await ipcRenderer.invoke('getStoreValue', 'GoXlrPluginExecutable');
document.querySelector(`input[name="GoXlrExecutable"]`).value = await ipcRenderer.invoke('getStoreValue', 'GoXlrExecutable');
// let routingTable = await ipcRenderer.invoke('getStoreValue', 'GoXlrRouting');
//
// for(const input in routingTable){
// for(const output in routingTable[input]){
// let nHotkeys = 0;
// let nEvents = 0;
// for(const action in routingTable[input][output]){
// if(routingTable[input][output][action]['hotkey'] !== undefined){
// //console.log(routingTable[input][output][action]);
// nHotkeys++;
// }
// }
// let elementId = 'hotkey-'+input+'-'+output;
// let element = document.getElementById(elementId);
// element.removeChild(element.firstChild);
// element.appendChild(document.createTextNode(nHotkeys));
// }
// }
//
//
// let inputs = ['mic'];
// let outputs = ['headphones'];
//
// inputs.forEach(input => {
// outputs.forEach(output => {
// document.getElementById('button-'+input+'-'+output).addEventListener('click', () => {
// ipcRenderer.send('button-configureRouting', {input: input, output: output});
// });
// });
// });
})();
*/