-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
48 lines (43 loc) · 1.8 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
fetch('https://al-quran-8d642.firebaseio.com/data.json')
.then(respon => respon.json())
.then(ayats =>
ayats.forEach(a => {
const listAyat = document.querySelector('.list-ayat');
listAyat.innerHTML += `
<option value="${a.nomor}">${a.asma}</option>
`
}));
const listAyat = document.querySelector('.list-ayat');
listAyat.addEventListener('change', event => {
const pilihanAyat = document.querySelector('.pilihan-ayat');
pilihanAyat.textContent = `Ayat yang terpilih : ${event.target.value}`;
// fetch('https://api.npoint.io/99c279bb173a6e28359c/surat/' + event.target.value)
// .then(respon => respon.json())
// .then(json => {
// let li = ''
// json.map(ayat => li += `<li class="list-group-item">${ayat.ar}</li></li>`)
// const ul = document.querySelector('.arab');
// ul.innerHTML = li;
// });
// fetch('https://api.npoint.io/99c279bb173a6e28359c/surat/' + event.target.value)
// .then(respon => respon.json())
// .then(json => {
// let li = ''
// json.map(ayat => li += showData(ayat))
// const ul = document.querySelector('.arab');
// ul.innerHTML = li;
// // ul.innerHTML = json.map(resp => `<li class="list-group-item">${resp.ar}</li></li>`)
// });
fetch('https://api.npoint.io/99c279bb173a6e28359c/surat/' + event.target.value)
.then(respon => respon.json())
.then(json => {
console.log(json)
json.map(resp => {
const ul = document.querySelector('.arab');
ul.innerHTML += `<li class="list-group-item">${resp.ar}</li></li>`;
});
});
});
function showData(ayat) {
return `<li class="list-group-item">${ayat.ar}</li></li>`
}