BraydenMoore commited on
Commit
5584bf1
1 Parent(s): 5b4bf65

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +13 -40
templates/index.html CHANGED
@@ -177,46 +177,19 @@
177
  // });
178
 
179
 
180
- document.addEventListener("DOMContentLoaded", function() {
181
- var xhr = new XMLHttpRequest();
182
- xhr.open('GET', "{{ url }}", true);
183
- xhr.setRequestHeader('Cache-Control', 'no-cache');
184
- xhr.responseType = 'arraybuffer';
185
-
186
- var image = document.getElementById("feed");
187
- image.src = "{{ url_for('static', filename='loading.gif') }}"; // Display loading image initially
188
-
189
- var boundary = "--MOBOTIX_Fast_Serverpush"; // Update based on the server's Content-Type header
190
-
191
- var buffer = new ArrayBuffer(0);
192
-
193
- xhr.onprogress = function(e) {
194
- var arrayBuffer = new Uint8Array(buffer.byteLength + e.loaded);
195
- arrayBuffer.set(new Uint8Array(buffer), 0);
196
- arrayBuffer.set(new Uint8Array(xhr.response), buffer.byteLength);
197
-
198
- // Parse buffer to find the boundary and extract JPEG images
199
- while (true) {
200
- var start = arrayBuffer.indexOf(boundary);
201
- var end = arrayBuffer.indexOf(boundary, start + boundary.length);
202
-
203
- if (start === -1 || end === -1) {
204
- break;
205
- }
206
-
207
- var blob = new Blob([arrayBuffer.slice(start + boundary.length, end)], { type: "image/jpeg" });
208
- var urlCreator = window.URL || window.webkitURL;
209
- var imageUrl = urlCreator.createObjectURL(blob);
210
- image.src = imageUrl;
211
-
212
- arrayBuffer = arrayBuffer.slice(end);
213
- }
214
-
215
- buffer = arrayBuffer;
216
- };
217
-
218
- xhr.send();
219
- });
220
  </script>
221
  </body>
222
 
 
177
  // });
178
 
179
 
180
+ document.addEventListener("DOMContentLoaded", function() {
181
+ const feed = document.getElementById("feed");
182
+ feed.src = "{{ url_for('static', filename='loading.gif') }}";
183
+
184
+ const newUrl = "{{ url }}";
185
+
186
+ const img = new Image();
187
+ img.onload = function() {
188
+ feed.src = this.src;
189
+ };
190
+ img.src = newUrl;
191
+ });
192
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  </script>
194
  </body>
195