This repository has been archived by the owner on Apr 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hot-fix: add error when internet disconnect or when something wrong
- Loading branch information
1 parent
a54cf4e
commit 9b890e6
Showing
3 changed files
with
43 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,49 @@ | ||
$(document).ready(function () { | ||
if ($('#jadwal-shalat').length) { | ||
|
||
const BASE_API_URL = 'https://api.banghasan.com/'; | ||
const endpoint_nama_kota = `sholat/format/json/kota/kode/${KODE_KOTA}`; | ||
const endpoint_jadwal = `sholat/format/json/jadwal/kota/${KODE_KOTA}/tanggal/${TANGGAL}`; | ||
|
||
// get nama kota | ||
$.ajax({ | ||
url: BASE_API_URL + endpoint_nama_kota, | ||
type: 'get', | ||
dataType: 'json', | ||
crossDomain: true, | ||
success: function (res) { | ||
$('[data-name=kota]').html(res.kota[0].nama).removeClass('shimmer line-short'); | ||
} | ||
}); | ||
|
||
// get jadwal sholat | ||
$.ajax({ | ||
url: BASE_API_URL + endpoint_jadwal, | ||
type: 'get', | ||
dataType: 'json', | ||
crossDomain: true, | ||
success: function (res) { | ||
$('.shimmer').removeClass('shimmer'); | ||
$('[data-name=imsak]').html(`<span class="small text-bold">Imsak</span><span>${res.jadwal.data.imsak}</span>`); | ||
$('[data-name=subuh]').html(`<span class="small text-bold">Subuh</span><span>${res.jadwal.data.subuh}</span>`); | ||
$('[data-name=dzuhur]').html(`<span class="small text-bold">Dzuhur</span><span>${res.jadwal.data.dzuhur}</span>`); | ||
$('[data-name=ashar]').html(`<span class="small text-bold">Ashar</span><span>${res.jadwal.data.ashar}</span>`); | ||
$('[data-name=maghrib]').html(`<span class="small text-bold">Maghrib</span><span>${res.jadwal.data.maghrib}</span>`); | ||
$('[data-name=isya]').html(`<span class="small text-bold">Isya</span><span>${res.jadwal.data.isya}</span>`); | ||
} | ||
}) | ||
try { | ||
// get nama kota | ||
$.ajax({ | ||
url: BASE_API_URL + endpoint_nama_kota, | ||
type: 'get', | ||
dataType: 'json', | ||
crossDomain: true, | ||
success: function (res) { | ||
$('[data-name=kota]').html(res.kota[0].nama).removeClass('shimmer line-short'); | ||
}, | ||
error: function (err) { | ||
$('.line-short').html(`<span class="small"><i class="fa fa-exclamation-triangle pr-1"></i> Gagal memuat</span>`); | ||
$('.line-short').removeClass('shimmer line-short'); | ||
} | ||
}); | ||
|
||
// get jadwal sholat | ||
$.ajax({ | ||
url: BASE_API_URL + endpoint_jadwal, | ||
type: 'get', | ||
dataType: 'json', | ||
crossDomain: true, | ||
success: function (res) { | ||
$('.shimmer').removeClass('shimmer'); | ||
$('[data-name=imsak]').html(`<span class="small">Imsak</span><span>${res.jadwal.data.imsak}</span>`); | ||
$('[data-name=subuh]').html(`<span class="small">Subuh</span><span>${res.jadwal.data.subuh}</span>`); | ||
$('[data-name=dzuhur]').html(`<span class="small">Dzuhur</span><span>${res.jadwal.data.dzuhur}</span>`); | ||
$('[data-name=ashar]').html(`<span class="small">Ashar</span><span>${res.jadwal.data.ashar}</span>`); | ||
$('[data-name=maghrib]').html(`<span class="small">Maghrib</span><span>${res.jadwal.data.maghrib}</span>`); | ||
$('[data-name=isya]').html(`<span class="small">Isya</span><span>${res.jadwal.data.isya}</span>`); | ||
}, | ||
error: function (err) { | ||
$('.box-shalat').html(`<span class="small"><i class="fa fa-exclamation-triangle pr-1"></i> Gagal memuat</span>`); | ||
$('.box-shalat').removeClass('shimmer'); | ||
} | ||
}); | ||
} catch(err) { | ||
console.log(err); | ||
} | ||
|
||
} | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters