-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify the interface language to display as_ zh-CN
Modify the interface language to display as_ zh-CN
- Loading branch information
Showing
19 changed files
with
12,234 additions
and
12,269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Abdullah Alfaraj | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
MIT License | ||
|
||
Copyright (c) 2022 Abdullah Alfaraj | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,78 @@ | ||
async function prompt( | ||
heading, | ||
body, | ||
buttons = ['Cancel', 'Ok'], | ||
options = { title: heading, size: { width: 360, height: 280 } } | ||
) { | ||
const [dlgEl, formEl, headingEl, dividerEl, bodyEl, footerEl] = [ | ||
'dialog', | ||
'form', | ||
'sp-heading', | ||
'sp-divider', | ||
'sp-body', | ||
'footer', | ||
].map((tag) => document.createElement(tag)) | ||
;[headingEl, dividerEl, bodyEl, footerEl].forEach((el) => { | ||
el.style.margin = '6px' | ||
el.style.width = 'calc(100% - 12px)' | ||
}) | ||
|
||
formEl.setAttribute('method', 'dialog') | ||
formEl.addEventListener('submit', () => dlgEl.close()) | ||
|
||
footerEl.style.marginTop = '26px' | ||
|
||
dividerEl.setAttribute('size', 'large') | ||
|
||
headingEl.textContent = heading | ||
|
||
bodyEl.textContent = body | ||
|
||
buttons.forEach((btnText, idx) => { | ||
const btnEl = document.createElement('sp-button') | ||
btnEl.setAttribute( | ||
'variant', | ||
idx === buttons.length - 1 ? btnText.variant || 'cta' : 'secondary' | ||
) | ||
if (idx === buttons.length - 1) | ||
btnEl.setAttribute('autofocus', 'autofocus') | ||
if (idx < buttons.length - 1) btnEl.setAttribute('quiet') | ||
btnEl.textContent = btnText.text || btnText | ||
btnEl.style.marginLeft = '12px' | ||
btnEl.addEventListener('click', () => | ||
dlgEl.close(btnText.text || btnText) | ||
) | ||
footerEl.appendChild(btnEl) | ||
}) | ||
;[headingEl, dividerEl, bodyEl, footerEl].forEach((el) => | ||
formEl.appendChild(el) | ||
) | ||
dlgEl.appendChild(formEl) | ||
document.body.appendChild(dlgEl) | ||
|
||
return dlgEl.uxpShowModal(options) | ||
} | ||
|
||
// const r1 = await prompt( | ||
// 'Upload Large File', | ||
// 'This is a large file (over 100MB) -- it may take a few moments to upload.', | ||
// ['Skip', 'Upload'] | ||
// ) | ||
// if ((r1 || 'Upload') !== 'Upload') { | ||
// /* cancelled or No */ | ||
// } else { | ||
// /* Yes */ | ||
// } | ||
|
||
// const r2 = await prompt( | ||
// 'Delete File', | ||
// 'Are you sure you wish to delete this file? This action cannot be undone.', | ||
// ['Cancel', { variant: 'warning', text: 'Delete' }] | ||
// ) | ||
// if (r2 !== 'Delete') { | ||
// /* nope, don't do it! */ | ||
// } else { | ||
// /* Do the delete */ | ||
// } | ||
|
||
module.exports = { prompt } | ||
async function prompt( | ||
heading, | ||
body, | ||
buttons = ['Cancel', 'Ok'], | ||
options = { title: heading, size: { width: 360, height: 280 } } | ||
) { | ||
const [dlgEl, formEl, headingEl, dividerEl, bodyEl, footerEl] = [ | ||
'dialog', | ||
'form', | ||
'sp-heading', | ||
'sp-divider', | ||
'sp-body', | ||
'footer', | ||
].map((tag) => document.createElement(tag)) | ||
;[headingEl, dividerEl, bodyEl, footerEl].forEach((el) => { | ||
el.style.margin = '6px' | ||
el.style.width = 'calc(100% - 12px)' | ||
}) | ||
|
||
formEl.setAttribute('method', 'dialog') | ||
formEl.addEventListener('submit', () => dlgEl.close()) | ||
|
||
footerEl.style.marginTop = '26px' | ||
|
||
dividerEl.setAttribute('size', 'large') | ||
|
||
headingEl.textContent = heading | ||
|
||
bodyEl.textContent = body | ||
|
||
buttons.forEach((btnText, idx) => { | ||
const btnEl = document.createElement('sp-button') | ||
btnEl.setAttribute( | ||
'variant', | ||
idx === buttons.length - 1 ? btnText.variant || 'cta' : 'secondary' | ||
) | ||
if (idx === buttons.length - 1) | ||
btnEl.setAttribute('autofocus', 'autofocus') | ||
if (idx < buttons.length - 1) btnEl.setAttribute('quiet') | ||
btnEl.textContent = btnText.text || btnText | ||
btnEl.style.marginLeft = '12px' | ||
btnEl.addEventListener('click', () => | ||
dlgEl.close(btnText.text || btnText) | ||
) | ||
footerEl.appendChild(btnEl) | ||
}) | ||
;[headingEl, dividerEl, bodyEl, footerEl].forEach((el) => | ||
formEl.appendChild(el) | ||
) | ||
dlgEl.appendChild(formEl) | ||
document.body.appendChild(dlgEl) | ||
|
||
return dlgEl.uxpShowModal(options) | ||
} | ||
|
||
// const r1 = await prompt( | ||
// 'Upload Large File', | ||
// 'This is a large file (over 100MB) -- it may take a few moments to upload.', | ||
// ['Skip', 'Upload'] | ||
// ) | ||
// if ((r1 || 'Upload') !== 'Upload') { | ||
// /* cancelled or No */ | ||
// } else { | ||
// /* Yes */ | ||
// } | ||
|
||
// const r2 = await prompt( | ||
// 'Delete File', | ||
// 'Are you sure you wish to delete this file? This action cannot be undone.', | ||
// ['Cancel', { variant: 'warning', text: 'Delete' }] | ||
// ) | ||
// if (r2 !== 'Delete') { | ||
// /* nope, don't do it! */ | ||
// } else { | ||
// /* Do the delete */ | ||
// } | ||
|
||
module.exports = { prompt } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
const clickTypeEnum = { | ||
Click: 'click', | ||
ShiftClick: 'shift_click', | ||
AltClick: 'alt_click', | ||
SecondClick: 'second_click', //when we click a thumbnail that is active/ has orange border | ||
} | ||
const generationModeEnum = { | ||
Txt2Img: 'txt2img', | ||
Img2Img: 'img2img', | ||
Inpaint: 'inpaint', | ||
Outpaint: 'outpaint', | ||
Upscale: 'upscale', | ||
} | ||
|
||
const AutomaticStatusEnum = { | ||
NoApi: 'no_api', | ||
Offline: 'offline', | ||
RunningNoApi: 'running_no_api', | ||
RunningWithApi: 'running_with_api', | ||
} | ||
|
||
const ViewerObjectTypeEnum = { | ||
OutputImage: 'output_image', | ||
InitImage: 'init_image', | ||
MaskImage: 'mask_image', | ||
} | ||
|
||
const RequestStateEnum = { | ||
Generating: 'generating', // in the generation process | ||
Interrupted: 'interrupted', // canceled/ interrupted | ||
Finished: 'finished', // finished generating | ||
} | ||
const DocumentTypeEnum = { | ||
NoBackground: 'no_background', | ||
ImageBackground: 'image_background', | ||
SolidBackground: 'solid_background', | ||
ArtBoard: 'artboard', | ||
} | ||
const BackgroundHistoryEnum = { | ||
CorrectBackground: 'correct_background', | ||
NoBackground: 'no_background', | ||
} | ||
|
||
const PresetTypeEnum = { | ||
SDPreset: 'sd_preset', | ||
ControlNetPreset: 'controlnet_preset', | ||
} | ||
module.exports = { | ||
clickTypeEnum, | ||
generationModeEnum, | ||
AutomaticStatusEnum, | ||
ViewerObjectTypeEnum, | ||
RequestStateEnum, | ||
DocumentTypeEnum, | ||
BackgroundHistoryEnum, | ||
PresetTypeEnum, | ||
} | ||
const clickTypeEnum = { | ||
Click: 'click', | ||
ShiftClick: 'shift_click', | ||
AltClick: 'alt_click', | ||
SecondClick: 'second_click', //when we click a thumbnail that is active/ has orange border | ||
} | ||
const generationModeEnum = { | ||
Txt2Img: 'txt2img', | ||
Img2Img: 'img2img', | ||
Inpaint: 'inpaint', | ||
Outpaint: 'outpaint', | ||
Upscale: 'upscale', | ||
} | ||
|
||
const AutomaticStatusEnum = { | ||
NoApi: 'no_api', | ||
Offline: 'offline', | ||
RunningNoApi: 'running_no_api', | ||
RunningWithApi: 'running_with_api', | ||
} | ||
|
||
const ViewerObjectTypeEnum = { | ||
OutputImage: 'output_image', | ||
InitImage: 'init_image', | ||
MaskImage: 'mask_image', | ||
} | ||
|
||
const RequestStateEnum = { | ||
Generating: 'generating', // in the generation process | ||
Interrupted: 'interrupted', // canceled/ interrupted | ||
Finished: 'finished', // finished generating | ||
} | ||
const DocumentTypeEnum = { | ||
NoBackground: 'no_background', | ||
ImageBackground: 'image_background', | ||
SolidBackground: 'solid_background', | ||
ArtBoard: 'artboard', | ||
} | ||
const BackgroundHistoryEnum = { | ||
CorrectBackground: 'correct_background', | ||
NoBackground: 'no_background', | ||
} | ||
|
||
const PresetTypeEnum = { | ||
SDPreset: 'sd_preset', | ||
ControlNetPreset: 'controlnet_preset', | ||
} | ||
module.exports = { | ||
clickTypeEnum, | ||
generationModeEnum, | ||
AutomaticStatusEnum, | ||
ViewerObjectTypeEnum, | ||
RequestStateEnum, | ||
DocumentTypeEnum, | ||
BackgroundHistoryEnum, | ||
PresetTypeEnum, | ||
} |
Oops, something went wrong.