Skip to content

Commit 42c88b6

Browse files
Added loading
1 parent be0eaa7 commit 42c88b6

File tree

8 files changed

+73
-75
lines changed

8 files changed

+73
-75
lines changed

coronatracker/State.html

Lines changed: 0 additions & 67 deletions
This file was deleted.

coronatracker/country.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ <h2 id="title">All Over The World</h2>
5050
<div id="search">
5151
<input type="text" name="search-input" id="search-input" onkeyup="searchCountry()" placeholder="SEARCH HERE...">
5252
</div>
53+
<!-- ########################## LOADING ########################-->
54+
<div class="loading__container">
55+
<div class="loading"></div>
56+
Loading...
57+
</div>
5358
<div class="error_container">
5459
<p class="error-msg" style="margin:0;text-align: center;"></p>
5560
</div>

coronatracker/country.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
let country_name_array=[];
22
function getTodayStatus()
33
{
4+
let loading=document.querySelector(".loading__container");
5+
loading.style["display"]="flex";
46
let status_link="https://corona.lmao.ninja/v2/all";
57
$.getJSON(status_link,function(data)
68
{
@@ -51,6 +53,8 @@ function getTodayStatus()
5153
$("#recovered-no").append(recovered+decreases+Math.abs(today_recovered)+"</span>");
5254
}
5355
$("#active-no").append(active);
56+
let loading=document.querySelector(".loading__container");
57+
loading.style["display"]="none";
5458
}).fail(handleError);
5559
getCountryStatus()
5660

@@ -123,6 +127,7 @@ function getCountryStatus()
123127
<div class='deaths-country'>Deaths<br><span id='active-no'>"+deaths+"</span></div><br>\
124128
</div>"
125129
$(".country-container").append(country_html);
130+
126131
});
127132
}).fail(handleError);
128133
}

coronatracker/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ <h2 id="title">All Over India</h2>
6060
But you can see the old data by using filter option<br>
6161
</p>
6262
</div>
63-
<!-- ########################## FETCHING ########################-->
64-
65-
63+
<!-- ########################## LOADING ########################-->
64+
<div class="loading__container">
65+
<div class="loading"></div>
66+
Loading...
67+
</div>
6668
<!-- ########################## Live Table ########################-->
6769
<div class="state-container">
6870
</div>

coronatracker/script.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,17 +360,22 @@ function search()
360360
{
361361
let search_button=document.querySelector("#search_button");
362362

363-
search_button.addEventListener("click",function(){
363+
search_button.addEventListener("click",async function(){
364+
let loading=document.querySelector(".loading__container");
365+
loading.style["display"]="flex";
364366
let date=$("#search_date").val();
365367
//if user requested date greater than API CLOSED DATE handle error
366368
if(new Date(date)<new Date(API_CLOSED_DATE))
367369
{
368-
getSpecificData(date);
370+
await getSpecificData(date);
369371
}
370372
else
371373
{
374+
loading.style["display"]="none";
372375
handleError();
376+
373377
}
378+
374379
});
375380
}
376381

@@ -453,6 +458,8 @@ function getSpecificData(date)
453458
addDataToTable(data_array,prev_data_array,0,1);
454459
}
455460
//calling the search state function to filter if user entered
461+
let loading=document.querySelector(".loading__container");
462+
loading.style["display"]="none";
456463
searchState();
457464
}).catch(handleError);
458465

coronatracker/state.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@
5454
<input type="button" name="Search" value="Search" id="search_button">
5555
</div>
5656

57+
<!-- ########################## LOADING ########################-->
58+
<div class="loading__container">
59+
<div class="loading"></div>
60+
Loading...
61+
</div>
62+
5763
<div class="error_container">
5864
<img src="./image/error.png" class="error_img">
5965
<p class="error-msg" style="margin:0;text-align: center;">

coronatracker/state.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var district_name_array=[];
1+
ovar district_name_array=[];
22
var state_code;
33
const API_CLOSED_DATE="2021-02-01";
44
function getAllData(isspecific=0)
@@ -302,13 +302,16 @@ function search()
302302
let search_button=document.querySelector("#search_button");
303303

304304
search_button.addEventListener("click",function(){
305-
let date=$("#search_date").val();
305+
let date=$("#search_date").val();
306+
let loading=document.querySelector(".loading__container");
307+
loading.style["display"]="flex";
306308
if(new Date(date)<new Date(API_CLOSED_DATE))
307309
{
308310
getSpecificData(date);
309311
}
310312
else
311313
{
314+
loading.style["display"]="none";
312315
handleError();
313316
}
314317
});
@@ -318,6 +321,7 @@ function getSpecificData(date)
318321
{
319322

320323
$(".district-container").empty();
324+
321325
document.querySelector(".district-container").style.display="flex";
322326
document.querySelector(".error_container").style.display="none";
323327
let link="https://api.covid19india.org/v3/data-"+date+".json";
@@ -391,6 +395,9 @@ function getSpecificData(date)
391395
data_array[4]=district_name;
392396
data_array[5]=date;
393397
addDataToTable(data_array,prev_data_array,0,1);
398+
let loading=document.querySelector(".loading__container");
399+
loading.style["display"]="none";
400+
394401
}
395402

396403
}).catch(handleError);

coronatracker/style.css

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,33 @@ nav span
8787
font-size:1.5rem;
8888
font-weight:500;
8989
}
90+
.loading__container
91+
{
92+
display: none;
93+
justify-content: center;
94+
flex-direction: column;
95+
align-items: center;
96+
margin: 10px;
97+
98+
}
99+
.loading
100+
{
101+
height: 100px;
102+
width:100px;
103+
background-color:#03a9f4;
104+
border-radius: 50%;
105+
border-top: 5px solid #03a9f4;
106+
border-left:5px solid black;
107+
border-right: 5px solid black;
108+
border-bottom: 5px solid black;
109+
animation-name:spin;
110+
animation-duration: 1s;
111+
animation-iteration-count: infinite;
112+
113+
}
90114
.error_container
91115
{
92-
display: flex;
116+
display: none;
93117
flex-direction: column;
94118
height: auto;
95119
max-width: 300px;
@@ -245,6 +269,15 @@ nav span
245269
transform: translateX(0);
246270
}
247271
}
272+
@keyframes spin
273+
{
274+
0% {
275+
transform: rotate(0);
276+
}
277+
100%{
278+
transform: rotate(360deg);
279+
}
280+
}
248281
/* fro mobile device */
249282
@media (max-width: 575.98px) {
250283

0 commit comments

Comments
 (0)