-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalqura.html
296 lines (261 loc) · 10.2 KB
/
alqura.html
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quran - Verse Details</title>
<link href="https://fonts.googleapis.com/css2?family=Scheherazade+New&family=Amiri&display=swap" rel="stylesheet">
<script src="https://kit.fontawesome.com/a076d05399.js"></script> <!-- FontAwesome for icons -->
<style>
body {
font-family: 'Amiri', serif;
background-color: #f4f4f9;
color: #333;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
#verse-container {
max-width: 900px;
margin: 20px;
background-color: white;
padding: 20px;
text-align: center;
border-radius: 12px;
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
border: 1px solid #ddd;
}
#verse-heading {
font-size: 36px;
margin-bottom: 20px;
font-family: 'Scheherazade New', serif;
color: #1d72b8;
}
#verse-content {
margin-bottom: 30px;
border-bottom: 2px solid #ddd;
padding-bottom: 20px;
}
.arabic-text {
font-family: 'Scheherazade New', serif;
font-size: 28px;
color: #3d3d3d;
line-height: 1.8;
margin-bottom: 20px;
}
.verse-number {
font-size: 1.2em;
margin-top: 10px;
font-weight: bold;
background-image: url('https://quran-online.pages.dev/source/download.png');
background-size: cover;
background-position: center;
padding: 8px 15px;
border-radius: 15px;
color: black;
display: inline-block;
margin-top: 10px;
}
.translation-text,
.urdu-text {
margin-top: 15px;
font-size: 18px;
line-height: 1.8;
}
.translation-text strong,
.urdu-text strong {
font-weight: bold;
}
#tafsir-content {
background-color: #f9f9f9;
border-radius: 10px;
text-align: center;
padding: 20px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border: 1px solid #ddd;
margin-bottom: 20px;
}
#tafsir-content h3 {
font-size: 24px;
margin-bottom: 15px;
font-family: 'Scheherazade New', serif;
color: #1d72b8;
}
#tafsir-content .tafsir-text {
font-size: 16px;
line-height: 1.7;
color: #555;
}
#verse-actions {
display: flex;
justify-content: space-between;
margin-top: 20px;
flex-wrap: wrap;
}
.share-btn, .back-btn {
background-color: #1d72b8;
color: white;
border: none;
padding: 12px 25px;
border-radius: 8px;
cursor: pointer;
font-size: 18px;
transition: background-color 0.3s ease;
margin-bottom: 10px;
}
.share-btn:hover, .back-btn:hover {
background-color: #155a8a;
}
.share-btn:focus, .back-btn:focus {
outline: none;
}
/* For smaller screens */
@media (max-width: 768px) {
#verse-container {
padding: 15px;
}
#verse-heading {
font-size: 32px;
}
.share-btn, .back-btn {
font-size: 16px;
padding: 10px 20px;
}
}
@media (max-width: 480px) {
#verse-heading {
font-size: 28px;
}
.arabic-text {
font-size: 24px;
}
.share-btn, .back-btn {
font-size: 14px;
padding: 8px 18px;
}
#verse-actions {
flex-direction: column;
align-items: center;
}
}
</style>
</head>
<body>
<div id="verse-container">
<h1 id="verse-heading">Verse Details</h1>
<div id="verse-content"></div>
<div id="tafsir-language">
<label for="tafsir-select">Select Tafsir Language:</label>
<select id="tafsir-select" onchange="loadTafsir()">
<option value="en">English (Ibn Kathir)</option>
<option value="ur">Urdu</option>
<option value="maarif-ul-quran">English (Maarif-ul-Quran)</option>
</select>
</div>
<div id="tafsir-content" class="tafsir-box"></div>
<div id="verse-actions">
<button class="share-btn" onclick="shareVerse()">Share <i class="fas fa-share-alt"></i></button>
<button class="back-btn" onclick="goBack()">Back to Surah</button>
</div>
</div>
<script>
const urlParams = new URLSearchParams(window.location.search);
const surahIndex = urlParams.get('surah');
const verseId = urlParams.get('verse');
async function fetchVerseDetails(surahIndex, verseId) {
try {
const arabicResponse = await fetch(`https://raw.githubusercontent.com/itzfew/Quran-Online/refs/heads/main/source/surah/surah_${String(surahIndex).padStart(1, '0')}.json`);
const arabicData = await arabicResponse.json();
const translationResponse = await fetch(`https://raw.githubusercontent.com/itzfew/Quran-Online/refs/heads/main/source/translation/en/en_translation_${String(surahIndex).padStart(1, '0')}.json`);
const translationData = await translationResponse.json();
const urduResponse = await fetch(`https://raw.githubusercontent.com/itzfew/Quran-Online/refs/heads/main/source/translation/ur/t_surah_${String(surahIndex).padStart(3, '0')}.json`);
const urduData = await urduResponse.json();
displayVerse(arabicData, translationData, urduData, verseId);
loadTafsir(); // Load default Tafsir in English (Ibn Kathir)
} catch (error) {
console.error('Error fetching verse data:', error);
}
}
function displayVerse(arabicData, translationData, urduData, verseId) {
const verseDiv = document.getElementById('verse-content');
const arabicVerse = arabicData.verse[`verse_${verseId}`];
const translatedVerse = translationData.verse[`verse_${verseId}`];
const urduVerse = urduData.data.find(v => v.aya == verseId)?.text || '';
let verseContent = `
<div class="arabic-text">
<p>${arabicVerse}</p>
<div class="verse-number">Verse ${verseId}</div>
</div>
<div class="translation-text">
<strong>Translation (English):</strong> <p>${translatedVerse}</p>
</div>
<div class="urdu-text">
<strong>Translation (Urdu):</strong> <p>${urduVerse}</p>
</div>
`;
verseDiv.innerHTML = verseContent;
}
async function loadTafsir() {
const selectedLanguage = document.getElementById('tafsir-select').value;
const tafsirDiv = document.getElementById('tafsir-content');
let tafsirUrl = '';
if (selectedLanguage === 'en') {
tafsirUrl = `https://raw.githubusercontent.com/itzfew/Quran-Online/refs/heads/main/source/tafsir/en-tafisr-ibn-kathir/${surahIndex}.json`;
} else if (selectedLanguage === 'ur') {
tafsirUrl = `https://raw.githubusercontent.com/itzfew/Quran-Online/refs/heads/main/source/tafsir/ur-tafseer-ibn-e-kaseer/${surahIndex}.json`;
} else if (selectedLanguage === 'maarif-ul-quran') {
tafsirUrl = `https://raw.githubusercontent.com/itzfew/Quran-Online/refs/heads/main/source/tafsir/en-tafsir-maarif-ul-quran/${surahIndex}.json`;
}
try {
const response = await fetch(tafsirUrl);
const tafsirData = await response.json();
const tafsirText = tafsirData.ayahs.find(v => v.ayah == verseId)?.text || 'No tafsir available for this verse.';
tafsirDiv.innerHTML = `
<h3>Tafsir for Verse ${verseId}</h3>
<div class="tafsir-text">
<p>${tafsirText}</p>
</div>
`;
} catch (error) {
console.error('Error fetching tafsir:', error);
tafsirDiv.innerHTML = `<p>Unable to load Tafsir.</p>`;
}
}
function shareVerse() {
const verseText = document.getElementById('verse-content').innerText;
if (navigator.share) {
navigator.share({
title: 'Quran Verse',
text: verseText,
url: window.location.href
}).catch((error) => console.log('Error sharing: ', error));
} else {
navigator.clipboard.writeText(verseText).then(() => {
alert('Verse copied to clipboard!');
}).catch((error) => {
console.log('Error copying to clipboard: ', error);
});
}
}
function goBack() {
window.location.href = `surah.html?index=${surahIndex}`;
}
fetchVerseDetails(surahIndex, verseId);
</script>
<!-- Service Worker for Offline Capabilities -->
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js')
.then(registration => {
console.log('Service Worker registered with scope: ', registration.scope);
})
.catch(error => {
console.log('Service Worker registration failed: ', error);
});
}
</script>
</body>
</html>