{
    "sourceFile": "adhan-webapp/static/countdown.js",
    "activeCommit": 0,
    "commits": [
        {
            "activePatchIndex": 2,
            "patches": [
                {
                    "date": 1748182675995,
                    "content": "Index: \n===================================================================\n--- \n+++ \n"
                },
                {
                    "date": 1748202535810,
                    "content": "Index: \n===================================================================\n--- \n+++ \n@@ -3,20 +3,57 @@\n   const timeStr = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });\n   document.getElementById(\"current-time\").textContent = timeStr;\n }\n \n-function startCountdown(targetTimeStr) {\n+// Gebedstijden ophalen uit een globale variabele (wordt in de template gezet)\n+let prayerTimes = window.prayerTimes || [];\n+let prayerNames = window.prayerNames || [];\n+let currentPrayerIndex = 0;\n+\n+function startCountdowns(times, names) {\n+  prayerTimes = times;\n+  prayerNames = names;\n+  currentPrayerIndex = getNextPrayerIndex();\n+  startCountdown(prayerTimes[currentPrayerIndex], prayerNames[currentPrayerIndex]);\n+}\n+\n+function getNextPrayerIndex() {\n+  const now = new Date();\n+  for (let i = 0; i < prayerTimes.length; i++) {\n+    const [h, m] = prayerTimes[i].split(\":\");\n+    const t = new Date();\n+    t.setHours(parseInt(h));\n+    t.setMinutes(parseInt(m));\n+    t.setSeconds(0);\n+    if (t > now) return i;\n+  }\n+  return 0; // fallback: eerste gebed\n+}\n+\n+function startCountdown(targetTimeStr, prayerName) {\n   const parts = targetTimeStr.split(\":\");\n-  const target = new Date();\n+  let target = new Date();\n   target.setHours(parseInt(parts[0]));\n   target.setMinutes(parseInt(parts[1]));\n-  target.setSeconds(parseInt(parts[2]) || 0);\n+  target.setSeconds(0);\n \n+  document.querySelector('.huidig-gebed .naam').textContent = prayerName;\n+\n   function update() {\n     const now = new Date();\n     let diff = Math.floor((target - now) / 1000);\n \n-    if (diff < 0) diff = 0;\n+    if (diff <= 0) {\n+      // Speel adhaan af via browser\n+      const audio = document.getElementById('adhanAudio');\n+      if (audio) audio.play();\n+      // Ga naar volgende gebed\n+      currentPrayerIndex = (currentPrayerIndex + 1) % prayerTimes.length;\n+      const nextTime = prayerTimes[currentPrayerIndex];\n+      const nextName = prayerNames[currentPrayerIndex];\n+      startCountdown(nextTime, nextName);\n+      return;\n+    }\n \n     const h = String(Math.floor(diff / 3600)).padStart(2, '0');\n     const m = String(Math.floor((diff % 3600) / 60)).padStart(2, '0');\n     const s = String(diff % 60).padStart(2, '0');\n@@ -24,9 +61,10 @@\n     document.getElementById(\"countdown\").textContent = `${h}:${m}:${s}`;\n   }\n \n   update();\n-  setInterval(update, 1000);\n+  window._countdownInterval && clearInterval(window._countdownInterval);\n+  window._countdownInterval = setInterval(update, 1000);\n }\n \n function setupThemeToggle() {\n   const toggleBtn = document.getElementById(\"themeToggle\");\n"
                },
                {
                    "date": 1748204399019,
                    "content": "Index: \n===================================================================\n--- \n+++ \n@@ -1,10 +1,30 @@\n function updateCurrentTime() {\n   const now = new Date();\n   const timeStr = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });\n   document.getElementById(\"current-time\").textContent = timeStr;\n+  \n+  // Update datum informatie elke minuut\n+  updateDateInfo();\n }\n \n+function updateDateInfo() {\n+  fetch('/api/date-info')\n+    .then(response => response.json())\n+    .then(data => {\n+      const gregorianElement = document.querySelector('.gregorian-datum');\n+      const hijriArabicElement = document.querySelector('.hijri-datum-arabic');\n+      const hijriDutchElement = document.querySelector('.hijri-datum-dutch');\n+      \n+      if (gregorianElement) gregorianElement.textContent = data.gregorian_full;\n+      if (hijriArabicElement) hijriArabicElement.textContent = data.hijri_arabic;\n+      if (hijriDutchElement) hijriDutchElement.textContent = data.hijri_dutch;\n+    })\n+    .catch(error => {\n+      console.log('Fout bij bijwerken datum:', error);\n+    });\n+}\n+\n // Gebedstijden ophalen uit een globale variabele (wordt in de template gezet)\n let prayerTimes = window.prayerTimes || [];\n let prayerNames = window.prayerNames || [];\n let currentPrayerIndex = 0;\n"
                }
            ],
            "date": 1748182675995,
            "name": "Commit-0",
            "content": "function updateCurrentTime() {\n  const now = new Date();\n  const timeStr = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });\n  document.getElementById(\"current-time\").textContent = timeStr;\n}\n\nfunction startCountdown(targetTimeStr) {\n  const parts = targetTimeStr.split(\":\");\n  const target = new Date();\n  target.setHours(parseInt(parts[0]));\n  target.setMinutes(parseInt(parts[1]));\n  target.setSeconds(parseInt(parts[2]) || 0);\n\n  function update() {\n    const now = new Date();\n    let diff = Math.floor((target - now) / 1000);\n\n    if (diff < 0) diff = 0;\n\n    const h = String(Math.floor(diff / 3600)).padStart(2, '0');\n    const m = String(Math.floor((diff % 3600) / 60)).padStart(2, '0');\n    const s = String(diff % 60).padStart(2, '0');\n\n    document.getElementById(\"countdown\").textContent = `${h}:${m}:${s}`;\n  }\n\n  update();\n  setInterval(update, 1000);\n}\n\nfunction setupThemeToggle() {\n  const toggleBtn = document.getElementById(\"themeToggle\");\n  const html = document.documentElement;\n\n  function applyTheme(theme) {\n    html.className = theme;\n    localStorage.setItem('theme', theme);\n  }\n\n  const saved = localStorage.getItem('theme') || 'light';\n  applyTheme(saved);\n\n  toggleBtn.addEventListener(\"click\", () => {\n    const current = html.className === 'light' ? 'dark' : 'light';\n    applyTheme(current);\n  });\n}\n"
        }
    ]
}