git » subscription-tool.git » commit a178d41

move JavaScript to separate file

author Thorsten Ortlepp
2026-02-18 23:02:51 UTC
committer Thorsten Ortlepp
2026-02-18 23:02:51 UTC
parent 49feb0f4d8af09bda8716ad8f99300bb30831417

move JavaScript to separate file

src/main/resources/static/manage.js +4 -0
src/main/resources/templates/Manage.html +2 -7

diff --git a/src/main/resources/static/manage.js b/src/main/resources/static/manage.js
new file mode 100644
index 0000000..174fa0b
--- /dev/null
+++ b/src/main/resources/static/manage.js
@@ -0,0 +1,4 @@
+function copyToClipboard() {
+  var text = document.getElementById("mailto").textContent;
+  navigator.clipboard.writeText(text);
+}
diff --git a/src/main/resources/templates/Manage.html b/src/main/resources/templates/Manage.html
index c5eb33f..dea9fd1 100644
--- a/src/main/resources/templates/Manage.html
+++ b/src/main/resources/templates/Manage.html
@@ -5,12 +5,7 @@
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link href="/bootstrap.min.css" rel="stylesheet">
   <title th:text="#{title}"/>
-  <script>
-    function copyTo() {
-      var text = document.getElementById("mailto").textContent;
-      navigator.clipboard.writeText(text);
-    }
-  </script>
+  <script src="/manage.js" async></script>
 </head>
 <body>
 <div class="container-fluid">
@@ -67,7 +62,7 @@
 
   <div class="py-3">
     <pre class="bg-secondary text-white text-wrap lh-lg" id="mailto" th:text="${mails}"/>
-    <p><button class="btn btn-primary btn-sm" onclick="copyTo()" th:text="#{manage.action.copy}"/></p>
+    <p><button class="btn btn-primary btn-sm" onclick="copyToClipboard()" th:text="#{manage.action.copy}"/></p>
   </div>
 
 </div>