ai ile yapılan daha büyük güncelleme
This commit is contained in:
@@ -13,7 +13,8 @@ export function renderDesktop(selectedCity = "İstanbul") {
|
||||
});
|
||||
|
||||
const html = `
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6 w-full max-w-6xl">
|
||||
<div class="flex justify-end w-full">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6 w-full max-w-6xl">
|
||||
<div class="bg-slate-900/40 backdrop-blur-2xl border border-white/10 p-6 rounded-3xl shadow-2xl text-left space-y-3">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="inline-flex p-2 bg-indigo-500/20 border border-indigo-500/30 rounded-xl text-indigo-300 text-xl">
|
||||
@@ -121,7 +122,11 @@ async function loadImsakiye(container, selectedCity) {
|
||||
|
||||
widget.innerHTML = `
|
||||
🌅 İmsak: <span class="text-white font-semibold">${times.imsak}</span><br />
|
||||
🕌 İftar: <span class="text-emerald-300 font-semibold">${times.maghrib}</span>
|
||||
🌅 Güneş: <span class="text-white font-semibold">${times.sunrise}</span><br />
|
||||
🌅 Öğle: <span class="text-white font-semibold">${times.dhuhr}</span><br />
|
||||
🌅 İkindi: <span class="text-white font-semibold">${times.asr}</span><br />
|
||||
🕌 Akşam: <span class="text-emerald-300 font-semibold">${times.maghrib}</span>
|
||||
🌅 Yatsı: <span class="text-white font-semibold">${times.isha}</span><br />
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
+57
-17
@@ -66,15 +66,18 @@ export function renderKaza(pb) {
|
||||
</div>
|
||||
|
||||
<div class="bg-slate-900/40 border border-white/10 p-4 rounded-2xl mb-6">
|
||||
<h3 class="text-sm font-semibold text-slate-300 mb-3">Kaza Namaz Ekle</h3>
|
||||
<h3 class="text-sm font-semibold text-slate-300 mb-3">Kaza Namaz Ekle / Çıkar</h3>
|
||||
<form id="addKazaForm" class="flex items-center gap-3">
|
||||
<select id="kazaPrayerType" class="bg-slate-950 border border-slate-800 rounded-xl px-4 py-2 text-white text-sm">
|
||||
${PRAYERS.map((p) => `<option value="${p.id}">${p.name}</option>`).join("")}
|
||||
</select>
|
||||
<input type="number" id="kazaCount" min="1" value="1" required class="w-20 bg-slate-950 border border-slate-800 rounded-xl px-4 py-2 text-white text-sm" />
|
||||
<button type="submit" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-xl text-sm font-medium transition-all">
|
||||
<button type="button" id="addKazaBtn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-xl text-sm font-medium transition-all">
|
||||
Ekle
|
||||
</button>
|
||||
<button type="button" id="removeKazaBtn" class="bg-rose-600 hover:bg-rose-700 text-white px-4 py-2 rounded-xl text-sm font-medium transition-all">
|
||||
Çıkar
|
||||
</button>
|
||||
</form>
|
||||
<p id="kazaMsg" class="text-xs mt-2 hidden"></p>
|
||||
</div>
|
||||
@@ -146,10 +149,11 @@ export function renderKaza(pb) {
|
||||
} else {
|
||||
refreshKazaStats(container, pb, profile);
|
||||
|
||||
const addForm = container.querySelector("#addKazaForm");
|
||||
if (addForm) {
|
||||
addForm.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
const addBtn = container.querySelector("#addKazaBtn");
|
||||
const removeBtn = container.querySelector("#removeKazaBtn");
|
||||
|
||||
if (addBtn) {
|
||||
addBtn.addEventListener("click", async () => {
|
||||
const prayerId = container.querySelector("#kazaPrayerType").value;
|
||||
const countInput = container.querySelector("#kazaCount");
|
||||
const count = Math.max(1, parseInt(countInput?.value || "1", 10));
|
||||
@@ -163,21 +167,50 @@ export function renderKaza(pb) {
|
||||
date: new Date().toISOString().split("T")[0],
|
||||
});
|
||||
|
||||
if (msg) {
|
||||
msg.textContent = `${count} kaza namaz eklendi!`;
|
||||
msg.className = "text-xs mt-2 text-emerald-400";
|
||||
msg.classList.remove("hidden");
|
||||
}
|
||||
|
||||
showKazaMsg(msg, `${count} kaza namaz eklendi!`, true);
|
||||
if (countInput) countInput.value = "1";
|
||||
refreshKazaStats(container, pb, profile);
|
||||
await refreshKazaStats(container, pb, profile);
|
||||
} catch (err) {
|
||||
console.error("Kaza eklenemedi:", err);
|
||||
if (msg) {
|
||||
msg.textContent = "Eklenemedi. PocketBase bağlantısını kontrol et.";
|
||||
msg.className = "text-xs mt-2 text-rose-400";
|
||||
msg.classList.remove("hidden");
|
||||
showKazaMsg(msg, "Eklenemedi. PocketBase bağlantısını kontrol et.", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (removeBtn) {
|
||||
removeBtn.addEventListener("click", async () => {
|
||||
const prayerId = container.querySelector("#kazaPrayerType").value;
|
||||
const countInput = container.querySelector("#kazaCount");
|
||||
const count = Math.max(1, parseInt(countInput?.value || "1", 10));
|
||||
const msg = container.querySelector("#kazaMsg");
|
||||
|
||||
try {
|
||||
const records = await pb.collection("kaza_logs").getFullList({
|
||||
filter: `user = "${pb.authStore.model.id}" && prayerId = "${prayerId}"`,
|
||||
sort: "-createdAt",
|
||||
});
|
||||
|
||||
let remaining = count;
|
||||
for (const record of records) {
|
||||
if (remaining <= 0) break;
|
||||
const recordCount = record.count || 1;
|
||||
if (recordCount > remaining) {
|
||||
await pb.collection("kaza_logs").update(record.id, {
|
||||
count: recordCount - remaining,
|
||||
});
|
||||
remaining = 0;
|
||||
} else {
|
||||
await pb.collection("kaza_logs").delete(record.id);
|
||||
remaining -= recordCount;
|
||||
}
|
||||
}
|
||||
|
||||
showKazaMsg(msg, `${count} kaza namaz çıkarıldı!`, true);
|
||||
if (countInput) countInput.value = "1";
|
||||
await refreshKazaStats(container, pb, profile);
|
||||
} catch (err) {
|
||||
console.error("Kaza çıkarılamadı:", err);
|
||||
showKazaMsg(msg, "Çıkarılamadı. PocketBase bağlantısını kontrol et.", false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -227,6 +260,7 @@ async function refreshKazaStats(container, pb, profile) {
|
||||
const todayKey = new Date().toISOString().split("T")[0];
|
||||
const todayLogs = logs.filter((l) => l.date === todayKey);
|
||||
profile.todayLogs = todayLogs;
|
||||
localStorage.setItem("kaza_profile", JSON.stringify(profile));
|
||||
|
||||
if (logsContainer) {
|
||||
logsContainer.innerHTML = logs
|
||||
@@ -243,3 +277,9 @@ async function refreshKazaStats(container, pb, profile) {
|
||||
.join("") || '<p class="text-xs text-slate-500">Henüz kayıt yok.</p>';
|
||||
}
|
||||
}
|
||||
|
||||
function showKazaMsg(el, text, success) {
|
||||
el.textContent = text;
|
||||
el.className = `text-xs mt-2 ${success ? "text-emerald-400" : "text-rose-400"}`;
|
||||
el.classList.remove("hidden");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user