منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[كود] اريد كود جافا نافذه تخرج بين وقتين - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (https://vb4arb.com/vb)
+-- قسم : قسم لغات البرمجة الاخرى (https://vb4arb.com/vb/forumdisplay.php?fid=4)
+--- قسم : قسم لغة Java (https://vb4arb.com/vb/forumdisplay.php?fid=17)
+--- الموضوع : [كود] اريد كود جافا نافذه تخرج بين وقتين (/showthread.php?tid=56187)

الصفحات: 1 2


RE: اريد كود جافا نافذه تخرج بين وقتين - Amir_Alzubidy - 24-03-26

(24-03-26, 07:20 PM)nnnjk كتب : يعطيك العافيه حبذا  وقت الصلاه يكون بصيغة 24  ساعه مثلا 20:25
بدل تحديد عدد الساعات h وعدد الدقائق m

PHP كود :
<!DOCTYPE html>
<
html>
<
head>
    <title>تذكير الصلاة</title>
</
head>
<
body>

<
script>
// أوقات الصلاة بصيغة 24 ساعة مباشرة
let prayerTimes = [
    name"الفجر"time"05:30" },
    name"الظهر"time"12:30" },
    name"العصر"time"15:45" },
    name"المغرب"time"18:15" },
    name"العشاء"time"20:25" }
];

// منع التكرار
let notified = {};

// تحويل "HH:MM" إلى دقائق
function toMinutes(timeStr) {
    let parts timeStr.split(":");
    return parseInt(parts[0]) * 60 parseInt(parts[1]);
}

function 
checkTime() {
    let now = new Date();
    let current now.getHours() * 60 now.getMinutes();

    for (let i 0prayerTimes.lengthi++) {
        let p prayerTimes[i];

        let start toMinutes(p.time);
        let end start 5// 5 دقائق تنبيه

        if (current >= start && current <= end && !notified[p.name]) {
            alert("حان وقت صلاة " p.name);
            notified[p.name] = true;
        }
    }

    // تصفير يومي
    if (current === 0) {
        notified = {};
    }
}

// فحص كل دقيقة
setInterval(checkTime60000);
checkTime();
</
script>

</
body>
</
html



RE: اريد كود جافا نافذه تخرج بين وقتين - nnnjk - 24-03-26

ظبط الكود بارك الله فيك


RE: اريد كود جافا نافذه تخرج بين وقتين - Amir_Alzubidy - 24-03-26

(24-03-26, 08:12 PM)nnnjk كتب : ظبط الكود بارك الله فيك

PHP كود :
<!DOCTYPE html>
<
html lang="ar">
<
head>
<
meta charset="UTF-8">
<
meta name="viewport" content="width=device-width, initial-scale=1.0">
<
title>تذكير الصلاة</title>

<
style>
body {
    font-familyArialsans-serif;
    backgroundlinear-gradient(135deg#020617, #0f172a);
    colorwhite;
    text-aligncenter;
    padding20px;
}

.
container {
    max-width450px;
    marginauto;
    background#111827;
    padding25px;
    border-radius25px;
    box-shadow0 0 40px rgba(0,0,0,0.7);
}

h1 {
    font-size48px;
    margin10px 0;
    color#FFD700; /* الساعة الذهبية */
}

.
next {
    color#38bdf8;
    font-size20px;
}

.
countdown {
    font-size22px;
    margin10px 0;
    color#facc15;
}

.
prayer {
    margin6px 0;
    padding12px;
    border-radius12px;
    background#020617;
    transition0.3s;
    font-size18px;
}

.
prayer.active {
    background#22c55e;
    colorblack;
    transformscale(1.05);
}

.
prayer span.amPm {
    font-size12px;
    color#facc15;
    margin-left5px;
}

input {
    width65%;
    max-width200px;
    padding8px 6px;
    border-radius10px;
    bordernone;
    text-aligncenter;
    margin5px auto;
    displayblock;
    background#1e293b;
    colorwhite;
    font-size16px;
    transition0.3s;
}

input:hover {
    background#334155;
}

button#saveBtn {
    margin10px auto;
    displayblock;
    padding10px 20px;
    border-radius12px;
    bordernone;
    background#FFD700;
    colorblack;
    font-weightbold;
    cursorpointer;
    transitionall 0.3s;
}

button#saveBtn:hover {
    background#e6c200;
}

#inputs, #saveBtn {
    opacity0;
    max-height0;
    transitionall 0.5s ease;
    overflowhidden;
}

#inputs.show, #saveBtn.show {
    opacity1;
    max-height250px;
}

h3 {
    cursorpointer;
    margin-top15px;
    transition0.3s;
}

h3:hover {
    color#38bdf8;
}
</
style>
</
head>
<
body>

<
div class="container">
    <h2>? تذكير الصلاة</h2>
    <h1 id="clock">--:--</h1>

    <div class="next" id="nextPrayer">...</div>
    <div class="countdown" id="countdown">--</div>

    <div id="list"></div>

    <h3 onclick="toggleInputs()">⚙️ تعديل الأوقات</h3>
    <div id="inputs"></div>
    <button id="saveBtn" onclick="saveTimes()">حفظ ?</button>
</
div>

<
audio id="adhan" src="https://cdn.islamic.network/audio/adhan/adhan.mp3"></audio>

<
script>
let defaultTimes = [
    name"الفجر"time"05:30" },
    name"الظهر"time"12:30" },
    name"العصر"time"15:45" },
    name"المغرب"time"18:15" },
    name"العشاء"time"20:25" }
];

let prayerTimes JSON.parse(localStorage.getItem("prayerTimes")) || defaultTimes;
let notified = {};

if (
Notification.permission !== "granted") {
    Notification.requestPermission();
}

function 
toMinutes(t) {
    let [hm] = t.split(":");
    return parseInt(h) * 60 parseInt(m);
}

// AM/PM للساعه الكبيرة فقط
function formatAmPmHour(date) {
    return date.getHours() < 12 "AM" "PM";
}

function 
updateClock() {
    let now = new Date();
    let h String(now.getHours()).padStart(2,'0');
    let m String(now.getMinutes()).padStart(2,'0');
    let ampm formatAmPmHour(now);
    document.getElementById("clock").innerText = `${h}:${m} ${ampm}`;
}

function 
getNextPrayerData(current) {
    for (let p of prayerTimes) {
        let time toMinutes(p.time);
        if (time current) return { namep.nametimep.timedifftime current };
    }
    let fajr prayerTimes[0];
    return { namefajr.nametimefajr.timediff: (1440-current)+toMinutes(fajr.time) };
}

function 
renderList(current) {
    let html "";
    for (let p of prayerTimes) {
        let start toMinutes(p.time);
        let end start 5;
        let active = (current >= start && current <= end) ? "active" "";
        html += `<div class="prayer ${active}">
                    <span>
${p.name} - ${p.time}</span>
                    <span class="amPm">
${p.time "12:00" "AM":"PM"}</span>
                 </div>
`;
    }
    document.getElementById("list").innerHTML html;
}

function 
updateCountdown(diff) {
    let h Math.floor(diff/60);
    let m diff 60;
    document.getElementById("countdown").innerText = `⏳ بعد ${h} ساعة و ${m} دقيقة`;
}

function 
checkPrayer() {
    let now = new Date();
    let current now.getHours()*60 now.getMinutes();

    let next getNextPrayerData(current);
    document.getElementById("nextPrayer").innerText = `الصلاة القادمة: ${next.name} (${next.time})`;

    updateCountdown(next.diff);
    renderList(current);

    for (let p of prayerTimes) {
        let start toMinutes(p.time);
        let end start 5;
        if (current >= start && current <= end && !notified[p.name]) {
            alert("? حان وقت صلاة " p.name);
            if (Notification.permission==="granted") {
                new Notification("وقت الصلاة",{body:"حان وقت صلاة "+p.name});
            }
            document.getElementById("adhan").play();
            notified[p.name] = true;
        }
        if (current end && notified[p.name]) notified[p.name] = false;
    }
    if (current===0notified={};
}

function 
renderInputs() {
    let html "";
    for (let i=0;i<prayerTimes.length;i++){
        html += `<input type="time" id="t${i}" value="${prayerTimes[i].time}">`;
    }
    document.getElementById("inputs").innerHTML html;
}

function 
saveTimes() {
    for (let i=0;i<prayerTimes.length;i++){
        prayerTimes[i].time document.getElementById("t"+i).value;
    }
    localStorage.setItem("prayerTimes"JSON.stringify(prayerTimes));
    alert("تم الحفظ ✅");
    document.getElementById("inputs").classList.remove("show");
    document.getElementById("saveBtn").classList.remove("show");
}

function 
toggleInputs() {
    let inputs document.getElementById("inputs");
    let btn document.getElementById("saveBtn");
    inputs.classList.toggle("show");
    btn.classList.toggle("show");
    if (inputs.classList.contains("show")) {
        let lastInput inputs.querySelector("input:last-child");
        if (lastInputlastInput.scrollIntoView({behavior:"smooth",block:"center"});
    }
}

setInterval(()=>{updateClock(); checkPrayer();},1000);
updateClock(); checkPrayer(); renderInputs();
</
script>

</
body>
</
html