Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
74c538e8
Commit
74c538e8
authored
Sep 18, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
script.js split work - dragdrop.js
parent
27b9b233
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
266 deletions
+0
-266
javascript/dragdrop.js
javascript/dragdrop.js
+0
-209
script.js
script.js
+0
-57
No files found.
javascript/dragdrop.js
View file @
74c538e8
This diff is collapsed.
Click to expand it.
script.js
View file @
74c538e8
...
...
@@ -202,63 +202,6 @@ function submit(){
return
res
}
function
isValidImageList
(
files
)
{
return
files
&&
files
?.
length
===
1
&&
[
'
image/png
'
,
'
image/gif
'
,
'
image/jpeg
'
].
includes
(
files
[
0
].
type
);
}
function
dropReplaceImage
(
imgWrap
,
files
)
{
if
(
!
isValidImageList
(
files
)
)
{
return
;
}
imgWrap
.
querySelector
(
'
.modify-upload button + button
'
)?.
click
();
window
.
requestAnimationFrame
(
()
=>
{
const
fileInput
=
imgWrap
.
querySelector
(
'
input[type="file"]
'
);
if
(
fileInput
)
{
fileInput
.
files
=
files
;
fileInput
.
dispatchEvent
(
new
Event
(
'
change
'
));
}
});
}
window
.
document
.
addEventListener
(
'
dragover
'
,
e
=>
{
const
target
=
e
.
composedPath
()[
0
];
const
imgWrap
=
target
.
closest
(
'
[data-testid="image"]
'
);
if
(
!
imgWrap
)
{
return
;
}
e
.
stopPropagation
();
e
.
preventDefault
();
e
.
dataTransfer
.
dropEffect
=
'
copy
'
;
});
window
.
document
.
addEventListener
(
'
drop
'
,
e
=>
{
const
target
=
e
.
composedPath
()[
0
];
const
imgWrap
=
target
.
closest
(
'
[data-testid="image"]
'
);
if
(
!
imgWrap
)
{
return
;
}
e
.
stopPropagation
();
e
.
preventDefault
();
const
files
=
e
.
dataTransfer
.
files
;
dropReplaceImage
(
imgWrap
,
files
);
});
window
.
addEventListener
(
'
paste
'
,
e
=>
{
const
files
=
e
.
clipboardData
.
files
;
if
(
!
isValidImageList
(
files
)
)
{
return
;
}
[...
gradioApp
().
querySelectorAll
(
'
input[type=file][accept="image/x-png,image/gif,image/jpeg"]
'
)]
.
filter
(
input
=>
!
input
.
matches
(
'
.
\\
!hidden input[type=file]
'
))
.
forEach
(
input
=>
{
input
.
files
=
files
;
input
.
dispatchEvent
(
new
Event
(
'
change
'
))
});
[...
gradioApp
().
querySelectorAll
(
'
[data-testid="image"]
'
)]
.
forEach
(
imgWrap
=>
dropReplaceImage
(
imgWrap
,
files
));
});
function
ask_for_style_name
(
_
,
prompt_text
,
negative_prompt_text
)
{
name_
=
prompt
(
'
Style name:
'
)
return
name_
===
null
?
[
null
,
null
,
null
]:
[
name_
,
prompt_text
,
negative_prompt_text
]
...
...
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