Update static/index.html
Browse files- static/index.html +28 -39
static/index.html
CHANGED
|
@@ -446,58 +446,47 @@
|
|
| 446 |
});
|
| 447 |
}
|
| 448 |
|
| 449 |
-
|
|
|
|
|
|
|
|
|
|
| 450 |
const inputs = document.getElementById("inputs").value;
|
| 451 |
-
if (!inputs) {
|
| 452 |
-
const imageBox = document.getElementById("resultContainer");
|
| 453 |
-
imageBox.innerHTML = "<p>Please enter a prompt before sending.</p>";
|
| 454 |
-
return;
|
| 455 |
-
}
|
| 456 |
-
|
| 457 |
-
const loadingSpinner = document.getElementById('loadingSpinner');
|
| 458 |
-
loadingSpinner.style.display = 'block';
|
| 459 |
const noiseLevel = document.getElementById("noise_level").value;
|
| 460 |
const isNegative = document.getElementById("is_negative").value;
|
| 461 |
const steps = document.getElementById("steps").value;
|
| 462 |
const cfgScale = document.getElementById("cfg_scale").value;
|
| 463 |
const seed = document.getElementById("seed").value;
|
| 464 |
-
|
| 465 |
const resultContainer = document.getElementById("resultContainer");
|
| 466 |
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
return response.json();
|
| 473 |
-
})
|
| 474 |
-
.then(data => {
|
| 475 |
-
const img = new Image();
|
| 476 |
-
img.onload = () => {
|
| 477 |
-
loadingSpinner.style.display = 'none'; // Hide the loading spinner after the image is loaded
|
| 478 |
-
};
|
| 479 |
-
img.src = 'data:image/jpeg;base64,' + data.image_base64;
|
| 480 |
-
const maxWidth = 200;
|
| 481 |
-
const maxHeight = 200;
|
| 482 |
-
if (img.width > maxWidth || img.height > maxHeight) {
|
| 483 |
-
const ratio = Math.min(maxWidth / img.width, maxHeight / img.height);
|
| 484 |
-
img.width *= ratio;
|
| 485 |
-
img.height *= ratio;
|
| 486 |
-
}
|
| 487 |
-
resultContainer.innerHTML = ""; // Clear previous content
|
| 488 |
-
resultContainer.appendChild(img); // Append new image
|
| 489 |
-
})
|
| 490 |
-
.catch(error => {
|
| 491 |
-
console.error('Error:', error);
|
| 492 |
-
resultContainer.innerHTML = "<p>An error occurred. Please try again later.</p>";
|
| 493 |
-
loadingSpinner.style.display = 'none'; // Hide the loading spinner on error
|
| 494 |
-
});
|
| 495 |
-
}
|
| 496 |
|
|
|
|
|
|
|
| 497 |
|
|
|
|
|
|
|
|
|
|
| 498 |
|
|
|
|
|
|
|
| 499 |
|
|
|
|
|
|
|
| 500 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 501 |
|
| 502 |
|
| 503 |
|
|
|
|
| 446 |
});
|
| 447 |
}
|
| 448 |
|
| 449 |
+
|
| 450 |
+
|
| 451 |
+
|
| 452 |
+
async function sendInputs() {
|
| 453 |
const inputs = document.getElementById("inputs").value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 454 |
const noiseLevel = document.getElementById("noise_level").value;
|
| 455 |
const isNegative = document.getElementById("is_negative").value;
|
| 456 |
const steps = document.getElementById("steps").value;
|
| 457 |
const cfgScale = document.getElementById("cfg_scale").value;
|
| 458 |
const seed = document.getElementById("seed").value;
|
|
|
|
| 459 |
const resultContainer = document.getElementById("resultContainer");
|
| 460 |
|
| 461 |
+
// Check if the input field is empty
|
| 462 |
+
if (!inputs) {
|
| 463 |
+
resultContainer.innerHTML = `<p style="color: white;">Please enter a prompt before sending.</p>`;
|
| 464 |
+
return;
|
| 465 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 466 |
|
| 467 |
+
// Clear the result container
|
| 468 |
+
resultContainer.innerHTML = "";
|
| 469 |
|
| 470 |
+
// Display loading spinner
|
| 471 |
+
const loadingSpinner = document.getElementById('loadingSpinner');
|
| 472 |
+
loadingSpinner.style.display = 'block';
|
| 473 |
|
| 474 |
+
try {
|
| 475 |
+
const response = await fetch(`/send_inputs?inputs=${encodeURIComponent(inputs)}&noise_level=${noiseLevel}&is_negative=${isNegative}&steps=${steps}&cfg_scale=${cfgScale}&seed=${seed}`);
|
| 476 |
|
| 477 |
+
// Hide loading spinner
|
| 478 |
+
loadingSpinner.style.display = 'none';
|
| 479 |
|
| 480 |
+
if (!response.ok) {
|
| 481 |
+
throw new Error('Network response was not ok');
|
| 482 |
+
}
|
| 483 |
+
|
| 484 |
+
return response.json();
|
| 485 |
+
} catch (error) {
|
| 486 |
+
console.error('Error:', error);
|
| 487 |
+
resultContainer.innerHTML = `<p style="color: white;">Oops! Something went wrong. Please try again later.</p>`;
|
| 488 |
+
}
|
| 489 |
+
}
|
| 490 |
|
| 491 |
|
| 492 |
|