From 200d11ca99f1420a4fe5a06806772b494da838aa Mon Sep 17 00:00:00 2001 From: Woody Date: Sat, 2 Mar 2024 21:56:25 +0100 Subject: [PATCH 1/4] Revert "Fix preset sorting" This reverts commit 00038453e1fd15c8b8a3063badb8e00577737375. --- wled00/data/index.js | 45 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/wled00/data/index.js b/wled00/data/index.js index d42cef2aa..d88dc11ec 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -2794,7 +2794,6 @@ function search(field, listId = null) { if (!listId) return; const search = field.value !== ''; - const presets = listId === 'pcont'; // clear filter if searching in fxlist if (listId === 'fxlist' && search) { @@ -2806,7 +2805,7 @@ function search(field, listId = null) { const listItems = gId(listId).querySelectorAll('.lstI'); // filter list items but leave (Default & Solid) always visible - for (i = (presets ? 0 : 1); i < listItems.length; i++) { + for (i = (listId === 'pcont' ? 0 : 1); i < listItems.length; i++) { const listItem = listItems[i]; const listItemName = listItem.querySelector('.lstIname').innerText.toUpperCase(); const searchIndex = listItemName.indexOf(field.value.toUpperCase()); @@ -2814,30 +2813,28 @@ function search(field, listId = null) { listItem.dataset.searchIndex = searchIndex; } - if (!presets) { - // sort list items by search index and name - const sortedListItems = Array.from(listItems).sort((a, b) => { - const aSearchIndex = parseInt(a.dataset.searchIndex); - const bSearchIndex = parseInt(b.dataset.searchIndex); + // sort list items by search index and name + const sortedListItems = Array.from(listItems).sort((a, b) => { + const aSearchIndex = parseInt(a.dataset.searchIndex); + const bSearchIndex = parseInt(b.dataset.searchIndex); - if (aSearchIndex !== bSearchIndex) { - return aSearchIndex - bSearchIndex; - } - - const aName = a.querySelector('.lstIname').innerText.toUpperCase(); - const bName = b.querySelector('.lstIname').innerText.toUpperCase(); - - return aName.localeCompare(bName); - }); - sortedListItems.forEach(item => { - gId(listId).append(item); - }); - - // scroll to first search result - const firstVisibleItem = sortedListItems.find(item => item.style.display !== 'none' && !item.classList.contains('sticky') && !item.classList.contains('selected')); - if (firstVisibleItem && search) { - firstVisibleItem.scrollIntoView({ behavior: "instant", block: "center" }); + if (aSearchIndex !== bSearchIndex) { + return aSearchIndex - bSearchIndex; } + + const aName = a.querySelector('.lstIname').innerText.toUpperCase(); + const bName = b.querySelector('.lstIname').innerText.toUpperCase(); + + return aName.localeCompare(bName); + }); + sortedListItems.forEach(item => { + gId(listId).append(item); + }); + + // scroll to first search result + const firstVisibleItem = sortedListItems.find(item => item.style.display !== 'none' && !item.classList.contains('sticky') && !item.classList.contains('selected')); + if (firstVisibleItem && search) { + firstVisibleItem.scrollIntoView({ behavior: "instant", block: "center" }); } } From f25fadafd8489e85541d9b89dac70deddf094b81 Mon Sep 17 00:00:00 2001 From: Woody Date: Sun, 3 Mar 2024 15:16:10 +0100 Subject: [PATCH 2/4] fix preset sorting reordering bug --- wled00/data/index.htm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wled00/data/index.htm b/wled00/data/index.htm index a58c76da6..32a8c9b21 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -133,7 +133,7 @@

Color palette

- +
@@ -155,7 +155,7 @@

Effect mode

- +
@@ -274,7 +274,7 @@

Presets

- +
From 66f14c63437ba02468189b2aed061c8c6cff10ae Mon Sep 17 00:00:00 2001 From: Woody Date: Sun, 3 Mar 2024 15:58:30 +0100 Subject: [PATCH 3/4] restore default preset sorting if no search term is entered --- wled00/data/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wled00/data/index.js b/wled00/data/index.js index d88dc11ec..a735e1eae 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -2795,6 +2795,12 @@ function search(field, listId = null) { const search = field.value !== ''; + // restore default preset sorting if no search term is entered + if (listId === 'pcont' && !search) { + populatePresets(); + return; + } + // clear filter if searching in fxlist if (listId === 'fxlist' && search) { gId("filters").querySelectorAll("input[type=checkbox]").forEach((e) => { e.checked = false; }); From 2a480ab7db29d3ed45691cbf2722a8695c8f73b5 Mon Sep 17 00:00:00 2001 From: Woody Date: Tue, 5 Mar 2024 11:30:11 +0100 Subject: [PATCH 4/4] Revert "fix preset sorting reordering bug" This reverts commit f25fadafd8489e85541d9b89dac70deddf094b81. --- wled00/data/index.htm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wled00/data/index.htm b/wled00/data/index.htm index 32a8c9b21..a58c76da6 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -133,7 +133,7 @@

Color palette

- +
@@ -155,7 +155,7 @@

Effect mode

- +
@@ -274,7 +274,7 @@

Presets

- +