forked from extern/easydiffusion
ef90832aea
* New engine.js first draft. * Small fixes... * Bump version for cache... * Improved cancellation code. * Cleaning * Wrong argument used in Task.waitUntil * session_id needs to always match SD.sessionId * Removed passing explicit Session ID from UI. Use SD.sessionID to replace. * Cleaning... Removed a disabled line and a hardcoded value. * Fix return if tasks are still waiting. * Added checkbox to reverse processing order. * Fixed progress not displaying properly. * Renamed reverse label. * Only hide progress bar inside onCompleted. * Thanks to rbertus2000 for helping testing and debugging! * Resolve async promises when used optionally. * when removed var should have used let, not const. * Renamed getTaskErrorHandler to onTaskErrorHandler to better reflect actual implementation. * Switched to the unsafer and less git friendly end of lines comma as requested in review. * Raised SERVER_STATE_VALIDITY_DURATION to 90 seconds to match the changes to Beta. * Added logging. * Added one more hook before those inside the SD engine. * Added selftest.plugin.js as part of core. * Removed a tests that wasn't yet implemented... * Groupped task stopping and abort in single function. * Added optional test for plugins. * Allow prompt text to be selected. * Added comment. * Improved isServerAvailable for better mobile usage and added comments for easier debugging. * Comments... * Normalized EVENT_STATUS_CHANGED to follow the same pattern as the other events. * Disable plugins if editorModifierTagsList is not defined. * Adds a new ServiceContainer to register IOC handlers. * Added expect test for a missing dependency in a ServiceContainer * Moved all event code in it's own sub class for easier reuse. * Removed forgotten unused var... * Allow getPrompts to be reused be plugins. * Renamed EventSource to GenericEventSource to avoid redefining an existing class name. * Added missing time argument to debounce * Added output_quality to engine.js * output_quality need to be an int. * Fixed typo. * Replaced the default euler_a by dpm2 to work with both SD1.# and SD2 * Remove generic completed tasks from plugins on generator complete. * dpm2 starts at step 2, replaced with plms to start at step 1. * Merge error * Merge error * changelog Co-authored-by: Marc-Andre Ferland <madrang@gmail.com>
95 lines
4.2 KiB
JavaScript
95 lines
4.2 KiB
JavaScript
(function () { "use strict"
|
|
if (typeof editorModifierTagsList !== 'object') {
|
|
console.error('editorModifierTagsList missing...')
|
|
return
|
|
}
|
|
|
|
const styleSheet = document.createElement("style");
|
|
styleSheet.textContent = `
|
|
.modifier-card-tiny.drag-sort-active {
|
|
background: transparent;
|
|
border: 2px dashed white;
|
|
opacity:0.2;
|
|
}
|
|
`;
|
|
document.head.appendChild(styleSheet);
|
|
|
|
// observe for changes in tag list
|
|
const observer = new MutationObserver(function (mutations) {
|
|
// mutations.forEach(function (mutation) {
|
|
if (editorModifierTagsList.childNodes.length > 0) {
|
|
ModifierDragAndDrop(editorModifierTagsList)
|
|
}
|
|
// })
|
|
})
|
|
|
|
observer.observe(editorModifierTagsList, {
|
|
childList: true
|
|
})
|
|
|
|
let current
|
|
function ModifierDragAndDrop(target) {
|
|
let overlays = document.querySelector('#editor-inputs-tags-list').querySelectorAll('.modifier-card-overlay')
|
|
overlays.forEach (i => {
|
|
i.parentElement.draggable = true;
|
|
|
|
i.parentElement.ondragstart = (e) => {
|
|
current = i
|
|
i.parentElement.getElementsByClassName('modifier-card-image-overlay')[0].innerText = ''
|
|
i.parentElement.draggable = true
|
|
i.parentElement.classList.add('drag-sort-active')
|
|
for(let item of document.querySelector('#editor-inputs-tags-list').getElementsByClassName('modifier-card-image-overlay')) {
|
|
if (item.parentElement.parentElement.getElementsByClassName('modifier-card-overlay')[0] != current) {
|
|
item.parentElement.parentElement.getElementsByClassName('modifier-card-image-overlay')[0].style.opacity = 0
|
|
if(item.parentElement.getElementsByClassName('modifier-card-image').length > 0) {
|
|
item.parentElement.getElementsByClassName('modifier-card-image')[0].style.filter = 'none'
|
|
}
|
|
item.parentElement.parentElement.style.transform = 'none'
|
|
item.parentElement.parentElement.style.boxShadow = 'none'
|
|
}
|
|
item.innerText = ''
|
|
}
|
|
}
|
|
|
|
i.ondragenter = (e) => {
|
|
e.preventDefault()
|
|
if (i != current) {
|
|
let currentPos = 0, droppedPos = 0;
|
|
for (let it = 0; it < overlays.length; it++) {
|
|
if (current == overlays[it]) { currentPos = it; }
|
|
if (i == overlays[it]) { droppedPos = it; }
|
|
}
|
|
|
|
if (i.parentElement != current.parentElement) {
|
|
let currentPos = 0, droppedPos = 0
|
|
for (let it = 0; it < overlays.length; it++) {
|
|
if (current == overlays[it]) { currentPos = it }
|
|
if (i == overlays[it]) { droppedPos = it }
|
|
}
|
|
if (currentPos < droppedPos) {
|
|
current = i.parentElement.parentNode.insertBefore(current.parentElement, i.parentElement.nextSibling).getElementsByClassName('modifier-card-overlay')[0]
|
|
} else {
|
|
current = i.parentElement.parentNode.insertBefore(current.parentElement, i.parentElement).getElementsByClassName('modifier-card-overlay')[0]
|
|
}
|
|
// update activeTags
|
|
const tag = activeTags.splice(currentPos, 1)
|
|
activeTags.splice(droppedPos, 0, tag[0])
|
|
}
|
|
}
|
|
};
|
|
|
|
i.ondragover = (e) => {
|
|
e.preventDefault()
|
|
}
|
|
|
|
i.parentElement.ondragend = (e) => {
|
|
i.parentElement.classList.remove('drag-sort-active')
|
|
for(let item of document.querySelector('#editor-inputs-tags-list').getElementsByClassName('modifier-card-image-overlay')) {
|
|
item.style.opacity = ''
|
|
item.innerText = '-'
|
|
}
|
|
}
|
|
})
|
|
}
|
|
})()
|