@@ -253,6 +253,28 @@ def result(self, path: Path) -> str | None:
253253app = Flask ("compare" )
254254
255255
256+ @app .route ("/script.js" )
257+ def script_js ():
258+ logger .debug ("Serving script.js" )
259+
260+ return """
261+ function updateRef(path) {
262+ fetch(`/update_ref/${path}`)
263+ .then(response => {
264+ if (response.ok) {
265+ alert(`Reference updated for ${path}`);
266+ location.reload();
267+ } else {
268+ alert(`Failed to update reference for ${path}: ${response.statusText}`);
269+ }
270+ })
271+ .catch(error => {
272+ alert(`Error updating reference for ${path}: ${error}`);
273+ });
274+ }
275+ """
276+
277+
256278@app .route ("/" )
257279def root ():
258280 logger .debug ("Generating root directory listing" )
@@ -444,6 +466,7 @@ def generate_tree(
444466 padding-left: calc(1.0rem * var(--depth));
445467}
446468</style>
469+ <script src="/script.js"></script>
447470</head>
448471<body>
449472"""
@@ -507,21 +530,6 @@ def generate_tree(
507530 }
508531 });
509532}
510-
511- function updateRef(path) {
512- fetch(`/update_ref/${path}`)
513- .then(response => {
514- if (response.ok) {
515- alert(`Reference updated for ${path}`);
516- location.reload();
517- } else {
518- alert(`Failed to update reference for ${path}: ${response.statusText}`);
519- }
520- })
521- .catch(error => {
522- alert(`Error updating reference for ${path}: ${error}`);
523- });
524- }
525533</script>
526534</body>
527535</html>
@@ -553,6 +561,7 @@ def compare(path: str):
553561<style>
554562html,body {{height:100%;margin:0;}}
555563</style>
564+ <script src="/script.js"></script>
556565</head>
557566<body style="display:flex;flex-flow:row;">
558567<div style="display:flex;flex:1;flex-flow:column;margin:5px;">
@@ -561,6 +570,7 @@ def compare(path: str):
561570</div>
562571<div style="display:flex;flex:0 0 50px;flex-flow:column;">
563572 <a href="/image_diff/{ path } " target="_blank">diff</a>
573+ <button onclick="updateRef('{ path } ')">▶</button>
564574 <img src="/image_diff/{ path } " width="50" height="0" style="flex:1;">
565575</div>
566576<div style="display:flex;flex:1;flex-flow:column;margin:5px;">
0 commit comments