File tree Expand file tree Collapse file tree 4 files changed +92
-1
lines changed
12 - Key Sequence Detection Expand file tree Collapse file tree 4 files changed +92
-1
lines changed Original file line number Diff line number Diff line change 1717 transition : .25s ease-in-out;
1818 }
1919
20- .container .title {
20+ .container .title , h1 {
2121 color : black;
22+ text-shadow : 1px 1px 1px gray;
23+ text-transform : uppercase;
2224 }
2325
2426 .container .active h1 , .container .active .title {
27+ text-shadow : 2px 2px 2px black;
2528 color : white;
2629 }
2730
3336 .secret_test {
3437 appearance : none;
3538 padding : 10px ;
39+ text-transform : uppercase;
3640 }
3741
3842</ style >
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+
4+ < head >
5+ < meta charset ="UTF-8 ">
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
8+ < title > MLB POSTSEASON SCHEDULE</ title >
9+ < link rel ="stylesheet " type ="text/css " href ="styles.css ">
10+ </ head >
11+
12+ < body >
13+
14+ < div class ="container ">
15+ < h1 > Using Fetch</ h1 >
16+ < div class ="team ">
17+ < h2 > Post Season Scoreboard</ h2 >
18+ < ul class ="games "> </ ul >
19+ </ div >
20+ </ div >
21+ < script src ="index.js "> </ script >
22+ </ body >
23+
24+ </ html >
Original file line number Diff line number Diff line change 1+ const games = document . querySelector ( '.games' ) ;
2+ const url = "http://gd2.mlb.com/components/game/mlb/year_2017/postseason_scoreboard.json"
3+
4+ function createNode ( element ) {
5+ return document . createElement ( element ) ;
6+ }
7+
8+ function append ( parent , child ) {
9+ return parent . appendChild ( child ) ;
10+ }
11+
12+ fetch ( url )
13+ . then ( ( resp ) => resp . json ( ) )
14+ . then ( ( data ) => {
15+ const game_data = data . games ;
16+ return game_data . map ( ( game ) => {
17+
18+ let game_container = createNode ( 'div' )
19+ let home_team = createNode ( 'h3' )
20+ let away_team = createNode ( 'h3' )
21+
22+ game_container . classList . add ( 'game' ) ;
23+ home_team . classList . add ( 'team' ) ;
24+ away_team . classList . add ( 'team' ) ;
25+
26+ home_team . innerHTML = `${ game . home_team_city } ${ game . home_team_name } `
27+ away_team . innerHTML = `${ game . away_team_city } ${ game . away_team_name } `
28+
29+ append ( game_container , home_team ) ;
30+ append ( game_container , away_team ) ;
31+ append ( games , game_container ) ;
32+ } )
33+ } )
34+ . catch ( ( err ) => {
35+ console . log ( err )
36+ } ) ;
37+
38+ console . log ( "LOADED" ) ;
Original file line number Diff line number Diff line change 1+ body {
2+ padding : 0 ;
3+ margin : 0 ;
4+ }
5+
6+ .container {
7+ margin : 0 auto;
8+ text-align : center;
9+ padding : 40px ;
10+ background-color : gray;
11+ }
12+
13+ .game {
14+ display : flex;
15+ }
16+
17+ .team {
18+ flex : 1 ;
19+ padding : 10px ;
20+ }
21+
22+ ul {
23+ padding-left : 0 ;
24+ text-align : center;
25+ }
You can’t perform that action at this time.
0 commit comments