File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11
22
3- const loader = document . getElementById ( "loader" ) ;
43function getQuote ( ) {
54 const quoteText = document . getElementById ( 'quoteText' ) ;
65 const characterName = document . getElementById ( 'characterName' ) ;
76 const imageUrl = document . querySelector ( ".image" ) ;
7+ const loader = document . getElementById ( "loader" ) ;
8+ const quoteBox = document . querySelector ( '.quote-box' ) ;
9+ loader . style . display = "block" ;
10+ imageUrl . classList . remove ( 'visible' ) ;
11+ quoteBox . style . display = 'none' ;
812 fetch ( 'https://thesimpsonsquoteapi.glitch.me/quotes' )
913 . then ( response => response . json ( ) )
1014 . then ( data => {
11- console . log ( "=>(main.js:20) data" , data ) ;
15+ quoteBox . style . display = 'block' ;
1216 const quote = data [ 0 ] . quote ;
1317 const character = data [ 0 ] . character ;
1418 imageUrl . src = data [ 0 ] . image ;
@@ -19,5 +23,10 @@ function getQuote() {
1923 . catch ( error => {
2024 console . error ( 'Error fetching the quote:' , error ) ;
2125 document . getElementById ( 'quoteText' ) . innerText = 'Failed to fetch quote. Please try again.' ;
22- } ) ;
26+ } )
27+ . finally ( ( ) => {
28+ loader . style . display = "none" ;
29+ quoteBox . style . display = "block" ;
30+ } ) ;
31+
2332}
Original file line number Diff line number Diff line change 3131 justify-content : center;
3232 text-align : center;
3333 width : 500px ;
34+ min-height : 350px ;
3435}
3536# quoteText {
3637 font-size : larger;
@@ -76,6 +77,7 @@ img.visible {
7677 user-select : none;
7778 -webkit-user-select : none;
7879 touch-action : manipulation;
80+ margin-bottom : 10px ;
7981}
8082
8183.btn_class : focus {
@@ -106,14 +108,14 @@ img.visible {
106108
107109.loader {
108110 border : 8px solid # f3f3f3 ;
109- border-top : 8px solid # 3498db ;
111+ border-top : 8px solid # ff001a ;
110112 border-radius : 50% ;
111113 width : 60px ;
112114 height : 60px ;
113115 animation : spin 1s linear infinite;
114- position : absolute;
116+ /* position: absolute;*/
115117 top : 50% ;
116- left : 50 % ;
118+ margin : 60 px auto 10 px auto ;
117119 transform : translate (-50% , -50% );
118120 display : none;
119121}
You can’t perform that action at this time.
0 commit comments