توفي الفنان المصري محمود ياسين عن عمر ناهز 79 عاما بعد صراع طويل مع المرض.
0;
if (clearWrapper) clearWrapper.style.display = hasVal ? 'flex' : 'none';
searchBtn.disabled = !hasVal;
}
function showSuggestions(val) {
if (!suggestionsEl) return;
var lower = val.toLowerCase();
var visible = 0;
items.forEach(function (item) {
var match = item.dataset.value.toLowerCase().indexOf(lower) !== -1;
item.style.display = match ? '' : 'none';
if (match) visible++;
});
suggestionsEl.style.display = visible > 0 ? 'block' : 'none';
}
input.addEventListener('input', function () {
syncControls(this.value);
showSuggestions(this.value);
});
input.addEventListener('focus', function () {
showSuggestions(this.value);
});
input.addEventListener('blur', function () {
setTimeout(function () {
if (suggestionsEl) suggestionsEl.style.display = 'none';
}, 200);
});
input.addEventListener('keydown', function (e) {
if (e.key === 'Enter' && this.value) navigate(this.value);
});
searchBtn.addEventListener('click', function () {
navigate(input.value);
});
if (clearBtn) {
clearBtn.addEventListener('click', function () {
input.value = '';
syncControls('');
if (suggestionsEl) suggestionsEl.style.display = 'none';
input.focus();
});
}
items.forEach(function (item) {
item.addEventListener('mousedown', function () {
var val = this.dataset.value;
input.value = val;
syncControls(val);
navigate(val);
});
});
// Pre-populate if there is an existing search query
if (input.value) syncControls(input.value);
// Typing animation
var typingEl = document.getElementById('sa-typing-text');
if (typingEl && saData.calls_to_action.length > 0) {
var phrases = saData.calls_to_action;
var phraseIndex = 0;
var charIndex = 0;
var deleting = false;
var SPEED = 125;
var PAUSE = 5000;
function tick() {
var phrase = phrases[phraseIndex];
if (!deleting) {
typingEl.textContent = phrase.substring(0, charIndex + 1);
charIndex++;
if (charIndex === phrase.length) {
deleting = true;
setTimeout(tick, PAUSE);
return;
}
} else {
typingEl.textContent = phrase.substring(0, charIndex - 1);
charIndex--;
if (charIndex === 0) {
deleting = false;
phraseIndex = (phraseIndex + 1) % phrases.length;
}
}
setTimeout(tick, SPEED);
}
tick();
}
});
}());