mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 10:58:20 -07:00
feat: search bar for plugin catalogue
Adds a search bar to the `Catalogue` section, allowing you to filter the available plugins
This commit is contained in:
parent
8af09253c8
commit
3ef73904c1
@ -1,6 +1,10 @@
|
||||
<div id="pluginCatalogPage" data-role="page" class="page type-interior pluginConfigurationPage withTabs fullWidthContent">
|
||||
<div>
|
||||
<div class="content-primary">
|
||||
<div class="inputContainer">
|
||||
<label class="inputLabel" for="txtSearchPlugins">${Search}</label>
|
||||
<input id="txtSearchPlugins" name="txtSearchPlugins" type="text" is="emby-input" class="emby-input">
|
||||
</div>
|
||||
<div id="noPlugins" class="hide">${MessageNoAvailablePlugins}</div>
|
||||
<div id="pluginTiles" style="text-align:left;"></div>
|
||||
</div>
|
||||
|
@ -86,10 +86,37 @@ function populateList(options) {
|
||||
options.noItemsElement.classList.remove('hide');
|
||||
}
|
||||
|
||||
const searchBar = document.getElementById('txtSearchPlugins');
|
||||
if (searchBar) {
|
||||
searchBar.addEventListener('input', () => onSearchBarType(searchBar));
|
||||
}
|
||||
|
||||
options.catalogElement.innerHTML = html;
|
||||
loading.hide();
|
||||
}
|
||||
|
||||
function onSearchBarType(searchBar) {
|
||||
const filter = searchBar.value.toLowerCase();
|
||||
for (const header of document.querySelectorAll("div .verticalSection")) {
|
||||
// keep track of shown cards after each search
|
||||
let shown = 0;
|
||||
for (const card of header.querySelectorAll("div .card")) {
|
||||
if (filter && filter != '' && !card.textContent.toLowerCase().includes(filter)) {
|
||||
card.style.display = 'none';
|
||||
} else {
|
||||
card.style.display = 'unset';
|
||||
shown += 1;
|
||||
}
|
||||
}
|
||||
// hide title if no cards are shown
|
||||
if (shown <= 0) {
|
||||
header.style.display = 'none';
|
||||
} else {
|
||||
header.style.display = 'unset';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getPluginHtml(plugin, options, installedPlugins) {
|
||||
let html = '';
|
||||
let href = plugin.externalUrl ? plugin.externalUrl : '#/addplugin.html?name=' + encodeURIComponent(plugin.name) + '&guid=' + plugin.guid;
|
||||
|
Loading…
Reference in New Issue
Block a user