mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-25 17:44:32 +02:00 
			
		
		
		
	Enable a few more useful options in tsconfig. `noImplicitReturns` had two cases which I've fixed. Also, partially sort the file.
		
			
				
	
	
		
			23 lines
		
	
	
		
			802 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			802 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| export function initTableSort() {
 | |
|   for (const header of document.querySelectorAll('th[data-sortt-asc]') || []) {
 | |
|     const sorttAsc = header.getAttribute('data-sortt-asc');
 | |
|     const sorttDesc = header.getAttribute('data-sortt-desc');
 | |
|     const sorttDefault = header.getAttribute('data-sortt-default');
 | |
|     header.addEventListener('click', () => {
 | |
|       tableSort(sorttAsc, sorttDesc, sorttDefault);
 | |
|     });
 | |
|   }
 | |
| }
 | |
| 
 | |
| function tableSort(normSort: string, revSort: string, isDefault: string) {
 | |
|   if (!normSort) return;
 | |
|   if (!revSort) revSort = '';
 | |
| 
 | |
|   const url = new URL(window.location.href);
 | |
|   let urlSort = url.searchParams.get('sort');
 | |
|   if (!urlSort && isDefault) urlSort = normSort;
 | |
| 
 | |
|   url.searchParams.set('sort', urlSort !== normSort ? normSort : revSort);
 | |
|   window.location.replace(url.href);
 | |
| }
 |