mirror of
https://github.com/openvinotoolkit/stable-diffusion-webui.git
synced 2024-12-15 23:22:48 +03:00
remove timestamp for js files, reformat code
This commit is contained in:
parent
7c8852b8e7
commit
e4e0918f58
@ -1918,38 +1918,20 @@ def create_ui():
|
|||||||
|
|
||||||
|
|
||||||
def reload_javascript():
|
def reload_javascript():
|
||||||
scripts_list = modules.scripts.list_scripts("javascript", ".js")
|
head = f'<script type="text/javascript" src="file={os.path.abspath("script.js")}"></script>\n'
|
||||||
js_files = []
|
|
||||||
for basedir, filename, path in scripts_list:
|
|
||||||
path = path[len(script_path) + 1:]
|
|
||||||
js_files.append(path)
|
|
||||||
|
|
||||||
inline = [f"{localization.localization_js(shared.opts.localization)};"]
|
inline = f"{localization.localization_js(shared.opts.localization)};"
|
||||||
if cmd_opts.theme is not None:
|
if cmd_opts.theme is not None:
|
||||||
inline.append(f"set_theme('{cmd_opts.theme}');", )
|
inline += f"set_theme('{cmd_opts.theme}');"
|
||||||
|
|
||||||
t = int(time.time())
|
head += f'<script type="text/javascript">{inline}</script>\n'
|
||||||
head = [
|
|
||||||
f"""
|
for script in modules.scripts.list_scripts("javascript", ".js"):
|
||||||
<script type="text/javascript" src="file=./script.js?{t}"></script>
|
head += f'<script type="text/javascript" src="file={script.path}"></script>\n'
|
||||||
""".strip()
|
|
||||||
]
|
|
||||||
inline_code = "\n".join(inline)
|
|
||||||
head.append(f"""
|
|
||||||
<script type="text/javascript">
|
|
||||||
{inline_code}
|
|
||||||
</script>
|
|
||||||
""".strip())
|
|
||||||
for file in js_files:
|
|
||||||
head.append(f"""
|
|
||||||
<script type="text/javascript" src="file={file}?{t}"></script>
|
|
||||||
""".strip())
|
|
||||||
|
|
||||||
def template_response(*args, **kwargs):
|
def template_response(*args, **kwargs):
|
||||||
res = shared.GradioTemplateResponseOriginal(*args, **kwargs)
|
res = shared.GradioTemplateResponseOriginal(*args, **kwargs)
|
||||||
head_inject = "\n".join(head)
|
res.body = res.body.replace(b'</head>', f'{head}</head>'.encode("utf8"))
|
||||||
res.body = res.body.replace(
|
|
||||||
b'</head>', f'{head_inject}</head>'.encode("utf8"))
|
|
||||||
res.init_headers()
|
res.init_headers()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user