From 7b79703de69f044a03884be83d6df3790d8f8ee9 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 16 Apr 2022 21:07:34 -0400 Subject: tweak code style --- src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 27 +++++++++++--------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'src/SMAPI.Web/wwwroot/Content/js') 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(); -- cgit