schoolbox web extension :)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: legacy-timetable #57

Willow a2925073 083e4363

+11 -9
+11 -9
src/plugins/legacy-timetable/legacy-timetable.js
··· 1 - // If window pathname is "/" and the element with the class "timetable" exists, run the code 2 - if (window.location.pathname === "/" && document.getElementsByClassName("timetable")[0]) { 3 - let timetableContainer = document.querySelectorAll("[data-timetable-container]"); 1 + // moves the timetable to it's own row on the dashboard, preventing it from being squished by other elements 4 2 5 - // Add the class "columns" to timetableContainer 6 - timetableContainer[0].classList.add("columns"); 3 + // check if we're on the homepage and a timetable element exists 4 + if (window.location.pathname !== "/" || !document.querySelector(".timetable")) return; 7 5 8 - let rowElement = document.getElementsByClassName("Component_Dashboard_TimetableController")[0].parentNode.parentNode; 6 + // get the timetable container and add the 'columns' class 7 + let timetableContainer = document.querySelector("[data-timetable-container]"); 8 + if (!timetableContainer) return; 9 + timetableContainer.classList.add("columns"); 9 10 10 - // Move timetableContainer to the start of the row 11 - rowElement.insertBefore(timetableContainer[0], rowElement.firstChild); 12 - } 11 + // get the row element and move the timetable container to the beginning 12 + let rowElement = document.querySelector(".Component_Dashboard_TimetableController")?.parentNode?.parentNode; 13 + if (!rowElement) return; 14 + rowElement.insertBefore(timetableContainer, rowElement.firstChild);