أخبار الاقتصاد

زر الذهاب إلى الأعلى
(function(){ // ===== الساعة (عربي بالكلمات + أرقام إنجليزي) var el = document.getElementById('nxbarClock'); function toEnDigits(s){ return s .replace(/[\u0660-\u0669]/g, c => String(c.charCodeAt(0)-0x0660)) .replace(/[\u06F0-\u06F9]/g, c => String(c.charCodeAt(0)-0x06F0)); } function tick(){ try{ var d = new Date(); var dateAr = new Intl.DateTimeFormat('ar-EG',{weekday:'long',month:'long',day:'numeric',year:'numeric'}).format(d); var dateStr = toEnDigits(dateAr); var timeStr = new Intl.DateTimeFormat('en-GB',{hour:'2-digit',minute:'2-digit',hour12:false}).format(d); if(el) el.textContent = dateStr + ' — ' + timeStr; }catch(e){ if(el) el.textContent = new Date().toLocaleString('en-GB'); } } tick(); setInterval(tick, 30000); // ===== بحث REST — عناوين فقط const form = document.getElementById('nxbarSearchForm'); const input = document.getElementById('nxbarSearchInput'); const box = document.getElementById('nxbarSearchResults'); if(!form || !input || !box) return; const REST = ""; let t, ctrl; function highlight(title, q){ const i = title.toLowerCase().indexOf(q.toLowerCase()); if(i < 0) return title; return title.slice(0,i) + '' + title.slice(i, i+q.length) + '' + title.slice(i+q.length); } async function doSearch(q){ const qs = encodeURIComponent(q); const url = `${REST}?search=${qs}&subtype=post&_fields=title,url&per_page=8`; if(ctrl) ctrl.abort(); ctrl = new AbortController(); const res = await fetch(url, {signal: ctrl.signal, headers:{'Accept':'application/json'}}); if(!res.ok) return []; const data = await res.json(); // فلترة صارمة: العنوان يحتوي الكلمة return (data||[]).filter(it => (it?.title || '').toLowerCase().includes(q.toLowerCase())); } function render(list, q){ if(!list.length){ box.innerHTML = 'لا توجد نتائج'; box.classList.add('show'); input.setAttribute('aria-expanded','true'); return; } box.innerHTML = list.map(it => `${highlight(it.title, q)}` ).join(''); box.classList.add('show'); input.setAttribute('aria-expanded','true'); } input.addEventListener('input', ()=>{ if(t) clearTimeout(t); const q = (input.value||'').trim(); if(q.length < 2){ box.classList.remove('show'); box.innerHTML=''; input.setAttribute('aria-expanded','false'); return; } t = setTimeout(async ()=>{ try{ render(await doSearch(q), q); }catch(e){ box.classList.remove('show'); } }, 220); }); form.addEventListener('submit', (e)=>{ e.preventDefault(); const first = box.querySelector('a[href]'); if(first) window.location.href = first.getAttribute('href'); }); document.addEventListener('click', (ev)=>{ if(!form.contains(ev.target)){ box.classList.remove('show'); input.setAttribute('aria-expanded','false'); } }); })();