code.gitea.io/gitea@v1.21.7/web_src/js/features/repo-migration.js (about) 1 import $ from 'jquery'; 2 import {hideElem, showElem, toggleElem} from '../utils/dom.js'; 3 4 const $service = $('#service_type'); 5 const $user = $('#auth_username'); 6 const $pass = $('#auth_password'); 7 const $token = $('#auth_token'); 8 const $mirror = $('#mirror'); 9 const $lfs = $('#lfs'); 10 const $lfsSettings = $('#lfs_settings'); 11 const $lfsEndpoint = $('#lfs_endpoint'); 12 const $items = $('#migrate_items').find('input[type=checkbox]'); 13 14 export function initRepoMigration() { 15 checkAuth(); 16 setLFSSettingsVisibility(); 17 18 $user.on('input', () => {checkItems(false)}); 19 $pass.on('input', () => {checkItems(false)}); 20 $token.on('input', () => {checkItems(true)}); 21 $mirror.on('change', () => {checkItems(true)}); 22 $('#lfs_settings_show').on('click', () => { showElem($lfsEndpoint); return false }); 23 $lfs.on('change', setLFSSettingsVisibility); 24 25 const $cloneAddr = $('#clone_addr'); 26 $cloneAddr.on('change', () => { 27 const $repoName = $('#repo_name'); 28 if ($cloneAddr.val().length > 0 && $repoName.val().length === 0) { // Only modify if repo_name input is blank 29 $repoName.val($cloneAddr.val().match(/^(.*\/)?((.+?)(\.git)?)$/)[3]); 30 } 31 }); 32 } 33 34 function checkAuth() { 35 const serviceType = $service.val(); 36 37 checkItems(serviceType !== 1); 38 } 39 40 function checkItems(tokenAuth) { 41 let enableItems; 42 if (tokenAuth) { 43 enableItems = $token.val() !== ''; 44 } else { 45 enableItems = $user.val() !== '' || $pass.val() !== ''; 46 } 47 if (enableItems && $service.val() > 1) { 48 if ($mirror.is(':checked')) { 49 $items.not('[name="wiki"]').attr('disabled', true); 50 $items.filter('[name="wiki"]').attr('disabled', false); 51 return; 52 } 53 $items.attr('disabled', false); 54 } else { 55 $items.attr('disabled', true); 56 } 57 } 58 59 function setLFSSettingsVisibility() { 60 const visible = $lfs.is(':checked'); 61 toggleElem($lfsSettings, visible); 62 hideElem($lfsEndpoint); 63 }