Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Verified Commit bf6ab324 authored by Carl Schwan's avatar Carl Schwan 🚴🏻

add search for applications

parent 759ec913
......@@ -22,3 +22,28 @@ let swiper = new Swiper('.swiper-container', {
prevEl: '.swiper-button-prev',
},
});
const search = document.getElementById('search');
search.addEventListener('input', function(e) {
const apps = document.querySelectorAll('.app');
const regex = new RegExp(e.target.value, 'i');
apps.forEach(function(app) {
if (app.querySelector('img').title.search(regex) !== -1) {
// app name is in search
if (app.classList.contains('d-none')) {
app.classList.remove('d-none');
}
} else if (!app.classList.contains('d-none')) {
app.classList.add('d-none');
}
});
const categories = document.querySelectorAll('.category');
categories.forEach(function(category) {
if (category.querySelectorAll('.app:not(.d-none)').length > 0 && category.classList.contains('d-none')) {
category.classList.remove('d-none');
} else if (category.querySelectorAll('.app:not(.d-none)').length === 0 && !category.classList.contains('d-none')) {
category.classList.add('d-none');
}
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment