diff --git a/index.html b/index.html
index 58e27a0ee..332ea0a1c 100644
--- a/index.html
+++ b/index.html
@@ -26,6 +26,9 @@
padding-bottom: 1rem;
padding-top: 1rem;
text-align:center;
+ }
+ .chip {
+ cursor: pointer;
}
@@ -62,19 +65,19 @@
-
+
diff --git a/index.js b/index.js
index acda07439..5d3b7834e 100644
--- a/index.js
+++ b/index.js
@@ -109,9 +109,23 @@ function showTab(tabname) {
}
// =========================================== Library
+
+var activeFilter = '';
+var currentSearch = '';
+
function refreshLibrary() {
var panelbody = document.querySelector("#librarycontainer .panel-body");
- panelbody.innerHTML = appJSON.map((app,idx) => {
+ var visibleApps = appJSON;
+
+ if (activeFilter) {
+ visibleApps = visibleApps.filter(app => app.tags && app.tags.split(',').includes(activeFilter));
+ }
+
+ if (currentSearch) {
+ visibleApps = visibleApps.filter(app => app.name.toLowerCase().includes(currentSearch) || app.tags.includes(currentSearch));
+ }
+
+ panelbody.innerHTML = visibleApps.map((app,idx) => {
var icon = "icon-upload";
if (app.custom)
icon = "icon-menu";
@@ -281,6 +295,24 @@ connectMyDeviceBtn.addEventListener("click", () => {
});
Comms.watchConnectionChange(handleConnectionChange);
+var filtersContainer = document.querySelector("#librarycontainer .filter-nav");
+filtersContainer.addEventListener('click', ({ target }) => {
+ if (!target.hasAttribute('filterid')) return;
+ if (target.classList.contains('active')) return;
+
+ activeFilter = target.getAttribute('filterid');
+ filtersContainer.querySelector('.active').classList.remove('active');
+ target.classList.add('active');
+ refreshLibrary();
+});
+
+var librarySearchInput = document.querySelector("#searchform input");
+
+librarySearchInput.addEventListener('input', evt => {
+ currentSearch = evt.target.value.toLowerCase();
+ refreshLibrary();
+});
+
// =========================================== About
document.getElementById("settime").addEventListener("click",event=>{