Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.48 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>Covid Widget</title>
  8. <style>
  9. .covid__widget {
  10. position: relative;
  11. padding-bottom: 20px;
  12. }
  13.  
  14. @media (min-width: 768px) {
  15.  
  16. .covid__widget {
  17. padding-bottom: 0;
  18. }
  19. }
  20.  
  21. .covid__wrap {
  22. width: 100%;
  23. padding: 10px 0;
  24. }
  25.  
  26. @media (min-width: 768px) {
  27. .covid__wrap {
  28. display: -webkit-box;
  29. /* OLD - iOS 6-, Safari 3.1-6, BB7 */
  30. display: -ms-flexbox;
  31. /* TWEENER - IE 10 */
  32. display: -webkit-flex;
  33. /* NEW - Safari 6.1+. iOS 7.1+, BB10 */
  34. display: flex;
  35. /* NEW, Spec - Firefox, Chrome, Opera */
  36. flex-wrap: wrap;
  37. align-content: space-evenly;
  38. }
  39. }
  40. .covid__col {
  41. position: relative;
  42. width: 100%;
  43. display: block;
  44. }
  45.  
  46. @media (min-width: 768px) {
  47. .covid__col {
  48. width: calc(100% / 2);
  49. }
  50. }
  51.  
  52. .covid__box {
  53. position: relative;
  54. display: -webkit-box;
  55. /* OLD - iOS 6-, Safari 3.1-6, BB7 */
  56. display: -ms-flexbox;
  57. /* TWEENER - IE 10 */
  58. display: -webkit-flex;
  59. /* NEW - Safari 6.1+. iOS 7.1+, BB10 */
  60. display: flex;
  61. /* NEW, Spec - Firefox, Chrome, Opera */
  62. flex-wrap: wrap;
  63. align-content: space-evenly;
  64. }
  65.  
  66. .covid__box2 {
  67. position: relative;
  68. font-size: 22px;
  69. font-weight: 700;
  70. line-height: 1;
  71. color: #fff;
  72. text-align: center;
  73. width: calc(100% / 3);
  74. padding: 10px 0;
  75. }
  76.  
  77. .covid__box2 span {
  78. font-family: "Roboto Condensed", sans-serif;
  79. font-size: 14px;
  80. font-weight: 700;
  81. display: block;
  82. padding: 0 0 5px;
  83. text-transform: uppercase;
  84. }
  85.  
  86. .covid__box2 i {
  87. font-family: inherit;
  88. font-size: 9px;
  89. font-weight: 400;
  90. padding: 0 5px;
  91. font-style: normal;
  92. vertical-align: middle;
  93. display: inline-block;
  94. }
  95.  
  96. .covid__box2.-cases {
  97. width: 100%;
  98. background: #8F8F8F;
  99. font-size: 31px;
  100. }
  101.  
  102. .covid__box2.-odp {
  103. background: #FE9B44;
  104. }
  105.  
  106. .covid__box2.-gone {
  107. background: #F24E4E;
  108. }
  109.  
  110. .covid__box2.-health {
  111. background: #44C644;
  112. }
  113.  
  114. .covid__banner {
  115. width: 50%;
  116. height: auto;
  117. position: relative !important;
  118. display: block;
  119. z-index: 999;
  120. flex: 1;
  121. }
  122.  
  123. @media (min-width: 768px) {
  124. .covid__banner {
  125. width: 50%;
  126. }
  127. }
  128.  
  129. @media (max-width: 720px) {
  130. .covid__wrap {
  131. display: block !important;
  132. }
  133.  
  134. .covid__banner {
  135. height: 90px;
  136. padding-bottom: 0;
  137. width: auto;
  138. background-size: cover;
  139. }
  140. }
  141.  
  142. .covid__bottom {
  143. padding: 0 5px 10px;
  144. }
  145.  
  146. @media (min-width: 768px) {
  147. .covid__bottom {
  148. padding: 0 20px 10px;
  149. }
  150. }
  151.  
  152. .covid__bottom span {
  153. text-align: left;
  154. font-family: "Roboto Condensed", sans-serif;
  155. font-size: 12px;
  156. font-weight: 700;
  157. }
  158.  
  159. .covid__date {
  160. padding: 2px 0;
  161. text-align: center;
  162. display: block;
  163. font-size: 12px;
  164. font-weight: 400;
  165. line-height: 1;
  166. color: #fff;
  167. }
  168.  
  169. @media (min-width: 768px) {
  170. .covid__date {
  171. padding: 7px 0 0;
  172. float: right;
  173. font-size: 14px;
  174. text-align: right;
  175. }
  176. }
  177.  
  178. .covid__date span {
  179. font-weight: 700;
  180. }
  181. </style>
  182. </head>
  183. <body>
  184. <div class="covid__widget">
  185. <div class="covid__wrap">
  186. <div class="covid__col">
  187. <div class="covid__box">
  188. <div class="covid__box2 -cases"></div>
  189. </div>
  190. <div class="covid__box">
  191. <div class="covid__box2 -odp"></div>
  192. <div class="covid__box2 -gone"></div>
  193. <div class="covid__box2 -health"></div>
  194. </div>
  195. </div>
  196. <a class="covid__banner" style="background-image: url('https://www.trenasia.co/wp-content/uploads/2020/03/banner-web-2.png');background-size: contain;background-repeat: no-repeat;background-position: right center;" href="https://www.trenasia.co/covid-19/" rel="bookmark"></a>
  197. </div>
  198. <div class="covid__bottom">
  199. <div class="latest">
  200. Updated at:
  201. <span class="dates"></span>
  202. </div>
  203. </div>
  204. </div>
  205. <script>
  206. var xmlhttp = new XMLHttpRequest();
  207. xmlhttp.onreadystatechange = function () {
  208. if (this.readyState == 4 && this.status == 200) {
  209. const dataJson = JSON.parse(this.response);
  210. const summary = dataJson.features.filter(f => {
  211. return f.attributes.Jumlah_Kasus_Baru_per_Hari !== null
  212. });
  213. const latest = summary[summary.length - 1];
  214. const { attributes } = latest
  215. const dates = new Date(attributes.Tanggal).toDateString();
  216. const times = new Date(attributes.Tanggal).toLocaleTimeString();
  217.  
  218. // inject data into html element
  219. document.querySelector('.-cases').innerHTML = `<span>Terkonfirmasi</span>${attributes.Jumlah_Kasus_Kumulatif} <i>+${attributes.Jumlah_Kasus_Baru_per_Hari} Kasus</i>`;
  220. document.querySelector('.-odp').innerHTML = `<span>Dirawat</span>${attributes.Jumlah_pasien_dalam_perawatan}<i>${attributes.Persentase_Pasien_dalam_Perawatan.toFixed(2)}% dari terkonfirmasi</i>`;
  221. document.querySelector('.-gone').innerHTML = `<span>Meninggal</span>${attributes.Jumlah_Pasien_Meninggal} <i>${attributes.Jumlah_Pasien_Meninggal.toFixed(2)}% dari terkonfirmasi</i>`;
  222. document.querySelector('.-health').innerHTML = `<span>Sembuh</span>${attributes.Jumlah_Pasien_Sembuh} <i>${attributes.Persentase_Pasien_Sembuh.toFixed(2)}% dari terkonfirmasi</i>`;
  223. document.querySelector('.dates').innerHTML = `${dates} ${times}`;
  224. }
  225. };
  226. xmlhttp.open("GET", "https://services5.arcgis.com/VS6HdKS0VfIhv8Ct/ArcGIS/rest/services/Statistik_Perkembangan_COVID19_Indonesia/FeatureServer/0/query?where=1%3D1&objectIds=&time=&resultType=standard&outFields=*&returnIdsOnly=false&returnUniqueIdsOnly=false&returnCountOnly=false&returnDistinctValues=false&cacheHint=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&having=&resultOffset=&resultRecordCount=&sqlFormat=standard&f=pjson&token=", true);
  227. xmlhttp.send();
  228. </script>
  229. </body>
  230. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement