Move tabs script to its own file

This commit is contained in:
Pk11 2020-09-03 17:57:47 -05:00 committed by lifehackerhansol
parent f5f876441c
commit 3b87b88d71
No known key found for this signature in database
GPG key ID: 80FB184AFC0B3B0E
3 changed files with 42 additions and 50 deletions

View file

@ -152,27 +152,4 @@ We have many other tutorials that you might like.
You can now use homebrew such as [USB Loader GX](usbloadergx) and [WiiFlow](wiiflow).
{: .notice--info}
<script>
let tabcontent = document.getElementsByClassName("blanktabcontent");
let tablinks = document.getElementsByClassName("tablinks");
function openTab(evt, tabName) {
let element;
for (element of tabcontent) {
element.style.display = "none";
}
for (element of tablinks) {
element.className = element.className.replace("btn--primary", "btn--info");
if (!element.className.includes('btn--info'))
element.className += " btn--info";
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className = evt.currentTarget.className.replace("btn--info", "btn--primary");
}
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>
<script src="/assets/js/tabs.js"></script>

View file

@ -109,29 +109,4 @@ If you dumped the disc on a FAT32 formatted, device, you should've got at least
To organize the games on your drive properly, you'll need to use [Wii Backup Manager](wiibackupmanager).
{: .notice--info}
<script>
let tabcontent = document.getElementsByClassName("blanktabcontent");
let tablinks = document.getElementsByClassName("tablinks");
for (e of tabcontent) element.style.display = "none";
function openTab(evt, tabName) {
let element;
for (element of tabcontent) {
element.style.display = "none";
}
for (element of tablinks) {
element.className = element.className.replace("btn--primary", "btn--info");
if (!element.className.includes('btn--info'))
element.className += " btn--info";
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className = evt.currentTarget.className.replace("btn--info", "btn--primary");
}
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>
<script src="/assets/js/tabs.js"></script>

40
assets/js/tabs.js Normal file
View file

@ -0,0 +1,40 @@
let tabcontent = document.getElementsByClassName("blanktabcontent");
let tablinks = document.getElementsByClassName("tablinks");
function openTab(evt, tabName) {
let element;
for (element of tabcontent) {
element.style.display = "none";
}
for (element of tablinks) {
element.className = element.className.replace("btn--primary", "btn--info");
if (!element.className.includes('btn--info'))
element.className += " btn--info";
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className = evt.currentTarget.className.replace("btn--info", "btn--primary");
}
// Remove links from tab buttons
for(a of tablinks) {
a.href = "javascript:void(0);";
}
// Open the tab for the current OS
if(navigator.platform.includes("Win")) {
if(document.getElementById("windows"))
document.getElementById("windows").click();
else
document.getElementById("other").click();
} else if(navigator.platform.includes("Mac")) {
if(document.getElementById("macos"))
document.getElementById("macos").click();
else
document.getElementById("other").click();
} else {
document.getElementById("other").click();
}