Spaces:
Running
Running
Upload 7 files
Browse files- QURAN_INTEGRATION.md +76 -0
- al_khatma_source_attribution.md +38 -0
- quran_core_registry.json +0 -0
- quran_reader.css +29 -0
- quran_reader.js +270 -0
- quran_reader_registry.json +39 -0
- registry_app.js +24 -15
QURAN_INTEGRATION.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# قارئ القرآن المستقل لساعة المسلم
|
| 2 |
+
|
| 3 |
+
هذه إضافة للنسخة المرفقة `index(6).html` و`registry_app.js`، وليست مشروع ساعة بديلًا كاملًا.
|
| 4 |
+
اسم ملف الواجهة الناتج هو `index.html`.
|
| 5 |
+
|
| 6 |
+
## الملفات
|
| 7 |
+
|
| 8 |
+
تكون الملفات السبعة الآتية بجوار ملفات الساعة الحالية، بنفس الأسماء تمامًا:
|
| 9 |
+
|
| 10 |
+
| الملف | المسؤولية |
|
| 11 |
+
|---|---|
|
| 12 |
+
| `index.html` | ربط JavaScript وCSS فقط؛ لا يحتوي كود القرآن أو آياته |
|
| 13 |
+
| `registry_app.js` | نقاط الربط بنافذة الساعة وإعداداتها |
|
| 14 |
+
| `quran_reader.js` | التحميل، العرض، البحث، التنقل وإعدادات القراءة |
|
| 15 |
+
| `quran_reader.css` | تنسيق القارئ داخل نافذة الساعة الحالية |
|
| 16 |
+
| `quran_reader_registry.json` | عناوين الواجهة، إعدادات العرض ومسارات البيانات |
|
| 17 |
+
| `quran_core_registry.json` | السور والآيات والأجزاء والصفحات من المصدر |
|
| 18 |
+
| `al_khatma_source_attribution.md` | نسبة المصدر ونص ترخيصه |
|
| 19 |
+
|
| 20 |
+
يبقى `README.md` الحالي للمساحة كما هو؛ هذا الدليل اسمه `QURAN_INTEGRATION.md` كي لا يحل محل إعدادات Hugging Face.
|
| 21 |
+
بقية ملفات الساعة ومحركاتها وRegistries مطلوبة كما كانت قبل هذه الإضافة.
|
| 22 |
+
عند استخدام بدائل تنزيل تنتهي بـ`.txt` تكون أسماء الملفات المنشورة هي الأسماء الأصلية في الجدول.
|
| 23 |
+
|
| 24 |
+
## الاستخدام
|
| 25 |
+
|
| 26 |
+
1. اضغط على خانة ساعة، ثم «قراءة القرآن الكريم».
|
| 27 |
+
2. اختر سورة أو جزءًا، أو أدخل رقم صفحة. يعرض القارئ الصفحة المرتبطة بذلك الموضع، ويحدد أول آية مطلوبة.
|
| 28 |
+
3. البحث يشمل القرآن كله؛ الضغط على النتيجة يفتح صفحتها ويحدد الآية.
|
| 29 |
+
4. إعدادات حجم الخط وتذكر آخر صفحة موجودة داخل إعدادات القراءة، ويمكن الوصول إليها أيضًا من إعدادات الساعة الموجودة.
|
| 30 |
+
5. زر الإغلاق الموجود يغلق النافذة فقط؛ لا يسجل إتمام عبادة أو ختمة.
|
| 31 |
+
|
| 32 |
+
يحمّل الملف الصغير الخاص بواجهة القارئ عند فتح مدخله، وبيانات القرآن عند فتح القراءة لأول مرة.
|
| 33 |
+
بعد تحميل البيانات يستخدمها القارئ من ذاكرة الصفحة دون اتصال إضافي. لا تضمن هذه المرحلة فتح التطبيق من جديد دون إنترنت؛ ذلك يحتاج تخزينًا دائمًا وآلية عمل دون اتصال لاحقًا.
|
| 34 |
+
إعدادات القراءة وآخر صفحة فقط تحفظ محليًا على الجهاز؛ لا حساب ولا إرسال لبحث المستخدم إلى خدمة خارجية.
|
| 35 |
+
|
| 36 |
+
النسخة الحالية قراءة نصية؛ لا صور مصحف أو صوت أو تفسير أو خطة ختمة بعد، ولا ذكاء اصطناعي في القرآن.
|
| 37 |
+
هذه الأقسام يمكن ربطها لاحقًا بملفات مستقلة. لا تتضمن الإضافة نقل كود القبلة والمحاكاة الموجود مسبقًا داخل الاندكس.
|
| 38 |
+
|
| 39 |
+
## عقد الربط للصيانة
|
| 40 |
+
|
| 41 |
+
`RegistryApp.openPanel` يعيد استخدام مدير النوافذ الحالي للعرض والتركيز والإغلاق.
|
| 42 |
+
`MuslimClockQuran.mountEntry` يضيف المدخل داخل نافذة الساعة، و`mountSettingsEntry` داخل الإعدادات.
|
| 43 |
+
لا يضيف القارئ تبويبًا دائمًا أو منبهات جديدة. نقطة فتحه من أحداث مستقبلية:
|
| 44 |
+
|
| 45 |
+
```js
|
| 46 |
+
window.MuslimClockQuran.open({surah: 2, ayah: 255});
|
| 47 |
+
// أو من موزع أحداث المشروع:
|
| 48 |
+
window.dispatchEvent(new CustomEvent('muslim-clock-quran-open', {
|
| 49 |
+
detail: {page: 1}
|
| 50 |
+
}));
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
تعديلات نصوص الأزرار في `quran_reader_registry.json`، وتعديلات المظهر في CSS، والمنطق في JS.
|
| 54 |
+
يحتفظ `quran_core_registry.json` ببصمة SHA-256 للملف الأصلي ومرجع النسخة. لإعادة التحويل:
|
| 55 |
+
|
| 56 |
+
```bash
|
| 57 |
+
node maintenance/build_quran_registry.cjs /path/to/AL-Khatma-main/DATA/Language/main.json .
|
| 58 |
+
node maintenance/test_quran_reader.cjs
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
الاختبار يحتاج Node.js وPlaywright وChromium. يستخدم مدير النافذة ومدخل الساعة الفعليين مع بيانات اختبار للأجزاء غير المرفقة من الساعة؛ ليس اختبارًا كاملًا للمواقيت والتنبيهات أو للمساحة المنشورة.
|
| 62 |
+
|
| 63 |
+
## نتيجة التحقق لهذه النسخة
|
| 64 |
+
|
| 65 |
+
- نجح فحص مطابقة النصوص والحقول لكل الآيات الـ6236 مع الملف الأصلي، وترتيب 114 سورة و604 صفحات و30 جزءًا.
|
| 66 |
+
- نجح التحقق من بقاء محتوى الاندكس الأصلي كما هو بعد استثناء روابط القارئ وإصدار رابط `registry_app.js`.
|
| 67 |
+
- نجح اختبار السلوك بواسطة jsdom: فتح القارئ من الساعة، السورة والجزء والصفحة، البحث العربي، صفحات نتائج البحث، الإعدادات، التخزين المحلي، الإغلاق، إعادة استخدام البيانات، فتح آية من حدث، إعادة المحاولة بعد خطأ بيانات أو إعدادات، وإلغاء عرض نتيجة تحميل متأخر بعد الإغلاق.
|
| 68 |
+
- لم يعمل اختبار Playwright البصري لعدم توفر Chromium وتعذر تنزيله في بيئة التنفيذ. لم تُراجع هيئة العرض على متصفح هاتف فعلي ولم تختبر المساحة المنشورة.
|
| 69 |
+
|
| 70 |
+
لاختبار السلوك دون Chromium، مع إتاحة حزمة `jsdom` لـNode:
|
| 71 |
+
|
| 72 |
+
```bash
|
| 73 |
+
node maintenance/test_quran_dom.cjs
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
بدائل TXT تطابق الملفات الأصلية بايتًا ببايت؛ هي بدائل للتنزيل فقط ولا يحتاج التطبيق النسختين معًا.
|
al_khatma_source_attribution.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# مصدر بيانات القرآن
|
| 2 |
+
|
| 3 |
+
مصدر التحويل: أرشيف `AL-Khatma-main.zip` المرفق من عاصم، الملف `DATA/Language/main.json`.
|
| 4 |
+
|
| 5 |
+
- المشروع: AL-Khatma، Osamah Awadh، https://github.com/oaokm/AL-Khatma
|
| 6 |
+
- معرّف النسخة المسجل في الأرشيف: `07bb3782d0104286fdd0f8d87c816f24578a29b4`.
|
| 7 |
+
- أبقينا نص كل آية مطابقًا حرفيًا للمصدر، مع أرقام السور والآيات والأجزاء والصفحات.
|
| 8 |
+
- أزلنا الترجمات وتهجئة النطق الإنجليزية والحقول المكررة من نسخة القراءة العربية لتقليل حجمها.
|
| 9 |
+
- حقل `search_text` مأخوذ من النص دون تشكيل في المصدر. تبسيط حروف البحث يحدث في الذاكرة فقط.
|
| 10 |
+
- أرقام الصفحات مأخوذة من البيانات؛ العرض هنا نصي متجاوب وليس صورًا أو محاكاة لتوزيع سطور المصحف المطبوع.
|
| 11 |
+
- يذكر README الأصلي مشروع https://github.com/nawafalqari/ayah ضمن مصادره، وhttps://github.com/risan/quran-json للغات الأخرى. هذه نسبة للمصدر المرفق وليست تحققًا مستقلًا من تلك المواقع.
|
| 12 |
+
- الفحوص تؤكد مطابقة التحويل وتمام الأعداد، ولا تمثل تدقيقًا مستقلاً لكل آية مقابل مصحف آخر.
|
| 13 |
+
|
| 14 |
+
## الترخيص الأصلي
|
| 15 |
+
|
| 16 |
+
```text
|
| 17 |
+
MIT License
|
| 18 |
+
|
| 19 |
+
Copyright (C) 2023 Osamah Awadh (https://github.com/oaokm)
|
| 20 |
+
|
| 21 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 22 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 23 |
+
in the Software without restriction, including without limitation the rights
|
| 24 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 25 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 26 |
+
furnished to do so, subject to the following conditions:
|
| 27 |
+
|
| 28 |
+
The above copyright notice and this permission notice shall be included in all
|
| 29 |
+
copies or substantial portions of the Software.
|
| 30 |
+
|
| 31 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 32 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 33 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 34 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 35 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 36 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 37 |
+
SOFTWARE.
|
| 38 |
+
```
|
quran_core_registry.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
quran_reader.css
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#adaptivePopupBody .quran-reader,
|
| 2 |
+
#adaptivePopupBody .quran-settings{white-space:normal;direction:rtl;min-width:0}
|
| 3 |
+
#adaptivePopupBody .quran-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;align-items:end}
|
| 4 |
+
#adaptivePopupBody .quran-toolbar label{margin:0;min-width:0}
|
| 5 |
+
#adaptivePopupBody .quran-toolbar select,
|
| 6 |
+
#adaptivePopupBody .quran-toolbar input{min-width:0;max-width:100%;margin:4px 0}
|
| 7 |
+
#adaptivePopupBody .quran-reader button{white-space:normal;overflow-wrap:anywhere}
|
| 8 |
+
#adaptivePopupBody .quran-search{display:flex;gap:8px;align-items:center;margin:10px 0}
|
| 9 |
+
#adaptivePopupBody .quran-search input{flex:1;min-width:0;margin:0}
|
| 10 |
+
#adaptivePopupBody .quran-search button{width:auto;flex-shrink:0;margin:0}
|
| 11 |
+
#adaptivePopupBody .quran-nav{display:flex;gap:8px}
|
| 12 |
+
#adaptivePopupBody .quran-nav button{flex:1;text-align:center;min-width:0}
|
| 13 |
+
#adaptivePopupBody .quran-reader button:disabled{opacity:.5;cursor:default}
|
| 14 |
+
#adaptivePopupBody .quran-page-title{font-size:1.15rem;text-align:center;margin:18px 0 8px}
|
| 15 |
+
#adaptivePopupBody .quran-page-text{font-family:"Noto Naskh Arabic","Amiri",serif;font-size:var(--quran-font-size,26px);line-height:2.3;margin:8px 0;overflow-wrap:break-word}
|
| 16 |
+
#adaptivePopupBody .quran-verse{scroll-margin-block:20px}
|
| 17 |
+
#adaptivePopupBody .quran-verse:focus{outline:2px solid currentColor;outline-offset:3px;border-radius:3px}
|
| 18 |
+
#adaptivePopupBody .quran-verse-number{font-family:inherit;font-size:.8em;white-space:nowrap}
|
| 19 |
+
#adaptivePopupBody .quran-basmala{text-align:center;font-family:"Noto Naskh Arabic","Amiri",serif;font-size:var(--quran-font-size,26px);line-height:2}
|
| 20 |
+
#adaptivePopupBody .quran-meta{font-size:.85rem;line-height:1.6;margin:10px 0}
|
| 21 |
+
#adaptivePopupBody .quran-result-text{display:block;font-family:"Noto Naskh Arabic","Amiri",serif;font-size:var(--quran-font-size,26px);line-height:2}
|
| 22 |
+
#adaptivePopupBody .quran-settings input[type="range"]{width:100%;padding:0;min-height:44px}
|
| 23 |
+
#adaptivePopupBody .quran-settings input[type="checkbox"]{width:auto}
|
| 24 |
+
#adaptivePopupBody .quran-reader :focus-visible,
|
| 25 |
+
#adaptivePopupBody .quran-settings :focus-visible{outline:2px solid currentColor;outline-offset:2px}
|
| 26 |
+
@media(max-width:400px){
|
| 27 |
+
#adaptivePopupBody .quran-nav button{font-size:14px;padding:8px}
|
| 28 |
+
#adaptivePopupBody .quran-toolbar{gap:6px}
|
| 29 |
+
}
|
quran_reader.js
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
(function () {
|
| 2 |
+
'use strict';
|
| 3 |
+
const base = new URL('.', document.currentScript.src);
|
| 4 |
+
const configFile = 'quran_reader_registry.json';
|
| 5 |
+
let configPromise, corePromise, preferences, epoch = 0;
|
| 6 |
+
const node = (tag, text, className) => {
|
| 7 |
+
const element = document.createElement(tag);
|
| 8 |
+
if (text != null) element.textContent = text;
|
| 9 |
+
if (className) element.className = className;
|
| 10 |
+
return element;
|
| 11 |
+
};
|
| 12 |
+
const button = (text, action) => {
|
| 13 |
+
const element = node('button', text);
|
| 14 |
+
element.type = 'button';
|
| 15 |
+
element.addEventListener('click', action);
|
| 16 |
+
return element;
|
| 17 |
+
};
|
| 18 |
+
const format = (text, values) => text.replace(/\{(\w+)\}/g, (_, key) => String(values[key] ?? ''));
|
| 19 |
+
// Normalize only the search index; the displayed Quran text is never transformed.
|
| 20 |
+
const normalize = text => String(text).normalize('NFD').replace(/[\u0610-\u061a\u064b-\u065f\u0670\u06d6-\u06ed\u0300-\u036f\u0640]/g, '')
|
| 21 |
+
.replace(/[\u0622\u0623\u0625\u0671]/g, '\u0627').replace(/\u0649/g, '\u064a').replace(/\s+/g, ' ').trim();
|
| 22 |
+
|
| 23 |
+
async function fetchJSON(file, timeout = 30000) {
|
| 24 |
+
const url = new URL(file, base);
|
| 25 |
+
if (url.origin !== base.origin) throw Error('Cross-origin Quran registry');
|
| 26 |
+
const controller = new AbortController();
|
| 27 |
+
const timer = setTimeout(() => controller.abort(), timeout);
|
| 28 |
+
try {
|
| 29 |
+
const response = await fetch(url, {signal: controller.signal});
|
| 30 |
+
if (!response.ok) throw Error(file + ' HTTP ' + response.status);
|
| 31 |
+
return await response.json();
|
| 32 |
+
} finally { clearTimeout(timer); }
|
| 33 |
+
}
|
| 34 |
+
function config() {
|
| 35 |
+
if (!configPromise) configPromise = fetchJSON(configFile).then(value => {
|
| 36 |
+
if (value.schema_version !== 1 || !value.ui || !value.core_file || !value.defaults || !value.limits) throw Error('Invalid reader registry');
|
| 37 |
+
for (const key of ['title','open','settings','loading','load_error','retry','surah','ayah','page','juz','go','previous','next',
|
| 38 |
+
'search','search_submit','search_empty','no_results','results','more','reader','page_status','invalid_page','font_size',
|
| 39 |
+
'remember_page','save','saved','storage_error','back','source']) {
|
| 40 |
+
if (typeof value.ui[key] !== 'string') throw Error('Missing UI: ' + key);
|
| 41 |
+
}
|
| 42 |
+
if (!Number.isInteger(value.limits.search_batch) || value.limits.search_batch < 1) throw Error('Invalid search limit');
|
| 43 |
+
return value;
|
| 44 |
+
}).catch(error => { configPromise = null; throw error; });
|
| 45 |
+
return configPromise;
|
| 46 |
+
}
|
| 47 |
+
function data(c) {
|
| 48 |
+
if (!corePromise) corePromise = fetchJSON(c.core_file, c.limits.request_timeout_ms).then(value => {
|
| 49 |
+
if (value.schema_version !== 1 || value.counts?.ayahs !== 6236 || value.counts?.pages !== 604 || value.counts?.juz !== 30 ||
|
| 50 |
+
value.counts?.surahs !== 114 || value.surahs?.length !== 114 || value.verses?.length !== 6236) throw Error('Invalid Quran registry');
|
| 51 |
+
const pages = Array.from({length: value.counts.pages + 1}, () => []);
|
| 52 |
+
const juzPages = [];
|
| 53 |
+
const nextAyah = Array(115).fill(1);
|
| 54 |
+
value.surahs.forEach((s, i) => {
|
| 55 |
+
if (s.id !== i + 1 || typeof s.name !== 'string' || !Number.isInteger(s.ayah_count)) throw Error('Invalid surah');
|
| 56 |
+
});
|
| 57 |
+
let previousPage = 1, previousSurah = 1, previousJuz = 1;
|
| 58 |
+
value.verses.forEach((v, i) => {
|
| 59 |
+
if (v.id !== i + 1 || !Number.isInteger(v.page) || !pages[v.page] || v.page < 1 || v.page < previousPage ||
|
| 60 |
+
!Number.isInteger(v.juz) || v.juz < previousJuz || v.juz > 30 ||
|
| 61 |
+
!Number.isInteger(v.surah) || v.surah < previousSurah || v.surah > 114 ||
|
| 62 |
+
v.ayah !== nextAyah[v.surah]++ || typeof v.text !== 'string' || !v.text || typeof v.search_text !== 'string') throw Error('Invalid ayah: ' + (i + 1));
|
| 63 |
+
previousPage = v.page; previousSurah = v.surah; previousJuz = v.juz;
|
| 64 |
+
pages[v.page].push(v);
|
| 65 |
+
if (!juzPages[v.juz]) juzPages[v.juz] = v.page;
|
| 66 |
+
});
|
| 67 |
+
value.surahs.forEach(s => {
|
| 68 |
+
if (nextAyah[s.id] - 1 !== s.ayah_count || pages[s.first_page]?.find(v => v.surah === s.id)?.ayah !== 1) throw Error('Surah count mismatch');
|
| 69 |
+
});
|
| 70 |
+
if (pages.slice(1).some(p => !p.length) || Array.from({length:30}, (_, i) => juzPages[i + 1]).some(p => !p)) throw Error('Missing page or juz');
|
| 71 |
+
return {...value, pages, juzPages, searchIndex: value.verses.map(v => normalize(v.search_text))};
|
| 72 |
+
}).catch(error => { corePromise = null; throw error; });
|
| 73 |
+
return corePromise;
|
| 74 |
+
}
|
| 75 |
+
function prefs(c) {
|
| 76 |
+
if (preferences) return preferences;
|
| 77 |
+
let saved;
|
| 78 |
+
try { saved = JSON.parse(localStorage.getItem(c.storage_key)); } catch { /* Storage is optional. */ }
|
| 79 |
+
preferences = {
|
| 80 |
+
font_size: Number.isFinite(saved?.font_size) ? Math.max(c.limits.font_min, Math.min(c.limits.font_max, saved.font_size)) : c.defaults.font_size,
|
| 81 |
+
remember_page: typeof saved?.remember_page === 'boolean' ? saved.remember_page : c.defaults.remember_page,
|
| 82 |
+
page: Number.isInteger(saved?.page) && saved.page >= 1 && saved.page <= 604 ? saved.page : 1
|
| 83 |
+
};
|
| 84 |
+
return preferences;
|
| 85 |
+
}
|
| 86 |
+
function persist(c) {
|
| 87 |
+
try { localStorage.setItem(c.storage_key, JSON.stringify(preferences)); return true; }
|
| 88 |
+
catch { return false; }
|
| 89 |
+
}
|
| 90 |
+
function panel(title, root, back, ui) {
|
| 91 |
+
RegistryApp.openPanel('worship', {title, compact: true}, () => {
|
| 92 |
+
document.getElementById('adaptivePopupBody').append(root);
|
| 93 |
+
if (back) document.getElementById('adaptivePopupActions').append(button(ui.back, back));
|
| 94 |
+
});
|
| 95 |
+
document.getElementById('adaptivePopupCard').dataset.size = 'long';
|
| 96 |
+
}
|
| 97 |
+
async function mount(parent, back, settingsOnly) {
|
| 98 |
+
const entry = button('…', () => {});
|
| 99 |
+
entry.disabled = true;
|
| 100 |
+
entry.dataset.quranEntry = settingsOnly ? 'settings' : 'reader';
|
| 101 |
+
parent.append(entry);
|
| 102 |
+
try {
|
| 103 |
+
const c = await config();
|
| 104 |
+
if (!entry.isConnected) return;
|
| 105 |
+
entry.textContent = settingsOnly ? c.ui.settings : c.ui.open;
|
| 106 |
+
entry.disabled = false;
|
| 107 |
+
entry.onclick = () => settingsOnly ? openSettings(back) : open({back});
|
| 108 |
+
} catch (error) {
|
| 109 |
+
if (!entry.isConnected) return;
|
| 110 |
+
entry.textContent = configFile + ': ' + error.message;
|
| 111 |
+
entry.disabled = false;
|
| 112 |
+
entry.onclick = () => { entry.remove(); mount(parent, back, settingsOnly); };
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
async function open(options = {}) {
|
| 116 |
+
const request = ++epoch;
|
| 117 |
+
let c;
|
| 118 |
+
try { c = await config(); }
|
| 119 |
+
catch (error) {
|
| 120 |
+
if (request !== epoch) return;
|
| 121 |
+
const root = node('div', configFile + ': ' + error.message);
|
| 122 |
+
root.append(button('↻', () => open(options)));
|
| 123 |
+
panel(configFile, root, options.back, {back: '←'});
|
| 124 |
+
return;
|
| 125 |
+
}
|
| 126 |
+
if (request !== epoch) return;
|
| 127 |
+
const root = node('div', null, 'quran-reader');
|
| 128 |
+
const loading = node('p', c.ui.loading);
|
| 129 |
+
loading.setAttribute('role', 'status');
|
| 130 |
+
root.append(loading);
|
| 131 |
+
panel(c.ui.title, root, options.back, c.ui);
|
| 132 |
+
const token = epoch;
|
| 133 |
+
try {
|
| 134 |
+
const source = await data(c);
|
| 135 |
+
if (token !== epoch || !root.isConnected) return;
|
| 136 |
+
renderReader(root, source, c, options);
|
| 137 |
+
} catch (error) {
|
| 138 |
+
if (token !== epoch || !root.isConnected) return;
|
| 139 |
+
loading.textContent = c.ui.load_error;
|
| 140 |
+
root.append(node('p', error.message, 'quran-meta'), button(c.ui.retry, () => open(options)));
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
function renderReader(root, source, c, options) {
|
| 144 |
+
const ui = c.ui, p = prefs(c);
|
| 145 |
+
let page = p.remember_page ? p.page : 1;
|
| 146 |
+
let focusVerse = null;
|
| 147 |
+
if (Number.isInteger(options.page) && source.pages[options.page]?.length) page = options.page;
|
| 148 |
+
if (Number.isInteger(options.surah)) {
|
| 149 |
+
focusVerse = source.verses.find(v => v.surah === options.surah && v.ayah === (options.ayah || 1));
|
| 150 |
+
if (focusVerse) page = focusVerse.page;
|
| 151 |
+
}
|
| 152 |
+
root.replaceChildren();
|
| 153 |
+
root.style.setProperty('--quran-font-size', p.font_size + 'px');
|
| 154 |
+
const toolbar = node('div', null, 'quran-toolbar');
|
| 155 |
+
const field = (label, input) => { const wrap = node('label', label); wrap.append(input); toolbar.append(wrap); return input; };
|
| 156 |
+
const select = (items, label) => {
|
| 157 |
+
const input = node('select');
|
| 158 |
+
for (const [value, text] of items) { const option = node('option', text); option.value = value; input.append(option); }
|
| 159 |
+
return field(label, input);
|
| 160 |
+
};
|
| 161 |
+
const surahSelect = select(source.surahs.map(s => [s.id, s.id + '. ' + s.name]), ui.surah);
|
| 162 |
+
const juzSelect = select(Array.from({length: source.counts.juz}, (_, i) => [i + 1, i + 1]), ui.juz);
|
| 163 |
+
const pageForm = node('form');
|
| 164 |
+
const pageLabel = node('label', ui.page);
|
| 165 |
+
const pageInput = node('input');
|
| 166 |
+
pageInput.type = 'number'; pageInput.min = 1; pageInput.max = source.counts.pages; pageInput.required = true;
|
| 167 |
+
pageLabel.append(pageInput); pageForm.append(pageLabel);
|
| 168 |
+
const go = node('button', ui.go); go.type = 'submit'; pageForm.append(go); toolbar.append(pageForm);
|
| 169 |
+
toolbar.append(button(ui.settings, () => openSettings(() => open({...options, page, surah: undefined, ayah: undefined}))));
|
| 170 |
+
const searchForm = node('form', null, 'quran-search'); searchForm.setAttribute('role', 'search');
|
| 171 |
+
const query = node('input'); query.type = 'search'; query.setAttribute('aria-label', ui.search); query.placeholder = ui.search;
|
| 172 |
+
const submit = node('button', ui.search_submit); submit.type = 'submit'; searchForm.append(query, submit);
|
| 173 |
+
const status = node('p', null, 'quran-meta'); status.setAttribute('role', 'status');
|
| 174 |
+
const content = node('div');
|
| 175 |
+
const nav = node('div', null, 'quran-nav');
|
| 176 |
+
const previous = button(ui.previous, () => showPage(page - 1));
|
| 177 |
+
const next = button(ui.next, () => showPage(page + 1)); nav.append(previous, next);
|
| 178 |
+
const attribution = node('a', ui.source); attribution.href = new URL(c.source_file, base).href;
|
| 179 |
+
attribution.target = '_blank'; attribution.rel = 'noopener'; attribution.className = 'quran-meta';
|
| 180 |
+
root.append(toolbar, searchForm, status, content, nav, attribution);
|
| 181 |
+
function showPage(value, selectedVerse) {
|
| 182 |
+
if (!Number.isInteger(value) || !source.pages[value]?.length) { status.textContent = format(ui.invalid_page, {total:source.counts.pages}); return; }
|
| 183 |
+
page = value;
|
| 184 |
+
const verses = source.pages[page];
|
| 185 |
+
content.replaceChildren(); nav.hidden = false;
|
| 186 |
+
pageInput.value = page; surahSelect.value = selectedVerse?.surah || verses[0].surah; juzSelect.value = selectedVerse?.juz || verses[0].juz;
|
| 187 |
+
const juz = [...new Set(verses.map(v => v.juz))].join('، ');
|
| 188 |
+
status.textContent = format(ui.page_status, {page, total: source.counts.pages, juz});
|
| 189 |
+
previous.disabled = page === 1; next.disabled = page === source.counts.pages;
|
| 190 |
+
let lastSurah, paragraph;
|
| 191 |
+
for (const verse of verses) {
|
| 192 |
+
if (verse.surah !== lastSurah) {
|
| 193 |
+
content.append(node('h3', source.surahs[verse.surah - 1].name, 'quran-page-title'));
|
| 194 |
+
if (verse.ayah === 1 && verse.surah !== 1 && verse.surah !== 9) content.append(node('p', source.verses[0].text, 'quran-basmala'));
|
| 195 |
+
paragraph = node('p', null, 'quran-page-text'); content.append(paragraph); lastSurah = verse.surah;
|
| 196 |
+
}
|
| 197 |
+
const span = node('span', verse.text, 'quran-verse');
|
| 198 |
+
span.id = 'quran-verse-' + verse.id; span.tabIndex = -1;
|
| 199 |
+
const number = node('span', ' (' + verse.ayah + ') ', 'quran-verse-number');
|
| 200 |
+
number.setAttribute('aria-label', ui.ayah + ' ' + verse.ayah);
|
| 201 |
+
span.append(number); paragraph.append(span, document.createTextNode(' '));
|
| 202 |
+
}
|
| 203 |
+
if (p.remember_page) {
|
| 204 |
+
p.page = page;
|
| 205 |
+
if (!persist(c)) status.textContent += ' ' + ui.storage_error;
|
| 206 |
+
}
|
| 207 |
+
document.getElementById('adaptivePopupBody').scrollTop = 0;
|
| 208 |
+
if (selectedVerse) {
|
| 209 |
+
const target = document.getElementById('quran-verse-' + selectedVerse.id);
|
| 210 |
+
target?.focus({preventScroll: true}); target?.scrollIntoView({block:'center'});
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
pageForm.addEventListener('submit', event => { event.preventDefault(); showPage(Number(pageInput.value)); });
|
| 214 |
+
surahSelect.addEventListener('change', () => {
|
| 215 |
+
const verse = source.verses.find(v => v.surah === Number(surahSelect.value)); showPage(verse.page, verse);
|
| 216 |
+
});
|
| 217 |
+
juzSelect.addEventListener('change', () => {
|
| 218 |
+
const verse = source.verses.find(v => v.juz === Number(juzSelect.value)); showPage(verse.page, verse);
|
| 219 |
+
});
|
| 220 |
+
searchForm.addEventListener('submit', event => {
|
| 221 |
+
event.preventDefault();
|
| 222 |
+
const text = normalize(query.value);
|
| 223 |
+
if (!text) { status.textContent = ui.search_empty; query.focus(); return; }
|
| 224 |
+
const matches = source.verses.filter((_, i) => source.searchIndex[i].includes(text));
|
| 225 |
+
content.replaceChildren(); nav.hidden = true;
|
| 226 |
+
status.textContent = matches.length ? format(ui.results, {count: matches.length}) : ui.no_results;
|
| 227 |
+
content.append(button(ui.reader, () => showPage(page)));
|
| 228 |
+
let shown = 0;
|
| 229 |
+
const more = button(ui.more, appendResults);
|
| 230 |
+
function appendResults() {
|
| 231 |
+
more.remove();
|
| 232 |
+
for (const verse of matches.slice(shown, shown + c.limits.search_batch)) {
|
| 233 |
+
const result = button(source.surahs[verse.surah - 1].name + ' · ' + ui.ayah + ' ' + verse.ayah + ' · ' + ui.page + ' ' + verse.page,
|
| 234 |
+
() => showPage(verse.page, verse));
|
| 235 |
+
result.className = 'quran-result';
|
| 236 |
+
result.append(node('span', verse.text, 'quran-result-text')); content.append(result);
|
| 237 |
+
}
|
| 238 |
+
shown += c.limits.search_batch;
|
| 239 |
+
if (shown < matches.length) content.append(more);
|
| 240 |
+
}
|
| 241 |
+
appendResults();
|
| 242 |
+
});
|
| 243 |
+
showPage(page, focusVerse);
|
| 244 |
+
}
|
| 245 |
+
async function openSettings(back) {
|
| 246 |
+
const request = ++epoch;
|
| 247 |
+
let c;
|
| 248 |
+
try { c = await config(); } catch { return open({back}); }
|
| 249 |
+
if (request !== epoch) return;
|
| 250 |
+
const ui = c.ui, p = prefs(c), root = node('div', null, 'quran-settings');
|
| 251 |
+
const label = node('label', ui.font_size), font = node('input'), output = node('output', p.font_size);
|
| 252 |
+
font.type = 'range'; font.min = c.limits.font_min; font.max = c.limits.font_max; font.step = 1; font.value = p.font_size;
|
| 253 |
+
label.append(font, output);
|
| 254 |
+
font.addEventListener('input', () => { output.value = font.value; });
|
| 255 |
+
const rememberLabel = node('label', ui.remember_page), remember = node('input');
|
| 256 |
+
remember.type = 'checkbox'; remember.checked = p.remember_page; rememberLabel.prepend(remember);
|
| 257 |
+
const status = node('p'); status.setAttribute('role', 'status');
|
| 258 |
+
root.append(label, rememberLabel, button(ui.save, () => {
|
| 259 |
+
p.font_size = Number(font.value); p.remember_page = remember.checked;
|
| 260 |
+
if (!p.remember_page) p.page = 1;
|
| 261 |
+
status.textContent = persist(c) ? ui.saved : ui.storage_error;
|
| 262 |
+
}), status);
|
| 263 |
+
panel(ui.settings, root, back, ui);
|
| 264 |
+
}
|
| 265 |
+
window.addEventListener('muslim-clock-popup-leave', () => { epoch++; });
|
| 266 |
+
window.addEventListener('muslim-clock-quran-open', event => open(event.detail || {}));
|
| 267 |
+
window.MuslimClockQuran = Object.freeze({open, openSettings,
|
| 268 |
+
mountEntry: (parent, back) => mount(parent, back, false),
|
| 269 |
+
mountSettingsEntry: (parent, back) => mount(parent, back, true)});
|
| 270 |
+
})();
|
quran_reader_registry.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema_version": 1,
|
| 3 |
+
"core_file": "quran_core_registry.json",
|
| 4 |
+
"source_file": "al_khatma_source_attribution.md",
|
| 5 |
+
"storage_key": "muslim_clock_quran_reader_v1",
|
| 6 |
+
"defaults": {"font_size": 26, "remember_page": true},
|
| 7 |
+
"limits": {"font_min": 20, "font_max": 40, "search_batch": 40, "request_timeout_ms": 30000},
|
| 8 |
+
"ui": {
|
| 9 |
+
"title": "القرآن الكريم",
|
| 10 |
+
"open": "قراءة القرآن الكريم",
|
| 11 |
+
"settings": "إعدادات قراءة القرآن",
|
| 12 |
+
"loading": "جارٍ تحميل القرآن الكريم…",
|
| 13 |
+
"load_error": "تعذّر تحميل بيانات القرآن. تحقق من اتصالك ووجود ملف البيانات ثم أعد المحاولة.",
|
| 14 |
+
"retry": "إعادة المحاولة",
|
| 15 |
+
"surah": "السورة",
|
| 16 |
+
"ayah": "الآية",
|
| 17 |
+
"page": "الصفحة",
|
| 18 |
+
"juz": "الجزء",
|
| 19 |
+
"go": "انتقال",
|
| 20 |
+
"previous": "الصفحة السابقة",
|
| 21 |
+
"next": "الصفحة التالية",
|
| 22 |
+
"search": "بحث في القرآن",
|
| 23 |
+
"search_submit": "بحث",
|
| 24 |
+
"search_empty": "اكتب كلمة أو عبارة للبحث.",
|
| 25 |
+
"no_results": "لا توجد نتائج مطابقة.",
|
| 26 |
+
"results": "نتائج البحث: {count}",
|
| 27 |
+
"more": "عرض نتائج إضافية",
|
| 28 |
+
"reader": "العودة للقراءة",
|
| 29 |
+
"page_status": "الصفحة {page} من {total} · الجزء {juz}",
|
| 30 |
+
"invalid_page": "أدخل رقم صفحة من 1 إلى {total}.",
|
| 31 |
+
"font_size": "حجم خط الآيات",
|
| 32 |
+
"remember_page": "تذكّر آخر صفحة مفتوحة على هذا الجهاز",
|
| 33 |
+
"save": "حفظ الإعدادات",
|
| 34 |
+
"saved": "حُفظت إعدادات القراءة.",
|
| 35 |
+
"storage_error": "تعذّر الحفظ على هذا الجهاز. ستبقى الإعدادات لهذه الجلسة فقط.",
|
| 36 |
+
"back": "رجوع",
|
| 37 |
+
"source": "مصدر النص والترخيص"
|
| 38 |
+
}
|
| 39 |
+
}
|
registry_app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
const RegistryApp = (() => {
|
| 2 |
-
const files = ['visual_states_registry','fiqh_time_registry','worship_fiqh_registry','islamic_events_registry','religious_content_registry','contextual_knowledge_registry','on_this_day_registry','user_time_markers_registry','announcements_guidance_registry','content_channels_registry','astronomy_events_registry','external_sources_registry'];
|
| 3 |
const R = {}; let ui, visual, layout, lastFocus, currentKind, view, initialScroll = false;
|
| 4 |
const $ = id => document.getElementById(id);
|
| 5 |
const registry = name => R[name + '_registry'] || {rules:[],boundaries:[],madhhabs:{},legacy_rule_map:[],items:[],events:[],channels:[],providers:[],event_types:[],marker_types:{}};
|
|
@@ -32,6 +32,7 @@ const RegistryApp = (() => {
|
|
| 32 |
function link(parent,label,url){const href=safeURL(url);if(!href)return;const a=make('a',label);a.href=href;a.target='_blank';a.rel='noopener noreferrer';parent.appendChild(a);}
|
| 33 |
function para(text){if(text)$('adaptivePopupBody').appendChild(make('p',text));}
|
| 34 |
function show(kind,data,render){
|
|
|
|
| 35 |
const overlay=$('adaptivePopup');if(overlay.hidden)lastFocus=document.activeElement;
|
| 36 |
const target=safeScreen(kind);kind=target.id;currentKind=kind; view=()=>show(kind,data,render);
|
| 37 |
$('adaptivePopupKind').textContent=target.title;
|
|
@@ -46,7 +47,7 @@ const RegistryApp = (() => {
|
|
| 46 |
overlay.hidden=false;document.body.style.overflow='hidden';$('adaptivePopupClose').focus();
|
| 47 |
$('adaptivePopupCard').scrollTop=0;$('adaptivePopupBody').scrollTop=0;
|
| 48 |
}
|
| 49 |
-
function close(){ $('adaptivePopup').hidden=true;document.body.style.overflow='';lastFocus?.focus(); }
|
| 50 |
function back(fn){$('adaptivePopupActions').appendChild(button(ui.back,fn));}
|
| 51 |
function home(kind){show(kind,{title:screen(kind).title,text:ui.catalogue},()=>{
|
| 52 |
screen(kind).groups.forEach(group=>$('adaptivePopupBody').appendChild(button(ui.groupTitles[group],()=>list(kind,group))));
|
|
@@ -68,6 +69,7 @@ const RegistryApp = (() => {
|
|
| 68 |
}
|
| 69 |
}
|
| 70 |
function list(kind,group){
|
|
|
|
| 71 |
if(group==='markers'){remindersHome();return;}
|
| 72 |
show(kind,{title:ui.groupTitles[group],text:group==='history'?ui.historyNote:group==='markers'?ui.markerNote:''},()=>{
|
| 73 |
const rows=records(group);if(!R[ui.groupRegistry[group]+'_registry'])para(ui.unavailable);else if(!rows.length)para(ui.empty);
|
|
@@ -216,10 +218,10 @@ const RegistryApp = (() => {
|
|
| 216 |
if(!navigator.geolocation){para(ui.locationFailed);return;}
|
| 217 |
const status=make('p',ui.locating);body.appendChild(status);
|
| 218 |
navigator.geolocation.getCurrentPosition(pos=>{
|
| 219 |
-
observer={lat:pos.coords.latitude,lng:pos.coords.longitude,name:ui.gps};save('clock_observer_v1',observer);recalculate();close();
|
| 220 |
},()=>status.textContent=ui.locationFailed,{timeout:15000,maximumAge:300000});
|
| 221 |
}));
|
| 222 |
-
p.locations.forEach(loc=>body.appendChild(button(loc.name,()=>{observer={...loc};save('clock_observer_v1',observer);recalculate();close();})));
|
| 223 |
const lat=make('input'),lng=make('input');
|
| 224 |
[[lat,ui.latitude,-90,90,observer?.lat],[lng,ui.longitude,-180,180,observer?.lng]].forEach(([e,label,min,max,val])=>{
|
| 225 |
e.type='number';e.step='any';e.min=min;e.max=max;e.value=val??'';const field=make('label',label);field.appendChild(e);body.appendChild(field);
|
|
@@ -230,7 +232,7 @@ const RegistryApp = (() => {
|
|
| 230 |
body.appendChild(button(ui.apply,()=>{
|
| 231 |
if(lat.value===''||lng.value===''){para(ui.invalidLocation);return;}
|
| 232 |
const loc={lat:Number(lat.value),lng:Number(lng.value)};if(!validLocation(loc)){para(ui.invalidLocation);return;}
|
| 233 |
-
observer=loc;madhhab=select.value;save('clock_observer_v1',observer);save('clock_madhhab_v1',madhhab);recalculate();close();
|
| 234 |
}));
|
| 235 |
para(p.note_ar);
|
| 236 |
});
|
|
@@ -271,12 +273,25 @@ const RegistryApp = (() => {
|
|
| 271 |
}
|
| 272 |
function hourSettings(start){
|
| 273 |
show('worship',{title:hourAccessibleLabel(new Date(start).getHours()),compact:true},()=>{
|
|
|
|
| 274 |
$('adaptivePopupBody').appendChild(button(ui.adhkar.title,()=>adhkarHome(start)));
|
| 275 |
$('adaptivePopupBody').appendChild(button(ui.worshipSchedules,()=>list('worship','events')));
|
| 276 |
$('adaptivePopupActions').appendChild(button(ru().add,()=>reminderChoose(start)));
|
| 277 |
$('adaptivePopupBody').appendChild(button(ru().settings,reminderSettings));
|
| 278 |
$('adaptivePopupBody').appendChild(button(ru().tools,remindersHome));
|
| 279 |
$('adaptivePopupBody').appendChild(button(ui.location,configureLocation));$('adaptivePopupBody').appendChild(button(ui.calendarSettings,calendarSettings));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
});
|
| 281 |
}
|
| 282 |
function periodDetails(p){
|
|
@@ -675,6 +690,7 @@ const RegistryApp = (() => {
|
|
| 675 |
});
|
| 676 |
}
|
| 677 |
function reminderSettings(){const s=reminderAction(()=>personal.read());if(!s)return;show('worship',{title:ru().settings,text:ru().scope},()=>{
|
|
|
|
| 678 |
const sound=reminderField(ru().sound,'checkbox','');sound.checked=s.settings.sound_enabled===true;
|
| 679 |
$('adaptivePopupBody').appendChild(button(ru().enableAlerts,async()=>{const result=await requestAlertPermission();if(result.permission==='denied')para(ru().notificationDenied);else if(result.sound&&result.permission==='granted')para(ru().alertsReady);else if(result.permission==='unsupported')para(ru().notificationUnavailable);else para(ru().alertsPartlyReady);}));
|
| 680 |
$('adaptivePopupBody').appendChild(button(ru().testSound,async()=>{if(await enableReminderSound())playReminderSound();else para(ru().soundUnavailable);}));para(ru().closedBrowserNote);
|
|
@@ -755,15 +771,8 @@ const RegistryApp = (() => {
|
|
| 755 |
for(const cell of cells){
|
| 756 |
cell.style.height=upperHeight+'px';
|
| 757 |
const reminders=[...cell.querySelectorAll('.event-marker,.personal-hour')].sort((a,b)=>Number(a.dataset.timelineTime)-Number(b.dataset.timelineTime));
|
| 758 |
-
|
| 759 |
-
|
| 760 |
-
const cardWidth=Math.max(58,(cellWidth-8-(columns-1)*6)/columns);
|
| 761 |
-
reminders.forEach((entry,index)=>{
|
| 762 |
-
const row=Math.floor(index/columns),column=index%columns;
|
| 763 |
-
entry.style.top=(upperHeight+20+row*70)+'px';entry.style.bottom='auto';
|
| 764 |
-
entry.style.left=(4+column*(cardWidth+6))+'px';entry.style.right='auto';entry.style.width=cardWidth+'px';
|
| 765 |
-
});
|
| 766 |
-
lowerRows=Math.max(lowerRows,Math.ceil(reminders.length/columns));
|
| 767 |
}
|
| 768 |
ruler.querySelector('.reminder-axis')?.remove();
|
| 769 |
if(lowerRows){const axis=make('div');axis.className='reminder-axis';axis.setAttribute('aria-hidden','true');axis.style.top=(95+upperHeight+8)+'px';ruler.prepend(axis);}
|
|
@@ -797,7 +806,7 @@ const RegistryApp = (() => {
|
|
| 797 |
}
|
| 798 |
});
|
| 799 |
}
|
| 800 |
-
return {start,home,close,records,detail,boundaryInfo,ruleText,remindersHome,reminderChoose,reminderForm,reminderDetail,reminderSettings,prayerEntries,indicatorState,twelveHourLabel,hourDetails,hourSettings,periodDetails,recalculate,configureLocation,tickPersonal,calendarText,applyPrayerMethod,solarState:()=>({observer,madhhab,solarDays,solarPeriods}),resolveLegacy(id){return registry('religious_content').legacy_rule_map.find(x=>x.legacy_id===id);}};
|
| 801 |
})();
|
| 802 |
window.PopupManager={open:(kind)=>RegistryApp.home(kind),close:()=>RegistryApp.close()};
|
| 803 |
window.registryReady=RegistryApp.start();
|
|
|
|
| 1 |
const RegistryApp = (() => {
|
| 2 |
+
const files = ['visual_states_registry','fiqh_time_registry','worship_fiqh_registry','islamic_events_registry','religious_content_registry','contextual_knowledge_registry','on_this_day_registry','user_time_markers_registry','announcements_guidance_registry','content_channels_registry','astronomy_events_registry','external_sources_registry','sky_simulation_registry'];
|
| 3 |
const R = {}; let ui, visual, layout, lastFocus, currentKind, view, initialScroll = false;
|
| 4 |
const $ = id => document.getElementById(id);
|
| 5 |
const registry = name => R[name + '_registry'] || {rules:[],boundaries:[],madhhabs:{},legacy_rule_map:[],items:[],events:[],channels:[],providers:[],event_types:[],marker_types:{}};
|
|
|
|
| 32 |
function link(parent,label,url){const href=safeURL(url);if(!href)return;const a=make('a',label);a.href=href;a.target='_blank';a.rel='noopener noreferrer';parent.appendChild(a);}
|
| 33 |
function para(text){if(text)$('adaptivePopupBody').appendChild(make('p',text));}
|
| 34 |
function show(kind,data,render){
|
| 35 |
+
window.dispatchEvent(new Event('muslim-clock-popup-leave'));
|
| 36 |
const overlay=$('adaptivePopup');if(overlay.hidden)lastFocus=document.activeElement;
|
| 37 |
const target=safeScreen(kind);kind=target.id;currentKind=kind; view=()=>show(kind,data,render);
|
| 38 |
$('adaptivePopupKind').textContent=target.title;
|
|
|
|
| 47 |
overlay.hidden=false;document.body.style.overflow='hidden';$('adaptivePopupClose').focus();
|
| 48 |
$('adaptivePopupCard').scrollTop=0;$('adaptivePopupBody').scrollTop=0;
|
| 49 |
}
|
| 50 |
+
function close(){ window.dispatchEvent(new Event('muslim-clock-popup-leave')); $('adaptivePopup').hidden=true;document.body.style.overflow='';lastFocus?.focus(); }
|
| 51 |
function back(fn){$('adaptivePopupActions').appendChild(button(ui.back,fn));}
|
| 52 |
function home(kind){show(kind,{title:screen(kind).title,text:ui.catalogue},()=>{
|
| 53 |
screen(kind).groups.forEach(group=>$('adaptivePopupBody').appendChild(button(ui.groupTitles[group],()=>list(kind,group))));
|
|
|
|
| 69 |
}
|
| 70 |
}
|
| 71 |
function list(kind,group){
|
| 72 |
+
if(group==='quran'&&window.MuslimClockQuran){window.MuslimClockQuran.open({back:()=>home(kind)});return;}
|
| 73 |
if(group==='markers'){remindersHome();return;}
|
| 74 |
show(kind,{title:ui.groupTitles[group],text:group==='history'?ui.historyNote:group==='markers'?ui.markerNote:''},()=>{
|
| 75 |
const rows=records(group);if(!R[ui.groupRegistry[group]+'_registry'])para(ui.unavailable);else if(!rows.length)para(ui.empty);
|
|
|
|
| 218 |
if(!navigator.geolocation){para(ui.locationFailed);return;}
|
| 219 |
const status=make('p',ui.locating);body.appendChild(status);
|
| 220 |
navigator.geolocation.getCurrentPosition(pos=>{
|
| 221 |
+
observer={lat:pos.coords.latitude,lng:pos.coords.longitude,name:ui.gps};save('clock_observer_v1',observer);window.dispatchEvent(new CustomEvent('muslim-clock-location-change',{detail:{...observer}}));recalculate();close();
|
| 222 |
},()=>status.textContent=ui.locationFailed,{timeout:15000,maximumAge:300000});
|
| 223 |
}));
|
| 224 |
+
p.locations.forEach(loc=>body.appendChild(button(loc.name,()=>{observer={...loc};save('clock_observer_v1',observer);window.dispatchEvent(new CustomEvent('muslim-clock-location-change',{detail:{...observer}}));recalculate();close();})));
|
| 225 |
const lat=make('input'),lng=make('input');
|
| 226 |
[[lat,ui.latitude,-90,90,observer?.lat],[lng,ui.longitude,-180,180,observer?.lng]].forEach(([e,label,min,max,val])=>{
|
| 227 |
e.type='number';e.step='any';e.min=min;e.max=max;e.value=val??'';const field=make('label',label);field.appendChild(e);body.appendChild(field);
|
|
|
|
| 232 |
body.appendChild(button(ui.apply,()=>{
|
| 233 |
if(lat.value===''||lng.value===''){para(ui.invalidLocation);return;}
|
| 234 |
const loc={lat:Number(lat.value),lng:Number(lng.value)};if(!validLocation(loc)){para(ui.invalidLocation);return;}
|
| 235 |
+
observer=loc;madhhab=select.value;save('clock_observer_v1',observer);window.dispatchEvent(new CustomEvent('muslim-clock-location-change',{detail:{...observer}}));save('clock_madhhab_v1',madhhab);recalculate();close();
|
| 236 |
}));
|
| 237 |
para(p.note_ar);
|
| 238 |
});
|
|
|
|
| 273 |
}
|
| 274 |
function hourSettings(start){
|
| 275 |
show('worship',{title:hourAccessibleLabel(new Date(start).getHours()),compact:true},()=>{
|
| 276 |
+
window.MuslimClockQuran?.mountEntry($('adaptivePopupBody'),()=>hourSettings(start));
|
| 277 |
$('adaptivePopupBody').appendChild(button(ui.adhkar.title,()=>adhkarHome(start)));
|
| 278 |
$('adaptivePopupBody').appendChild(button(ui.worshipSchedules,()=>list('worship','events')));
|
| 279 |
$('adaptivePopupActions').appendChild(button(ru().add,()=>reminderChoose(start)));
|
| 280 |
$('adaptivePopupBody').appendChild(button(ru().settings,reminderSettings));
|
| 281 |
$('adaptivePopupBody').appendChild(button(ru().tools,remindersHome));
|
| 282 |
$('adaptivePopupBody').appendChild(button(ui.location,configureLocation));$('adaptivePopupBody').appendChild(button(ui.calendarSettings,calendarSettings));
|
| 283 |
+
const qiblaUI=registry('sky_simulation').qibla_accessibility?.ui;
|
| 284 |
+
if(qiblaUI?.settings)$('adaptivePopupBody').appendChild(button(qiblaUI.settings,()=>qiblaSettings(start)));
|
| 285 |
+
});
|
| 286 |
+
}
|
| 287 |
+
function qiblaSettings(start){
|
| 288 |
+
const config=registry('sky_simulation').qibla_accessibility;
|
| 289 |
+
if(!config?.ui)return;
|
| 290 |
+
show('worship',{title:config.ui.settings,compact:true},()=>{
|
| 291 |
+
const host=make('div');host.id='celestialSettingsHost';$('adaptivePopupBody').appendChild(host);
|
| 292 |
+
if(window.MuslimClockQibla)window.MuslimClockQibla.mountSettings(host);
|
| 293 |
+
else para(config.ui.loading);
|
| 294 |
+
back(()=>hourSettings(start));
|
| 295 |
});
|
| 296 |
}
|
| 297 |
function periodDetails(p){
|
|
|
|
| 690 |
});
|
| 691 |
}
|
| 692 |
function reminderSettings(){const s=reminderAction(()=>personal.read());if(!s)return;show('worship',{title:ru().settings,text:ru().scope},()=>{
|
| 693 |
+
window.MuslimClockQuran?.mountSettingsEntry($('adaptivePopupBody'),reminderSettings);
|
| 694 |
const sound=reminderField(ru().sound,'checkbox','');sound.checked=s.settings.sound_enabled===true;
|
| 695 |
$('adaptivePopupBody').appendChild(button(ru().enableAlerts,async()=>{const result=await requestAlertPermission();if(result.permission==='denied')para(ru().notificationDenied);else if(result.sound&&result.permission==='granted')para(ru().alertsReady);else if(result.permission==='unsupported')para(ru().notificationUnavailable);else para(ru().alertsPartlyReady);}));
|
| 696 |
$('adaptivePopupBody').appendChild(button(ru().testSound,async()=>{if(await enableReminderSound())playReminderSound();else para(ru().soundUnavailable);}));para(ru().closedBrowserNote);
|
|
|
|
| 771 |
for(const cell of cells){
|
| 772 |
cell.style.height=upperHeight+'px';
|
| 773 |
const reminders=[...cell.querySelectorAll('.event-marker,.personal-hour')].sort((a,b)=>Number(a.dataset.timelineTime)-Number(b.dataset.timelineTime));
|
| 774 |
+
reminders.forEach((entry,index)=>{entry.style.top=(upperHeight+20+index*70)+'px';entry.style.bottom='auto';});
|
| 775 |
+
lowerRows=Math.max(lowerRows,reminders.length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 776 |
}
|
| 777 |
ruler.querySelector('.reminder-axis')?.remove();
|
| 778 |
if(lowerRows){const axis=make('div');axis.className='reminder-axis';axis.setAttribute('aria-hidden','true');axis.style.top=(95+upperHeight+8)+'px';ruler.prepend(axis);}
|
|
|
|
| 806 |
}
|
| 807 |
});
|
| 808 |
}
|
| 809 |
+
return {openPanel:show,start,home,close,qiblaSettings,celestialRegistry:()=>registry('sky_simulation'),records,detail,boundaryInfo,ruleText,remindersHome,reminderChoose,reminderForm,reminderDetail,reminderSettings,prayerEntries,indicatorState,twelveHourLabel,hourDetails,hourSettings,periodDetails,recalculate,configureLocation,tickPersonal,calendarText,applyPrayerMethod,solarState:()=>({observer,madhhab,solarDays,solarPeriods}),resolveLegacy(id){return registry('religious_content').legacy_rule_map.find(x=>x.legacy_id===id);}};
|
| 810 |
})();
|
| 811 |
window.PopupManager={open:(kind)=>RegistryApp.home(kind),close:()=>RegistryApp.close()};
|
| 812 |
window.registryReady=RegistryApp.start();
|