diff --git a/src/gui/html/index.html b/src/gui/html/index.html
index 61054f55..0198677d 100644
--- a/src/gui/html/index.html
+++ b/src/gui/html/index.html
@@ -477,7 +477,6 @@
-
diff --git a/src/gui/html/js/events.js b/src/gui/html/js/events.js
index d0083196..6d411da9 100644
--- a/src/gui/html/js/events.js
+++ b/src/gui/html/js/events.js
@@ -6,7 +6,7 @@ function onSidebarFilterToggle(evt) {
} else {
loot.filters.contentSearchString = evt.target.value;
}
- filterPluginData(loot.game.plugins, loot.filters);
+ loot.filters.apply(loot.game.plugins);
}
function onJumpToGeneralInfo() {
document.getElementById('pluginCardList').scroll(0, 0);
@@ -38,7 +38,7 @@ function onChangeGame(evt) {
loot.Filters.fillConflictsFilterList(loot.game.plugins);
/* Now update virtual lists. */
- filterPluginData(loot.game.plugins, loot.filters);
+ loot.filters.apply(loot.game.plugins);
loot.Dialog.closeProgress();
}).catch(loot.handlePromiseError);
@@ -74,7 +74,7 @@ function onUpdateMasterlist() {
function onSortPlugins() {
if (loot.filters.deactivateConflictsFilter()) {
/* Conflicts filter was undone, update the displayed cards. */
- filterPluginData(loot.game.plugins, loot.filters);
+ loot.filters.apply(loot.game.plugins);
}
let promise = Promise.resolve();
@@ -129,7 +129,7 @@ function onSortPlugins() {
/* Now update the UI for the new order. */
loot.game.plugins = loot.game.loadOrder;
- filterPluginData(loot.game.plugins, loot.filters);
+ loot.filters.apply(loot.game.plugins);
loot.state.enterSortingState();
@@ -150,7 +150,7 @@ function onCancelSort() {
return loot.query('cancelSort').then(JSON.parse).then((messages) => {
/* Sort UI elements again according to stored old load order. */
loot.game.plugins = loot.game.oldLoadOrder;
- filterPluginData(loot.game.plugins, loot.filters);
+ loot.filters.apply(loot.game.plugins);
delete loot.game.loadOrder;
delete loot.game.oldLoadOrder;
@@ -238,7 +238,7 @@ function onContentRefresh() {
loot.Filters.fillConflictsFilterList(loot.game.plugins);
/* Reapply filters. */
- filterPluginData(loot.game.plugins, loot.filters);
+ loot.filters.apply(loot.game.plugins);
loot.Dialog.closeProgress();
}).catch(loot.handlePromiseError);
@@ -421,12 +421,12 @@ function onConflictsFilter(evt) {
gamePlugin.update(plugin);
}
});
- filterPluginData(loot.game.plugins, loot.filters);
+ loot.filters.apply(loot.game.plugins);
loot.Dialog.closeProgress();
}).catch(loot.handlePromiseError);
} else {
loot.filters.deactivateConflictsFilter();
- filterPluginData(loot.game.plugins, loot.filters);
+ loot.filters.apply(loot.game.plugins);
}
}
function onCopyMetadata(evt) {
diff --git a/src/gui/html/js/filters.js b/src/gui/html/js/filters.js
index 40c5609b..f3f2b391 100644
--- a/src/gui/html/js/filters.js
+++ b/src/gui/html/js/filters.js
@@ -97,6 +97,32 @@
}).catch(handlePromiseError);
}
+ apply(plugins) {
+ const filteredPlugins = plugins.filter(this.pluginFilter, this);
+
+ document.getElementById('cardsNav').items = filteredPlugins;
+ document.getElementById('pluginCardList').items = filteredPlugins;
+
+ const pluginCards = document.getElementById('pluginCardList').children;
+ for (let i = 0; i < pluginCards.length; ++i) {
+ if (pluginCards[i].data) {
+ pluginCards[i].updateContent(true);
+ }
+ }
+ document.getElementById('cardsNav').notifyResize();
+ document.getElementById('pluginCardList').notifyResize();
+
+ /* Now perform search again. If there is no current search, this won't
+ do anything. */
+ document.getElementById('searchBar').search();
+
+ /* Re-count all hidden plugins and messages. */
+ document.getElementById('hiddenPluginNo').textContent = plugins.length - filteredPlugins.length;
+ document.getElementById('hiddenMessageNo').textContent = plugins.reduce((previousValue, currentValue) => (
+ previousValue + currentValue.messages.length - currentValue.getCardContent(this).messages.length
+ ), 0);
+ }
+
static fillConflictsFilterList(plugins) {
const list = document.getElementById('conflictsFilter');
diff --git a/src/gui/html/js/helpers.js b/src/gui/html/js/helpers.js
deleted file mode 100644
index 0e1012e8..00000000
--- a/src/gui/html/js/helpers.js
+++ /dev/null
@@ -1,28 +0,0 @@
-'use strict';
-function filterPluginData(plugins, filters) {
- const filteredPlugins = plugins.filter(filters.pluginFilter, filters);
-
- document.getElementById('cardsNav').items = filteredPlugins;
- document.getElementById('pluginCardList').items = filteredPlugins;
-
- const pluginCards = document.getElementById('pluginCardList').children;
- for (let i = 0; i < pluginCards.length; ++i) {
- if (pluginCards[i].data) {
- pluginCards[i].updateContent(true);
- }
- }
- document.getElementById('cardsNav').notifyResize();
- document.getElementById('pluginCardList').notifyResize();
-
- /* Now perform search again. If there is no current search, this won't
- do anything. */
- document.getElementById('searchBar').search();
-
- /* Re-count all hidden plugins and messages. */
- document.getElementById('hiddenPluginNo').textContent = plugins.length - filteredPlugins.length;
- let hiddenMessageNo = 0;
- plugins.forEach((plugin) => {
- hiddenMessageNo += plugin.messages.length - plugin.getCardContent(filters).messages.length;
- });
- document.getElementById('hiddenMessageNo').textContent = hiddenMessageNo;
-}
diff --git a/src/gui/html/js/initialise.js b/src/gui/html/js/initialise.js
index 00183792..df97f1db 100644
--- a/src/gui/html/js/initialise.js
+++ b/src/gui/html/js/initialise.js
@@ -134,7 +134,7 @@
|| filters.hideNotes
|| filters.hideDoNotCleanMessages
|| filters.hideAllPluginMessages) {
- filterPluginData(plugins, filters);
+ filters.apply(plugins);
}
if (filters.hideVersionNumbers) {