@@ -2,64 +2,64 @@ window.addEventListener('load', function() {
2
2
var revisionLinks = document . querySelectorAll ( '#issue-changesets a[href*="/revisions/"]:not([href$="diff"])' ) ;
3
3
4
4
for ( i = 0 ; i < revisionLinks . length ; ++ i ) {
5
- var revisionLink = revisionLinks [ i ] ;
5
+ ( function ( revisionLink ) {
6
+ fetch ( revisionLink . href + '/status.json' , {
7
+ headers : {
8
+ 'X-Requested-With' : 'XMLHttpRequest'
9
+ }
10
+ } )
11
+ . then ( function ( response ) {
12
+ return response . json ( ) ;
13
+ } )
14
+ . then ( function ( data ) {
15
+ if ( ! data . state ) {
16
+ return ;
17
+ }
6
18
7
- fetch ( revisionLink . href + '/status.json' , {
8
- headers : {
9
- 'X-Requested-With' : 'XMLHttpRequest'
10
- }
11
- } )
12
- . then ( function ( response ) {
13
- return response . json ( ) ;
14
- } )
15
- . then ( function ( data ) {
16
- if ( ! data . state ) {
17
- return ;
18
- }
19
+ var details = document . createElement ( 'details' ) ;
19
20
20
- var details = document . createElement ( 'details' ) ;
21
+ details . className = 'changeset-status__popover' ;
22
+ details . setAttribute ( 'role' , 'menu' ) ;
21
23
22
- details . className = 'changeset-status__popover' ;
23
- details . setAttribute ( 'role' , 'menu' ) ;
24
+ details . innerHTML = '<summary aria-haspopup="menu" class=" changeset-status changeset-status--' + data . state + '">•</summary>' +
25
+ '<div class="changeset-status__popup"><ul></ul></div>' ;
24
26
25
- details . innerHTML = '<summary aria-haspopup="menu" class="changeset-status changeset-status--' + data . state + '">•</summary>' +
26
- '<div class="changeset-status__popup"><ul></ul></div>' ;
27
+ var ul = details . querySelector ( 'ul' ) ;
27
28
28
- var ul = details . querySelector ( 'ul' ) ;
29
+ data . statuses . forEach ( function ( status ) {
30
+ var li = document . createElement ( 'li' ) ;
31
+ li . innerHTML = '<span class="changeset-status changeset-status--' + status . state + '">•</span> <strong></strong>'
29
32
30
- data . statuses . forEach ( function ( status ) {
31
- var li = document . createElement ( 'li' ) ;
32
- li . innerHTML = '<span class="changeset-status changeset-status--' + status . state + '">•</span> <strong></strong>'
33
+ var strong = li . querySelector ( 'strong' ) ;
33
34
34
- var strong = li . querySelector ( 'strong' ) ;
35
+ if ( status . target_url ) {
36
+ var a = document . createElement ( 'a' ) ;
35
37
36
- if ( status . target_url ) {
37
- var a = document . createElement ( 'a' ) ;
38
+ a . setAttribute ( 'href' , status . target_url ) ;
39
+ a . setAttribute ( 'target' , '_blank' ) ;
40
+ a . setAttribute ( 'rel' , 'noopener noreferrer' ) ;
38
41
39
- a . setAttribute ( 'href' , status . target_url ) ;
40
- a . setAttribute ( 'target' , '_blank' ) ;
41
- a . setAttribute ( 'rel' , 'noopener noreferrer' ) ;
42
+ a . innerText = status . context ;
42
43
43
- a . innerText = status . context ;
44
+ strong . appendChild ( a ) ;
45
+ } else {
46
+ strong . innerText = status . context ;
47
+ }
44
48
45
- strong . appendChild ( a ) ;
46
- } else {
47
- strong . innerText = status . context ;
48
- }
49
+ if ( status . description ) {
50
+ var em = document . createElement ( 'em' ) ;
49
51
50
- if ( status . description ) {
51
- var em = document . createElement ( 'em' ) ;
52
+ em . setAttribute ( 'title' , status . description ) ;
53
+ em . innerText = status . description ;
52
54
53
- em . setAttribute ( 'title' , status . description ) ;
54
- em . innerText = status . description ;
55
+ li . appendChild ( em ) ;
56
+ }
55
57
56
- li . appendChild ( em ) ;
57
- }
58
+ ul . appendChild ( li ) ;
59
+ } ) ;
58
60
59
- ul . appendChild ( li ) ;
61
+ revisionLink . parentNode . insertBefore ( details , revisionLink ) ;
60
62
} ) ;
61
-
62
- revisionLink . parentNode . insertBefore ( details , revisionLink ) ;
63
- } ) ;
63
+ } ) ( revisionLinks [ i ] ) ;
64
64
}
65
65
} ) ;
0 commit comments