29-03-26, 06:10 AM
PHP كود :
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<title>تنبيه صلاة الفجر</title>
<style>
#overlay {
display: none;
position: fixed;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
top: 0;
left: 0;
}
#popup {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #fff;
padding: 20px;
border-radius: 10px;
text-align: center;
}
#countdown {
font-size: 18px;
margin-top: 20px;
text-align: center;
}
button {
margin-top: 10px;
}
</style>
</head>
<body>
<div id="overlay"></div>
<div id="popup">
<h3 id="popupTitle">تنبيه صلاة الفجر</h3>
<p id="popupMsg">حان الآن وقت صلاة الفجر</p>
<button onclick="closePopupAndStartReminder()">إغلاق</button>
</div>
<div id="countdown"></div>
<script>
let fajrTime = "04:07"; // وقت الفجر المحدد مسبقًا
let reminderTimeout;
let reminderShown = false;
function showPopup(title = "تنبيه", msg = "حان الآن وقت الصلاة") {
document.getElementById("popupTitle").textContent = title;
document.getElementById("popupMsg").textContent = msg;
document.getElementById("popup").style.display = "block";
document.getElementById("overlay").style.display = "block";
}
function closePopup() {
document.getElementById("popup").style.display = "none";
document.getElementById("overlay").style.display = "none";
}
function closePopupAndStartReminder() {
closePopup();
if (!reminderShown) {
let endReminderTime = new Date().getTime() + 5 * 60 * 1000;
localStorage.setItem("fajrReminderEnd", endReminderTime);
startReminderCountdown(endReminderTime);
}
}
function startReminderCountdown(endTime) {
reminderShown = true;
reminderTimeout = setInterval(() => {
let now = new Date().getTime();
if (now >= endTime) {
clearInterval(reminderTimeout);
localStorage.removeItem("fajrReminderEnd");
showPopup("تذكير", "يرجى قضاء صلاة الفجر");
}
}, 1000);
}
function startFajrAlert() {
showPopup("تنبيه صلاة الفجر", "حان الآن وقت صلاة الفجر");
}
function checkSavedReminder() {
let savedEndTime = localStorage.getItem("fajrReminderEnd");
if (savedEndTime) {
let now = new Date().getTime();
if (now < parseInt(savedEndTime)) {
startReminderCountdown(parseInt(savedEndTime));
} else {
localStorage.removeItem("fajrReminderEnd");
}
}
}
function updateCountdown() {
let now = new Date();
let [hour, minute] = fajrTime.split(":");
let fajrDate = new Date();
fajrDate.setHours(parseInt(hour));
fajrDate.setMinutes(parseInt(minute));
fajrDate.setSeconds(0);
if (fajrDate < now) {
fajrDate.setDate(fajrDate.getDate() + 1);
}
let diff = fajrDate - now;
let hours = Math.floor(diff / 1000 / 60 / 60);
let minutes = Math.floor((diff / 1000 / 60) % 60);
let seconds = Math.floor((diff / 1000) % 60);
document.getElementById("countdown").textContent =
`الوقت المتبقي لصلاة الفجر: ${hours} ساعة، ${minutes} دقيقة، ${seconds} ثانية`;
}
function scheduleFajr() {
let now = new Date();
let [hour, minute] = fajrTime.split(":");
let fajrDate = new Date();
fajrDate.setHours(parseInt(hour));
fajrDate.setMinutes(parseInt(minute));
fajrDate.setSeconds(0);
if (fajrDate < now) {
fajrDate.setDate(fajrDate.getDate() + 1);
}
let diff = fajrDate - now;
setTimeout(startFajrAlert, diff);
}
setInterval(updateCountdown, 1000);
checkSavedReminder();
scheduleFajr();
updateCountdown();
</script>
</body>
</html>


![[صورة مرفقة: 177461173141861.gif]](https://up6.cc/2026/03/177461173141861.gif)