Merge pull request #52 from seijihariki/quick-patches

Quick patches 2
This commit is contained in:
tim h 2022-11-25 18:16:47 -06:00 committed by GitHub
commit 4fb754ec9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 100 additions and 15 deletions

View file

@ -97,8 +97,9 @@ body {
.content {
max-height: 0;
overflow: hidden;
transition: max-height 0.2s ease-out;
overflow-y: clip;
overflow-x: visible;
transition: max-height 0.2s ease-out, height 0s ease-out;
}
.menu-container {
@ -155,3 +156,30 @@ body {
font-weight: 600;
color: #fff;
}
#models {
width: 100%;
text-overflow: ellipsis;
}
/* Prompt Fields */
div.prompt-wrapper {
overflow: visible;
}
div.prompt-wrapper > textarea {
margin: 0;
padding: 0;
top: 0px;
bottom: 0px;
left: 0px;
right: 0;
resize: vertical;
}
div.prompt-wrapper > textarea:focus {
width: 700px;
}

View file

@ -37,16 +37,13 @@
<div class="content">
<label for="prompt">Prompt:</label>
<br />
<textarea id="prompt">
ocean floor scientific expedition, underwater wildlife</textarea
>
<br />
<div class="prompt-wrapper">
<textarea id="prompt"></textarea>
</div>
<label for="negPrompt">Negative prompt:</label>
<br />
<textarea id="negPrompt">
people, person, humans, human, divers, diver, glitch, error, text, watermark, bad quality, blurry</textarea
>
<br />
<div class="prompt-wrapper">
<textarea id="negPrompt"></textarea>
</div>
<!-- <hr /> -->
</div>
<!-- SD section -->

View file

@ -113,8 +113,29 @@ const bgCanvas = document.getElementById("backgroundCanvas"); // gray bg grid
const bgCtx = bgCanvas.getContext("2d");
function startup() {
checkIfWebuiIsRunning();
loadSettings();
const hostEl = document.getElementById("host");
hostEl.oninput = () => {
host = hostEl.value;
localStorage.setItem("host", host);
};
const promptEl = document.getElementById("prompt");
promptEl.oninput = () => {
stableDiffusionData.prompt = promptEl.value;
promptEl.title = promptEl.value;
localStorage.setItem("prompt", stableDiffusionData.prompt);
};
const negPromptEl = document.getElementById("negPrompt");
negPromptEl.oninput = () => {
stableDiffusionData.negative_prompt = negPromptEl.value;
negPromptEl.title = negPromptEl.value;
localStorage.setItem("neg_prompt", stableDiffusionData.negative_prompt);
};
checkIfWebuiIsRunning();
getSamplers();
getUpscalers();
getModels();
@ -859,6 +880,18 @@ async function upscaleAndDownload() {
function loadSettings() {
// set default values if not set
var _host =
localStorage.getItem("host") == null
? "http://127.0.0.1:7860"
: localStorage.getItem("host");
var _prompt =
localStorage.getItem("prompt") == null
? "oceanographic study, underwater wildlife, award winning"
: localStorage.getItem("prompt");
var _negprompt =
localStorage.getItem("neg_prompt") == null
? "people, person, humans, human, divers, diver, glitch, error, text, watermark, bad quality, blurry"
: localStorage.getItem("neg_prompt");
var _sampler =
localStorage.getItem("sampler") == null
? "DDIM"
@ -885,9 +918,18 @@ function loadSettings() {
: localStorage.getItem("overmask_px");
// set the values into the UI
document.getElementById("host").value = String(_host);
document.getElementById("prompt").value = String(_prompt);
document.getElementById("prompt").title = String(_prompt);
document.getElementById("negPrompt").value = String(_negprompt);
document.getElementById("negPrompt").title = String(_negprompt);
document.getElementById("samplerSelect").value = String(_sampler);
document.getElementById("maskBlur").value = Number(_mask_blur);
document.getElementById("seed").value = Number(_seed);
document.getElementById("cbxHRFix").checked = Boolean(_enable_hr);
// document.getElementById("overMaskPx").value = Number(_overmask_px);
}
document.getElementById("mainHSplit").addEventListener("wheel", (evn) => {
evn.preventDefault();
});

View file

@ -323,7 +323,6 @@ window.onmousemove = (evn) => {
window.addEventListener(
"wheel",
(evn) => {
evn.preventDefault();
mouse.contexts.forEach(({name}) => {
mouse.listen[name].onwheel.emit({
target: evn.target,

View file

@ -36,13 +36,32 @@ document.querySelectorAll(".floating-window").forEach((w) => {
var coll = document.getElementsByClassName("collapsible");
for (var i = 0; i < coll.length; i++) {
let active = false;
coll[i].addEventListener("click", function () {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.maxHeight) {
if (!active) {
this.classList.add("active");
content.classList.add("active");
} else {
this.classList.remove("active");
content.classList.remove("active");
}
const observer = new ResizeObserver(() => {
if (active) content.style.maxHeight = content.scrollHeight + "px";
});
Array.from(content.children).forEach((child) => {
observer.observe(child);
});
if (active) {
content.style.maxHeight = null;
active = false;
} else {
content.style.maxHeight = content.scrollHeight + "px";
active = true;
}
});
}