انتقل إلى المحتوى

الفرق بين المراجعتين لصفحة: «ميدياويكي: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('https://api.aladhan.com/v1/gToH?date=' + new Date().toISOString().split('T')[0])
  const today = new Date();
  .then(response => response.json())
  const yyyy = today.getFullYear();
  .then(data => {
  const mm = String(today.getMonth() + 1).padStart(2, '0');
    const hijri = data.data.hijri;
  const dd = String(today.getDate()).padStart(2, '0');
    const dateString = hijri.weekday.ar + ' '
  const dateStr = `${dd}-${mm}-${yyyy}`;
                    + hijri.day + ' '
 
                    + hijri.month.ar + ' '
  fetch(`https://api.aladhan.com/v1/gToH?date=${dateStr}`)
                    + hijri.year + ' هـ';
    .then(res => res.json())
     const el = document.getElementById('hijri-date');
    .then(data => {
     if (el) el.innerText = dateString;
      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 = "❌ تعذر جلب التاريخ الهجري.";
    });
});