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

46 lines
1.2 KiB
JavaScript

/*
* Detect no next Gancio events and deactivate Next events
*/
function GetNextEventsCount(ge_id) {
const entryComponent = document.querySelector('#' + ge_id);
const shadowRoot = entryComponent.shadowRoot;
const app = shadowRoot.querySelector('div');
if (app != null) {
return app.children.length;
} else {
return 0;
}
}
function ActivePastEvents(tab_next, tab_past) {
const nexttab = document.getElementById("tab-" + tab_next);
const next = document.getElementById("tab-pane-" + tab_next);
const pasttab = document.getElementById("tab-" + tab_past);
const past = document.getElementById("tab-pane-" + tab_past);
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 ShowElement(id) {
const element = document.getElementById(id);
if (element) {
element.style.display = "block";
}
}
function ActivePastEventsIfNotNexts(ge_id, tab_next, tab_past, msg_id) {
if (GetNextEventsCount(ge_id) == 0) {
ActivePastEvents(tab_next, tab_past);
}
ShowElement(msg_id);
}