Blog adds real-time data display of new coronavirus epidemic
Add Method
?> <div class="row row-sm" style="position: relative;"> <div class="col-12"> <div class="card" style="color:#fff;background-color:#61adff"> <div class="card-body py-2"> <div class="d-flex flex-fill text-sm"> <span>New coronavirus data</span> <div class="flex-fill"></div> <div>Up to<span id="updateTime">0000-00-00 00:00:00</span></div> </div> </div> </div> </div> <div class="col-6 col-md-3"> <div class="card" style="color:#fff;background-color:#FF464D"> <div class="card-body py-3"> <div class="d-flex flex-fill text-md mb-4"> <span>Diagnosis</span> <div class="flex-fill"></div> <span class="text sm">Compared with yesterday:<span id="confirmedIncr">00</span></span> </div> <h1 id="confirmedCount" class="h2 m-0">000</h1> </div> </div> </div> <div class="col-6 col-md-3"> <div class="card" style="color:#fff;background-color:#FFA746"> <div class="card-body py-3"> <div class="d-flex flex-fill text-md mb-4"> <span>Suspected</span> <div class="flex-fill"></div> <span class="text sm">Compared with yesterday:<span id="suspectedIncr">00</span></span> </div> <h1 id="suspectedCount" class="h2 m-0">000</h1> </div> </div> </div> <div class="col-6 col-md-3"> <div class="card" style="color:#fff;background-color:#67727d"> <div class="card-body py-3"> <div class="d-flex flex-fill text-md mb-4"> <span>Death</span> <div class="flex-fill"></div> <span class="text sm">Compared with yesterday:<span id="deadIncr">00</span></span> </div> <h1 id="deadCount" class="h2 m-0">000</h1> </div> </div> </div> <div class="col-6 col-md-3"> <div class="card" style="color:#fff;background-color:#02B88C"> <div class="card-body py-3"> <div class="d-flex flex-fill text-md mb-4"> <span>Healing</span> <div class="flex-fill"></div> <span class="text sm">Compared with yesterday:<span id="curedIncr">00</span></span> </div> <h1 id="curedCount" class="h2 m-0">000</h1> </div> </div> </div> <div class="col-12 col-md-6 d-none d-md-block"> <div class="card" style=""> <div class="card-body py-3"> <h1 class="h5 mb-3">Virus information</h1> <div class="overflow-auto" style="height:100px"> <div id="bd_note"> <div class="text-sm mb-2"><i class="iconfont icon-point mr-2"></i><span id="note1"></span></div> <div class="text-sm mb-2"><i class="iconfont icon-point mr-2"></i><span id="note2"></span></div> <div class="text-sm mb-2"><i class="iconfont icon-point mr-2"></i><span id="note3"></span></div> </div> </div> <div class="d-flex flex-fill text-xs text-muted pt-2 mb-n2"> <span>Data source:<a href=“ https://ncov.dxy.cn/ncovh5/view/pneumonia "Target=" _blank "rel='external nofollow 'style=" color: # 6c757d ">Clove Garden</a></span> <div class="flex-fill"></div> <span><a href= " https://lab.isaaclin.cn/nCoV/ " target="_blank" rel='external nofollow' style="color:#6c757d">API</a></span> </div> </div> </div> </div> <div class="col-12 col-md-6"> <div class="card" style=""> <div class="card-body py-3"> <h1 class="h5 mb-3">Epidemic information</h1> <div class="overflow-auto" style="height:100px"> <div id="bd_news"> </div> </div> <div class="d-flex flex-fill text-xs text-muted pt-2 mb-n2"> <span>Data source:<a href=“ https://ncov.dxy.cn/ncovh5/view/pneumonia "Target=" _blank "rel='external nofollow 'style=" color: # 6c757d ">Clove Garden</a></span> <div class="flex-fill"></div> <span><a href= " https://lab.isaaclin.cn/nCoV/ " target="_blank" rel='external nofollow' style="color:#6c757d">API</a></span> </div> </div> </div> </div> <div id="bd-loading" class="ajax-loading text-center rounded" style="position:absolute;display:flex;width:100%;top:-1rem;bottom:.5rem;background:rgba(125,125,125,.5)"><div id="bd-success" class="col align-self-center"><i class="iconfont icon-loading icon-spin icon-2x"></i></div></div> </div> <script> let url = " https://lab.isaaclin.cn/nCoV/api/overall "; let newsurl = " https://lab.isaaclin.cn/nCoV/api/news "; $.getJSON(url,function(data,status){ let res = data["results"][0]; $("#confirmedCount").text(res["confirmedCount"]); $("# confirmedIncr"). text (res ["confirmedIncr"]? Res ["confirmedIncr"]: 'to be updated'); $("#suspectedCount").text(res["suspectedCount"]); $("# suspectedIncr"). text (res ["suspectedIncr"]? Res ["suspectedIncr"]: 'to be updated'); $("#curedCount").text(res["curedCount"]); $("# curedIncr"). text (res ["curedIncr"]? Res ["curedIncr"]: 'to be updated'); $("#deadCount").text(res["deadCount"]); $("# deadIncr"). text (res ["deadIncr"]? Res ["deadIncr"]: 'to be updated'); $("#note1").text(res["note1"]); $("#note2").text(res["note2"]); $("#note3").text(res["note3"]); $("#updateTime").text(timestampToTime(res["updateTime"],1)); $("#bd-loading").hide(); }).fail(function () { $("# bd success"). html ('Blocked by the api server, please try again later. Note:<a href=“ https://lab.isaaclin.cn/nCoV/ " rel="external nofollow" target="_blank">API</a>'); }); $.getJSON(newsurl,function(data,status){ let res = data["results"][0]; let html = ''; for(let item of data['results']) { html += '<div class="text-sm mb-2">'+timestampToTime(item['pubDate'],1,true)+'<a class="ml-2" href="'+item['sourceUrl']+'" target="_blank" rel="external nofollow">'+item['title']+'</a></div>'; } $("#bd_news").html(html); }).fail(function () { $("# bd success"). html ('Blocked by the api server, please try again later. Note:<a href=“ https://lab.isaaclin.cn/nCoV/ " rel="external nofollow" target="_blank">API</a>'); }); function timestampToTime(timestamp,s,time = false) { var date = new Date(timestamp * s); Y = date.getFullYear() + '-'; M = (date.getMonth()+1 < 10 ? ' 0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; D = date.getDate() + ' '; h = date.getHours(); m = ':' + (date.getMinutes() < 10 ? ' 0'+(date.getMinutes()) : date.getMinutes()); s = ':' + (date.getSeconds() < 10 ? ' 0'+(date.getSeconds()) : date.getSeconds()); if(time) return h+m; else return Y+M+D+h+m+s; } </script> <? php
be careful
to update
let url = " https://i.iowen.cn/BlankerL/DXY-COVID-19-Data/master/json/DXYOverall.json "; let newsurl = " https://i.iowen.cn/BlankerL/DXY-COVID-19-Data/master/json/DXYNews.json ";