Skip to content

Instantly share code, notes, and snippets.

@kcarnold
Created October 17, 2023 18:52
Show Gist options
  • Save kcarnold/8e607b1f5c0cf27d19ff328f936f12e1 to your computer and use it in GitHub Desktop.
Save kcarnold/8e607b1f5c0cf27d19ff328f936f12e1 to your computer and use it in GitHub Desktop.
core double counts
// Run this on the Core Curriculum page
// Gather courses by section
courses = new Map();
document.querySelectorAll('.acalog-course').forEach(x => {
let name = x.textContent;
let section = x.closest('.acalog-core').querySelector('h3, h4').textContent;
console.log(name, section);
if (!courses.has(name)) {courses.set(name, [])}
courses.get(name).push(section);
});
// Note multi-listings
document.querySelectorAll('.acalog-course').forEach(x => {
let name = x.textContent;
let section = x.closest('.acalog-core').querySelector('h3, h4').textContent;
let others = []
courses.get(name).forEach(otherSection => {
if (section !== otherSection) {
others.push(otherSection);
}
});
if (others.length > 0) {
console.log("Multi:", name, section, others.join(', '));
let elt = document.createElement('span');
elt.appendChild(document.createTextNode(" also in " + others.join(', ') ));
elt.style.fontSize = '75%';
elt.style.color = "#97252b"; // maroon
x.appendChild(elt);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment