checks highlight opportunities to improve the accessibility of your
// <![CDATA[
(function() {
window.addEventListener('load', function() {
var area = document.getElementById('js-posts-area');
if (!area) return;
// استخدام رابط نسبي لضمان عدم وجود مشاكل في البروتوكول (HTTP/HTTPS)
var currentPath = window.location.pathname;
var isPost = (currentPath.length > 5 && currentPath.indexOf('.html') !== -1);
var feedUrl = '';
if (isPost) {
// البحث عن المقال بالمسار الكامل
feedUrl = '/feeds/posts/default?alt=json&q=' + encodeURIComponent(currentPath);
} else if (currentPath.indexOf('/search/label/') !== -1) {
var label = currentPath.split('/search/label/')[1].split('/')[0].split('?')[0];
feedUrl = '/feeds/posts/default/-/' + label + '?alt=json&max-results=12';
} else {
feedUrl = '/feeds/posts/default?alt=json&max-results=10&orderby=published';
}
area.innerHTML = '<div style="padding:50px;text-align:center">جاري استلام البيانات...</div>';
// استخدام XMLHttpRequest بطريقة أكثر توافقاً مع بلوجر
var request = new XMLHttpRequest();
request.open('GET', feedUrl, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var data = JSON.parse(request.responseText);
var entries = (data.feed && data.feed.entry) || [];
var html = '';
if (entries.length === 0) {
html = '<div style="padding:50px;text-align:center">لا يوجد مقالات. تأكد من ضبط (خلاصة الموقع) على "بالكامل" من الإعدادات.</div>';
} else if (isPost) {
// عرض المقال الفردي
html = (typeof fullHTML === 'function') ? fullHTML(entries[0]) : 'Error: fullHTML function missing';
} else {
// عرض قائمة المقالات
html = '<div class="blog-posts">';
entries.forEach(function(e) {
if(typeof cardHTML === 'function') html += cardHTML(e);
});
html += '</div>';
if(typeof pagerHTML === 'function') html += pagerHTML(data.feed);
}
area.innerHTML = html;
} else {
area.innerHTML = '<div style="padding:50px;text-align:center">خطأ من السيرفر: تأكد من تفعيل خلاصة المدونة من الإعدادات.</div>';
}
};
request.onerror = function() {
area.innerHTML = '<div style="padding:50px;text-align:center">فشل الاتصال: يرجى التحقق من اتصالك بالإنترنت.</div>';
};
request.send();
});
})();
// ]]>