mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Implemented conflicts filter.
However, I've noticed that the checkbox never actually changes state, despite the `changed` event, so the checkbox always `checked` as true.
This commit is contained in:
@@ -4,6 +4,7 @@ var filters = {
|
||||
|
||||
hiddenPluginNo: 0,
|
||||
hiddenMessageNo: 0,
|
||||
conflicts: [],
|
||||
|
||||
searchFilter: function(plugin, needle) {
|
||||
if (needle.length == 0) {
|
||||
@@ -70,6 +71,14 @@ var filters = {
|
||||
}
|
||||
},
|
||||
|
||||
conflictsFilter: function(plugin) {
|
||||
if (this.conflicts.length > 0) {
|
||||
return this.conflicts.indexOf(plugin.name) != -1;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
applyPluginFilters: function(plugins) {
|
||||
var search = document.getElementById('searchBox').value.toLowerCase();
|
||||
hiddenPluginNo = 0;
|
||||
@@ -80,6 +89,7 @@ var filters = {
|
||||
/* Messageless filter needs to run first. */
|
||||
if (this.messagelessFilter(plugin)
|
||||
&& this.inactiveFilter(plugin)
|
||||
&& this.conflictsFilter(plugin)
|
||||
&& this.searchFilter(plugin, search)) {
|
||||
|
||||
filteredPlugins.push(plugin);
|
||||
@@ -137,13 +147,20 @@ var filters = {
|
||||
};
|
||||
|
||||
function setFilteredUIData(evt) {
|
||||
var filtered = filters.applyPluginFilters(loot.game.plugins);
|
||||
document.getElementById('cardsNav').lastElementChild.data = filtered;
|
||||
document.getElementById('main').lastElementChild.data = filtered;
|
||||
/* The conflict filter, if enabled, executes C++ code, so needs to be
|
||||
handled using a promise, so the rest of the function should wait until
|
||||
it is completed.
|
||||
*/
|
||||
getConflictingPluginsFromFilter().then(function(conflicts) {
|
||||
filters.conflicts = conflicts;
|
||||
var filtered = filters.applyPluginFilters(loot.game.plugins);
|
||||
document.getElementById('cardsNav').lastElementChild.data = filtered;
|
||||
document.getElementById('main').lastElementChild.data = filtered;
|
||||
|
||||
/* Also run message filters on the current card elements. */
|
||||
var cards = document.getElementById('main').getElementsByTagName('loot-plugin-card');
|
||||
for (var i = 0; i < cards.length; ++i) {
|
||||
cards[i].onMessagesChange(); // Calls Plugin.getUIMessages(), which calls filters.applyMessageFilters().
|
||||
}
|
||||
/* Also run message filters on the current card elements. */
|
||||
var cards = document.getElementById('main').getElementsByTagName('loot-plugin-card');
|
||||
for (var i = 0; i < cards.length; ++i) {
|
||||
cards[i].onMessagesChange(); // Calls Plugin.getUIMessages(), which calls filters.applyMessageFilters().
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -423,27 +423,6 @@ function getConflictingPluginsFromFilter() {
|
||||
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
function applyFilters(evt) {
|
||||
/* The conflict filter, if enabled, executes C++ code, so needs to be
|
||||
handled using a promise, so the rest of the function should wait until
|
||||
it is completed.
|
||||
*/
|
||||
getConflictingPluginsFromFilter().then(function(conflicts) {
|
||||
for (var i = 0; i < cards.length; ++i) {
|
||||
if (conflicts.length > 0 && !conflicts.indexOf(cards[i].getName()) != -1) {
|
||||
hideElement(cards[i]);
|
||||
hideElement(entries[i]);
|
||||
++hiddenPluginNo;
|
||||
} else {
|
||||
showElement(cards[i]);
|
||||
showElement(entries[i]);
|
||||
}
|
||||
}
|
||||
document.getElementById('hiddenMessageNo').textContent = hiddenMessageNo;
|
||||
document.getElementById('hiddenPluginNo').textContent = hiddenPluginNo;
|
||||
});
|
||||
}
|
||||
|
||||
function showMessageDialog(title, text, yesNo, closeCallback) {
|
||||
var dialog = document.createElement('loot-message-dialog');
|
||||
if (yesNo) {
|
||||
@@ -514,9 +493,6 @@ function changeGame(evt) {
|
||||
console.log('changeGame response: ' + result);
|
||||
}
|
||||
|
||||
/* Reapply previously active filters. */
|
||||
applyFilters();
|
||||
|
||||
closeProgressDialog();
|
||||
}).catch(processCefError);
|
||||
}
|
||||
@@ -1025,7 +1001,7 @@ function handleConflictsFilter(evt) {
|
||||
evt.target.classList.toggle('highlight', false);
|
||||
document.body.removeAttribute('data-conflicts');
|
||||
}
|
||||
applyFilters(evt);
|
||||
setFilteredUIData(evt);
|
||||
}
|
||||
function handleCopyMetadata(evt) {
|
||||
/* evt.detail is the name of the plugin. */
|
||||
@@ -1348,7 +1324,7 @@ function onFocus(evt) {
|
||||
sortUIElements(pluginNames);
|
||||
|
||||
/* Reapply filters. */
|
||||
applyFilters();
|
||||
setFilteredUIData();
|
||||
|
||||
closeProgressDialog();
|
||||
}).catch(processCefError);
|
||||
|
||||
Reference in New Issue
Block a user