lollms-webui/static/js/tabs.js
2023-04-13 22:44:26 +02:00

39 lines
1.0 KiB
JavaScript

function showTab(tabId) {
// hide all tabs
var tabs = document.getElementsByClassName('tab-pane');
for (var i = 0; i < tabs.length; i++) {
tabs[i].style.display = 'none';
}
// show the selected tab
console.log(tabId)
var tab = document.getElementById(tabId);
tab.style.display = 'block';
}
// show the main tab by default
showTab('main');
// add event listeners to the tab links
var tabLinks = document.getElementsByTagName('a');
for (var i = 0; i < tabLinks.length; i++) {
tabLinks[i].addEventListener('click', function(event) {
event.preventDefault();
var tabId = this.getAttribute('href').substring(1);
showTab(tabId);
});
}
fetch('/main')
.then(response => response.text())
.then(html => {
document.getElementById('main').innerHTML = html;
// First time we populate the discussions list
populate_discussions_list()
load_discussion();
update_main();
db_export();
})
.catch(error => {
console.error('Error loading main page:', error);
});