-
Notifications
You must be signed in to change notification settings - Fork 0
/
Muslim-PrayerTime.js
66 lines (54 loc) · 2.14 KB
/
Muslim-PrayerTime.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
$(document).ready(function()
{
let CurrentYear = new Date().getFullYear();
let startYear = 1;
let yearSelect = $('select[name="year"]');
for (var year = CurrentYear; year >= startYear; year--) {
yearSelect.append($('<option></option>').val(year).html(year));
};
let monthSelect = $('select[name="month"]');
for(var month = 1 ; month <= 12 ; month ++)
{
const monthName = new Date(2000 , month - 1 ).toLocaleString('default' , {month :'long'});
monthSelect.append($('<option></option>').val(month).html(monthName));
}
//Month and Year
// Ajax for calling data
let country = $('input[name="country"]');
let mosque = $('input[name="mosque"]');
let city = $('input[name="city"]');
let method = $('select[name="method"]');
let submitBtn = $('#getTime');
$(submitBtn).on('click' ,function(e){
e.preventDefault();
$.ajax({
url : "https://api.aladhan.com/v1/calendarByAddress/"+yearSelect.val()+"/"+monthSelect.val()+"?address="+mosque.val()+",%20"+city.val()+",%20"+country.val()+"&method="+method.val()+"",
type : "Get",
success:function(data)
{
$('#prayerContainer').empty(); // Clear previous data
$(data.data).each(function(index, value) {
let table = `
<tr>
<td>${index + 1}</td>
<td>${value.timings.Fajr}</td>
<td>${value.timings.Dhuhr}</td>
<td>${value.timings.Asr}</td>
<td>${value.timings.Maghrib}</td>
<td>${value.timings.Isha}</td>
</tr>
`;
$('#prayerContainer').append(table);
});
// $(data.data).each(function(index, value) {
// const fajrTime = new Date(`2000-01-${index + 1} ${value.timings.Fajr}`);
// const hourDegree = (fajrTime.getHours() % 12) * 30 + fajrTime.getMinutes() / 2;
// const minuteDegree = fajrTime.getMinutes() * 6;
// console.log("Hour" + hourDegree);
// console.log("Minute" + minuteDegree);
// // ... (existing code)
// });
}
})
})
});