genel olarak yapılan düzeltmeler

This commit is contained in:
2026-07-29 04:17:22 +02:00
parent dc4af9cc1d
commit 579a51f899
4 changed files with 146 additions and 84 deletions
+25 -6
View File
@@ -1,13 +1,31 @@
import { getCityByName } from "./locations.js";
export async function fetchPrayerTimes(cityName = "Edremit", lat, lon) {
try {
let url;
if (lat !== undefined && lon !== undefined) {
url = `https://api.aladhan.com/v1/timings?latitude=${encodeURIComponent(lat)}&longitude=${encodeURIComponent(lon)}&method=13`;
} else {
url = `https://api.aladhan.com/v1/timingsByCity?city=${encodeURIComponent(cityName)}&country=Turkey&method=13`;
let fetchLat = lat;
let fetchLon = lon;
// Eğer enlem/boylam verilmediyse şehir listemizden koordinatları çekiyoruz
if (fetchLat === undefined || fetchLon === undefined) {
const cityObj = getCityByName(cityName);
if (cityObj) {
fetchLat = cityObj.lat;
fetchLon = cityObj.lon;
}
}
let url;
if (fetchLat !== undefined && fetchLon !== undefined) {
// Diyanet İşleri Başkanlığı Metodu = 13
url = `https://api.aladhan.com/v1/timings?latitude=${fetchLat}&longitude=${fetchLon}&method=13`;
} else {
url = `https://api.aladhan.com/v1/timingsByCity?city=Edremit&country=Turkey&method=13`;
}
const res = await fetch(url);
if (!res.ok) throw new Error("Namaz vakitleri alınamadı");
if (!res.ok) {
throw new Error("Namaz vakitleri alınamadı");
}
const data = await res.json();
const t = data.data.timings;
@@ -33,6 +51,7 @@ function getCurrentPrayer(timings) {
const currentMinutes = now.getHours() * 60 + now.getMinutes();
const parseTime = (timeStr) => {
if (!timeStr) return 0;
const [h, m] = timeStr.split(":").map(Number);
return h * 60 + m;
};