OctoSpaccHub/source/SpiderADB/holo-web/holo-extra-octt.js

55 lines
1.9 KiB
JavaScript
Raw Normal View History

2024-04-15 01:30:58 +02:00
window.addEventListener('load', (function() {
var initialSectionName = $('[data-section][data-open]').dataset.section;
2024-04-15 01:30:58 +02:00
$('::[data-action-sidebar]').forEach(function(actionSidebarElem){
var sidebarElem = $('[data-sidebar="' + actionSidebarElem.dataset.actionSidebar + '"]');
function toggleSidebar () {
2024-04-15 01:30:58 +02:00
sidebarElem.dataset.open = (sidebarElem.dataset.open !== 'open' ? 'open' : false);
}
actionSidebarElem.addEventListener('click', toggleSidebar);
sidebarElem.addEventListener('click', toggleSidebar);
sidebarElem.querySelector('.holo-list').addEventListener('click', (function(event){
2024-04-15 01:30:58 +02:00
event.stopPropagation();
}));
2024-04-15 01:30:58 +02:00
arrayFrom(sidebarElem.querySelectorAll('.holo-list li button, .holo-list li [role="button"]')).forEach(function(buttonElem){
buttonElem.addEventListener('click', (function(){
sidebarElem.dataset.open = false;
}));
})
});
$('::[data-action-section]').forEach(function(actionSectionElem){
var sectionElems = $('::[data-section]');
var sectionTargetName = actionSectionElem.dataset.actionSection;
var sectionTargetElem = $('[data-section="' + sectionTargetName + '"]');
actionSectionElem.addEventListener('click', (function(event){
sectionElems.forEach(function(sectionElem){
sectionElem.dataset.open = false;
});
sectionTargetElem.dataset.open = 'open';
2024-04-17 01:30:25 +02:00
location.hash = `/${sectionTargetName}`;
2024-04-15 01:30:58 +02:00
refreshDisplaySections(sectionTargetName);
}));
});
function refreshDisplaySections (sectionTargetName) {
$('::[data-display-sections]').forEach(function(displaySectionsElem){
if (displaySectionsElem.dataset.displaySections.split(' ').includes(sectionTargetName)) {
displaySectionsElem.style.display = null;
} else {
displaySectionsElem.style.display = 'none';
}
});
}
refreshDisplaySections();
function hashChange () {
var sectionHash = location.hash.slice(2).split('/')[0];
$(`[data-action-section="${sectionHash || initialSectionName}"]`).click();
2024-04-17 01:30:25 +02:00
}
window.addEventListener('hashchange', hashChange);
hashChange();
2024-04-17 01:30:25 +02:00
2024-04-15 01:30:58 +02:00
}));