-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.html
More file actions
108 lines (96 loc) · 3.08 KB
/
index.html
File metadata and controls
108 lines (96 loc) · 3.08 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Moon Report Generator</title>
<link rel="stylesheet" href="static/style.css">
<link rel="icon" href="/static/favicon.ico" type="image/x-icon">
</head>
<body>
<div class="container">
<h2>Moon Report Generator</h2>
<form id="reportForm">
<label for="date">Date (DD-MM-YYYY):</label>
<input type="text" id="date" value="28-05-2025" required />
<label for="month">Islamic Month:</label>
<select id="month" required></select>
<label for="year">Islamic Year:</label>
<input type="number" id="year" value="1446" required />
<div class="btn-class">
<button type="button" onclick="generateReport('moon-parameters')">
Generate Moon Parameters
</button>
<button type="button" onclick="generateReport('visibility-report')">
Generate Visibility Report
</button>
</div>
</form>
<p id="responseMessage"></p>
</div>
<script>
// Populate Islamic months dropdown
const islamicMonths = [
"MUHARRAM",
"SAFAR",
"RABI-UL-AWWAL",
"RABI-US-SANI",
"JAMADI-UL-AWWAL",
"JAMADI-US-SANI",
"RAJAB",
"SHABAN",
"RAMADAN",
"SHAWWAL",
"ZUL-QADAH",
"ZUL-HIJJAH"
];
const select = document.getElementById("month");
islamicMonths.forEach(month => {
const option = document.createElement("option");
option.value = month;
option.textContent = month;
select.appendChild(option);
});
const backendURL = "https://moonai-backend.onrender.com"; // Use your real Render URL
function generateReport(type) {
const formData = {
date: document.getElementById("date").value,
islamic_month: document.getElementById("month").value,
islamic_year: document.getElementById("year").value,
};
let endpoint = "";
if (type === "moon-parameters") {
endpoint = "/generate-moon-parameters/";
} else {
endpoint = "/generate-visibility-report/";
}
fetch(`${backendURL}${endpoint}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(formData),
})
.then((response) => {
if (!response.ok) throw new Error("Failed to generate report.");
return response.blob();
})
.then((blob) => {
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = `${type.replace("-", "_")}.pdf`;
document.body.appendChild(a);
a.click();
a.remove();
document.getElementById("responseMessage").innerText =
"Download started.";
})
.catch((error) => {
document.getElementById("responseMessage").innerText =
"Error: " + error.message;
document.getElementById("responseMessage").style.color = "red";
});
}
</script>
</body>
</html>