Ashrafb commited on
Commit
41f4a26
·
verified ·
1 Parent(s): 3c3792f

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +30 -26
static/index.html CHANGED
@@ -127,32 +127,36 @@
127
  }
128
 
129
  function sendInputs() {
130
- const inputs = document.getElementById("inputs").value;
131
- const noiseLevel = document.getElementById("noise_level").value;
132
- fetch(`/send_inputs?inputs=${encodeURIComponent(inputs)}&noise_level=${noiseLevel}`)
133
- .then(response => response.json())
134
- .then(data => {
135
- // Get the empty image box
136
- const imageBox = document.getElementById("image-box");
137
- // Create a new image element
138
- const img = new Image();
139
- // Set the source of the image to the base64-encoded image data received from the server
140
- img.src = 'data:image/jpeg;base64,' + data.image_base64;
141
- // Resize the image
142
- const maxWidth = 200; // Set the maximum width for the image
143
- const maxHeight = 200; // Set the maximum height for the image
144
- if (img.width > maxWidth || img.height > maxHeight) {
145
- const ratio = Math.min(maxWidth / img.width, maxHeight / img.height);
146
- img.width *= ratio;
147
- img.height *= ratio;
148
- }
149
- // Append the image to the image box
150
- imageBox.appendChild(img);
151
- })
152
- .catch(error => {
153
- console.error('Error:', error);
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}&timestamp=${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>