// script.js document.addEventListener('DOMContentLoaded', () => { // التعامل مع التبويبات const tabButtons = document.querySelectorAll('.tab-btn'); const tabContents = document.querySelectorAll('.tab-content'); tabButtons.forEach(btn => { btn.addEventListener('click', () => { // تفعيل زر التبويب المحدد tabButtons.forEach(b => b.classList.remove('active')); btn.classList.add('active'); // إظهار المحتوى المناسب const target = btn.getAttribute('data-tab'); tabContents.forEach(tc => { if(tc.id === `${target}-tab`) { tc.classList.add('active'); } else { tc.classList.remove('active'); } }); }); }); // دوال الحسابات لكل تحليل // حساب الرطوبة document.querySelector('.calculate-moisture').addEventListener('click', () => { const wet = parseFloat(document.getElementById('sample-weight').value) || 0; const dry = parseFloat(document.getElementById('dry-weight').value) || 0; if(wet <= 0 || dry < 0 || dry > wet){ alert('يرجى إدخال أوزان صحيحة حيث يجب أن يكون وزن العينة الرطبة أكبر من وزن العينة بعد التجفيف.'); return; } const moisture = ((wet - dry) / wet) * 100; document.getElementById('moisture-result').textContent = moisture.toFixed(2); let interpretation = ''; if (moisture < 10) interpretation = 'نسبة رطوبة منخفضة'; else if (moisture < 20) interpretation = 'نسبة رطوبة متوسطة'; else interpretation = 'نسبة رطوبة عالية'; document.getElementById('moisture-interpretation').textContent = interpretation; // تحديث الملخص updateSummary('moisture', moisture, interpretation); }); // حساب الرماد document.querySelector('.calculate-ash').addEventListener('click', () => { const crucibleEmpty = parseFloat(document.getElementById('crucible-weight').value) || 0; const crucibleSample = parseFloat(document.getElementById('crucible-sample').value) || 0; const crucibleAsh = parseFloat(document.getElementById('ash-weight').value) || 0; if(crucibleEmpty <= 0 || crucibleSample <= 0 || crucibleAsh <= 0 || crucibleSample < crucibleEmpty || crucibleAsh < crucibleEmpty){ alert('يرجى إدخال أوزان صحيحة حيث يجب أن يكون وزن البوتقة + العينة ووزن البوتقة + الرماد أكبر من وزن البوتقة الفارغة.'); return; } const sampleWeight = crucibleSample - crucibleEmpty; const ashWeight = crucibleAsh - crucibleEmpty; const ashPercent = (ashWeight / sampleWeight) * 100; document.getElementById('ash-result').textContent = ashPercent.toFixed(2); let interpretation = ''; if (ashPercent < 1) interpretation = 'نسبة رماد منخفضة'; else if (ashPercent < 5) interpretation = 'نسبة رماد متوسطة'; else interpretation = 'نسبة رماد عالية'; document.getElementById('ash-interpretation').textContent = interpretation; updateSummary('ash', ashPercent, interpretation); }); // حساب البرو