Change summary
pkg/web/static/url-switcher.js | 17 +++++++++++++++++
pkg/web/templates/overview.html | 15 +--------------
2 files changed, 18 insertions(+), 14 deletions(-)
Detailed changes
@@ -0,0 +1,17 @@
+document.addEventListener('DOMContentLoaded', function() {
+ const urlTypeSwitch = document.querySelector('input[name="url-type"]');
+ if (!urlTypeSwitch) return;
+
+ urlTypeSwitch.addEventListener('change', function() {
+ const sshUrl = document.getElementById('ssh-url');
+ const httpUrl = document.getElementById('http-url');
+
+ if (this.checked) {
+ sshUrl.style.display = 'none';
+ httpUrl.style.display = 'block';
+ } else {
+ sshUrl.style.display = 'block';
+ httpUrl.style.display = 'none';
+ }
+ });
+});
@@ -21,20 +21,7 @@ git push -u origin main</code></pre>
<p id="http-url" style="display: none;"><code>git clone {{.HTTPURL}}</code></p>
</fieldset>
-<script>
-document.querySelector('input[name="url-type"]').addEventListener('change', function() {
- const sshUrl = document.getElementById('ssh-url');
- const httpUrl = document.getElementById('http-url');
-
- if (this.checked) {
- sshUrl.style.display = 'none';
- httpUrl.style.display = 'block';
- } else {
- sshUrl.style.display = 'block';
- httpUrl.style.display = 'none';
- }
-});
-</script>
+<script src="/static/url-switcher.js"></script>
{{if .ReadmeHTML}}
<section aria-labelledby="readme-heading">