@@ -133,6 +133,23 @@ async function fetchTrips() {
133
133
134
134
var logInner = document . getElementById ( "log" ) . innerHTML
135
135
136
+
137
+ // Request permission for notifications
138
+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
139
+ if ( Notification . permission !== "granted" ) {
140
+ Notification . requestPermission ( ) ;
141
+ }
142
+ } ) ;
143
+
144
+ function sendNotification ( title , body ) {
145
+ if ( Notification . permission === "granted" ) {
146
+ new Notification ( title , {
147
+ body : body ,
148
+ icon : 'tcdd-cli.png'
149
+ } ) ;
150
+ }
151
+ }
152
+
136
153
function checkTrip ( trip ) {
137
154
let seatType = document . getElementById ( 'seatType' ) . value ;
138
155
let disabled_seat_count = 0 ;
@@ -162,6 +179,7 @@ function checkTrip(trip) {
162
179
  ♿ Disabled: ${ disabled_seat_count } <br/>` ;
163
180
found = true ;
164
181
audio . play ( ) ;
182
+ sendNotification ( 'Economy seats available' , `${ tripDate } , ${ tripTime } - Economy: ${ economy_seat_count } ` ) ;
165
183
} else if ( seatType === "business" && business_seat_count > 0 ) {
166
184
document . getElementById ( "status" ) . innerHTML
167
185
+= `<br/><span style="color:Tomato;"><b>Business seats available for:</b></span><br/>
@@ -171,6 +189,8 @@ function checkTrip(trip) {
171
189
  ♿ Disabled: ${ disabled_seat_count } <br/> ` ;
172
190
found = true ;
173
191
audio . play ( ) ;
192
+ sendNotification ( 'Business seats available' , `${ tripDate } , ${ tripTime } - Business: ${ business_seat_count } ` ) ;
193
+
174
194
}
175
195
}
176
196
0 commit comments