Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
7b1db45e
Commit
7b1db45e
authored
Oct 11, 2022
by
yfszzx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
images history improvement
parent
1e18a5ff
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
238 additions
and
166 deletions
+238
-166
images_history.js
javascript/images_history.js
+114
-56
jquery-3.6.0.min.js
javascript/jquery-3.6.0.min.js
+0
-2
images_history.py
modules/images_history.py
+121
-108
style.css
style.css
+3
-0
No files found.
javascript/images_history.js
View file @
7b1db45e
function
init_images_history
(){
images_history_tab_list
=
[
"txt2img"
,
"img2img"
,
"extras"
]
if
(
gradioApp
().
getElementById
(
'txt2img_images_history_first_page'
)
==
null
)
{
function
images_history_init
(){
setTimeout
(
init_images_history
,
1000
)
if
(
gradioApp
().
getElementById
(
'txt2img_images_history_first_page'
)
==
null
)
{
}
else
{
setTimeout
(
images_history_init
,
500
)
tab_list
=
[
"txt2img"
,
"img2img"
]
}
else
{
for
(
i
in
tab_list
){
for
(
i
in
images_history_tab_list
){
tab
=
tab_list
[
i
]
tab
=
images_history_tab_list
[
i
]
gradioApp
().
getElementById
(
tab
+
"_images_history_first_page"
).
click
()
gradioApp
().
getElementById
(
tab
+
'_images_history'
).
classList
.
add
(
"images_history_gallery"
)
$
(
gradioApp
().
getElementById
(
tab
+
'_images_history'
)).
addClass
(
"images_history_gallery"
)
gradioApp
().
getElementById
(
tab
+
'_images_history_set_index'
).
classList
.
add
(
"images_history_set_index"
)
item
=
$
(
gradioApp
().
getElementById
(
tab
+
'_images_history_set_index'
))
item
.
addClass
(
"images_history_set_index"
)
}
item
.
hide
()
gradioApp
().
getElementById
(
"txt2img_images_history_first_page"
).
click
()
}
}
}
}
setTimeout
(
images_history_init
,
500
)
var
images_history_button_actions
=
function
(){
if
(
!
this
.
classList
.
contains
(
"transform"
)){
gallery
=
this
.
parentElement
while
(
!
gallery
.
classList
.
contains
(
"images_history_gallery"
)){
gallery
=
gallery
.
parentElement
}
buttons
=
gallery
.
querySelectorAll
(
".gallery-item"
)
i
=
0
hidden_list
=
[]
buttons
.
forEach
(
function
(
e
){
if
(
e
.
style
.
display
==
"none"
){
hidden_list
.
push
(
i
)
}
i
+=
1
})
if
(
hidden_list
.
length
>
0
){
setTimeout
(
images_history_hide_buttons
,
10
,
hidden_list
,
gallery
)
}
}
images_history_set_image_info
(
this
)
}
}
setTimeout
(
init_images_history
,
1000
)
onUiUpdate
(
function
(){
onUiUpdate
(
function
(){
fullImg_preview
=
gradioApp
().
querySelectorAll
(
'#txt2img_images_history img.w-full'
)
for
(
i
in
images_history_tab_list
){
if
(
fullImg_preview
.
length
>
0
){
tab
=
images_history_tab_list
[
i
]
fullImg_preview
.
forEach
(
set_history_index_from_img
);
buttons
=
gradioApp
().
querySelectorAll
(
'#'
+
tab
+
'_images_history .gallery-item'
)
}
buttons
.
forEach
(
function
(
bnt
){
fullImg_preview
=
gradioApp
().
querySelectorAll
(
'#img2img_images_history img.w-full'
)
bnt
.
addEventListener
(
'click'
,
images_history_button_actions
,
true
)
if
(
fullImg_preview
.
length
>
0
){
});
fullImg_preview
.
forEach
(
set_history_index_from_img
);
}
}
})
})
function
images_history_hide_buttons
(
hidden_list
,
gallery
){
buttons
=
gallery
.
querySelectorAll
(
".gallery-item"
)
num
=
0
buttons
.
forEach
(
function
(
e
){
if
(
e
.
style
.
display
==
"none"
){
num
+=
1
}
})
if
(
num
==
hidden_list
.
length
){
setTimeout
(
images_history_hide_buttons
,
10
,
hidden_list
,
gallery
)
}
for
(
i
in
hidden_list
){
buttons
[
hidden_list
[
i
]].
style
.
display
=
"none"
}
}
function
set_history_gallery_index
(
item
){
function
images_history_set_image_info
(
button
){
buttons
=
item
.
find
(
".gallery-item"
)
item
=
button
.
parentElement
// alert(item.attr("id") + " " + buttons.length)
while
(
item
.
tagName
!=
"DIV"
){
item
=
item
.
parentElement
}
index
=
-
1
buttons
=
item
.
querySelectorAll
(
".gallery-item"
)
i
=
0
index
=
-
1
buttons
.
each
(
function
(){
i
=
0
if
(
$
(
this
).
hasClass
(
"!ring-2"
)){
index
=
i
}
buttons
.
forEach
(
function
(
e
){
i
+=
1
if
(
e
==
button
){
index
=
i
}
})
if
(
e
.
style
.
display
!=
"none"
){
if
(
index
==
-
1
){
i
+=
1
setTimeout
(
set_history_gallery_index
,
10
,
item
)
}
}
else
{
})
item
=
item
.
find
(
".images_history_set_index"
).
first
()
gallery
=
button
.
parentElement
item
.
attr
(
"img_index"
,
index
)
while
(
!
gallery
.
classList
.
contains
(
"images_history_gallery"
)){
gallery
=
gallery
.
parentElement
}
item
.
click
()
set_btn
=
gallery
.
querySelector
(
".images_history_set_index"
)
}
set_btn
.
setAttribute
(
"img_index"
,
index
)
set_btn
.
click
()
}
}
function
set_history_index_from_img
(
e
){
if
(
e
&&
e
.
parentElement
.
tagName
==
'BUTTON'
){
bnt
=
$
(
e
).
parent
()
if
(
bnt
.
hasClass
(
"transform"
)){
bnt
.
off
(
"click"
).
on
(
"click"
,
function
(){
set_history_gallery_index
(
$
(
this
).
parents
(
".images_history_gallery"
).
first
())
})
}
else
{
bnt
.
off
(
"mousedown"
).
on
(
"mousedown"
,
function
(){
set_history_gallery_index
(
$
(
this
).
parents
(
".images_history_gallery"
).
first
())
})
}
function
images_history_get_current_img
(
tabname
,
image_path
,
files
){
}
s
=
gradioApp
().
getElementById
(
tabname
+
'_images_history_set_index'
).
getAttribute
(
"img_index"
)
return
[
s
,
image_path
,
files
]
}
}
function
images_history_get_current_img
(
is_image2image
,
image_path
,
files
){
head
=
is_image2image
?
"img2img"
:
"txt2img"
function
images_history_delete
(
tabname
,
img_path
,
img_file_name
,
page_index
,
filenames
,
image_index
){
s
=
$
(
gradioApp
().
getElementById
(
head
+
'_images_history_set_index'
)).
attr
(
"img_index"
)
image_index
=
parseInt
(
image_index
)
return
[
s
,
image_path
,
files
]
tab
=
gradioApp
().
getElementById
(
tabname
+
'_images_history'
)
set_btn
=
tab
.
querySelector
(
".images_history_set_index"
)
buttons
=
[]
tab
.
querySelectorAll
(
".gallery-item"
).
forEach
(
function
(
e
){
if
(
e
.
style
.
display
!=
'none'
){
buttons
.
push
(
e
)
}
})
img_num
=
buttons
.
length
/
2
if
(
img_num
==
1
){
setTimeout
(
function
(
tabname
){
gradioApp
().
getElementById
(
tabname
+
'_images_history_renew_page'
).
click
()
},
30
,
tabname
)
}
else
{
buttons
[
image_index
].
style
.
display
=
'none'
buttons
[
image_index
+
img_num
].
style
.
display
=
'none'
if
(
image_index
>=
img_num
-
1
){
console
.
log
(
buttons
.
length
,
img_num
)
btn
=
buttons
[
img_num
-
2
]
}
else
{
btn
=
buttons
[
image_index
+
1
]
}
setTimeout
(
function
(
btn
){
btn
.
click
()},
30
,
btn
)
}
return
[
tabname
,
img_path
,
img_file_name
,
page_index
,
filenames
,
image_index
]
}
}
function
images_history_turnpage
(
img_path
,
page_index
,
image_index
,
tabname
){
buttons
=
gradioApp
().
getElementById
(
tabname
+
'_images_history'
).
querySelectorAll
(
".gallery-item"
)
buttons
.
forEach
(
function
(
elem
)
{
elem
.
style
.
display
=
'block'
})
return
[
img_path
,
page_index
,
image_index
,
tabname
]
}
javascript/jquery-3.6.0.min.js
deleted
100644 → 0
View file @
1e18a5ff
This diff is collapsed.
Click to expand it.
modules/images_history.py
View file @
7b1db45e
This diff is collapsed.
Click to expand it.
style.css
View file @
7b1db45e
...
@@ -463,3 +463,6 @@ input[type="range"]{
...
@@ -463,3 +463,6 @@ input[type="range"]{
max-width
:
32em
;
max-width
:
32em
;
padding
:
0
;
padding
:
0
;
}
}
.images-history-hidden
{
display
:
none
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment