/* Add custom Js styles below */
(function () {
// === الشرائح المطلوبة ===
const SLIDES = [
{
title: "About Us",
author: "PEM STAT",
date: "2021-06-01",
cover: "https://i.postimg.cc/bw3CMW0B/Pin1-page-0001.jpg",
excerpt: "PEM STAT was designed in 2021 during our PEM fellowship to close training gaps.",
content_html: `
PEM STAT is a course designed back in 2021 during our fellowship training in Pediatric Emergency Medicine (PEM). As we were approaching the end of the first year of the training, we were able to identify the gaps and missing needs for the fellows to have an optimal training experience.
All the training programs in Saudi Arabia are under the umbrella of the Saudi Commission for Health Specialities (SCFHS). Dr. Al Shehri & Dr. Bakhshwain, the course founders, wrote the course curriculum and proposed the idea to SCFHS that year. 3 years later, this course became an integral part of the academic calendar of the fellowship program based on a unique quality which is; second year fellows will always teach the newly joining fellows in the first week on the academic year.
`
},
{
title: "Our Team",
author: "PEM STAT",
date: "2024-01-01",
cover: "https://i.postimg.cc/bw3CMW0B/Pin1-page-0001.jpg",
excerpt: "Meet the committee heads and contributors behind PEM STAT.",
content_html: `
Dr. Muath Albalawi
Head of Organizing Committee
Pediatrics & Pediatric Emergency Consultant
Ad Diriyah Hospital
Dr. Bader Alabdulkarim
Head of Scientific Committee
Pediatrics & Pediatric Emergency Consultant
King Saud University Medical City
Dr. Fahad Alharbi
Head of Media & Marketing Committee
Pediatrics & Pediatric Emergency Consultant
Deputy head of Pediatric Emergency Department - MCH Buraydah
Fellow at the Faculty Development Program, Ronald Reagan Institute of Emergency Medicine at the George Washington University
Created By Dr Ahmed Aloraini
`
},
{
title: "Registration",
author: "PEM STAT",
date: "2025-01-15",
cover: "https://i.postimg.cc/bw3CMW0B/Pin1-page-0001.jpg",
excerpt: "Reserve your seat for the next PEM STAT cohort.",
content_html: `
Seats are limited. Eligibility: PEM fellows and pediatric residents interested in emergency medicine.
How to register:
Fill the online form.
Upload program letter.
Await confirmation email.
Go to Registration →
`
},
{
title: "Testimonials",
author: "PEM STAT",
date: "2024-10-01",
cover: "https://i.postimg.cc/bw3CMW0B/Pin1-page-0001.jpg",
excerpt: "What fellows say about their PEM STAT experience.",
content_html: `
“PEM STAT made week-one clinical shifts much smoother.” — Second-year fellow
“High-yield, practical, and perfectly timed at the start of the year.” — New fellow
`
},
{
title: "Board members",
author: "PEM STAT",
date: "2024-05-01",
cover: "https://i.postimg.cc/bw3CMW0B/Pin1-page-0001.jpg",
excerpt: "Oversight and academic guidance for PEM STAT.",
content_html: `
Dr. Dhafer Al Shehri
Chairman
Emergency Medicine & Pediatric Emergency Consultant
Deputy head of Pediatric Emergency Department
King Saud Medical City
Dr. Amal Bakhshwain
Co-Chairman
Pediatrics & Pediatric Emergency Consultant at King Saud Medical City
Deputy program director of Pediatric Emergency Fellowship
Fellow at SickKids Hospital in Toronto, Canada
Harvard Macy Institute Alumna
Dr. Yara Al Goraini
Board Member
Pediatrics & Pediatric Emergency Consultant at King Fahad Medical City
Deputy head of Pediatric Emergency Department
Deputy program director of Pediatric Emergency Fellowship
Dr. Nouf Al Jahdali
Board Member
Pediatrics & Pediatric Emergency Consultant
King Abdullah Specialized Children Hospital
Fellow at SickKids Hospital in Toronto, Canada
Dr. Abdullah Akkam
Honorary Board Member
Pediatrics & Pediatric Emergency Consultant
The Head of the scientific committee of the Pediatric Emergency Department at King Saud Medical City
A member of the scientific committee of the Saudi PEM fellowship program at SCFHS
Created By Dr Ahmed Aloraini
`
},
{
title: "Flash cards",
author: "PEM STAT",
date: "2024-09-10",
cover: "https://i.postimg.cc/bw3CMW0B/Pin1-page-0001.jpg",
excerpt: "High-yield PEM flash cards for rapid recall.",
content_html: `
Quick scenarios and checklists covering airway, shock, seizures, trauma, and tox.
Airway steps & drug doses
Shock algorithm (cold vs. warm)
Status epilepticus protocol
Browse flash cards →
`
}
];
const fmt = new Intl.DateTimeFormat('ar-SA', { dateStyle: 'medium' });
const iconUser = () =>
' ';
const iconCalendar = () =>
' ';
function slideHTML(p, i) {
return `
${iconUser()} ${p.author || ''}
${iconCalendar()} ${fmt.format(new Date(p.date))}
${p.title}
${p.excerpt || ""}
قراءة المزيد ⟵
`;
}
function makeSection() {
const wrap = document.createElement('section');
wrap.className = 's-blog';
wrap.innerHTML = `
${SLIDES.map(slideHTML).join('')}
‹
›
`;
return wrap;
}
// نافذة واحدة للمحتوى
function ensureModal() {
let modal = document.querySelector('.s-about-modal');
if (modal) return modal;
modal = document.createElement('div');
modal.className = 's-about-modal';
modal.innerHTML = `
`;
document.body.appendChild(modal);
const panel = modal.querySelector('.s-about-panel');
const closeBtn = modal.querySelector('.s-about-close');
function open() {
modal.classList.add('is-open');
document.documentElement.style.overflow = 'hidden';
document.body.style.overflow = 'hidden';
}
function close() {
modal.classList.remove('is-open');
document.documentElement.style.overflow = '';
document.body.style.overflow = '';
}
modal.addEventListener('click', e => { if (e.target === modal) close(); });
panel.addEventListener('click', e => e.stopPropagation());
closeBtn.addEventListener('click', close);
document.addEventListener('keydown', e => { if (e.key === 'Escape' && modal.classList.contains('is-open')) close(); });
modal._open = open; modal._close = close;
modal._title = modal.querySelector('#about-title');
modal._content = modal.querySelector('.s-about-content');
return modal;
}
// ابحث عن أول بنر ثابت فقط
function findFirstFixedBanner() {
// مطابق للكلاس المذكور
let sec = document.querySelector('section.s-block.s-block--fixed-banner.wide-placeholder');
if (sec) return sec;
// احتياطي: أقرب لأول عنصر يحمل banner--fixed
const el = document.querySelector('a.banner--fixed, .banner--fixed img');
return el ? el.closest('section') : null;
}
// يحقن/ينقل الكاروسيل تحت أول بنر فقط
function mount() {
const target = findFirstFixedBanner();
const modal = ensureModal();
// إن وُجدت .s-blog مسبقًا ننقلها بدل تكرارها
let section = document.querySelector('.s-blog');
if (!section) section = makeSection();
if (target) {
target.insertAdjacentElement('afterend', section);
} else {
document.body.appendChild(section); // احتياطي
}
// === تهيئة الأسهم والسحب وفتح النافذة ===
const track = section.querySelector('.s-track');
const prevBtn = section.querySelector('.s-prev .s-btn');
const nextBtn = section.querySelector('.s-next .s-btn');
function updateButtons() {
const maxScroll = track.scrollWidth - track.clientWidth;
const x = Math.abs(track.scrollLeft);
prevBtn.disabled = x < 5;
nextBtn.disabled = x > maxScroll - 5;
}
function scrollByDir(dir) {
const step = Math.round(track.clientWidth * 0.92);
track.scrollBy({ left: dir * (document.dir === 'rtl' || track.dir === 'rtl' ? -step : step), behavior: 'smooth' });
setTimeout(updateButtons, 350);
}
prevBtn.addEventListener('click', () => scrollByDir(-1));
nextBtn.addEventListener('click', () => scrollByDir(1));
track.addEventListener('scroll', updateButtons, { passive: true });
updateButtons();
// فتح نافذة “قراءة المزيد”
section.addEventListener('click', (e) => {
const a = e.target.closest('[data-open]');
if (!a) return;
e.preventDefault();
const i = +a.getAttribute('data-open');
const p = SLIDES[i];
modal._title.textContent = p.title;
modal._content.innerHTML = p.content_html || '';
modal._open();
});
// سحب بالماوس
let isDown = false, startX = 0, startLeft = 0;
track.addEventListener('mousedown', (e) => { isDown = true; startX = e.clientX; startLeft = track.scrollLeft; track.classList.add('grabbing'); });
window.addEventListener('mouseup', () => { isDown = false; track.classList.remove('grabbing'); });
window.addEventListener('mousemove', (e) => {
if (!isDown) return;
const dx = e.clientX - startX;
track.scrollLeft = startLeft - dx * (document.dir === 'rtl' || track.dir === 'rtl' ? -1 : 1);
});
}
// يراقب ظهور أول بنر ثم يحقن تحته (مرة واحدة)
function start() {
const t = findFirstFixedBanner();
if (t) { mount(); return; }
const obs = new MutationObserver(() => {
const found = findFirstFixedBanner();
if (found) { obs.disconnect(); mount(); }
});
obs.observe(document.documentElement, { childList: true, subtree: true });
setTimeout(() => obs.disconnect(), 10000);
}
// تشغيل
(document.readyState === 'loading') ? document.addEventListener('DOMContentLoaded', start) : start();
})();