mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 15:25:01 -04:00
[#181] check if localStorage has favourites at all to prevent errors when not available
This commit is contained in:
parent
984ce61924
commit
41d511a396
2 changed files with 26 additions and 15 deletions
|
@ -68,8 +68,18 @@ class HTMLOperation {
|
|||
html += "<i class='material-icons check-icon op-icon'>check</i>";
|
||||
}
|
||||
|
||||
const favourites = JSON.parse(localStorage.favourites);
|
||||
const isFavourite = favourites.includes(this.name);
|
||||
let isFavourite;
|
||||
|
||||
if ( localStorage.favourites ) {
|
||||
console.log(localStorage.favourites);
|
||||
const favourites = JSON.parse(localStorage.favourites);
|
||||
isFavourite = favourites.includes(this.name);
|
||||
} else {
|
||||
isFavourite = false;
|
||||
}
|
||||
|
||||
console.log(isFavourite);
|
||||
|
||||
|
||||
if (window.innerWidth < this.app.breakpoint) {
|
||||
html += `<i title="${this.name}" class='material-icons icon-add-favourite star-icon op-icon ${isFavourite ? "fav-op" : ""}'>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue