I have a deeply nested hierarchical deck structure so {{Deck}} doesn’t do it for me. The issue with {{Subdeck}} is it gives out too much context. Now, I need two things:
- I want “Biology”/“Chemistry”/“Physics” to be shown if the {{Deck}} contains those words. Also, something like “Biology: Zoology” and “Biology: Botany”.
- When I click the name, I want to be shown the {{Subdeck}} so I know where the card comes from.
Are these doable? I still had a unused JS script that divides the {{Deck}} into subdecks and puts /
between them. Using that, made ChatGPT generate some scripts but they don’t work in different ways.
One example if it’s useful:
<script>
// Access the deck element
var deckEl = document.querySelector('.prettify-deck');
// Split the full deck path by "::" and filter empty values
var subDecks = deckEl.innerHTML.split('::').filter(Boolean);
// Define subject and subtopic mappings
var subject = "";
var subtopic = "";
// Define chapter numbers for each subtopic
var subtopicChapters = {
Botany: ["The Living World", "Biological Classification", "Plant Kingdom", "Morphology of Flowering Plants", "Anatomy of Flowering Plants", "Cell: The Unit of Life", "Cell Cycle and Cell Division", "Photosynthesis in Higher Plants", "Respiration in Plants", "Plant Growth and Development", "Sexual Reproduction in Flowering Plants", "Principles of Inheritance and Variation", "Molecular Basis of Inheritance", "Microbes in Human Welfare", "Organisms and Populations", "Ecosystem", "Biodiversity and Coservation"]
};
// Loop through subDecks to find the main subject and subtopic
subDecks.forEach((subDeck) => {
if (subDeck.includes("Bio")) {
subject = "Biology";
subtopic = "Zoology";
if (subtopicChapters.Botany.some(ch => subDeck.includes(ch))) {
subtopic = "Botany";
}
} else if (subDeck.includes("Chem")) {
subject = "Chemistry";
} else if (subDeck.includes("Physics")) {
subject = "Physics";
}
});
// Display the subject with subtopic, or fallback to the full hierarchy
deckEl.innerHTML = subject
? (subtopic ? `${subject}: ${subtopic}` : subject)
: subDecks.join(' / ');
</script>