fix to_clipboard from non-localhost access (#1576)

tested on edge(windows&android)
This commit is contained in:
御坂IO
2023-12-28 07:54:59 -08:00
committed by GitHub
parent 48b1324a26
commit ad158450e3
+22 -7
View File
@@ -44,13 +44,28 @@ def log(img, dic):
) )
js = ( js = (
"<script>" """<script>
"function to_clipboard(txt) { " function to_clipboard(txt) {
"txt = decodeURIComponent(txt);" txt = decodeURIComponent(txt);
"navigator.clipboard.writeText(txt);" if (navigator.clipboard && navigator.permissions) {
"alert('Copied to Clipboard!\\nPaste to prompt area to load parameters.\\nCurrent clipboard content is:\\n\\n' + txt);" navigator.clipboard.writeText(txt)
"}" } else {
"</script>" const textArea = document.createElement('textArea')
textArea.value = txt
textArea.style.width = 0
textArea.style.position = 'fixed'
textArea.style.left = '-999px'
textArea.style.top = '10px'
textArea.setAttribute('readonly', 'readonly')
document.body.appendChild(textArea)
textArea.select()
document.execCommand('copy')
document.body.removeChild(textArea)
}
alert('Copied to Clipboard!\\nPaste to prompt area to load parameters.\\nCurrent clipboard content is:\\n\\n' + txt);
}
</script>"""
) )
begin_part = f"<html><head><title>Fooocus Log {date_string}</title>{css_styles}</head><body>{js}<p>Fooocus Log {date_string} (private)</p>\n<p>All images are clean, without any hidden data/meta, and safe to share with others.</p><!--fooocus-log-split-->\n\n" begin_part = f"<html><head><title>Fooocus Log {date_string}</title>{css_styles}</head><body>{js}<p>Fooocus Log {date_string} (private)</p>\n<p>All images are clean, without any hidden data/meta, and safe to share with others.</p><!--fooocus-log-split-->\n\n"