document.addEventListener('DOMContentLoaded', function() { const urlParams = new URLSearchParams(window.location.search); const setUserId = urlParams.get('set_user_id'); const error = urlParams.get('error'); // دالة عرض الإشعارات function showToast(title, message, type = "info") { if (typeof window.showToast === 'function') { window.showToast(title, message, type); } else { alert(`${title}: ${message}`); } } // التحقق من دعم localStorage function canUseLocalStorage() { try { const testKey = '__test__'; localStorage.setItem(testKey, testKey); localStorage.removeItem(testKey); return true; } catch { return false; } } if (setUserId) { if (canUseLocalStorage()) { localStorage.setItem("ticketSystemUserId", setUserId); showToast("تم تسجيل الدخول", "تم حفظ بيانات الجلسة بنجاح", "success"); } else { showToast("تحذير", "متصفحك لا يدعم التخزين المحلي، قد تواجه مشاكل في الجلسة", "warning"); } // إزالة معلمات URL بدون إعادة تحميل الصفحة window.history.replaceState({}, document.title, window.location.pathname); } if (error) { switch(error) { case 'banned': showToast("حظر", "تم حظرك من استخدام النظام", "error"); break; case 'not_in_guild': showToast("خطأ", "يجب أن تكون عضوًا في السيرفر لاستخدام النظام", "error"); break; case 'oauth_error': showToast("خطأ", "حدث خطأ أثناء المصادقة، الرجاء المحاولة مرة أخرى", "error"); break; case 'session_error': showToast("خطأ", "حدث خطأ في الجلسة، الرجاء المحاولة مرة أخرى", "error"); break; default: showToast("خطأ", "حدث خطأ غير معروف", "error"); break; } // إزالة معلمات URL للأخطاء بدون إعادة تحميل window.history.replaceState({}, document.title, window.location.pathname); } });