diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-16 21:07:34 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-16 21:07:34 -0400 |
commit | 7b79703de69f044a03884be83d6df3790d8f8ee9 (patch) | |
tree | bd329c292f5636ebd45e1e183ef8beaa3634e4f2 /src/SMAPI.Web/wwwroot/Content/js | |
parent | 36af2cf8ac46b3fce7144efdb6fcc2d3a71593fb (diff) | |
download | SMAPI-7b79703de69f044a03884be83d6df3790d8f8ee9.tar.gz SMAPI-7b79703de69f044a03884be83d6df3790d8f8ee9.tar.bz2 SMAPI-7b79703de69f044a03884be83d6df3790d8f8ee9.zip |
tweak code style
Diffstat (limited to 'src/SMAPI.Web/wwwroot/Content/js')
-rw-r--r-- | src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js index e19e3301..8886715e 100644 --- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js +++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js @@ -860,34 +860,29 @@ smapi.logParser = function (state) { // much easier. updateFilterText: helpers.getDebouncedHandler( function () { + // reset + this.filterError = null; + this.filterRegex = null; + + // apply search let text = state.filterText; - if (!text || !text.length) { + if (!text) this.filterText = ""; - this.filterRegex = null; - this.filterError = null; - } else { if (!state.useRegex) text = helpers.escapeRegex(text); const flags = state.useInsensitive ? "ig" : "g"; - this.filterError = null; - let regex; - try { - regex = new RegExp(text, flags); - } catch (err) { - regex = null; + this.filterRegex = new RegExp(text, flags); + } + catch (err) { this.filterError = err.message; } - if (regex) - this.filterRegex = state.useWord ? - new RegExp(`\\b(?:${text})\\b`, flags) : - regex; - else - this.filterRegex = null; + if (this.filterRegex && state.useWord) + this.filterRegex = new RegExp(`\\b(?:${text})\\b`, flags); } this.updateUrl(); |