-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvote-aggregator.js
23 lines (19 loc) · 1.05 KB
/
vote-aggregator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import {initialize as initializeBridgeProxy} from './homie-lit-components/SerialBridgeProxy';
document.getElementById('connectButton').addEventListener('click', async () => {
try {
const bridgeProxy = await initializeBridgeProxy('ws://localhost:9001');
document.getElementById('status').textContent = 'Connected successfully!';
// Add mode switching buttons
const votingButton = document.createElement('button');
votingButton.textContent = 'Switch to Voting Mode';
votingButton.addEventListener('click', () => bridgeProxy.switchMode('VOTING'));
document.body.appendChild(votingButton);
const sensorButton = document.createElement('button');
sensorButton.textContent = 'Switch to Sensor Mode';
sensorButton.addEventListener('click', () => bridgeProxy.switchMode('SENSOR'));
document.body.appendChild(sensorButton);
} catch (error) {
console.error('Error:', error);
document.getElementById('status').textContent = 'Connection failed: ' + error.message;
}
});