@@ -449,15 +415,15 @@ class StatusBarPanel {
keyboard_return
-
`;
}
@@ -476,7 +442,7 @@ function hideOnClickOutside(element, instantiatingEvent) {
* Closes element if click is outside it.
* @param {Event} event
*/
- const outsideClickListener = (event) => {
+ const outsideClickListener = event => {
// Don't trigger if we're clicking inside the element, or if the element
// is not visible, or if this is the same click event that opened it.
if (
@@ -509,14 +475,30 @@ function hideOnMoveFocus(element, instantiatingEvent) {
* Closes element if key press is outside it.
* @param {Event} event
*/
- const outsideClickListener = (event) => {
+ const outsidePressListener = (event) => {
// Don't trigger if we're pressing keys while inside the element, or if the element
// is not visible, or if this is the same click event that opened it.
if (
!element.contains(event.target) &&
+ event.timeStamp !== instantiatingEvent.timeStamp &&
+ event.key !== "ArrowUp"
+ ) {
+ hideElement(element);
+ } else if (
+ event.key === "Escape" &&
event.timeStamp !== instantiatingEvent.timeStamp
) {
hideElement(element);
+ } else if (
+ event.key === "ArrowUp" ||
+ (event.key === "ArrowDown" &&
+ event.timeStamp !== instantiatingEvent.timeStamp)
+ ) {
+ const menuItems = element.getElementsByTagName("a");
+ menuItems[0].focus();
+
+ console.log("ev target:", event.target);
+ console.log("element", element);
}
};
@@ -526,7 +508,7 @@ function hideOnMoveFocus(element, instantiatingEvent) {
element
)
) {
- elementsWithKeyDownListeners[element] = outsideClickListener;
+ elementsWithKeyDownListeners[element] = outsidePressListener;
document.addEventListener(
"keydown",
elementsWithKeyDownListeners[element],
@@ -535,6 +517,38 @@ function hideOnMoveFocus(element, instantiatingEvent) {
}
}
+/**
+ * Handler for menu item keydown events
+ * Moves focus to next/previous element based on arrow direction.
+ * @param {Event} event
+ */
+const arrowNav = (event) => {
+ const currentElement = event.target;
+ if (event.key === "ArrowDown") {
+ event.preventDefault();
+ event.stopPropagation();
+ const nextElement = currentElement.nextElementSibling;
+ if (nextElement === null) {
+ currentElement.parentElement.firstElementChild.focus();
+ } else {
+ nextElement.focus();
+ }
+ } else if (event.key === "ArrowUp") {
+ event.preventDefault();
+ event.stopPropagation();
+ const prevElement = currentElement.previousElementSibling;
+ if (prevElement === null) {
+ currentElement.parentElement.lastElementChild.focus();
+ } else {
+ prevElement.focus();
+ }
+ } else if (event.key === "Tab") {
+ event.preventDefault();
+ event.stopPropagation();
+ currentElement.parentElement.closest(".cm-status-bar-select-content").previousElementSibling.focus();
+ }
+};
+
/**
* Hides the specified element and removes the click or keydown listener for it
* @param {Element} element
diff --git a/src/web/waiters/ControlsWaiter.mjs b/src/web/waiters/ControlsWaiter.mjs
index 35941a13..20f70173 100755
--- a/src/web/waiters/ControlsWaiter.mjs
+++ b/src/web/waiters/ControlsWaiter.mjs
@@ -152,9 +152,7 @@ class ControlsWaiter {
const params = [
includeRecipe ? ["recipe", recipeStr] : undefined,
- includeInput && input.length
- ? ["input", Utils.escapeHtml(input)]
- : undefined,
+ includeInput && input.length ? ["input", Utils.escapeHtml(input)] : undefined,
inputChrEnc !== 0 ? ["ienc", inputChrEnc] : undefined,
outputChrEnc !== 0 ? ["oenc", outputChrEnc] : undefined,
inputEOLSeq !== "\n" ? ["ieol", inputEOLSeq] : undefined,
@@ -255,9 +253,7 @@ class ControlsWaiter {
return;
}
- const savedRecipes = localStorage.savedRecipes
- ? JSON.parse(localStorage.savedRecipes)
- : [];
+ const savedRecipes = localStorage.savedRecipes ? JSON.parse(localStorage.savedRecipes) : [];
let recipeId = localStorage.recipeId || 0;
savedRecipes.push({
@@ -287,9 +283,7 @@ class ControlsWaiter {
}
// Add recipes to select
- const savedRecipes = localStorage.savedRecipes
- ? JSON.parse(localStorage.savedRecipes)
- : [];
+ const savedRecipes = localStorage.savedRecipes ? JSON.parse(localStorage.savedRecipes) : [];
for (i = 0; i < savedRecipes.length; i++) {
const opt = document.createElement("option");
@@ -316,9 +310,7 @@ class ControlsWaiter {
if (!this.app.isLocalStorageAvailable()) return false;
const id = parseInt(document.getElementById("load-name").value, 10);
- const rawSavedRecipes = localStorage.savedRecipes
- ? JSON.parse(localStorage.savedRecipes)
- : [];
+ const rawSavedRecipes = localStorage.savedRecipes ? JSON.parse(localStorage.savedRecipes) : [];
const savedRecipes = rawSavedRecipes.filter((r) => r.id !== id);
@@ -333,9 +325,7 @@ class ControlsWaiter {
if (!this.app.isLocalStorageAvailable()) return false;
const el = e.target;
- const savedRecipes = localStorage.savedRecipes
- ? JSON.parse(localStorage.savedRecipes)
- : [];
+ const savedRecipes = localStorage.savedRecipes ? JSON.parse(localStorage.savedRecipes) : [];
const id = parseInt(el.value, 10);
const recipe = savedRecipes.find((r) => r.id === id);
From 4c31c16eef27385943c27e7239c75fc5a6bd7b59 Mon Sep 17 00:00:00 2001
From: e218736 <147728997+e218736@users.noreply.github.com>
Date: Wed, 21 Feb 2024 16:13:56 +0000
Subject: [PATCH 5/7] formatting
---
src/web/utils/statusBar.mjs | 57 ++++++---------
src/web/waiters/ControlsWaiter.mjs | 112 ++++++++++++++---------------
2 files changed, 75 insertions(+), 94 deletions(-)
diff --git a/src/web/utils/statusBar.mjs b/src/web/utils/statusBar.mjs
index 454b36b0..0e85e0b5 100644
--- a/src/web/utils/statusBar.mjs
+++ b/src/web/utils/statusBar.mjs
@@ -82,24 +82,24 @@ class StatusBarPanel {
* @param {Event} e
*/
showDropUp(e) {
- if (e.type === "click" || e.keyCode === 13) {
+ if (e.type === "click" || e.key === 'Enter'|| e.key === ' ') {
const el = e.target
.closest(".cm-status-bar-select")
.querySelector(".cm-status-bar-select-content");
const btn = e.target.closest(".cm-status-bar-select-btn");
- if (btn.classList.contains("disabled")) return;
+ if (btn.classList.contains("disabled")) return;
- el.classList.add("show");
+ el.classList.add("show");
- // Focus the filter input if present
- const filter = el.querySelector(".cm-status-bar-filter-input");
- if (filter) filter.focus();
+ // Focus the filter input if present
+ const filter = el.querySelector(".cm-status-bar-filter-input");
+ if (filter) filter.focus();
- // Set up a listener to close the menu if the user clicks outside of it
- hideOnClickOutside(el, e);
- // Set up a listener to close the menu if the user presses key outside of it
- hideOnMoveFocus(el, e);
+ // Set up a listener to close the menu if the user clicks outside of it
+ hideOnClickOutside(el, e);
+ // Set up a listener to close the menu if the user presses key outside of it
+ hideOnMoveFocus(el, e);
}
}
@@ -181,8 +181,7 @@ class StatusBarPanel {
// CodeMirror always counts line breaks as one character.
// We want to show an accurate reading of how many bytes there are.
if (state.lineBreak.length !== 1) {
- docLength +=
- state.lineBreak.length * state.doc.lines - state.doc.lines - 1;
+ docLength += (state.lineBreak.length * state.doc.lines) - state.doc.lines - 1;
}
length.textContent = docLength;
lines.textContent = state.doc.lines;
@@ -237,6 +236,7 @@ class StatusBarPanel {
}
}
+
/**
* Sets the current EOL separator in the status bar
* @param {EditorState} state
@@ -344,7 +344,7 @@ class StatusBarPanel {
*/
constructLHS() {
return `
-
+
abc
@@ -386,13 +386,13 @@ class StatusBarPanel {
}
return `
-
+
schedule
ms
-
+
text_fields Raw Bytes
@@ -427,6 +427,7 @@ class StatusBarPanel {
`;
}
+
}
const elementsWithListeners = {};
@@ -447,19 +448,14 @@ function hideOnClickOutside(element, instantiatingEvent) {
// is not visible, or if this is the same click event that opened it.
if (
!element.contains(event.target) &&
- event.timeStamp !== instantiatingEvent.timeStamp
- ) {
+ event.timeStamp !== instantiatingEvent.timeStamp) {
hideElement(element);
}
};
if (!Object.prototype.hasOwnProperty.call(elementsWithListeners, element)) {
elementsWithListeners[element] = outsideClickListener;
- document.addEventListener(
- "click",
- elementsWithListeners[element],
- false
- );
+ document.addEventListener("click", elementsWithListeners[element], false);
}
}
@@ -555,20 +551,13 @@ const arrowNav = (event) => {
*/
function hideElement(element) {
element.classList.remove("show");
- document.removeEventListener(
- "click",
- elementsWithListeners[element],
- false
- );
- document.removeEventListener(
- "keydown",
- elementsWithKeyDownListeners[element],
- false
- );
+ document.removeEventListener("click", elementsWithListeners[element], false);
+ document.removeEventListener("keydown", elementsWithKeyDownListeners[element], false);
delete elementsWithListeners[element];
delete elementsWithKeyDownListeners[element];
}
+
/**
* A panel constructor factory building a panel that re-counts the stats every time the document changes.
* @param {Object} opts
@@ -586,7 +575,7 @@ function makePanel(opts) {
sbPanel.monitorHTMLOutput();
return {
- dom: sbPanel.dom,
+ "dom": sbPanel.dom,
update(update) {
sbPanel.updateEOL(update.state);
sbPanel.updateCharEnc();
@@ -599,7 +588,7 @@ function makePanel(opts) {
if (update.docChanged) {
sbPanel.updateStats(update.state);
}
- },
+ }
};
};
}
diff --git a/src/web/waiters/ControlsWaiter.mjs b/src/web/waiters/ControlsWaiter.mjs
index 20f70173..5982be68 100755
--- a/src/web/waiters/ControlsWaiter.mjs
+++ b/src/web/waiters/ControlsWaiter.mjs
@@ -6,10 +6,12 @@
import Utils from "../../core/Utils.mjs";
+
/**
* Waiter to handle events related to the CyberChef controls (i.e. Bake, Step, Save, Load etc.)
*/
class ControlsWaiter {
+
/**
* ControlsWaiter constructor.
*
@@ -21,6 +23,7 @@ class ControlsWaiter {
this.manager = manager;
}
+
/**
* Initialise Bootstrap components
*/
@@ -30,10 +33,11 @@ class ControlsWaiter {
animation: false,
container: "body",
boundary: "viewport",
- trigger: "hover focus",
+ trigger: "hover focus"
});
}
+
/**
* Checks or unchecks the Auto Bake checkbox based on the given value.
*
@@ -47,6 +51,7 @@ class ControlsWaiter {
}
}
+
/**
* Handler to trigger baking.
*/
@@ -59,6 +64,7 @@ class ControlsWaiter {
}
}
+
/**
* Handler for the 'Step through' command. Executes the next step of the recipe.
*/
@@ -66,6 +72,7 @@ class ControlsWaiter {
this.app.step();
}
+
/**
* Handler for changes made to the Auto Bake checkbox.
*/
@@ -73,6 +80,7 @@ class ControlsWaiter {
this.app.autoBake_ = document.getElementById("auto-bake").checked;
}
+
/**
* Handler for the 'Clear recipe' command. Removes all operations from the recipe.
*/
@@ -80,6 +88,7 @@ class ControlsWaiter {
this.manager.recipe.clearRecipe();
}
+
/**
* Populates the save dialog box with a URL incorporating the recipe and input.
*
@@ -88,23 +97,16 @@ class ControlsWaiter {
initialiseSaveLink(recipeConfig) {
recipeConfig = recipeConfig || this.app.getRecipeConfig();
- const includeRecipe = document.getElementById(
- "save-link-recipe-checkbox"
- ).checked;
- const includeInput = document.getElementById("save-link-input-checkbox")
- .checked;
+ const includeRecipe = document.getElementById("save-link-recipe-checkbox").checked;
+ const includeInput = document.getElementById("save-link-input-checkbox").checked;
const saveLinkEl = document.getElementById("save-link");
- const saveLink = this.generateStateUrl(
- includeRecipe,
- includeInput,
- null,
- recipeConfig
- );
+ const saveLink = this.generateStateUrl(includeRecipe, includeInput, null, recipeConfig);
saveLinkEl.innerHTML = Utils.escapeHtml(Utils.truncate(saveLink, 120));
saveLinkEl.setAttribute("href", saveLink);
}
+
/**
* Generates a URL containing the current recipe and input state.
*
@@ -115,24 +117,15 @@ class ControlsWaiter {
* @param {string} [baseURL] - The CyberChef URL, set to the current URL if not included
* @returns {string}
*/
- generateStateUrl(
- includeRecipe,
- includeInput,
- input,
- recipeConfig,
- baseURL
- ) {
+ generateStateUrl(includeRecipe, includeInput, input, recipeConfig, baseURL) {
recipeConfig = recipeConfig || this.app.getRecipeConfig();
- const link =
- baseURL ||
- window.location.protocol +
- "//" +
+ const link = baseURL || window.location.protocol + "//" +
window.location.host +
window.location.pathname;
const recipeStr = Utils.generatePrettyRecipe(recipeConfig);
- includeRecipe = includeRecipe && recipeConfig.length > 0;
+ includeRecipe = includeRecipe && (recipeConfig.length > 0);
// If we don't get passed an input, get it from the current URI
if (input === null && includeInput) {
@@ -156,11 +149,11 @@ class ControlsWaiter {
inputChrEnc !== 0 ? ["ienc", inputChrEnc] : undefined,
outputChrEnc !== 0 ? ["oenc", outputChrEnc] : undefined,
inputEOLSeq !== "\n" ? ["ieol", inputEOLSeq] : undefined,
- outputEOLSeq !== "\n" ? ["oeol", outputEOLSeq] : undefined,
+ outputEOLSeq !== "\n" ? ["oeol", outputEOLSeq] : undefined
];
const hash = params
- .filter((v) => v)
+ .filter(v => v)
.map(([key, value]) => `${key}=${Utils.encodeURIFragment(value)}`)
.join("&");
@@ -171,6 +164,7 @@ class ControlsWaiter {
return link;
}
+
/**
* Handler for changes made to the save dialog text area. Re-initialises the save link.
*/
@@ -181,6 +175,7 @@ class ControlsWaiter {
} catch (err) {}
}
+
/**
* Handler for the 'Save' command. Pops up the save dialog box.
*/
@@ -188,14 +183,8 @@ class ControlsWaiter {
const recipeConfig = this.app.getRecipeConfig();
const recipeStr = JSON.stringify(recipeConfig);
- document.getElementById(
- "save-text-chef"
- ).value = Utils.generatePrettyRecipe(recipeConfig, true);
- document.getElementById("save-text-clean").value = JSON.stringify(
- recipeConfig,
- null,
- 2
- )
+ document.getElementById("save-text-chef").value = Utils.generatePrettyRecipe(recipeConfig, true);
+ document.getElementById("save-text-clean").value = JSON.stringify(recipeConfig, null, 2)
.replace(/{\n\s+"/g, '{ "')
.replace(/\[\n\s{3,}/g, "[")
.replace(/\n\s{3,}]/g, "]")
@@ -207,6 +196,7 @@ class ControlsWaiter {
$("#save-modal").modal();
}
+
/**
* Handler for the save link recipe checkbox change event.
*/
@@ -214,6 +204,7 @@ class ControlsWaiter {
this.initialiseSaveLink();
}
+
/**
* Handler for the save link input checkbox change event.
*/
@@ -221,6 +212,7 @@ class ControlsWaiter {
this.initialiseSaveLink();
}
+
/**
* Handler for the 'Load' command. Pops up the load dialog box.
*/
@@ -229,6 +221,7 @@ class ControlsWaiter {
$("#load-modal").modal();
}
+
/**
* Saves the recipe specified in the save textarea to local storage.
*/
@@ -241,25 +234,22 @@ class ControlsWaiter {
return false;
}
- const recipeName = Utils.escapeHtml(
- document.getElementById("save-name").value
- );
- const recipeStr = document.querySelector(
- "#save-texts .tab-pane.active textarea"
- ).value;
+ const recipeName = Utils.escapeHtml(document.getElementById("save-name").value);
+ const recipeStr = document.querySelector("#save-texts .tab-pane.active textarea").value;
if (!recipeName) {
this.app.alert("Please enter a recipe name", 3000);
return;
}
- const savedRecipes = localStorage.savedRecipes ? JSON.parse(localStorage.savedRecipes) : [];
+ const savedRecipes = localStorage.savedRecipes ?
+ JSON.parse(localStorage.savedRecipes) : [];
let recipeId = localStorage.recipeId || 0;
savedRecipes.push({
id: ++recipeId,
name: recipeName,
- recipe: recipeStr,
+ recipe: recipeStr
});
localStorage.savedRecipes = JSON.stringify(savedRecipes);
@@ -268,6 +258,7 @@ class ControlsWaiter {
this.app.alert(`Recipe saved as "${recipeName}".`, 3000);
}
+
/**
* Populates the list of saved recipes in the load dialog box from local storage.
*/
@@ -283,15 +274,14 @@ class ControlsWaiter {
}
// Add recipes to select
- const savedRecipes = localStorage.savedRecipes ? JSON.parse(localStorage.savedRecipes) : [];
+ const savedRecipes = localStorage.savedRecipes ?
+ JSON.parse(localStorage.savedRecipes) : [];
for (i = 0; i < savedRecipes.length; i++) {
const opt = document.createElement("option");
opt.value = savedRecipes[i].id;
// Unescape then re-escape in case localStorage has been corrupted
- opt.innerHTML = Utils.escapeHtml(
- Utils.unescapeHtml(savedRecipes[i].name)
- );
+ opt.innerHTML = Utils.escapeHtml(Utils.unescapeHtml(savedRecipes[i].name));
loadNameEl.appendChild(opt);
}
@@ -303,6 +293,7 @@ class ControlsWaiter {
loadText.dispatchEvent(evt);
}
+
/**
* Removes the currently selected recipe from local storage.
*/
@@ -310,14 +301,16 @@ class ControlsWaiter {
if (!this.app.isLocalStorageAvailable()) return false;
const id = parseInt(document.getElementById("load-name").value, 10);
- const rawSavedRecipes = localStorage.savedRecipes ? JSON.parse(localStorage.savedRecipes) : [];
+ const rawSavedRecipes = localStorage.savedRecipes ?
+ JSON.parse(localStorage.savedRecipes) : [];
- const savedRecipes = rawSavedRecipes.filter((r) => r.id !== id);
+ const savedRecipes = rawSavedRecipes.filter(r => r.id !== id);
localStorage.savedRecipes = JSON.stringify(savedRecipes);
this.populateLoadRecipesList();
}
+
/**
* Displays the selected recipe in the load text box.
*/
@@ -325,22 +318,22 @@ class ControlsWaiter {
if (!this.app.isLocalStorageAvailable()) return false;
const el = e.target;
- const savedRecipes = localStorage.savedRecipes ? JSON.parse(localStorage.savedRecipes) : [];
+ const savedRecipes = localStorage.savedRecipes ?
+ JSON.parse(localStorage.savedRecipes) : [];
const id = parseInt(el.value, 10);
- const recipe = savedRecipes.find((r) => r.id === id);
+ const recipe = savedRecipes.find(r => r.id === id);
document.getElementById("load-text").value = recipe.recipe;
}
+
/**
* Loads the selected recipe and populates the Recipe with its operations.
*/
loadButtonClick() {
try {
- const recipeConfig = Utils.parseRecipeConfig(
- document.getElementById("load-text").value
- );
+ const recipeConfig = Utils.parseRecipeConfig(document.getElementById("load-text").value);
this.app.setRecipeConfig(recipeConfig);
this.app.autoBake();
@@ -350,6 +343,7 @@ class ControlsWaiter {
}
}
+
/**
* Populates the bug report information box with useful technical info.
*
@@ -359,13 +353,7 @@ class ControlsWaiter {
e.preventDefault();
const reportBugInfo = document.getElementById("report-bug-info");
- const saveLink = this.generateStateUrl(
- true,
- true,
- null,
- null,
- "https://gchq.github.io/CyberChef/"
- );
+ const saveLink = this.generateStateUrl(true, true, null, null, "https://gchq.github.io/CyberChef/");
if (reportBugInfo) {
reportBugInfo.innerHTML = `* Version: ${PKG_VERSION}
@@ -378,6 +366,7 @@ ${navigator.userAgent}
}
}
+
/**
* Shows the stale indicator to show that the input or recipe has changed
* since the last bake.
@@ -387,6 +376,7 @@ ${navigator.userAgent}
staleIndicator.classList.remove("hidden");
}
+
/**
* Hides the stale indicator to show that the input or recipe has not changed
* since the last bake.
@@ -396,6 +386,7 @@ ${navigator.userAgent}
staleIndicator.classList.add("hidden");
}
+
/**
* Switches the Bake button between 'Bake', 'Cancel' and 'Loading' functions.
*
@@ -438,6 +429,7 @@ ${navigator.userAgent}
recList.style.bottom = controls.clientHeight + "px";
}
+
}
export default ControlsWaiter;
From d79d412959e981230a8b89fb50839c9a84112c70 Mon Sep 17 00:00:00 2001
From: e218736 <147728997+e218736@users.noreply.github.com>
Date: Wed, 21 Feb 2024 16:23:15 +0000
Subject: [PATCH 6/7] formatting
---
src/web/utils/statusBar.mjs | 5 +++--
src/web/waiters/ControlsWaiter.mjs | 16 ++++++++--------
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/web/utils/statusBar.mjs b/src/web/utils/statusBar.mjs
index 0e85e0b5..a17e2e37 100644
--- a/src/web/utils/statusBar.mjs
+++ b/src/web/utils/statusBar.mjs
@@ -11,6 +11,7 @@ import {CHR_ENC_SIMPLE_LOOKUP, CHR_ENC_SIMPLE_REVERSE_LOOKUP} from "../../core/l
* A Status bar extension for CodeMirror
*/
class StatusBarPanel {
+
/**
* StatusBarPanel constructor
* @param {Object} opts
@@ -264,6 +265,7 @@ class StatusBarPanel {
this.eolVal = state.lineBreak;
}
+
/**
* Sets the current character encoding of the document
*/
@@ -446,8 +448,7 @@ function hideOnClickOutside(element, instantiatingEvent) {
const outsideClickListener = event => {
// Don't trigger if we're clicking inside the element, or if the element
// is not visible, or if this is the same click event that opened it.
- if (
- !element.contains(event.target) &&
+ if (!element.contains(event.target) &&
event.timeStamp !== instantiatingEvent.timeStamp) {
hideElement(element);
}
diff --git a/src/web/waiters/ControlsWaiter.mjs b/src/web/waiters/ControlsWaiter.mjs
index 5982be68..5c721d76 100755
--- a/src/web/waiters/ControlsWaiter.mjs
+++ b/src/web/waiters/ControlsWaiter.mjs
@@ -121,8 +121,8 @@ class ControlsWaiter {
recipeConfig = recipeConfig || this.app.getRecipeConfig();
const link = baseURL || window.location.protocol + "//" +
- window.location.host +
- window.location.pathname;
+ window.location.host +
+ window.location.pathname;
const recipeStr = Utils.generatePrettyRecipe(recipeConfig);
includeRecipe = includeRecipe && (recipeConfig.length > 0);
@@ -185,7 +185,7 @@ class ControlsWaiter {
document.getElementById("save-text-chef").value = Utils.generatePrettyRecipe(recipeConfig, true);
document.getElementById("save-text-clean").value = JSON.stringify(recipeConfig, null, 2)
- .replace(/{\n\s+"/g, '{ "')
+ .replace(/{\n\s+"/g, "{ \"")
.replace(/\[\n\s{3,}/g, "[")
.replace(/\n\s{3,}]/g, "]")
.replace(/\s*\n\s*}/g, " }")
@@ -235,14 +235,14 @@ class ControlsWaiter {
}
const recipeName = Utils.escapeHtml(document.getElementById("save-name").value);
- const recipeStr = document.querySelector("#save-texts .tab-pane.active textarea").value;
+ const recipeStr = document.querySelector("#save-texts .tab-pane.active textarea").value;
if (!recipeName) {
this.app.alert("Please enter a recipe name", 3000);
return;
}
- const savedRecipes = localStorage.savedRecipes ?
+ const savedRecipes = localStorage.savedRecipes ?
JSON.parse(localStorage.savedRecipes) : [];
let recipeId = localStorage.recipeId || 0;
@@ -274,7 +274,7 @@ class ControlsWaiter {
}
// Add recipes to select
- const savedRecipes = localStorage.savedRecipes ?
+ const savedRecipes = localStorage.savedRecipes ?
JSON.parse(localStorage.savedRecipes) : [];
for (i = 0; i < savedRecipes.length; i++) {
@@ -318,7 +318,7 @@ class ControlsWaiter {
if (!this.app.isLocalStorageAvailable()) return false;
const el = e.target;
- const savedRecipes = localStorage.savedRecipes ?
+ const savedRecipes = localStorage.savedRecipes ?
JSON.parse(localStorage.savedRecipes) : [];
const id = parseInt(el.value, 10);
@@ -429,7 +429,7 @@ ${navigator.userAgent}
recList.style.bottom = controls.clientHeight + "px";
}
-
+
}
export default ControlsWaiter;
From f75d07bfc77d8f51dcb37ab831d565179478f837 Mon Sep 17 00:00:00 2001
From: e218736 <147728997+e218736@users.noreply.github.com>
Date: Wed, 21 Feb 2024 16:30:58 +0000
Subject: [PATCH 7/7] formatting
---
src/web/utils/statusBar.mjs | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/web/utils/statusBar.mjs b/src/web/utils/statusBar.mjs
index a17e2e37..84c9e4c3 100644
--- a/src/web/utils/statusBar.mjs
+++ b/src/web/utils/statusBar.mjs
@@ -83,24 +83,24 @@ class StatusBarPanel {
* @param {Event} e
*/
showDropUp(e) {
- if (e.type === "click" || e.key === 'Enter'|| e.key === ' ') {
+ if (e.type === "click" || e.key === "Enter"|| e.key === " ") {
const el = e.target
.closest(".cm-status-bar-select")
.querySelector(".cm-status-bar-select-content");
const btn = e.target.closest(".cm-status-bar-select-btn");
- if (btn.classList.contains("disabled")) return;
+ if (btn.classList.contains("disabled")) return;
- el.classList.add("show");
+ el.classList.add("show");
- // Focus the filter input if present
- const filter = el.querySelector(".cm-status-bar-filter-input");
- if (filter) filter.focus();
+ // Focus the filter input if present
+ const filter = el.querySelector(".cm-status-bar-filter-input");
+ if (filter) filter.focus();
- // Set up a listener to close the menu if the user clicks outside of it
- hideOnClickOutside(el, e);
- // Set up a listener to close the menu if the user presses key outside of it
- hideOnMoveFocus(el, e);
+ // Set up a listener to close the menu if the user clicks outside of it
+ hideOnClickOutside(el, e);
+ // Set up a listener to close the menu if the user presses key outside of it
+ hideOnMoveFocus(el, e);
}
}