{
this.deviceOnline = true;
this.checkService();
});
window.addEventListener('offline', () => {
this.deviceOnline = false;
this.serviceStatus = 'unknown';
});
// Listen for durable queue events
window.addEventListener('waafi-sync-updated', (event) => {
if (event.detail) {
if (typeof event.detail.pendingCount === 'number') this.pendingCount = event.detail.pendingCount;
if (typeof event.detail.conflictCount === 'number') this.conflictCount = event.detail.conflictCount;
if (typeof event.detail.supportsOffline === 'boolean') this.supportsOffline = event.detail.supportsOffline;
}
});
if (this.deviceOnline && this.showServiceBanner) {
this.checkService();
}
},
async checkService() {
if (!this.deviceOnline) {
this.serviceStatus = 'unknown';
return;
}
try {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 4000);
const res = await fetch(this.probeUrl, {
method: 'GET',
cache: 'no-store',
headers: { 'Accept': 'application/json' },
signal: controller.signal
});
clearTimeout(timeoutId);
this.serviceStatus = res.ok ? 'reachable' : 'unreachable';
} catch (err) {
this.serviceStatus = 'unreachable';
}
},
async retryCheck() {
if (this.isRetrying) return;
this.isRetrying = true;
this.serviceStatus = 'checking';
await this.checkService();
this.isRetrying = false;
},
get isVisible() {
return !this.deviceOnline || (this.deviceOnline && this.serviceStatus === 'unreachable');
},
get bannerText() {
if (this.customMessage) return this.customMessage;
if (!this.deviceOnline) {
if (!this.supportsOffline) {
return 'انقطع الاتصال بالإنترنت — تصفح المحتوى وإتمام المعاملات يتطلب اتصالاً نشطاً بالشبكة.';
}
if (this.conflictCount > 0) {
return `وضع عدم الاتصال — يوجد ${this.conflictCount} تعارض في البيانات المحفوظة محلياً بانتظار المراجعة.`;
}
if (this.pendingCount > 0) {
return `وضع عدم الاتصال — يعمل بدون إنترنت مع حفظ محلي (${this.pendingCount} معلقة ستتزامن عند استعادة الاتصال).`;
}
return 'وضع عدم الاتصال — يعمل بدون إنترنت مع حفظ محلي، وستتزامن العمليات تلقائياً فور عودة الاتصال.';
}
if (this.serviceStatus === 'unreachable') {
return 'تعذر الاتصال بخوادم وافي — الجهاز متصل بالشبكة ولكن خدمة الخادم غير متاحة حالياً.';
}
return '';
},
get statusBadgeText() {
if (!this.deviceOnline) {
return this.supportsOffline ? 'وضع عدم الاتصال' : 'غير متصل بالشبكة';
}
if (this.serviceStatus === 'unreachable') {
return 'انقطاع خدمة الخادم';
}
return '';
}
}"
x-show="isVisible"
x-cloak
data-waafi-state="offline"
:data-device-state="deviceOnline ? 'online' : 'offline'"
:data-service-state="serviceStatus"
:data-queue-state="supportsOffline ? (pendingCount > 0 ? 'pending' : 'ready') : 'unsupported'"
:data-offline-truth="!deviceOnline ? (supportsOffline ? 'offline-durable' : 'disconnected-no-queue') : 'service-unreachable'"
class="w-full bg-amber-500/15 border-b border-amber-500/30 text-amber-200 px-4 py-2.5 flex items-center justify-between gap-3 text-xs font-bold transition-all shadow-sm rounded-2xl"
dir="rtl"
role="alert"
aria-live="polite"
>
انقطع الاتصال بالإنترنت — تصفح المحتوى وإتمام المعاملات يتطلب اتصالاً نشطاً. (يعمل بدون إنترنت متاح فقط للشاشات الداعمة للحفظ المحلي)
وضع عدم الاتصال
منصة وافي المعرفية الرائدة
تعلم، اكتشف، وقارن بثقة قبل اتخاذ أي قرار
منصة المعرفة الموثوقة في مصر — مواصفات السيارات، الهواتف، الأدوية، الأمراض، القوانين، الإجراءات الحكومية، والوصفات.
المجالات المعرفية الرئيسية
أداة المقارنة التفاعلية ←السيارات والمركبات
تصفح البيانات الموثقة
الأجهزة والإلكترونيات
تصفح البيانات الموثقة
الأدوية والمستحضرات الطبية
تصفح البيانات الموثقة
الأمراض والأدلة الصحية
تصفح البيانات الموثقة
الوصفات والطهي
تصفح البيانات الموثقة
القوانين التشريعية
تصفح البيانات الموثقة
الإجراءات والخدمات الحكومية
تصفح البيانات الموثقة
أحدث البيانات المعرفية الموثقة حديثاً
لا توجد بيانات معرفية منشورة حالياً
تخضع كافة السجلات للفحص والتوثيق والاعتماد قبل ظهورها في المنصة.