From a262db883c890579ea6866a32ca74ce6710e6572 Mon Sep 17 00:00:00 2001 From: Casper Sluitman Date: Fri, 7 May 2021 12:57:27 +0200 Subject: [PATCH 1/3] Improved custom prompts. This commit introduces a few changes to the selection of custom filtered datasets: - The "ok" button has been separated into "add" and "set"; the former doesn't clear the text field, making it easier to combine datasets. - A few functions have been switched around to fix the loading button and to circumvent some finnicky behaviour. - The forEach loop has been replaced with a join; this looks a bit cleaner and is generally more performant. --- src/js/popups/word-filter-popup.js | 19 ++++++++++--------- static/index.html | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/js/popups/word-filter-popup.js b/src/js/popups/word-filter-popup.js index 79cb583d6..cc1bc9f6c 100644 --- a/src/js/popups/word-filter-popup.js +++ b/src/js/popups/word-filter-popup.js @@ -65,15 +65,15 @@ async function filter(language) { return filteredWords; } -async function apply() { +async function apply(set) { let language = $("#wordFilterPopup .languageInput").val(); let filteredWords = await filter(language); - let customText = ""; - filteredWords.forEach((word) => { - customText += word + " "; - }); + let customText = filteredWords.join(" "); + + $("#customTextPopup textarea").val( + (index, val) => (set ? "" : val + " ") + customText + ); hide(); - $("#customTextPopup textarea").val(customText); } $("#wordFilterPopupWrapper").mousedown((e) => { @@ -90,8 +90,9 @@ $("#wordFilterPopupWrapper .button").mousedown((e) => { $("#wordFilterPopupWrapper .loadingIndicator").removeClass("hidden"); $("#wordFilterPopupWrapper .button").addClass("hidden"); setTimeout(() => { - apply(); - $("#wordFilterPopupWrapper .loadingIndicator").addClass("hidden"); - $("#wordFilterPopupWrapper .button").removeClass("hidden"); + apply($(e.target).is("#set")).then(() => { + $("#wordFilterPopupWrapper .loadingIndicator").addClass("hidden"); + $("#wordFilterPopupWrapper .button").removeClass("hidden"); + }); }, 1); }); diff --git a/static/index.html b/static/index.html index 8963b0626..db07feb29 100644 --- a/static/index.html +++ b/static/index.html @@ -205,7 +205,8 @@ -
ok
+
set
+
add
+
+ "Set" replaces the current selection with the selected language, + "Add" appends the selected language to the current selection +
From a0ad3bb50775fcec6311af474edb7482bbabebd1 Mon Sep 17 00:00:00 2001 From: Casper Sluitman Date: Fri, 7 May 2021 17:02:44 +0200 Subject: [PATCH 3/3] Clarified tip. Rephrased the tip as to make it easier to understand. --- static/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/index.html b/static/index.html index c8e644a4f..e4266ebca 100644 --- a/static/index.html +++ b/static/index.html @@ -203,8 +203,8 @@ (separated by spaces)
- "Set" replaces the current selection with the selected language, - "Add" appends the selected language to the current selection + "Set" replaces the current custom word list with the filter result, "Add" + appends the filter result to the current custom word list