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:
Oliver Hamlet
2014-11-15 13:53:15 +00:00
parent 9ae1b0e5b4
commit 514ac00700
2 changed files with 27 additions and 34 deletions
+25 -8
View File
@@ -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().
}
});
}
+2 -26
View File
@@ -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);