File tree Expand file tree Collapse file tree 1 file changed +21
-16
lines changed
Expand file tree Collapse file tree 1 file changed +21
-16
lines changed Original file line number Diff line number Diff line change 1- $ . ajax ( {
2- url : "./images/" ,
3- success : data => {
4- $ ( data ) . find ( "a" ) . attr ( "href" , ( _i , filename ) => {
5- if ( filename . match ( / \. ( j p e ? g | p n g | g i f ) $ / ) ) {
6- $ ( 'body' ) . append (
7- "<div class=\"head-container\"><img class=\"head\" src=\"./images/" + filename + "\"/></div>"
8- ) ;
9- }
10- } ) ;
1+ fetch ( 'https://api.github.com/repos/code4community/git-tutorial/git/trees/master' )
2+ . then ( response => response . json ( ) )
3+ . then ( data => {
4+ const imagesUrl = data . tree . find ( element => element . path === 'images' ) . url
115
12- let people = document . getElementsByClassName ( "head-container" ) ;
13- for ( let person of people ) {
14- person . style [ "animation-delay" ] = - Math . floor ( Math . random ( ) * 1000 ) + "s"
15- }
16- }
17- } ) ;
6+ fetch ( imagesUrl )
7+ . then ( response => response . json ( ) )
8+ . then ( data => {
9+ const filenames = data . tree . map ( element => element . path )
10+
11+ filenames . forEach ( filename => {
12+ $ ( 'body' ) . append (
13+ "<div class=\"head-container\"><img class=\"head\" src=\"images/" + filename + "\"/></div>"
14+ )
15+ } )
16+
17+ const people = document . getElementsByClassName ( "head-container" ) ;
18+ for ( let person of people ) {
19+ person . style [ "animation-delay" ] = - Math . floor ( Math . random ( ) * 1000 ) + "s"
20+ }
21+ } )
22+ } )
You can’t perform that action at this time.
0 commit comments