function handleFile() {
const loadingIndicator = document.getElementById('loadingIndicator');
const reportContainer = document.getElementById('report');
const processBtn = document.getElementById('processBtn');
const printBtn = document.getElementById('printBtn');
try {
loadingIndicator.style.display = 'flex';
reportContainer.innerHTML = '';
processBtn.setAttribute('aria-busy', 'true');
processBtn.disabled = true;
printBtn.style.display = 'none';
const file = document.getElementById('excelFile').files[0];
if (!file) throw new Error("لطفاً یک فایل اکسل انتخاب کنید");
const reader = new FileReader();
reader.onload = function(e) {
try {
const data = new Uint8Array(e.target.result);
const workbook = XLSX.read(data, { type: 'array' });
if (workbook.SheetNames.length === 0) throw new Error("فایل انتخابی حاوی هیچ صفحهای نیست");
const sheetName = workbook.SheetNames[0];
const worksheet = workbook.Sheets[sheetName];
const jsonData = XLSX.utils.sheet_to_json(worksheet, { defval: null });
if (jsonData.length === 0) throw new Error("صفحه انتخابی حاوی دادهای نیست");
const students = jsonData.map(row => processStudent(row));
const reportHTML = students.map(student => generatePrintForm(student)).join("");
loadingIndicator.style.display = 'none';
reportContainer.innerHTML = reportHTML;
// Animate fade-in for each student card
document.querySelectorAll('.print-form').forEach((el, i) => {
el.classList.add('animate-fade-in');
el.style.animationDelay = `${i * 0.1}s`;
});
printBtn.style.display = 'inline-flex';
processBtn.setAttribute('aria-busy', 'false');
processBtn.disabled = false;
reportContainer.scrollIntoView({ behavior: 'smooth' });
} catch (error) {
loadingIndicator.style.display = 'none';
handleError(error);
}
};
reader.onerror = function() {
loadingIndicator.style.display = 'none';
handleError(new Error("خطا در خواندن فایل"));
};
reader.readAsArrayBuffer(file);
} catch (error) {
loadingIndicator.style.display = 'none';
handleError(error);
}
}
function handleError(error) {
console.error("Error:", error);
alert(error.message || "خطایی رخ داده است. لطفاً دوباره تلاش کنید.");
}
function processStudent(row) {
const gradeFields = {
'ریاضی': ['ریاضی7', 'ریاضی8', 'ریاضی9'],
'علوم': ['علوم7', 'علوم8', 'علوم9'],
'ادبیات فارسی': ['ادبیات7', 'ادبیات8', 'ادبیات9'],
'مطالعات اجتماعی': ['مطالعات7', 'مطالعات8', 'مطالعات9'],
'عربی': ['عربی7', 'عربی8', 'عربی9'],
'معارف اسلامی': ['معارف7', 'معارف8', 'معارف9'],
'کار و فناوری': ['کاروفناوری7', 'کاروفناوری8', 'کاروفناوری9'],
'فرهنگ و هنر': ['فرهنگ و هنر7', 'فرهنگ و هنر8', 'فرهنگ و هنر9']
};
const grades = {};
const averages = {};
for (const [subject, fields] of Object.entries(gradeFields)) {
const gradeData = {
g7: parseFloat(row[fields[0]]) || 0,
g8: parseFloat(row[fields[1]]) || 0,
g9: parseFloat(row[fields[2]]) || 0
};
grades[subject] = gradeData;
const weightedSum = (gradeData.g7 * 1) + (gradeData.g8 * 1) + (gradeData.g9 * 3);
const weight = 5;
averages[subject] = (weightedSum / weight).toFixed(2);
}
const student = {
name: row['نام'] || 'نامشخص',
family: row['نام خانوادگی'] || 'نامشخص',
nationalCode: row['کدملی'] || 'نامشخص',
school: row['مدرسه'] || 'مدرسه امام علی بن ابیطالب (ع)',
grades,
averages,
strengths: [],
weaknesses: []
};
determineFieldAndBranch(student);
analyzeStudentPerformance(student);
return student;
}
function determineFieldAndBranch(student) {
const avg = student.averages;
const math = parseFloat(avg['ریاضی']);
const sci = parseFloat(avg['علوم']);
const per = parseFloat(avg['ادبیات فارسی']);
const art = parseFloat(avg['فرهنگ و هنر']);
const tech = parseFloat(avg['کار و فناوری']);
const rel = parseFloat(avg['معارف اسلامی']);
const soc = parseFloat(avg['مطالعات اجتماعی']);
if (math >= 14 && sci >= 13) {
student.branch = "نظری";
student.field = "ریاضی و فیزیک";
}
else if (sci >= 14 && math >= 13) {
student.branch = "نظری";
student.field = "علوم تجربی";
}
else if (per >= 14 && rel >= 14) {
student.branch = "نظری";
student.field = "معارف اسلامی";
}
else if (per >= 14 && soc >= 12) {
student.branch = "نظری";
student.field = "علوم انسانی";
}
else if (art >= 12 && tech >= 12) {
student.branch = "فنی و حرفهای";
student.field = "هنر";
}
else if (tech >= 12) {
if (math >= 10) {
student.branch = "فنی و حرفهای";
student.field = "صنعت";
}
else if (sci >= 10) {
student.branch = "فنی و حرفهای";
student.field = "کشاورزی";
}
else {
student.branch = "فنی و حرفهای";
student.field = "خدمات";
}
}
else {
student.branch = "کار و دانش";
if (art >= 10) {
student.field = "هنر";
} else if (math >= 10) {
student.field = "صنعت";
} else if (sci >= 10) {
student.field = "کشاورزی";
} else {
student.field = "خدمات";
}
}
student.eligibleFields = {};
for (const branch in fieldsOfStudy) {
student.eligibleFields[branch] = {};
for (const field in fieldsOfStudy[branch]) {
const conditions = fieldsOfStudy[branch][field];
let isEligible = true;
for (const subject in conditions) {
if (subject !== 'توضیحات') {
const studentGrade = parseFloat(avg[subject]) || 0;
if (studentGrade < conditions[subject]) {
isEligible = false;
break;
}
}
}
student.eligibleFields[branch][field] = isEligible;
}
}
}
function analyzeStudentPerformance(student) {
const avg = student.averages;
if (parseFloat(avg['ریاضی']) >= 14) student.strengths.push('ریاضیات');
if (parseFloat(avg['علوم']) >= 14) student.strengths.push('علوم');
if (parseFloat(avg['ادبیات فارسی']) >= 14) student.strengths.push('ادبیات فارسی');
if (parseFloat(avg['فرهنگ و هنر']) >= 14) student.strengths.push('فرهنگ و هنر');
if (parseFloat(avg['کار و فناوری']) >= 14) student.strengths.push('کار و فناوری');
if (parseFloat(avg['ریاضی']) < 10) student.weaknesses.push('ریاضیات');
if (parseFloat(avg['علوم']) < 10) student.weaknesses.push('علوم');
if (parseFloat(avg['ادبیات فارسی']) < 10) student.weaknesses.push('ادبیات فارسی');
if (parseFloat(avg['کار و فناوری']) < 10) student.weaknesses.push('کار و فناوری');
if (student.strengths.length === 0) {
student.strengths.push('نیاز به بررسی بیشتر توسط مشاور');
}
}
function generatePrintForm(student) {
return `
نام و نام خانوادگی:
student.name{student.family}
کد ملی:
student.nationalCode</span></div><divclass="info−{student.school}
شاخه پیشنهادی:
{student.field}
Your particles effect does not show up because the container div with id particles-js is positioned behind all content and possibly obscured or not rendering correctly due to CSS stacking or size problems.
Here are some common reasons why particles.js does not show and how to fix it in your setup:
However, if your <body> or <html> (or any parent) element has no background color or is transparent, particles might not be visible or the negative z-index could push it behind the <body> background.
Fix suggestion:
Set a proper background color or gradient on body (e.g., dark or gradient that contrasts with the white particles).
Change the z-index of #particles-js to a low positive value, e.g., z-index: 0, and make sure content is at higher z-index (like your header and main content).
Example:
css
#particles-js {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 0; /* instead of -1 */
}
/* then make sure headers / other content are at z-index > 0 */
.dashboard-header {
position: sticky;
z-index: 1050;
}
2. Background Color for the Body or Container
Your body does not have a background color set explicitly. Since particles are white (#ffffff), if your background is also light, particles won't be visible.
Set a dark background on body to ensure white particles stand out:
css
body {
background-color: #1a202c; /* e.g., a dark blue/gray */
/* ...existing styles */
}
Or add a dark background directly to #particles-js, e.g.:
css
#particles-js {
background-color: #1a202c;
}
3. Order of scripts and initialization
Your particles.js script initialization is at the bottom, which is good; just make sure the particles.js library script is loaded before the initialization.
With z-index: -1 and no background color on <body>, the particles canvas is behind the page background and you probably see a white page with white particles—i.e., particles blended into background and invisible.
Negative z-index can push it behind even <html> background depending on browser, making it not shown.
If after changing these particles still do not show: check console for errors, test the particles initialization code in a minimal test page to confirm the CDN and config load correctly.
If you want, I can provide a minimal example snippet that shows particles.js working with your RTL page. Just ask!