diff --git a/Plan/common/src/main/resources/assets/plan/web/js/query.js b/Plan/common/src/main/resources/assets/plan/web/js/query.js index 9cd05e6b1..0b2efaeae 100644 --- a/Plan/common/src/main/resources/assets/plan/web/js/query.js +++ b/Plan/common/src/main/resources/assets/plan/web/js/query.js @@ -1,26 +1,41 @@ var filterCount = 0; +/* { + id: "DOM id", + options... +}*/ +var filterQuery = []; + function addFilter(parentSelector, filterIndex) { - $(parentSelector).append(createElement(filters[filterIndex])); + const id = "f" + filterCount; + $(parentSelector).append(createElement(filters[filterIndex], id)); filterCount++; } -function createElement(filter) { +function createElement(filter, id) { switch (filter.kind) { case "activityIndexNow": - return createMultipleChoiceSelector(`are in Activity Groups`, filter.options); + return createMultipleChoiceSelector( + id, + `are in Activity Groups`, + filter.options + ); case "banned": - return createMultipleChoiceSelector(`are`, filter.options); + return createMultipleChoiceSelector(id, `are`, filter.options); case "operators": - return createMultipleChoiceSelector(`are`, filter.options); + return createMultipleChoiceSelector(id, `are`, filter.options); case "pluginGroups": - return createMultipleChoiceSelector(`are in ${filter.options.plugin} Groups`, filter.options); + return createMultipleChoiceSelector( + id, + `are in ${filter.options.plugin} Groups`, + filter.options + ); case "playedBetween": - return createBetweenSelector("Played between", filter.options); + return createBetweenSelector(id, "Played between", filter.options); case "registeredBetween": - return createBetweenSelector("Registered between", filter.options); + return createBetweenSelector(id, "Registered between", filter.options); default: - throw new Error("Unsupported filter kind: '" + filter.kind + "'") + throw new Error("Unsupported filter kind: '" + filter.kind + "'"); } } @@ -28,46 +43,120 @@ function createFilterSelector(parent, index, filter) { return `${filter.kind}`; } -function createBetweenSelector(label, options) { - var select = filterCount === 0 ? "of Players who " : "and "; - return `` + - `