Skip to content

Commit

Permalink
Fix clone url JS error for the empty repo page (#19209)
Browse files Browse the repository at this point in the history
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
  • Loading branch information
3 people committed Mar 29, 2022
1 parent d59b854 commit b702f2d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions templates/repo/empty.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ git push -u origin {{.Repository.DefaultBranch}}</code></pre>
git push -u origin {{.Repository.DefaultBranch}}</code></pre>
</div>
</div>
<script defer>
/* eslint-disable no-undef */
const cloneUrls = document.getElementsByClassName('clone-url');
if (cloneUrls) {
for (let i = 0; i < cloneUrls.length; i++) {
cloneUrls[i].textContent = (isSSH ? sshButton : httpsButton).getAttribute('data-link');
<script>
(() => {
const proto = localStorage.getItem('repo-clone-protocol') || 'https';
const btn = document.getElementById(`repo-clone-${proto}`) || document.getElementById(`repo-clone-https`) || document.getElementById(`repo-clone-ssh`);
if (btn) {
const cloneUrls = document.getElementsByClassName('clone-url');
for (let i = 0; i < cloneUrls.length; i++) {
cloneUrls[i].textContent = btn.getAttribute('data-link');
}
}
}
})();
</script>
{{end}}
{{else}}
Expand Down

0 comments on commit b702f2d

Please sign in to comment.