Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
8ccc2712
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
10 个月 前同步成功
通知
1740
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
8ccc2712
编写于
4月 30, 2023
作者:
A
Aarni Koskela
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix a whole bunch of implicit globals
上级
34a6ad80
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
60 addition
and
62 deletion
+60
-62
javascript/aspectRatioOverlay.js
javascript/aspectRatioOverlay.js
+16
-16
javascript/contextMenus.js
javascript/contextMenus.js
+2
-3
javascript/edit-attention.js
javascript/edit-attention.js
+4
-4
javascript/extensions.js
javascript/extensions.js
+1
-1
javascript/extraNetworks.js
javascript/extraNetworks.js
+7
-7
javascript/generationParams.js
javascript/generationParams.js
+1
-1
javascript/hires_fix.js
javascript/hires_fix.js
+3
-3
javascript/imageMaskFix.js
javascript/imageMaskFix.js
+1
-1
javascript/imageviewer.js
javascript/imageviewer.js
+3
-3
javascript/localization.js
javascript/localization.js
+5
-5
javascript/notification.js
javascript/notification.js
+1
-1
javascript/progressbar.js
javascript/progressbar.js
+1
-2
javascript/ui.js
javascript/ui.js
+15
-15
未找到文件。
javascript/aspectRatioOverlay.js
浏览文件 @
8ccc2712
...
...
@@ -45,27 +45,27 @@ function dimensionChange(e, is_width, is_height){
var
viewportOffset
=
targetElement
.
getBoundingClientRect
();
viewportscale
=
Math
.
min
(
targetElement
.
clientWidth
/
targetElement
.
naturalWidth
,
targetElement
.
clientHeight
/
targetElement
.
naturalHeight
)
v
ar
v
iewportscale
=
Math
.
min
(
targetElement
.
clientWidth
/
targetElement
.
naturalWidth
,
targetElement
.
clientHeight
/
targetElement
.
naturalHeight
)
scaledx
=
targetElement
.
naturalWidth
*
viewportscale
scaledy
=
targetElement
.
naturalHeight
*
viewportscale
var
scaledx
=
targetElement
.
naturalWidth
*
viewportscale
var
scaledy
=
targetElement
.
naturalHeight
*
viewportscale
cleintRectTop
=
(
viewportOffset
.
top
+
window
.
scrollY
)
cleintRectLeft
=
(
viewportOffset
.
left
+
window
.
scrollX
)
cleintRectCentreY
=
cleintRectTop
+
(
targetElement
.
clientHeight
/
2
)
cleintRectCentreX
=
cleintRectLeft
+
(
targetElement
.
clientWidth
/
2
)
var
cleintRectTop
=
(
viewportOffset
.
top
+
window
.
scrollY
)
var
cleintRectLeft
=
(
viewportOffset
.
left
+
window
.
scrollX
)
var
cleintRectCentreY
=
cleintRectTop
+
(
targetElement
.
clientHeight
/
2
)
var
cleintRectCentreX
=
cleintRectLeft
+
(
targetElement
.
clientWidth
/
2
)
v
iewRectTop
=
cleintRectCentreY
-
(
scaledy
/
2
)
v
iewRectLeft
=
cleintRectCentreX
-
(
scaledx
/
2
)
arRectWidth
=
scaledx
arRectHeight
=
scaledy
v
ar
viewRectTop
=
cleintRectCentreY
-
(
scaledy
/
2
)
// TODO: unused?
v
ar
viewRectLeft
=
cleintRectCentreX
-
(
scaledx
/
2
)
// TODO: unused?
var
arRectWidth
=
scaledx
var
arRectHeight
=
scaledy
arscale
=
Math
.
min
(
arRectWidth
/
currentWidth
,
arRectHeight
/
currentHeight
)
arscaledx
=
currentWidth
*
arscale
arscaledy
=
currentHeight
*
arscale
var
arscale
=
Math
.
min
(
arRectWidth
/
currentWidth
,
arRectHeight
/
currentHeight
)
var
arscaledx
=
currentWidth
*
arscale
var
arscaledy
=
currentHeight
*
arscale
arRectTop
=
cleintRectCentreY
-
(
arscaledy
/
2
)
arRectLeft
=
cleintRectCentreX
-
(
arscaledx
/
2
)
var
arRectTop
=
cleintRectCentreY
-
(
arscaledy
/
2
)
var
arRectLeft
=
cleintRectCentreX
-
(
arscaledx
/
2
)
arRectWidth
=
arscaledx
arRectHeight
=
arscaledy
...
...
javascript/contextMenus.js
浏览文件 @
8ccc2712
...
...
@@ -16,8 +16,7 @@ contextMenuInit = function(){
oldMenu
.
remove
()
}
let
tabButton
=
uiCurrentTab
let
baseStyle
=
window
.
getComputedStyle
(
tabButton
)
let
baseStyle
=
window
.
getComputedStyle
(
uiCurrentTab
)
const
contextMenu
=
document
.
createElement
(
'
nav
'
)
contextMenu
.
id
=
"
context-menu
"
...
...
@@ -63,7 +62,7 @@ contextMenuInit = function(){
function
appendContextMenuOption
(
targetElementSelector
,
entryName
,
entryFunction
){
currentItems
=
menuSpecs
.
get
(
targetElementSelector
)
var
currentItems
=
menuSpecs
.
get
(
targetElementSelector
)
if
(
!
currentItems
){
currentItems
=
[]
...
...
javascript/edit-attention.js
浏览文件 @
8ccc2712
...
...
@@ -69,8 +69,8 @@ function keyupEditAttention(event){
event
.
preventDefault
();
closeCharacter
=
'
)
'
delta
=
opts
.
keyedit_precision_attention
var
closeCharacter
=
'
)
'
var
delta
=
opts
.
keyedit_precision_attention
if
(
selectionStart
>
0
&&
text
[
selectionStart
-
1
]
==
'
<
'
){
closeCharacter
=
'
>
'
...
...
@@ -91,8 +91,8 @@ function keyupEditAttention(event){
selectionEnd
+=
1
;
}
end
=
text
.
slice
(
selectionEnd
+
1
).
indexOf
(
closeCharacter
)
+
1
;
weight
=
parseFloat
(
text
.
slice
(
selectionEnd
+
1
,
selectionEnd
+
1
+
end
));
var
end
=
text
.
slice
(
selectionEnd
+
1
).
indexOf
(
closeCharacter
)
+
1
;
var
weight
=
parseFloat
(
text
.
slice
(
selectionEnd
+
1
,
selectionEnd
+
1
+
end
));
if
(
isNaN
(
weight
))
return
;
weight
+=
isPlus
?
delta
:
-
delta
;
...
...
javascript/extensions.js
浏览文件 @
8ccc2712
...
...
@@ -41,7 +41,7 @@ function install_extension_from_index(button, url){
button
.
disabled
=
"
disabled
"
button
.
value
=
"
Installing...
"
textarea
=
gradioApp
().
querySelector
(
'
#extension_to_install textarea
'
)
var
textarea
=
gradioApp
().
querySelector
(
'
#extension_to_install textarea
'
)
textarea
.
value
=
url
updateInput
(
textarea
)
...
...
javascript/extraNetworks.js
浏览文件 @
8ccc2712
...
...
@@ -11,10 +11,10 @@ function setupExtraNetworksForTab(tabname){
tabs
.
appendChild
(
refresh
)
search
.
addEventListener
(
"
input
"
,
function
(
evt
){
searchTerm
=
search
.
value
.
toLowerCase
()
var
searchTerm
=
search
.
value
.
toLowerCase
()
gradioApp
().
querySelectorAll
(
'
#
'
+
tabname
+
'
_extra_tabs div.card
'
).
forEach
(
function
(
elem
){
text
=
elem
.
querySelector
(
'
.name
'
).
textContent
.
toLowerCase
()
+
"
"
+
elem
.
querySelector
(
'
.search_term
'
).
textContent
.
toLowerCase
()
var
text
=
elem
.
querySelector
(
'
.name
'
).
textContent
.
toLowerCase
()
+
"
"
+
elem
.
querySelector
(
'
.search_term
'
).
textContent
.
toLowerCase
()
elem
.
style
.
display
=
text
.
indexOf
(
searchTerm
)
==
-
1
?
"
none
"
:
""
})
});
...
...
@@ -96,9 +96,9 @@ function saveCardPreview(event, tabname, filename){
}
function
extraNetworksSearchButton
(
tabs_id
,
event
){
searchTextarea
=
gradioApp
().
querySelector
(
"
#
"
+
tabs_id
+
'
> div > textarea
'
)
button
=
event
.
target
text
=
button
.
classList
.
contains
(
"
search-all
"
)
?
""
:
button
.
textContent
.
trim
()
var
searchTextarea
=
gradioApp
().
querySelector
(
"
#
"
+
tabs_id
+
'
> div > textarea
'
)
var
button
=
event
.
target
var
text
=
button
.
classList
.
contains
(
"
search-all
"
)
?
""
:
button
.
textContent
.
trim
()
searchTextarea
.
value
=
text
updateInput
(
searchTextarea
)
...
...
@@ -133,7 +133,7 @@ function popup(contents){
}
function
extraNetworksShowMetadata
(
text
){
elem
=
document
.
createElement
(
'
pre
'
)
var
elem
=
document
.
createElement
(
'
pre
'
)
elem
.
classList
.
add
(
'
popup-metadata
'
);
elem
.
textContent
=
text
;
...
...
@@ -165,7 +165,7 @@ function requestGet(url, data, handler, errorHandler){
}
function
extraNetworksRequestMetadata
(
event
,
extraPage
,
cardName
){
showError
=
function
(){
extraNetworksShowMetadata
(
"
there was an error getting metadata
"
);
}
var
showError
=
function
(){
extraNetworksShowMetadata
(
"
there was an error getting metadata
"
);
}
requestGet
(
"
./sd_extra_networks/metadata
"
,
{
"
page
"
:
extraPage
,
"
item
"
:
cardName
},
function
(
data
){
if
(
data
&&
data
.
metadata
){
...
...
javascript/generationParams.js
浏览文件 @
8ccc2712
...
...
@@ -23,7 +23,7 @@ let modalObserver = new MutationObserver(function(mutations) {
});
function
attachGalleryListeners
(
tab_name
)
{
gallery
=
gradioApp
().
querySelector
(
'
#
'
+
tab_name
+
'
_gallery
'
)
var
gallery
=
gradioApp
().
querySelector
(
'
#
'
+
tab_name
+
'
_gallery
'
)
gallery
?.
addEventListener
(
'
click
'
,
()
=>
gradioApp
().
getElementById
(
tab_name
+
"
_generation_info_button
"
).
click
());
gallery
?.
addEventListener
(
'
keydown
'
,
(
e
)
=>
{
if
(
e
.
keyCode
==
37
||
e
.
keyCode
==
39
)
// left or right arrow
...
...
javascript/hires_fix.js
浏览文件 @
8ccc2712
...
...
@@ -4,9 +4,9 @@ function onCalcResolutionHires(enable, width, height, hr_scale, hr_resize_x, hr_
elem
.
classList
.
toggle
(
'
inactive
'
,
!!
inactive
)
}
hrUpscaleBy
=
gradioApp
().
getElementById
(
'
txt2img_hr_scale
'
)
hrResizeX
=
gradioApp
().
getElementById
(
'
txt2img_hr_resize_x
'
)
hrResizeY
=
gradioApp
().
getElementById
(
'
txt2img_hr_resize_y
'
)
var
hrUpscaleBy
=
gradioApp
().
getElementById
(
'
txt2img_hr_scale
'
)
var
hrResizeX
=
gradioApp
().
getElementById
(
'
txt2img_hr_resize_x
'
)
var
hrResizeY
=
gradioApp
().
getElementById
(
'
txt2img_hr_resize_y
'
)
gradioApp
().
getElementById
(
'
txt2img_hires_fix_row2
'
).
style
.
display
=
opts
.
use_old_hires_fix_width_height
?
"
none
"
:
""
...
...
javascript/imageMaskFix.js
浏览文件 @
8ccc2712
...
...
@@ -5,7 +5,7 @@
function
imageMaskResize
()
{
const
canvases
=
gradioApp
().
querySelectorAll
(
'
#img2maskimg .touch-none canvas
'
);
if
(
!
canvases
.
length
)
{
canvases_fixed
=
false
;
canvases_fixed
=
false
;
// TODO: this is unused..?
window
.
removeEventListener
(
'
resize
'
,
imageMaskResize
);
return
;
}
...
...
javascript/imageviewer.js
浏览文件 @
8ccc2712
...
...
@@ -57,7 +57,7 @@ function modalImageSwitch(offset) {
})
if
(
result
!=
-
1
)
{
nextButton
=
galleryButtons
[
negmod
((
result
+
offset
),
galleryButtons
.
length
)]
var
nextButton
=
galleryButtons
[
negmod
((
result
+
offset
),
galleryButtons
.
length
)]
nextButton
.
click
()
const
modalImage
=
gradioApp
().
getElementById
(
"
modalImage
"
);
const
modal
=
gradioApp
().
getElementById
(
"
lightboxModal
"
);
...
...
@@ -148,7 +148,7 @@ function modalZoomSet(modalImage, enable) {
}
function
modalZoomToggle
(
event
)
{
modalImage
=
gradioApp
().
getElementById
(
"
modalImage
"
);
var
modalImage
=
gradioApp
().
getElementById
(
"
modalImage
"
);
modalZoomSet
(
modalImage
,
!
modalImage
.
classList
.
contains
(
'
modalImageFullscreen
'
))
event
.
stopPropagation
()
}
...
...
@@ -175,7 +175,7 @@ function galleryImageHandler(e) {
}
onUiUpdate
(
function
()
{
fullImg_preview
=
gradioApp
().
querySelectorAll
(
'
.gradio-gallery > div > img
'
)
var
fullImg_preview
=
gradioApp
().
querySelectorAll
(
'
.gradio-gallery > div > img
'
)
if
(
fullImg_preview
!=
null
)
{
fullImg_preview
.
forEach
(
setupImageForLightbox
);
}
...
...
javascript/localization.js
浏览文件 @
8ccc2712
...
...
@@ -35,11 +35,11 @@ function canBeTranslated(node, text){
if
(
!
text
)
return
false
;
if
(
!
node
.
parentElement
)
return
false
;
parentType
=
node
.
parentElement
.
nodeName
var
parentType
=
node
.
parentElement
.
nodeName
if
(
parentType
==
'
SCRIPT
'
||
parentType
==
'
STYLE
'
||
parentType
==
'
TEXTAREA
'
)
return
false
;
if
(
parentType
==
'
OPTION
'
||
parentType
==
'
SPAN
'
){
pnode
=
node
var
pnode
=
node
for
(
var
level
=
0
;
level
<
4
;
level
++
){
pnode
=
pnode
.
parentElement
if
(
!
pnode
)
break
;
...
...
@@ -69,7 +69,7 @@ function getTranslation(text){
}
function
processTextNode
(
node
){
text
=
node
.
textContent
.
trim
()
var
text
=
node
.
textContent
.
trim
()
if
(
!
canBeTranslated
(
node
,
text
))
return
...
...
@@ -105,7 +105,7 @@ function processNode(node){
}
function
dumpTranslations
(){
dumped
=
{}
var
dumped
=
{}
if
(
localization
.
rtl
)
{
dumped
.
rtl
=
true
}
...
...
@@ -151,7 +151,7 @@ document.addEventListener("DOMContentLoaded", function() {
})
function
download_localization
()
{
text
=
JSON
.
stringify
(
dumpTranslations
(),
null
,
4
)
var
text
=
JSON
.
stringify
(
dumpTranslations
(),
null
,
4
)
var
element
=
document
.
createElement
(
'
a
'
);
element
.
setAttribute
(
'
href
'
,
'
data:text/plain;charset=utf-8,
'
+
encodeURIComponent
(
text
));
...
...
javascript/notification.js
浏览文件 @
8ccc2712
...
...
@@ -2,7 +2,7 @@
let
lastHeadImg
=
null
;
notificationButton
=
null
let
notificationButton
=
null
;
onUiUpdate
(
function
(){
if
(
notificationButton
==
null
){
...
...
javascript/progressbar.js
浏览文件 @
8ccc2712
...
...
@@ -10,7 +10,6 @@ function getGallerySelectedIndex(id_gallery){
function
request
(
url
,
data
,
handler
,
errorHandler
){
var
xhr
=
new
XMLHttpRequest
();
var
url
=
url
;
xhr
.
open
(
"
POST
"
,
url
,
true
);
xhr
.
setRequestHeader
(
"
Content-Type
"
,
"
application/json
"
);
xhr
.
onreadystatechange
=
function
()
{
...
...
@@ -107,7 +106,7 @@ function requestProgress(id_task, progressbarContainer, gallery, atEnd, onProgre
divProgress
.
style
.
width
=
rect
.
width
+
"
px
"
;
}
progressText
=
""
let
progressText
=
""
divInner
.
style
.
width
=
((
res
.
progress
||
0
)
*
100.0
)
+
'
%
'
divInner
.
style
.
background
=
res
.
progress
?
""
:
"
transparent
"
...
...
javascript/ui.js
浏览文件 @
8ccc2712
// various functions for interaction with ui.py not large enough to warrant putting them in separate files
function
set_theme
(
theme
){
gradioURL
=
window
.
location
.
href
var
gradioURL
=
window
.
location
.
href
if
(
!
gradioURL
.
includes
(
'
?__theme=
'
))
{
window
.
location
.
replace
(
gradioURL
+
'
?__theme=
'
+
theme
);
}
...
...
@@ -47,7 +47,7 @@ function extract_image_from_gallery(gallery){
return
[
gallery
[
0
]];
}
index
=
selected_gallery_index
()
var
index
=
selected_gallery_index
()
if
(
index
<
0
||
index
>=
gallery
.
length
){
// Use the first image in the gallery as the default
...
...
@@ -58,7 +58,7 @@ function extract_image_from_gallery(gallery){
}
function
args_to_array
(
args
){
res
=
[]
var
res
=
[]
for
(
var
i
=
0
;
i
<
args
.
length
;
i
++
){
res
.
push
(
args
[
i
])
}
...
...
@@ -138,7 +138,7 @@ function get_img2img_tab_index() {
}
function
create_submit_args
(
args
){
res
=
[]
var
res
=
[]
for
(
var
i
=
0
;
i
<
args
.
length
;
i
++
){
res
.
push
(
args
[
i
])
}
...
...
@@ -160,7 +160,7 @@ function showSubmitButtons(tabname, show){
}
function
showRestoreProgressButton
(
tabname
,
show
){
button
=
gradioApp
().
getElementById
(
tabname
+
"
_restore_progress
"
)
var
button
=
gradioApp
().
getElementById
(
tabname
+
"
_restore_progress
"
)
if
(
!
button
)
return
button
.
style
.
display
=
show
?
"
flex
"
:
"
none
"
...
...
@@ -208,7 +208,7 @@ function submit_img2img(){
}
function
restoreProgressTxt2img
(
x
){
id
=
localStorage
.
getItem
(
"
txt2img_task_id
"
)
var
id
=
localStorage
.
getItem
(
"
txt2img_task_id
"
)
if
(
id
)
{
requestProgress
(
id
,
gradioApp
().
getElementById
(
'
txt2img_gallery_container
'
),
gradioApp
().
getElementById
(
'
txt2img_gallery
'
),
function
(){
...
...
@@ -219,7 +219,7 @@ function restoreProgressTxt2img(x){
return
[
id
]
}
function
restoreProgressImg2img
(
x
){
id
=
localStorage
.
getItem
(
"
img2img_task_id
"
)
var
id
=
localStorage
.
getItem
(
"
img2img_task_id
"
)
if
(
id
)
{
requestProgress
(
id
,
gradioApp
().
getElementById
(
'
img2img_gallery_container
'
),
gradioApp
().
getElementById
(
'
img2img_gallery
'
),
function
(){
...
...
@@ -248,7 +248,7 @@ function modelmerger(){
function
ask_for_style_name
(
_
,
prompt_text
,
negative_prompt_text
)
{
name_
=
prompt
(
'
Style name:
'
)
var
name_
=
prompt
(
'
Style name:
'
)
return
[
name_
,
prompt_text
,
negative_prompt_text
]
}
...
...
@@ -283,11 +283,11 @@ function recalculate_prompts_img2img(){
}
opts
=
{}
var
opts
=
{}
onUiUpdate
(
function
(){
if
(
Object
.
keys
(
opts
).
length
!=
0
)
return
;
json_elem
=
gradioApp
().
getElementById
(
'
settings_json
'
)
var
json_elem
=
gradioApp
().
getElementById
(
'
settings_json
'
)
if
(
json_elem
==
null
)
return
;
var
textarea
=
json_elem
.
querySelector
(
'
textarea
'
)
...
...
@@ -336,8 +336,8 @@ onUiUpdate(function(){
registerTextarea
(
'
img2img_prompt
'
,
'
img2img_token_counter
'
,
'
img2img_token_button
'
)
registerTextarea
(
'
img2img_neg_prompt
'
,
'
img2img_negative_token_counter
'
,
'
img2img_negative_token_button
'
)
show_all_pages
=
gradioApp
().
getElementById
(
'
settings_show_all_pages
'
)
settings_tabs
=
gradioApp
().
querySelector
(
'
#settings div
'
)
var
show_all_pages
=
gradioApp
().
getElementById
(
'
settings_show_all_pages
'
)
var
settings_tabs
=
gradioApp
().
querySelector
(
'
#settings div
'
)
if
(
show_all_pages
&&
settings_tabs
){
settings_tabs
.
appendChild
(
show_all_pages
)
show_all_pages
.
onclick
=
function
(){
...
...
@@ -349,9 +349,9 @@ onUiUpdate(function(){
})
onOptionsChanged
(
function
(){
elem
=
gradioApp
().
getElementById
(
'
sd_checkpoint_hash
'
)
sd_checkpoint_hash
=
opts
.
sd_checkpoint_hash
||
""
shorthash
=
sd_checkpoint_hash
.
substr
(
0
,
10
)
var
elem
=
gradioApp
().
getElementById
(
'
sd_checkpoint_hash
'
)
var
sd_checkpoint_hash
=
opts
.
sd_checkpoint_hash
||
""
var
shorthash
=
sd_checkpoint_hash
.
substr
(
0
,
10
)
if
(
elem
&&
elem
.
textContent
!=
shorthash
){
elem
.
textContent
=
shorthash
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录