الفرق بين المراجعتين لصفحة: «ميدياويكي:Common.js»
المظهر
أنشأ الصفحة ب' fetch('https://api.aladhan.com/v1/gToH?date=' + new Date().toISOString().split('T')[0]) .then(response => response.json()) .then(data => { const hijri = data.data.hijri; const dateString = hijri.weekday.ar + ' ' + hijri.day + ' ' + hijri.month.ar + ' ' + hijri.year + ' هـ'; const el = document.getElementById('hijri-date'); if (el) el.innerText = dateString; });' |
لا ملخص تعديل |
||
سطر ١: | سطر ١: | ||
document.addEventListener("DOMContentLoaded", function () { | |||
const dateBox = document.getElementById('hijri-date'); | |||
if (!dateBox) return; | |||
fetch( | const today = new Date(); | ||
const yyyy = today.getFullYear(); | |||
const mm = String(today.getMonth() + 1).padStart(2, '0'); | |||
const dd = String(today.getDate()).padStart(2, '0'); | |||
const dateStr = `${dd}-${mm}-${yyyy}`; | |||
fetch(`https://api.aladhan.com/v1/gToH?date=${dateStr}`) | |||
.then(res => res.json()) | |||
.then(data => { | |||
const hijri = data.data.hijri; | |||
const weekday = hijri.weekday.ar; | |||
const day = hijri.day; | |||
const month = hijri.month.ar; | |||
const year = hijri.year; | |||
dateBox.textContent = `📅 ${weekday} ${day} ${month} ${year} هـ`; | |||
}) | |||
.catch(() => { | |||
dateBox.textContent = "❌ تعذر جلب التاريخ الهجري."; | |||
}); | |||
}); |
المراجعة الحالية بتاريخ ١٣:٥٢، ١٢ يوليو ٢٠٢٥
document.addEventListener("DOMContentLoaded", function () {
const dateBox = document.getElementById('hijri-date');
if (!dateBox) return;
const today = new Date();
const yyyy = today.getFullYear();
const mm = String(today.getMonth() + 1).padStart(2, '0');
const dd = String(today.getDate()).padStart(2, '0');
const dateStr = `${dd}-${mm}-${yyyy}`;
fetch(`https://api.aladhan.com/v1/gToH?date=${dateStr}`)
.then(res => res.json())
.then(data => {
const hijri = data.data.hijri;
const weekday = hijri.weekday.ar;
const day = hijri.day;
const month = hijri.month.ar;
const year = hijri.year;
dateBox.textContent = `📅 ${weekday} ${day} ${month} ${year} هـ`;
})
.catch(() => {
dateBox.textContent = "❌ تعذر جلب التاريخ الهجري.";
});
});