move PageSwitchTab

This commit is contained in:
ReznoRMichael 2021-08-01 22:45:47 +02:00
commit 7ec11846d1
3 changed files with 122 additions and 122 deletions

View file

@ -602,62 +602,6 @@ function GenerateInnerHTML(db) {
benchmarkTimes.GenerateInnerHTML.timeEnd = performance.now();
}
/**
* Hides all other tabs, except the one which button was clicked (shows only the chosen tab)
* @param {String} clickedButton The click target (button clicked)
*/
function PageSwitchTab(clickedButton) {
let sectionList = document.querySelectorAll(".large-section");
let buttonList = document.querySelectorAll(".tab-switch");
/* Make Active Tab Visible */
for (let i = 0, length = sectionList.length; i < length; i++) {
/* Other tabs except the clicked one */
if (sectionList[i].id !== `tab-${clickedButton}`) {
if (!sectionList[i].classList.contains("hidden")) {
sectionList[i].classList.add("hidden");
}
}
/* The clicked tab */
else {
if (sectionList[i].classList.contains("hidden")) {
sectionList[i].classList.remove("hidden");
}
}
}
/* Make Active Button stand out */
for (let i = 0, length = buttonList.length; i < length; i++) {
/* Other buttons except the clicked one */
if (buttonList[i].id !== `button-switch-${clickedButton}`) {
if (buttonList[i].classList.contains("tab-active")) {
buttonList[i].classList.remove("tab-active");
}
}
/* The clicked button */
else {
if (!buttonList[i].classList.contains("tab-active")) {
buttonList[i].classList.add("tab-active");
}
}
}
/* remember this choice for subsequent page visits and browser restarts */
if (StorageAvailable('localStorage')) {
if (clickedButton) {
localStorage.setItem("hkTabActive", clickedButton);
}
}
}
function SectionDescription(section) {
return `<p class="section-description">${section.description}</p>`;
@ -924,6 +868,62 @@ function CheckboxSpoilersToggle(param = "none") {
}
}
/**
* Hides all other tabs, except the one which button was clicked (shows only the chosen tab)
* @param {String} clickedButton The click target (button clicked)
*/
function PageSwitchTab(clickedButton) {
let sectionList = document.querySelectorAll(".large-section");
let buttonList = document.querySelectorAll(".tab-switch");
/* Make Active Tab Visible */
for (let i = 0, length = sectionList.length; i < length; i++) {
/* Other tabs except the clicked one */
if (sectionList[i].id !== `tab-${clickedButton}`) {
if (!sectionList[i].classList.contains("hidden")) {
sectionList[i].classList.add("hidden");
}
}
/* The clicked tab */
else {
if (sectionList[i].classList.contains("hidden")) {
sectionList[i].classList.remove("hidden");
}
}
}
/* Make Active Button stand out */
for (let i = 0, length = buttonList.length; i < length; i++) {
/* Other buttons except the clicked one */
if (buttonList[i].id !== `button-switch-${clickedButton}`) {
if (buttonList[i].classList.contains("tab-active")) {
buttonList[i].classList.remove("tab-active");
}
}
/* The clicked button */
else {
if (!buttonList[i].classList.contains("tab-active")) {
buttonList[i].classList.add("tab-active");
}
}
}
/* remember this choice for subsequent page visits and browser restarts */
if (StorageAvailable('localStorage')) {
if (clickedButton) {
localStorage.setItem("hkTabActive", clickedButton);
}
}
}
/**
* Detects whether Storage is both supported and available.
* MDN WebDocs https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#feature-detecting_localstorage