Last active
August 27, 2020 20:52
-
-
Save pketh/a67374334f38023ad8ebffa18ef5378d to your computer and use it in GitHub Desktop.
search snippet for kinopio cards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// edit search and paste me into your browser console | |
search = 'my cool search'; | |
// this will only work for the spaces you have cached | |
// i.e. you've opened the space on this device recently | |
spaces = Object.keys(localStorage); | |
spaces = spaces.filter(space => space.startsWith('space-')); | |
spaces = spaces.map(space => JSON.parse(localStorage[space])); | |
matchingSpaces = spaces.filter(space => { | |
if (!space.name) { return }; | |
return space.name.toLowerCase().includes(search.toLowerCase()); | |
}); | |
console.log('๐ matching spaces', matchingSpaces); | |
matchingCards = [] | |
spaces.forEach(space => { | |
if (!space.cards) { return } | |
return space.cards.filter(card => { | |
if (!card.name) { return }; | |
if (card.name.toLowerCase().includes(search.toLowerCase())) { | |
match = { | |
cardId: card.id, | |
position: { | |
x: card.x, | |
y: card.y | |
}, | |
name: card.name, | |
space: space.name | |
} | |
matchingCards.push(match); | |
} | |
}) | |
}); | |
console.log('๐ matching cards', matchingCards); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment