-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
57 lines (50 loc) · 2.22 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
document.addEventListener('DOMContentLoaded', (event) => {
// Get the buttons
const startButton = document.querySelector('.calibration-button');
const stopButton = document.querySelector('.stop-button');
// Add event listener for the start calibration button
startButton.addEventListener('click', () => {
// Run the start.bat script
fetch('http://localhost:3000/start')
.then(response => response.text())
.then(data => console.log(data))
.catch((error) => {
console.error('Error:', error);
});
exec('start.bat', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
// Note: Running a batch script directly from JavaScript is not typically possible
// You might need a server-side solution like Node.js to do this
console.log('Start calibration button pressed. Running start.bat...');
// Display a window in the webcam-feed class
//const webcamFeed = document.querySelector('.webcam-feed');
//webcamFeed.innerHTML = '<div>Your window content here...</div>';
});
// Add event listener for the stop button
stopButton.addEventListener('click', () => {
// Run the stop.bat script
fetch('http://localhost:3000/stop')
.then(response => response.text())
.then(data => console.log(data))
.catch((error) => {
console.error('Error:', error);
});
exec('stop.bat', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
// Note: Running a batch script directly from JavaScript is not typically possible
// You might need a server-side solution like Node.js to do this
console.log('Stop button pressed. Running stop.bat...');
});
});