Merge branch 'beta' of github.com:cmdr2/stable-diffusion-ui into beta

This commit is contained in:
cmdr2 2022-12-26 21:00:57 +05:30
commit e241ef25e5
3 changed files with 23 additions and 9 deletions

View File

@ -235,13 +235,6 @@ const TASK_MAPPING = {
readUI: () => useCPUField.checked, readUI: () => useCPUField.checked,
parse: (val) => val parse: (val) => val
}, },
turbo: { name: 'Turbo',
setUI: (turbo) => {
turboField.checked = turbo
},
readUI: () => turboField.checked,
parse: (val) => Boolean(val)
},
stream_image_progress: { name: 'Stream Image Progress', stream_image_progress: { name: 'Stream Image Progress',
setUI: (stream_image_progress) => { setUI: (stream_image_progress) => {

View File

@ -287,6 +287,7 @@ function showImages(reqBody, res, outputContainer, livePreview) {
imageSeedLabel.innerText = 'Seed: ' + req.seed imageSeedLabel.innerText = 'Seed: ' + req.seed
let buttons = [ let buttons = [
{ text: 'Remove', on_click: onRemoveClick, class: 'secondaryButton' },
{ text: 'Use as Input', on_click: onUseAsInputClick }, { text: 'Use as Input', on_click: onUseAsInputClick },
{ text: 'Download', on_click: onDownloadImageClick }, { text: 'Download', on_click: onDownloadImageClick },
{ text: 'Make Similar Images', on_click: onMakeSimilarClick }, { text: 'Make Similar Images', on_click: onMakeSimilarClick },
@ -304,9 +305,12 @@ function showImages(reqBody, res, outputContainer, livePreview) {
const newButton = document.createElement('button') const newButton = document.createElement('button')
newButton.classList.add('tasksBtns') newButton.classList.add('tasksBtns')
newButton.innerText = btnInfo.text newButton.innerText = btnInfo.text
newButton.addEventListener('click', function() { newButton.addEventListener('click', function(event) {
btnInfo.on_click(req, img) btnInfo.on_click(req, img, event)
}) })
if (btnInfo.class !== undefined) {
newButton.classList.add(btnInfo.class)
}
imgItemInfo.appendChild(newButton) imgItemInfo.appendChild(newButton)
} }
buttons.forEach(btn => { buttons.forEach(btn => {
@ -320,6 +324,10 @@ function showImages(reqBody, res, outputContainer, livePreview) {
}) })
} }
function onRemoveClick(req, img, event) {
shiftOrConfirm(event, "Remove the image from the results?", () => { findClosestAncestor(img, '.imgItem').style.display='none' })
}
function onUseAsInputClick(req, img) { function onUseAsInputClick(req, img) {
const imgData = img.src const imgData = img.src

View File

@ -20,6 +20,19 @@ function getNextSibling(elem, selector) {
} }
} }
function findClosestAncestor(element, selector) {
if (!element || !element.parentNode) {
// reached the top of the DOM tree, return null
return null;
} else if (element.parentNode.matches(selector)) {
// found an ancestor that matches the selector, return it
return element.parentNode;
} else {
// continue searching upwards
return findClosestAncestor(element.parentNode, selector);
}
}
/* Panel Stuff */ /* Panel Stuff */