97
97
width : 100% ;
98
98
}
99
99
100
- # open-door {
100
+ # open-door , # open-garage {
101
101
font-size : 1.2em ;
102
102
padding : 12px 24px ;
103
103
background-color : # fffb00c0 ;
106
106
border-radius : 4px ;
107
107
cursor : pointer;
108
108
transition : background-color 0.3s ease;
109
+ margin-bottom : 10px ;
109
110
}
110
111
111
- # open-door : hover {
112
+ # open-door : hover , # open-garage : hover {
112
113
background-color : # 1669c1 ;
113
114
}
114
115
118
119
font-size : 1em ;
119
120
color : # 555 ;
120
121
}
122
+ .chat-box {
123
+ position : fixed;
124
+ bottom : 10px ;
125
+ right : 10px ;
126
+ width : 300px ;
127
+ max-height : 200px ;
128
+ overflow-y : auto;
129
+ background-color : # 333 ;
130
+ color : white;
131
+ padding : 10px ;
132
+ border-radius : 8px ;
133
+ font-size : 14px ;
134
+ }
135
+
136
+ .chat-box p {
137
+ margin : 0 ;
138
+ padding : 5px 0 ;
139
+ }
140
+
121
141
</ style >
122
142
</ head >
123
143
@@ -133,7 +153,7 @@ <h3>Outside Garage Camera</h3>
133
153
</ div >
134
154
</ div >
135
155
< div class ="logo-container ">
136
- < img src ="file:///C:/Users/emohi/Desktop/H3RU-Home_Control_System-main/ ra.jpg " alt ="H3RU Logo ">
156
+ < img src ="{{ url_for('static', path=' ra.jpg') }} " alt ="H3RU Logo ">
137
157
< p > To everyone who can't finish what they started< br > - H3RU</ p >
138
158
</ div >
139
159
< div class ="camera-feed ">
@@ -143,8 +163,10 @@ <h3>Inside Garage Camera</h3>
143
163
</ div >
144
164
</ div >
145
165
</ div >
166
+ < div id ="chat-box " class ="chat-box "> </ div >
146
167
< div class ="centered-button ">
147
168
< button id ="open-door "> Open Door</ button >
169
+ < button id ="open-garage "> Open Garage</ button >
148
170
</ div >
149
171
< div class ="camera-feed ">
150
172
< h3 > Entrance Camera</ h3 >
@@ -155,19 +177,31 @@ <h3>Entrance Camera</h3>
155
177
< div id ="result-message "> </ div >
156
178
< script >
157
179
const ws = new WebSocket ( "ws://localhost:8000/ws" ) ;
180
+
158
181
document . getElementById ( 'open-door' ) . addEventListener ( 'click' , function ( ) {
159
182
fetch ( '/open_door' , { method : 'POST' } )
160
183
. then ( response => response . json ( ) )
161
184
. then ( data => {
162
185
document . getElementById ( 'result-message' ) . innerText = data . message ;
163
186
} ) ;
164
187
} ) ;
188
+
189
+ document . getElementById ( 'open-garage' ) . addEventListener ( 'click' , function ( ) {
190
+ fetch ( '/open_garage' , { method : 'POST' } )
191
+ . then ( response => response . json ( ) )
192
+ . then ( data => {
193
+ document . getElementById ( 'result-message' ) . innerText = data . message ;
194
+ } ) ;
195
+ } ) ;
196
+
165
197
ws . onmessage = function ( event ) {
166
- document . getElementById ( 'result-message' ) . innerText = event . data ;
198
+ const chatBox = document . getElementById ( 'chat-box' ) ;
199
+ chatBox . innerHTML += `<p>${ event . data } </p>` ;
200
+ chatBox . scrollTop = chatBox . scrollHeight ; // En yeni mesajın görünebilmesi için
167
201
} ;
202
+
168
203
setInterval ( ( ) => ws . send ( "result" ) , 1000 ) ;
169
204
</ script >
170
205
</ body >
171
206
172
207
</ html >
173
-
0 commit comments