Skip to content

Instantly share code, notes, and snippets.

@pketh
Last active August 27, 2020 20:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pketh/a67374334f38023ad8ebffa18ef5378d to your computer and use it in GitHub Desktop.
Save pketh/a67374334f38023ad8ebffa18ef5378d to your computer and use it in GitHub Desktop.
search snippet for kinopio cards
// 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