Update static/index.html
Browse files- static/index.html +30 -26
static/index.html
CHANGED
|
@@ -127,32 +127,36 @@
|
|
| 127 |
}
|
| 128 |
|
| 129 |
function sendInputs() {
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
</script>
|
| 157 |
</body>
|
| 158 |
</html>
|
|
|
|
| 127 |
}
|
| 128 |
|
| 129 |
function sendInputs() {
|
| 130 |
+
const inputs = document.getElementById("inputs").value;
|
| 131 |
+
const noiseLevel = document.getElementById("noise_level").value;
|
| 132 |
+
const timestamp = new Date().getTime(); // Get current timestamp
|
| 133 |
+
fetch(`/send_inputs?inputs=${encodeURIComponent(inputs)}&noise_level=${noiseLevel}×tamp=${timestamp}`)
|
| 134 |
+
.then(response => response.json())
|
| 135 |
+
.then(data => {
|
| 136 |
+
// Get the empty image box
|
| 137 |
+
const imageBox = document.getElementById("image-box");
|
| 138 |
+
// Remove any existing images
|
| 139 |
+
imageBox.innerHTML = "";
|
| 140 |
+
// Create a new image element
|
| 141 |
+
const img = new Image();
|
| 142 |
+
// Set the source of the image to the base64-encoded image data received from the server
|
| 143 |
+
img.src = 'data:image/jpeg;base64,' + data.image_base64;
|
| 144 |
+
// Resize the image
|
| 145 |
+
const maxWidth = 200; // Set the maximum width for the image
|
| 146 |
+
const maxHeight = 200; // Set the maximum height for the image
|
| 147 |
+
if (img.width > maxWidth || img.height > maxHeight) {
|
| 148 |
+
const ratio = Math.min(maxWidth / img.width, maxHeight / img.height);
|
| 149 |
+
img.width *= ratio;
|
| 150 |
+
img.height *= ratio;
|
| 151 |
+
}
|
| 152 |
+
// Append the image to the image box
|
| 153 |
+
imageBox.appendChild(img);
|
| 154 |
+
})
|
| 155 |
+
.catch(error => {
|
| 156 |
+
console.error('Error:', error);
|
| 157 |
+
});
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
</script>
|
| 161 |
</body>
|
| 162 |
</html>
|