From 908d1c6203b3e790417b16644f016c721ac7c6f2 Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+Rsl1122@users.noreply.github.com> Date: Thu, 15 Oct 2020 19:41:11 +0300 Subject: [PATCH] Random tiny changes to code quality --- .../resolver/json/QueryJSONResolver.java | 2 +- .../database/queries/filter/Filter.java | 8 +++---- .../database/queries/filter/QueryFilters.java | 2 +- .../resources/assets/plan/web/js/query.js | 20 ++++++++-------- .../main/resources/assets/plan/web/query.html | 23 +++++++------------ 5 files changed, 24 insertions(+), 31 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/QueryJSONResolver.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/QueryJSONResolver.java index 748b7ad87..b4286ecae 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/QueryJSONResolver.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/QueryJSONResolver.java @@ -37,7 +37,7 @@ import java.util.Optional; @Singleton public class QueryJSONResolver implements Resolver { - private QueryFilters filters; + private final QueryFilters filters; @Inject public QueryJSONResolver( diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/Filter.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/Filter.java index 5f994d012..ee15ba134 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/Filter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/Filter.java @@ -51,11 +51,11 @@ public interface Filter { } class Result { - private Result previous; + private final Result previous; - private String filterKind; - private int resultSize; - private Set currentUUIDs; + private final String filterKind; + private final int resultSize; + private final Set currentUUIDs; private Result(Result previous, String filterKind, Set currentUUIDs) { this.previous = previous; diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/QueryFilters.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/QueryFilters.java index 93ad4e7ba..e88852806 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/QueryFilters.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/queries/filter/QueryFilters.java @@ -31,7 +31,7 @@ import java.util.*; @Singleton public class QueryFilters { - private Map filters; + private final Map filters; @Inject public QueryFilters(Set filters) { 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 0b2efaeae..c400c805c 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,10 +1,10 @@ -var filterCount = 0; +let filterCount = 0; /* { id: "DOM id", options... }*/ -var filterQuery = []; +const filterQuery = []; function addFilter(parentSelector, filterIndex) { const id = "f" + filterCount; @@ -59,20 +59,20 @@ function createBetweenSelector(id, label, options) { `
` + `
` + `
` + - `` + + `` + `
` + `
` + `
` + - `` + + `` + `
` + `
` + `
` + `
` + - `` + + `` + `
` + `
` + `
` + - `` + + `` + `
` + `
` ); @@ -105,12 +105,12 @@ function correctDate(value) { function isValidTime(value) { if (!value) return true; - const regex = /^[0-2][0-9]\:[0-5][0-9]$/; + const regex = /^[0-2][0-9]:[0-5][0-9]$/; return regex.test(value); } function correctTime(value) { - const d = value.match(/^(\d{2})\:?(\d{2})$/); + const d = value.match(/^(\d{2}):?(\d{2})$/); if (!d) return value; let hour = d[1]; while (hour > 23) hour--; @@ -134,10 +134,10 @@ function setFilterOption( console.log(element, value, id, elementId); - value = window[correctionFunction].apply(element, [value]); + value = correctionFunction.apply(element, [value]); element.val(value); - const isValid = window[isValidFunction].apply(element, [value]); + const isValid = isValidFunction.apply(element, [value]); if (isValid) { element.removeClass("is-invalid"); query[propertyName] = value; diff --git a/Plan/common/src/main/resources/assets/plan/web/query.html b/Plan/common/src/main/resources/assets/plan/web/query.html index 7a0c4dbff..a487edf5f 100644 --- a/Plan/common/src/main/resources/assets/plan/web/query.html +++ b/Plan/common/src/main/resources/assets/plan/web/query.html @@ -137,7 +137,8 @@ data-toggle="dropdown" id="filterDropdown" type="button"> Add a filter.. - @@ -300,14 +301,6 @@ - - - - - - - - @@ -317,16 +310,16 @@