You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
1.0 KiB
24 lines
1.0 KiB
2 years ago
|
<script>
|
||
|
// synchronously set clone button states and urls here to avoid flickering
|
||
|
// on page load. initRepoCloneLink calls this when proto changes.
|
||
|
// TODO: This localStorage setting should be moved to backend user config
|
||
|
// so it's available during rendering, then this inline script can be removed.
|
||
|
(window.updateCloneStates = function() {
|
||
|
const httpsBtn = document.getElementById('repo-clone-https');
|
||
|
const sshBtn = document.getElementById('repo-clone-ssh');
|
||
|
const value = localStorage.getItem('repo-clone-protocol') || 'https';
|
||
|
const isSSH = value === 'ssh' && sshBtn || value !== 'ssh' && !httpsBtn;
|
||
|
|
||
|
if (httpsBtn) httpsBtn.classList[!isSSH ? 'add' : 'remove']('primary');
|
||
|
if (sshBtn) sshBtn.classList[isSSH ? 'add' : 'remove']('primary');
|
||
|
|
||
|
const btn = isSSH ? sshBtn : httpsBtn;
|
||
|
if (!btn) return;
|
||
|
|
||
|
const link = btn.getAttribute('data-link');
|
||
|
for (const el of document.getElementsByClassName('js-clone-url')) {
|
||
|
el[el.nodeName === 'INPUT' ? 'value' : 'textContent'] = link;
|
||
|
}
|
||
|
})();
|
||
|
</script>
|