educaweb2/assets/js/gancio-events-detect.js~

38 lines
1004 B
JavaScript

/*
* Detect no next Gancio events and deactivare Next events
*/
function GetNextEventsCount() {
const entryComponent = document.querySelector('#nextevents');
const shadowRoot = entryComponent.shadowRoot;
const app = shadowRoot.querySelector('div');
if (app != null) {
return app.children.length;
} else {
return 0;
}
}
function ActivePastEvents() {
const nexttab = document.getElementById("proximostab");
const next = document.getElementById("proximos");
const pasttab = document.getElementById("pasadostab");
const past = document.getElementById("pasados");
if (nexttab != null && next !== null){
next.classList.remove("active");
nexttab.classList.remove("active");
next.classList.add("fade");
}
if (pasttab != null && past !== null){
past.classList.remove("fade");
past.classList.add("active");
pasttab.classList.add("active");
}
}
function ActivePastEventsIfNotNexts() {
if (GetNextEventsCount() == 0) {
ActivePastEvents();
}
}