Spaces:
Running
Running
Commit
·
5b4bf65
1
Parent(s):
dcd87ff
Update templates/index.html
Browse files- templates/index.html +39 -21
templates/index.html
CHANGED
@@ -177,28 +177,46 @@
|
|
177 |
// });
|
178 |
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
}
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
</script>
|
203 |
</body>
|
204 |
|
|
|
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 |
|