diff --git a/javascript/smart_process.js b/javascript/smart_process.js index b9f5fc3..3341a6a 100644 --- a/javascript/smart_process.js +++ b/javascript/smart_process.js @@ -1,9 +1,28 @@ -function start_smart_process() { - requestProgress('sp'); - gradioApp().querySelector('#sp_error').innerHTML = ''; - return args_to_array(arguments); -} +const SP_PROGRESSBAR_LABEL = 'sp_preview' +const SP_GALLERY_LABEL = 'sp_gallery' +const SP_ERROR_LABEL = '#sp_error' +const SP_GALLERY_CHILD = 'sp_gallery_kid'; +const SP_PROGRESS_LABEL = 'sp_progress'; -onUiUpdate(function () { - check_progressbar('sp', 'sp_progressbar', 'sp_progress_span', '', 'sp_interrupt', 'sp_preview', 'sp_gallery') -}) \ No newline at end of file +function start_smart_process() { + rememberGallerySelection(SP_GALLERY_LABEL) + gradioApp().querySelector('#sp_error').innerHTML = '' + var daGalleryElt = gradioApp().getElementById(SP_GALLERY_LABEL) + // set id of first child of daGalleryElt to 'sp_gallery_kid', + // required by AUTOMATIC1111 UI Logic + daGalleryElt.children[0].id = SP_GALLERY_CHILD + var id = randomId(); + requestProgress(id, + gradioApp().getElementById(SP_GALLERY_LABEL), + gradioApp().getElementById(SP_GALLERY_CHILD), + function () { + }, + function (progress) { + gradioApp().getElementById(SP_PROGRESS_LABEL).innerHTML = progress.textinfo + }) + + const argsToArray = args_to_array(arguments); + argsToArray.push(argsToArray[0]) + argsToArray[0] = id; + return argsToArray +}