mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 08:46:19 -04:00
Introduced use of conditional chaining operator
This commit is contained in:
parent
570206af77
commit
b92501ee35
14 changed files with 493 additions and 495 deletions
|
@ -342,7 +342,7 @@ class App {
|
|||
let favourites;
|
||||
|
||||
if (this.isLocalStorageAvailable()) {
|
||||
favourites = localStorage.favourites && localStorage.favourites.length > 2 ?
|
||||
favourites = localStorage?.favourites?.length > 2 ?
|
||||
JSON.parse(localStorage.favourites) :
|
||||
this.dfavourites;
|
||||
favourites = this.validFavourites(favourites);
|
||||
|
|
|
@ -159,7 +159,7 @@ class StatusBarPanel {
|
|||
* @param {boolean} selectionSet
|
||||
*/
|
||||
updateSelection(state, selectionSet) {
|
||||
const selLen = state.selection && state.selection.main ?
|
||||
const selLen = state?.selection?.main ?
|
||||
state.selection.main.to - state.selection.main.from :
|
||||
0;
|
||||
|
||||
|
|
|
@ -807,7 +807,7 @@ class InputWaiter {
|
|||
// Dropped text is handled by the editor itself
|
||||
if (e.dataTransfer.getData("Text")) return;
|
||||
|
||||
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
||||
if (e?.dataTransfer?.files?.length > 0) {
|
||||
this.loadUIFiles(e.dataTransfer.files);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ class OutputWaiter {
|
|||
getEOLSeq() {
|
||||
const currentTabNum = this.manager.tabs.getActiveTab("output");
|
||||
if (currentTabNum < 0) {
|
||||
return this.outputEditorConf.state.lineBreak;
|
||||
return this.outputEditorConf.state?.lineBreak || "\n";
|
||||
}
|
||||
return this.outputs[currentTabNum].eolSequence;
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ class RecipeWaiter {
|
|||
// Reinitialise the popover on the original element in the ops list because for some reason it
|
||||
// gets destroyed and recreated. If the clone isn't in the ops list, we use the original item instead.
|
||||
let enableOpsElement;
|
||||
if (evt.clone.parentNode && evt.clone.parentNode.classList.contains("op-list")) {
|
||||
if (evt.clone?.parentNode?.classList?.contains("op-list")) {
|
||||
enableOpsElement = evt.clone;
|
||||
} else {
|
||||
enableOpsElement = evt.item;
|
||||
|
@ -163,13 +163,13 @@ class RecipeWaiter {
|
|||
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if (e.target.className && e.target.className.indexOf("category-title") > -1) {
|
||||
if (e.target?.className?.indexOf("category-title") > -1) {
|
||||
// Hovering over the a
|
||||
e.target.classList.add("favourites-hover");
|
||||
} else if (e.target.parentNode.className && e.target.parentNode.className.indexOf("category-title") > -1) {
|
||||
} else if (e.target?.parentNode?.className?.indexOf("category-title") > -1) {
|
||||
// Hovering over the Edit button
|
||||
e.target.parentNode.classList.add("favourites-hover");
|
||||
} else if (e.target.parentNode.parentNode.className && e.target.parentNode.parentNode.className.indexOf("category-title") > -1) {
|
||||
} else if (e.target?.parentNode?.parentNode?.className?.indexOf("category-title") > -1) {
|
||||
// Hovering over the image on the Edit button
|
||||
e.target.parentNode.parentNode.classList.add("favourites-hover");
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ class RecipeWaiter {
|
|||
* @fires Manager#statechange
|
||||
*/
|
||||
ingChange(e) {
|
||||
if (e && e.target && e.target.classList.contains("no-state-change")) return;
|
||||
if (e && e?.target?.classList?.contains("no-state-change")) return;
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue