1
1
import { showElem } from '../utils/dom.js' ;
2
2
3
3
async function loadBranchesAndTags ( loadingButton , addHere ) {
4
- loadingButton . classList . add ( 'disabled' )
4
+ loadingButton . classList . add ( 'disabled' ) ;
5
5
let res ;
6
6
try {
7
- res = await fetch ( loadingButton . getAttribute ( 'data-fetch-url' ) , { method : 'GET' , } ) ;
7
+ res = await fetch ( loadingButton . getAttribute ( 'data-fetch-url' ) , {
8
+ method : 'GET' ,
9
+ } ) ;
8
10
} finally {
9
- loadingButton . classList . remove ( 'disabled' )
11
+ loadingButton . classList . remove ( 'disabled' ) ;
10
12
}
11
13
12
14
if ( ! res . ok ) {
@@ -16,10 +18,16 @@ async function loadBranchesAndTags(loadingButton, addHere) {
16
18
const data = await res . json ( ) ;
17
19
showAreas ( '.branch-tag-area-divider' ) ;
18
20
loadingButton . classList . add ( 'gt-hidden' ) ;
19
- addHere . querySelector ( '.branch-tag-area-text' ) . textContent = loadingButton . getAttribute ( 'data-contained-in-text' ) ;
21
+ addHere . querySelector ( '.branch-tag-area-text' ) . textContent =
22
+ loadingButton . getAttribute ( 'data-contained-in-text' ) ;
20
23
addTags ( data . tags , addHere . querySelector ( '.tag-area' ) ) ;
21
24
const branchArea = addHere . querySelector ( '.branch-area' ) ;
22
- addBranches ( data . branches , data . default_branch , branchArea . getAttribute ( 'data-defaultbranch-tooltip' ) , branchArea ) ;
25
+ addBranches (
26
+ data . branches ,
27
+ data . default_branch ,
28
+ branchArea . getAttribute ( 'data-defaultbranch-tooltip' ) ,
29
+ branchArea ,
30
+ ) ;
23
31
}
24
32
25
33
function addTags ( tags , addHere ) {
@@ -32,7 +40,12 @@ function addTags(tags, addHere) {
32
40
function addBranches ( branches , defaultBranch , defaultBranchTooltip , addHere ) {
33
41
if ( branches . length > 0 ) showAreas ( '.branch-area,.branch-area-parent' ) ;
34
42
for ( const branch of branches ) {
35
- addLink ( branch . web_link , branch . name , addHere , defaultBranch === branch . name ? defaultBranchTooltip : undefined ) ;
43
+ addLink (
44
+ branch . web_link ,
45
+ branch . name ,
46
+ addHere ,
47
+ defaultBranch === branch . name ? defaultBranchTooltip : undefined ,
48
+ ) ;
36
49
}
37
50
}
38
51
@@ -53,9 +66,14 @@ function addLink(href, text, addHere, tooltip) {
53
66
}
54
67
55
68
export function initLoadBranchesAndTagsButton ( ) {
56
- for ( const loadButton of document . querySelectorAll ( '.load-tags-and-branches' ) ) {
69
+ for ( const loadButton of document . querySelectorAll (
70
+ '.load-tags-and-branches' ,
71
+ ) ) {
57
72
loadButton . addEventListener ( 'click' , ( ) => {
58
- loadBranchesAndTags ( loadButton , document . querySelector ( '.branch-and-tag-area' ) ) ;
73
+ loadBranchesAndTags (
74
+ loadButton ,
75
+ document . querySelector ( '.branch-and-tag-area' ) ,
76
+ ) ;
59
77
} ) ;
60
78
}
61
79
}
0 commit comments