Remove unnecessary / duplicate code.

This commit is contained in:
Maximilian Krög
2020-02-09 17:56:40 +01:00
parent 2b8582fcad
commit b9455bfad9
@@ -3,16 +3,6 @@ $(function () {
// Allow user configuration? // Allow user configuration?
const allowRegex = true; const allowRegex = true;
// Search Items
$('#include_modules').change(function (e) {
console.log('change');
if ($(this).is(':checked')) {
} else {
}
});
const reNotCache = {}; const reNotCache = {};
function escapeRegexp(s, not) { function escapeRegexp(s, not) {
if (not) { if (not) {
@@ -39,8 +29,7 @@ $(function () {
var getSearchWeight = function (searchTerm, $matchedItem) { var getSearchWeight = function (searchTerm, $matchedItem) {
let weight = 0; let weight = 0;
// We could get smarter on the weight here // We could get smarter on the weight here
if ($matchedItem.data('shortname') if ($matchedItem.data('shortname').toLowerCase() === searchTerm.toLowerCase()) {
&& $matchedItem.data('shortname').toLowerCase() === searchTerm.toLowerCase()) {
weight++; weight++;
} }
return weight; return weight;
@@ -82,19 +71,17 @@ $(function () {
const $item = $(v); const $item = $(v);
const name = $item.data('name'); const name = $item.data('name');
if (name && regexp.test(name)) { if (regexp.test(name)) {
const $classEntry = $item.closest('.item'); const $classEntry = $item.closest('.item');
const $members = $item.closest('.member-list'); const $members = $item.closest('.member-list');
// Do the weight thing // Do the weight thing
$classEntry.removeData('weight');
$classEntry.show();
const weight = getSearchWeight(searchTerm, $classEntry); const weight = getSearchWeight(searchTerm, $classEntry);
$classEntry.data('weight', weight); $classEntry.data('weight', weight);
$item.show();
$members.show(); $members.show();
$classEntry.show(); $classEntry.show();
$item.show();
} }
}); });