-
Notifications
You must be signed in to change notification settings - Fork 2
/
verse.html
268 lines (236 loc) · 9.59 KB
/
verse.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
<!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;
}
#verse-container {
max-width: 900px;
margin: 0px auto;
background-color: white;
padding: 10px;
text-align: center;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border: 2px solid #ddd; /* Added border around the container */
}
#verse-heading {
text-align: center;
font-size: 32px;
margin-bottom: 20px;
font-family: 'Scheherazade New', serif;
}
#verse-content {
margin-bottom: 30px;
border-bottom: 2px solid #ddd; /* Border for verse content */
}
.arabic-text {
text-align: center;
font-family: 'Scheherazade New', serif;
font-size: 24px;
color: #3d3d3d;
line-height: 1.6;
}
.verse-number {
font-size: 1.0em;
margin-top: 10px;
font-weight: bold;
background-image: url('https://quran-online.pages.dev/source/download.png');
background-size: cover;
text-align: center;
background-position: center;
padding: 5px 10px;
border-radius: 8px;
color: black;
display: inline-block;
margin-left: 10px;
}
.translation-text,
.urdu-text {
margin-top: 15px;
}
.translation-text p,
.urdu-text p {
font-size: 18px;
line-height: 1.6;
}
.translation-text strong,
.urdu-text strong {
font-weight: bold;
}
#tafsir-content {
background-color: #f9f9f9;
border-radius: 10px;
text-align: center;
padding: 15px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
border: 1px solid #ddd; /* Added border for tafsir content */
}
#tafsir-content h3 {
font-size: 24px;
margin-bottom: 10px;
font-family: 'Scheherazade New', serif;
}
#tafsir-content .tafsir-text {
font-size: 16px;
line-height: 1.7;
color: #555;
}
#verse-actions {
display: flex;
justify-content: space-between;
margin-top: 20px;
}
.share-btn, .back-btn {
background-color: #1d72b8;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
.share-btn:hover, .back-btn:hover {
background-color: #155a8a;
}
.share-btn:focus, .back-btn:focus {
outline: none;
}
/* For smaller screens */
@media (max-width: 600px) {
#verse-container {
padding: 15px;
}
#verse-heading {
font-size: 28px;
}
.share-btn, .back-btn {
font-size: 14px;
padding: 8px 16px;
}
}
</style>
</head>
<body>
<div id="verse-container">
<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> <!-- Tafsir Section -->
<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>
// Get the surah and verse from URL parameters
const urlParams = new URLSearchParams(window.location.search);
const surahIndex = urlParams.get('surah');
const verseId = urlParams.get('verse');
// Fetch Verse Data
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);
// Load default Tafsir in English (Ibn Kathir)
loadTafsir(); // Default load English Ibn Kathir Tafsir
} 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 || '';
// Display Verse
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;
}
// Load Tafsir based on selected language
async function loadTafsir() {
const selectedLanguage = document.getElementById('tafsir-select').value;
const tafsirDiv = document.getElementById('tafsir-content');
let tafsirUrl = '';
// Set Tafsir URL based on selection
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>`;
}
}
// Share Verse
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);
});
}
}
// Go back to Surah page
function goBack() {
window.location.href = `surah.html?index=${surahIndex}`;
}
// Initial fetch for verse details
fetchVerseDetails(surahIndex, verseId);
</script>
</body>
</html>