Skip to content
This repository was archived by the owner on Apr 27, 2022. It is now read-only.

Commit f8d1135

Browse files
committed
perbaiki #37 #38 dan tambahkan widget siaga covid-19 dari kawalcoronadotcom
1 parent 9b890e6 commit f8d1135

File tree

11 files changed

+269
-83
lines changed

11 files changed

+269
-83
lines changed

assets/css/images/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<html>
2+
<head>
3+
<title>403 Forbidden</title>
4+
</head>
5+
<body>
6+
7+
<p>Directory access is forbidden.</p>
8+
9+
</body>
10+
</html>

assets/css/widget.css

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
.box-shalat {
1+
.square {
22
position: relative;
33
height: 70px;
44
width: 100%;
55
border-radius: 10px;
6-
background: #1B676B;
76
color: #efefef;
87
font-family: 'montserrat', sans-serif;
98
font-weight: bold;
@@ -15,6 +14,38 @@
1514
overflow: hidden;
1615
}
1716

17+
.shalat {
18+
background: #1B676B;
19+
}
20+
21+
.shalat span {
22+
text-transform: capitalize;
23+
}
24+
25+
.covid {
26+
height: 120px;
27+
}
28+
29+
.covid span:nth-child(1) {
30+
font-size: medium;
31+
font-weight: normal;
32+
}
33+
.covid span:nth-child(2) {
34+
font-size: xx-large;
35+
}
36+
37+
.positif {
38+
background: #F82649;
39+
}
40+
41+
.sembuh {
42+
background: #09AD95;
43+
}
44+
45+
.meninggal {
46+
background: #D43F8D;
47+
}
48+
1849
.line {
1950
position: relative;
2051
height: 15px;
@@ -24,10 +55,10 @@
2455
}
2556

2657
.line-short {
27-
width: 250px;
58+
width: 200px;
2859
}
2960

30-
.box-shalat::before {
61+
.shalat::before {
3162
content: '';
3263
position: absolute;
3364
background: url('../image/motif.png');
@@ -39,6 +70,23 @@
3970
opacity: 0.2;
4071
}
4172

73+
.covid::before {
74+
content: '';
75+
position: absolute;
76+
background-image: url('../image/corona.png');
77+
background-position: right bottom;
78+
background-repeat: no-repeat;
79+
background-size: contain;
80+
width: 100%;
81+
height: 100%;
82+
opacity: 0.2;
83+
}
84+
85+
.covid.shimmer::before {
86+
content: '';
87+
background-image: none;
88+
}
89+
4290
.shimmer {
4391
background: #efefef;
4492
background-image: linear-gradient(to right, #efefef 0%, #edeef1 20%, #f6f7f8 40%, #efefef 100%);
@@ -51,38 +99,6 @@
5199
animation-timing-function: linear;
52100
}
53101

54-
.p-relative {
55-
display: block;
56-
position: relative;
57-
height: 100%;
58-
min-height: 180px;
59-
}
60-
61-
.p-absolute {
62-
position: absolute;
63-
top: 0;
64-
left: 0;
65-
right: 0;
66-
bottom: 0;
67-
width: 100%;
68-
height: auto;
69-
z-index: 999;
70-
}
71-
72-
.p-relative::after {
73-
clear: both;
74-
position: static;
75-
}
76-
77-
.p-relative #jadwal-shalat {
78-
background: linear-gradient(rgba(5,5,5,.7), transparent) !important;
79-
padding-bottom: 60px !important;
80-
}
81-
.p-relative [data-name=kota] {
82-
color: #efefef !important;
83-
}
84-
85-
86102
@keyframes placeholderShimmer {
87103
0% {
88104
background-position: -468px 0;

assets/css/widget.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/image/corona.png

16.1 KB
Loading

assets/js/widget.js

Lines changed: 108 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,129 @@
1+
var regions = {
2+
indonesia: {
3+
id: 1,
4+
attributes: {
5+
wilayah: 'name',
6+
positif: 'positif',
7+
meninggal: 'meninggal',
8+
sembuh: 'sembuh'
9+
}
10+
},
11+
provinsi: {
12+
id: 2,
13+
attributes: {
14+
wilayah: 'Provinsi',
15+
positif: 'Kasus_Posi',
16+
meninggal: 'Kasus_Meni',
17+
sembuh: 'Kasus_Semb'
18+
}
19+
}
20+
}
21+
22+
function numberFormat(num) {
23+
return new Intl.NumberFormat('id-ID').format(num);
24+
}
25+
26+
function parseToNum(data) {
27+
return parseFloat(data.toString().replace(/,/g, ''));
28+
}
29+
30+
function showCovidData(data, region) {
31+
const elem = region.id === regions.indonesia.id ? '#covid-nasional' : '#covid-provinsi';
32+
Object.keys(region.attributes).forEach(function (prop) {
33+
let tempData = data[region.attributes[prop]];
34+
let finalData = prop === 'wilayah' ? tempData.toUpperCase() : numberFormat(parseToNum(tempData));
35+
$(elem).find(`[data-name=${prop}]`).html(`${finalData}`);
36+
});
37+
38+
$(elem).find('.shimmer').removeClass('shimmer');
39+
}
40+
41+
function showError(elem = '') {
42+
$(`${elem} .shimmer`).html('<span class="small"><i class="fa fa-exclamation-triangle"></i> Gagal memuat...</span>');
43+
$(`${elem} .shimmer`).removeClass('shimmer');
44+
}
45+
146
$(document).ready(function () {
247
if ($('#jadwal-shalat').length) {
348

4-
const BASE_API_URL = 'https://api.banghasan.com/';
5-
const endpoint_nama_kota = `sholat/format/json/kota/kode/${KODE_KOTA}`;
6-
const endpoint_jadwal = `sholat/format/json/jadwal/kota/${KODE_KOTA}/tanggal/${TANGGAL}`;
49+
const SHALAT_API_URL = 'https://api.banghasan.com/';
50+
const ENDPOINT_KOTA = `sholat/format/json/kota/kode/${KODE_KOTA}`;
51+
const ENDPOINT_JADWAL = `sholat/format/json/jadwal/kota/${KODE_KOTA}/tanggal/${TANGGAL}`;
752

853
try {
9-
// get nama kota
1054
$.ajax({
11-
url: BASE_API_URL + endpoint_nama_kota,
12-
type: 'get',
13-
dataType: 'json',
14-
crossDomain: true,
55+
async: true,
56+
cache: true,
57+
url: SHALAT_API_URL + ENDPOINT_KOTA,
1558
success: function (res) {
1659
$('[data-name=kota]').html(res.kota[0].nama).removeClass('shimmer line-short');
1760
},
1861
error: function (err) {
19-
$('.line-short').html(`<span class="small"><i class="fa fa-exclamation-triangle pr-1"></i> Gagal memuat</span>`);
20-
$('.line-short').removeClass('shimmer line-short');
62+
showError('#jadwal-shalat');
2163
}
2264
});
23-
24-
// get jadwal sholat
65+
2566
$.ajax({
26-
url: BASE_API_URL + endpoint_jadwal,
27-
type: 'get',
28-
dataType: 'json',
29-
crossDomain: true,
67+
url: SHALAT_API_URL + ENDPOINT_JADWAL,
68+
async: true,
69+
cache: true,
3070
success: function (res) {
31-
$('.shimmer').removeClass('shimmer');
32-
$('[data-name=imsak]').html(`<span class="small">Imsak</span><span>${res.jadwal.data.imsak}</span>`);
33-
$('[data-name=subuh]').html(`<span class="small">Subuh</span><span>${res.jadwal.data.subuh}</span>`);
34-
$('[data-name=dzuhur]').html(`<span class="small">Dzuhur</span><span>${res.jadwal.data.dzuhur}</span>`);
35-
$('[data-name=ashar]').html(`<span class="small">Ashar</span><span>${res.jadwal.data.ashar}</span>`);
36-
$('[data-name=maghrib]').html(`<span class="small">Maghrib</span><span>${res.jadwal.data.maghrib}</span>`);
37-
$('[data-name=isya]').html(`<span class="small">Isya</span><span>${res.jadwal.data.isya}</span>`);
71+
$('#jadwal-shalat .shimmer').removeClass('shimmer');
72+
const attrs = ['imsak', 'subuh', 'dzuhur', 'ashar', 'maghrib', 'isya'];
73+
attrs.forEach(function (val) {
74+
$(`[data-name=${val}]`).html(`<span class="small">${val}</span><span>${res.jadwal.data[val]}</span>`);
75+
})
3876
},
3977
error: function (err) {
40-
$('.box-shalat').html(`<span class="small"><i class="fa fa-exclamation-triangle pr-1"></i> Gagal memuat</span>`);
41-
$('.box-shalat').removeClass('shimmer');
78+
showError('#jadwal-shalat');
4279
}
4380
});
44-
} catch(err) {
45-
console.log(err);
81+
} catch (err) {
82+
showError('#jadwal-shalat');
83+
}
84+
85+
}
86+
87+
if ($('#covid-nasional').length) {
88+
const COVID_API_URL = 'https://api.kawalcorona.com/';
89+
const ENDPOINT_NASIONAL = '/indonesia/';
90+
const ENDPOINT_PROVINSI = '/indonesia/provinsi/';
91+
92+
try {
93+
$.ajax({
94+
async: true,
95+
cache: true,
96+
url: COVID_API_URL + ENDPOINT_NASIONAL,
97+
success: function (response) {
98+
const data = response[0];
99+
showCovidData(data, regions.indonesia);
100+
},
101+
error: function (error) {
102+
showError('#covid-nasional');
103+
}
104+
})
105+
} catch (error) {
106+
showError('#covid-nasional');
46107
}
47-
108+
109+
if (KODE_PROVINSI) {
110+
try {
111+
$.ajax({
112+
async: true,
113+
cache: true,
114+
url: COVID_API_URL + ENDPOINT_PROVINSI,
115+
success: function (response) {
116+
const data = response.filter(data => data.attributes.Kode_Provi == KODE_PROVINSI);
117+
data.length ? showCovidData(data[0]['attributes'], regions.provinsi) : showError('#covid-provinsi');
118+
},
119+
error: function (error) {
120+
showError('#covid-provinsi');
121+
}
122+
})
123+
} catch (error) {
124+
showError('#covid-provinsi')
125+
}
126+
}
127+
48128
}
49129
})

assets/js/widget.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

partials/content.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); ?>
22

33
<div id="main-content">
4-
<div class="p-relative">
5-
<?php
6-
if ((empty($_GET['cari'])) && ((count($slide_galeri)>0 || count($slide_artikel)>0)) AND $this->uri->segment(2) != 'kategori') {
7-
$this->load->view($folder_themes .'/partials/slider');
8-
}
9-
?>
10-
<div class="p-absolute">
11-
<?php $this->load->view($folder_themes . '/widgets/jadwal_shalat') ?>
12-
</div>
13-
</div>
4+
<?php
5+
if ((empty($_GET['cari'])) && ((count($slide_galeri)>0 || count($slide_artikel)>0)) AND $this->uri->segment(2) != 'kategori') {
6+
$this->load->view($folder_themes .'/partials/slider');
7+
}
8+
?>
9+
<section id="widget-temporer" class="bg-white py-5">
10+
<div class="container"><h2 class="h3 font-weight-bold my-0 judul-artikel d-inline-block border-bottom">Jadwal Sholat</h2></div>
11+
<?php $this->load->view($folder_themes . '/widgets/jadwal_shalat') ?>
12+
<?php if(config_item('covid_data')) : ?>
13+
<div class="container"><h2 class="h3 font-weight-bold py-2 mb-0 judul-artikel d-inline-block border-bottom">Status COVID-19</h2></div>
14+
<?php $this->load->view($folder_themes . '/widgets/covid19') ?>
15+
<?php endif ?>
16+
</section>
1417
<section id="artikel-area" class="py-3">
1518
<div class="container">
1619
<?php if(empty($_GET['cari']) AND $headline AND $this->uri->segment(2) != 'kategori') : ?>

partials/komentar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<?php
55
$k = array();
66
foreach ($komentar as $data) {
7-
if ($data['enabled'] == 1) {
7+
if (!$data['is_archived']) {
88
array_push($k, $data);
99
}
1010
}

0 commit comments

Comments
 (0)