-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
140 lines (123 loc) · 3.7 KB
/
scripts.js
File metadata and controls
140 lines (123 loc) · 3.7 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
let url = `http://api.aladhan.com/v1/timingsByCity`
function main() {
document.getElementById('city_name').innerHTML = 'الرياض'
get_timing('Ar Riyāḑ')
}
main()
let cities = [
{
arabic_name: 'الرياض',
value: 'Ar Riyāḑ'
},
{
arabic_name: 'مكة المكرمة',
value: 'Makkah al Mukarramah'
},
{
arabic_name: 'المدينة المنورة',
value: 'Al Madīnah al Munawwarah'
},
{
arabic_name: 'الشرقية',
value: 'Ash Sharqīyah'
},
{
arabic_name: 'الحدود الشمالية',
value: 'Al Ḩudūd ash Shamālīyah'
},
{
arabic_name: 'الباحة',
value: 'Al Bāḩah'
},
{
arabic_name: 'عسير',
value: '\'Asīr'
},
]
for(let city of cities){
let option = `<option class="cities">${city.arabic_name}</option>`
document.getElementById('cities').innerHTML += option
}
document.getElementById('cities').addEventListener('change', () => {
const selected = document.getElementById('cities').value
document.getElementById('city_name').innerHTML = selected
let city_name = ''
for(let city of cities){
if (city.arabic_name == selected) {
city_name = city.value
}
}
get_timing(city_name)
})
function get_timing(city){
const params = {
country: 'Saudi Arabia',
city: city
}
axios.get(url, {params: params})
.then((response) => {
show_timing(response.data.data)
})
}
function show_timing(data){
let city = document.getElementById('city_name')
let date = document.getElementById('day_date')
let cards = document.querySelector('.cards')
// SHOW HIJRI DATE
date.innerHTML = `${data.date.hijri.weekday.ar} ${data.date.hijri.day} ${data.date.hijri.month.ar} |
${data.date.gregorian.weekday.en} ${data.date.gregorian.month.en} ${data.date.gregorian.day}`
// SHOW PRAYER TIMIMNGS
cards.innerHTML =
`
<!-- CARD -->
<div class="item">
<div class="card_header">
<h2>الفجر</h2>
</div>
<div class="card_body center">
<h1 class="time">${data.timings.Fajr}</h1>
</div>
</div>
<!--*/* CARD */*-->
<!-- CARD -->
<div class="item">
<div class="card_header">
<h2>الظهر</h2>
</div>
<div class="card_body center">
<h1 class="time">${data.timings.Dhuhr}</h1>
</div>
</div>
<!--*/* CARD */*-->
<!-- CARD -->
<div class="item">
<div class="card_header">
<h2>العصر</h2>
</div>
<div class="card_body center">
<h1 class="time">${data.timings.Asr}</h1>
</div>
</div>
<!--*/* CARD */*-->
<!-- CARD -->
<div class="item">
<div class="card_header">
<h2>المغرب</h2>
</div>
<div class="card_body center">
<h1 class="time">${data.timings.Maghrib}</h1>
</div>
</div>
<!--*/* CARD */*-->
<!-- CARD -->
<div class="item">
<div class="card_header">
<h2>العشاء</h2>
</div>
<div class="card_body center">
<h1 class="time">${data.timings.Isha}</h1>
</div>
</div>
<!--*/* CARD */*-->
`
}