@@ -114,6 +114,26 @@ <h1>Chords-Python Applications</h1>
114
114
}
115
115
}
116
116
117
+ function checkStatus1 ( ) {
118
+ fetch ( "/app_status" )
119
+ . then ( response => response . json ( ) )
120
+ . then ( data => {
121
+ const lslButton = document . getElementById ( "start_lsl_button" ) ;
122
+ if ( data . lsl_started ) {
123
+ lslButton . classList . remove ( "lsl-not-running" ) ;
124
+ lslButton . classList . add ( "lsl-running" ) ;
125
+ lslButton . textContent = "LSL Stream Running" ;
126
+ lslButton . disabled = true ;
127
+ } else {
128
+ lslButton . classList . remove ( "lsl-running" ) ;
129
+ lslButton . classList . add ( "lsl-not-running" ) ;
130
+ lslButton . textContent = "Start LSL Stream" ;
131
+ lslButton . disabled = false ;
132
+ }
133
+ } )
134
+ . catch ( error => console . error ( "Error fetching LSL status:" , error ) ) ;
135
+ }
136
+
117
137
function checkStatus ( ) {
118
138
fetch ( "/app_status" )
119
139
. then ( response => response . json ( ) )
@@ -132,17 +152,15 @@ <h1>Chords-Python Applications</h1>
132
152
npgButton . disabled = false ;
133
153
}
134
154
} ) ;
135
- }
136
-
137
- setInterval ( checkStatus , 20 ) ;
155
+ }
138
156
139
157
function updateAppStatus ( ) {
140
158
fetch ( '/app_status' )
141
159
. then ( response => response . json ( ) )
142
160
. then ( statuses => {
143
161
const lslStarted = statuses . lsl_started || false ;
144
162
const npgStarted = statuses . npg_started || false ;
145
- console . log ( npgStarted ) ;
163
+ console . log ( lslStarted , npgStarted ) ;
146
164
updateButtons ( lslStarted , npgStarted ) ;
147
165
148
166
Object . keys ( statuses ) . forEach ( app => {
@@ -160,8 +178,11 @@ <h1>Chords-Python Applications</h1>
160
178
} )
161
179
. catch ( error => console . error ( "Error fetching app statuses:" , error ) ) ;
162
180
}
163
-
181
+
182
+ setInterval ( checkStatus , 50 ) ;
183
+ setInterval ( checkStatus1 , 50 ) ;
164
184
setInterval ( updateAppStatus , 100 ) ; // 100 ms checking
185
+
165
186
document . addEventListener ( "DOMContentLoaded" , updateAppStatus ) ;
166
187
</ script >
167
188
</ body >
0 commit comments