/* Scordemy v4 — shared: urgency bar, header, exam clock math, countdown,
course card, bonus stack, section header. */
(() => {
const D = window.SC;
const { useState, useEffect } = React;
const { Ic, rupee, months, offPct, tel, fmtPh, Img, useUI } = window;
/* ---------- icons ---------- */
const Sv = ({ s = 18, w = 1.7, children }) => ;
Object.assign(Ic, {
gift: p => ,
bolt: p => ,
cal: p => ,
shield: p => ,
users: p => ,
trophy: p => ,
rewind: p => ,
target: p => ,
minus: p => ,
});
/* ---------- time + exam math ---------- */
const XTAG = { ssc: 'SSC CHSL', teacher: 'CTET', neet: 'NEET UG', apsc: 'APSC Prelims', govt: 'ADRE 3.0', police: 'Assam Police', judiciary: 'AJS' };
const nowMs = () => Math.max(Date.now(), D.today().getTime());
const OFFER_END = (() => { const t = D.today(); return new Date(t.getFullYear(), t.getMonth() + 1, 0, 23, 59, 59).getTime(); })();
const OFFER_LABEL = new Date(OFFER_END).toLocaleDateString('en-IN', { day: 'numeric', month: 'short' });
function examInfo(goal) {
const normalizedGoal = goal === 'tet' ? 'teacher' : goal;
const c = D.examCal[normalizedGoal] || D.examCal[goal]; if (!c) return null;
const days = c.date ? D.daysTo(c.date) : null;
return { ...c, goal: normalizedGoal, tag: XTAG[normalizedGoal] || XTAG[goal], days, plan: days != null ? days : c.assume };
}
function readiness(goal, hpd, delay = 0) {
const e = examInfo(goal); const days = Math.max(0, e.plan - delay);
const have = days * hpd; const pct = Math.min(100, Math.round(have / e.hours * 100));
return { days, have, need: e.hours, pct, tone: pct >= 100 ? 'ok' : pct >= 70 ? 'warn' : 'hot' };
}
const verdict = (t) => t === 'ok' ? 'On track if you start now' : t === 'warn' ? 'Tight. Start this week' : 'Behind. Start today';
function useNow(ms = 1000) {
const [n, setN] = useState(nowMs());
useEffect(() => { const t = setInterval(() => setN(nowMs()), ms); return () => clearInterval(t); }, []);
return n;
}
function Countdown({ to = OFFER_END, compact, dark }) {
const now = useNow(compact ? 30000 : 1000);
const d = Math.max(0, to - now);
const dd = Math.floor(d / 864e5), hh = Math.floor(d / 36e5) % 24, mm = Math.floor(d / 6e4) % 60, ss = Math.floor(d / 1e3) % 60;
const p = (v) => String(v).padStart(2, '0');
if (compact) return {dd}d {p(hh)}h {p(mm)}m;
return (
{[[dd, 'days'], [hh, 'hrs'], [mm, 'min'], [ss, 'sec']].map(([v, l]) => {p(v)}{l})}
);
}
function ExamChip({ goal, light }) {
const e = examInfo(goal); if (!e) return null;
const hot = e.state === 'scheduled' && e.days <= 60;
return (
{e.state === 'scheduled' ? <>{e.tag} in {e.days} days> : <>{e.tag}: expected {e.expect}>}
);
}
/* ---------- header chrome ---------- */
function UrgencyBar() {
const content = (window.ScordemyAPI && window.ScordemyAPI.Content && window.ScordemyAPI.Content.getContent()) || {};
const tickerData = content.global?.ticker || D.ticker || {};
if (tickerData.active === false) {
return null;
}
const badgeLabel = tickerData.badge_label || 'Exam clock';
const offerText = tickerData.offer_text || 'Free GK course with every batch';
const offerLink = tickerData.offer_link || '#/free';
const offerTarget = tickerData.offer_target ? new Date(tickerData.offer_target).getTime() : OFFER_END;
const supportPhone = (content.global?.contact?.support) || (D.PHONE && D.PHONE.support) || '9394893988';
let items = [];
if (Array.isArray(tickerData.items_processed) && tickerData.items_processed.length > 0) {
items = tickerData.items_processed.filter(i => i.active !== false);
} else if (Array.isArray(tickerData.items) && tickerData.items.length > 0) {
items = tickerData.items.filter(i => i.active !== false).map(i => ({
...i,
display_text: i.type === 'countdown' ? (i.days_left != null ? i.days_left + ' days left' : '') : (i.static_text || '')
}));
} else {
items = ['ssc', 'teacher', 'govt', 'apsc'].map(goal => {
const e = examInfo(goal);
return {
id: goal,
title: e ? e.tag : goal,
link: '#/exam/' + goal,
display_text: e ? (e.state === 'scheduled' ? e.days + ' days left' : 'exp. ' + e.expect) : ''
};
});
}
const offerPrefix = offerText.split(' with ')[0];
const offerSuffix = offerText.includes(' with ') ? ' with ' + offerText.split(' with ').slice(1).join(' with ') : '';
return (
);
}
/* ---------- dynamic landing page routing helpers ---------- */
function useLandingPages() {
const [assignments, setAssignments] = React.useState({});
React.useEffect(() => {
if (window.ScordemyAPI && window.ScordemyAPI.LandingPage) {
return window.ScordemyAPI.LandingPage.subscribe(setAssignments);
}
}, []);
return assignments;
}
function resolveButtonProps(buttonId, defaultProps, fallbackButtonId) {
defaultProps = defaultProps || {};
if (!window.ScordemyAPI || !window.ScordemyAPI.LandingPage) {
return defaultProps;
}
var lp = window.ScordemyAPI.LandingPage;
var assignment = lp.getButtonAssignment(buttonId) || (fallbackButtonId ? lp.getButtonAssignment(fallbackButtonId) : null);
if (!assignment || !assignment.url) {
return defaultProps;
}
var props = Object.assign({}, defaultProps);
props.href = assignment.url;
if (assignment.target === '_blank') {
props.target = '_blank';
props.rel = 'noopener noreferrer';
} else if (!defaultProps.target) {
props.target = undefined;
}
return props;
}
function handleButtonClick(buttonId, defaultAction, fallbackButtonId) {
return function(e) {
if (window.ScordemyAPI && window.ScordemyAPI.LandingPage) {
var lp = window.ScordemyAPI.LandingPage;
var assignment = lp.getButtonAssignment(buttonId) || (fallbackButtonId ? lp.getButtonAssignment(fallbackButtonId) : null);
if (assignment && assignment.url) {
if (e && e.preventDefault) e.preventDefault();
if (assignment.target === '_blank') {
window.open(assignment.url, '_blank', 'noopener,noreferrer');
} else {
window.location.href = assignment.url;
}
return;
}
}
if (typeof defaultAction === 'function') {
defaultAction(e);
}
};
}
Object.assign(window, { useLandingPages, resolveButtonProps, handleButtonClick });
function TopNav4({ route }) {
const { openSearch, openTalk, openMenu } = useUI();
useLandingPages();
const p = route.parts[0] || '';
const L = (h, l, on) => {l};
const content = (window.ScordemyAPI && window.ScordemyAPI.Content && window.ScordemyAPI.Content.getContent()) || {};
const header = content.global?.header || D.header || {};
const logoUrl = header.logo_url || '/assets/v3/logo.png';
const logoAlt = header.logo_alt || 'Scordemy';
const searchLbl = header.search_label || 'Search courses';
const counselLbl = header.counsel_btn || 'Free counselling';
const enrolLbl = header.enrol_btn || 'Enrol now';
const supportPhone = (content.global?.contact?.support) || (D.PHONE && D.PHONE.support) || '9394893988';
return (
{
if (e.currentTarget.dataset.fb) return;
e.currentTarget.dataset.fb = '1';
const fallback = window.SCORDEMY_WORDPRESS_CONFIG ? window.SCORDEMY_WORDPRESS_CONFIG.themeUrl + '/assets/v3/logo.png' : '/assets/v3/logo.png';
e.currentTarget.src = fallback;
}}
/>
{enrolLbl}
);
}
/* ---------- section header (no reveal dependency) ---------- */
function SH({ over, title, sub, right, center, dark }) {
return (
{over &&
{over}}
{title}
{sub &&
{sub}
}
{right}
);
}
/* ---------- price ---------- */
function Price({ c, size }) {
const off = offPct(c);
if (c.free) return Free
;
return {rupee(c.price)}{c.mrp && {rupee(c.mrp)}}{off > 0 && {off}% off}
;
}
/* ---------- course card ---------- */
const medium = (c) => c.medium === 'English & Assamese' ? 'Assamese + English' : c.medium;
function CourseCard4({ c, eager }) {
const g = (D.goals && D.goals[c.goal]) || { short: c.goal || 'Exam', id: c.goal };
const href = '#/course/' + c.slug;
let title = c.name;
try {
if (window.useLang) {
const { lang } = window.useLang();
if (lang === 1 && c.name_as) {
title = c.name_as;
}
}
} catch (e) {}
return (
{(c.tag || c.free) && {c.free ? 'Free' : c.tag}}
{g.short}{medium(c)}{months(c.dur)}
{c.feats.slice(0, 2).map((f, i) => - {f}
)}
{!c.free && c.slug !== 'gk-ca-full' && +5 free courses}
);
}
/* ---------- free bonus stack (supports dynamic WP c.bonuses + fallback D.bonus) ---------- */
function BonusStack({ c, tight }) {
const hasWpBonuses = c && Array.isArray(c.bonuses) && c.bonuses.length > 0;
const items = hasWpBonuses
? c.bonuses.map((b, i) => ({
k: 'wpb_' + i,
name: b.title,
note: [b.resource_type, b.description].filter(Boolean).join(' · '),
value: Number(b.original_value) || 0,
freeLabel: b.free_value || 'Free',
url: b.resource_url || ''
}))
: D.bonus.filter(b => !c || b.slug !== c.slug).map(b => ({ ...b, freeLabel: 'Free', url: '' }));
const total = items.reduce((a, b) => a + (Number(b.value) || 0), 0);
const base = c ? (c.mrp || c.price) : 0;
return (
Free with {c ? 'this batch' : 'every paid batch'}{items.length} {items.length === 1 ? 'bonus item' : 'bonus items'} worth {rupee(total)} · unlock the day you enrol
{items.map(b => (
-
{b.url ? {b.name} : b.name}
{b.note && {b.note}}
{b.value > 0 &&
{rupee(b.value)}}{b.freeLabel}
))}
{c && !c.free && (c.pricing ? c.pricing.show_price !== false : true) &&
Batch value{rupee(base)}
Bonus value+ {rupee(total)}
Total value{rupee(base + total)}
You pay{rupee(c.price)}
}
);
}
/* ---------- v5: plain exam status (replaces the % / days-math clock) ---------- */
function ExamStatus({ goal, dark, hpd = 3 }) {
const e = examInfo(goal); if (!e) return null;
const known = e.state === 'scheduled' && e.date;
const m = D.monthsAt(goal, hpd);
const statusTone = e.notice_tone === 'ok' ? 'ok' : (e.notice_tone === 'wait' ? 'wait' : (known ? 'ok' : 'wait'));
const noticeText = e.notice || (known ? 'Exam date announced' : 'Notification not out yet');
const rawStatus = (e.window_status || (known ? 'CONFIRMED' : 'TENTATIVE')).toString().toUpperCase().trim();
const allowedStatuses = ['TENTATIVE', 'EXPECTED', 'CONFIRMED', 'POSTPONED'];
const windowStatus = allowedStatuses.includes(rawStatus) ? rawStatus : 'TENTATIVE';
const statusClass = 'sc-status-' + windowStatus.toLowerCase();
const expectedText = e.expect || (known ? D.fmtDate(e.date) : '');
const studyHours = e.study_hours != null ? e.study_hours : hpd;
const studyMonths = e.study_months != null ? e.study_months : m;
return (
{noticeText}
{known ? (
Exam date
{windowStatus && (
{windowStatus}
)}
{expectedText || D.fmtDate(e.date)}
{e.days != null ? e.days + ' days to go' : ''}
) : (
Expected window
{windowStatus}
{expectedText}
Why this window
{e.last}
)}
Study {studyHours} hours a day and you can finish the full syllabus in about {studyMonths} {studyMonths === 1 ? 'month' : 'months'}.
);
}
/* ---------- v5: career / pay card (dynamic WordPress Posts & Salary + static fallback) ---------- */
function CareerCard({ goal, compact, examData }) {
const hasWpData = examData && (examData.configured || (Array.isArray(examData.posts) && examData.posts.length > 0));
if (hasWpData) {
const posts = Array.isArray(examData.posts) ? examData.posts : [];
const showSalaryGlobal = examData.show_salary !== false;
const ladder = Array.isArray(examData.ladder) ? examData.ladder : [];
const perks = Array.isArray(examData.perks) ? examData.perks : [];
const fmtSal = (p) => {
const unit = p.salary_unit === 'annual' ? '/year' : '/month';
const min = (p.min_salary || '').toString().trim();
const max = (p.max_salary || '').toString().trim();
const addRs = (v) => v && !/^₹|^rs/i.test(v) ? '₹' + v : v;
if (min && max) return addRs(min) + ' – ' + addRs(max) + ' ' + unit;
if (min) return 'From ' + addRs(min) + ' ' + unit;
if (max) return 'Up to ' + addRs(max) + ' ' + unit;
return '';
};
return (
{examData.section_description &&
{examData.section_description}
}
{posts.length > 0 ? (
{posts.map((p, idx) => {
const showSal = showSalaryGlobal && p.show_salary !== false;
const salRange = showSal ? fmtSal(p) : '';
return (
{p.post_name}
{p.vacancies && {p.vacancies} Vacancies}
{(p.department || p.job_category || p.employment_type) && (
{p.department && Dept: {p.department}}
{p.job_category && · {p.job_category}}
{p.employment_type && · {p.employment_type}}
)}
{p.qualification &&
Qualification: {p.qualification}
}
{p.description &&
{p.description}
}
{showSal && (salRange || p.pay_scale || p.grade_pay || p.salary_notes) && (
{salRange &&
{salRange}
}
{p.pay_scale &&
Pay Scale: {p.pay_scale}
}
{p.grade_pay &&
Grade Pay: {p.grade_pay}
}
{p.salary_notes &&
{p.salary_notes}
}
)}
);
})}
) : (
No post records published for this exam yet.
)}
{ladder.length > 0 && (
Where it leads
{ladder.map((s, i) => - {s}{i < ladder.length - 1 && }
)}
)}
{perks.length > 0 &&
{perks.map((p, i) => {p})}
}
{examData.source_url && (
Official reference: {examData.source_url}
)}
);
}
const k = D.career && D.career[goal];
if (!k) {
return (
Posts & Salary
Post vacancies and pay scale details for this exam have not been added yet.
);
}
return (
{k.line}
Pay scale
{k.pay.map(([r, a, b]) =>
{r}{a}{b}
)}
{k.inhand}
Where it leads
{k.ladder.map((s, i) => - {s}{i < k.ladder.length - 1 && }
)}
{k.perks.map(p => {p})}
);
}
Object.assign(window, { ExamStatus, CareerCard });
Object.assign(window, { XTAG, OFFER_END, OFFER_LABEL, examInfo, readiness, verdict, useNow, Countdown, ExamChip, UrgencyBar, TopNav4, SH, Price, CourseCard4, BonusStack, medium4: medium });
// Live preview postMessage listener for split-screen customizer synchronization
if (typeof window !== 'undefined' && !window.__scCustomizerListenerAttached) {
window.__scCustomizerListenerAttached = true;
window.addEventListener('message', function(ev) {
if (!ev || !ev.data || ev.data.type !== 'SC_CUSTOMIZER_SYNC') return;
var msg = ev.data;
if (msg.componentId) {
var els = document.querySelectorAll('[data-sc-component="' + msg.componentId + '"], [data-sc-alias="' + msg.componentId + '"]');
for (var i = 0; i < els.length; i++) {
var el = els[i];
if (el.tagName === 'EM' && msg.componentId.indexOf('window-status') !== -1) {
var val = (msg.value || '').toString().toUpperCase().trim();
el.textContent = val;
el.setAttribute('data-status', val);
el.className = 'sc-status-' + val.toLowerCase();
} else {
el.textContent = msg.value;
}
}
}
});
}
})();