2018-03-14 07:16:21 +00:00
|
|
|
// I suck at JS okay, don't judge. I know this is horrendous. Heavy copy/paste junk.
|
|
|
|
// Code is commented more than it needs to be because I'm still learning and the comments are basically post-it notes to help me remember.
|
|
|
|
// Ajax is entirely pointless for this site, but I did it to learn.
|
|
|
|
|
|
|
|
// Find all our buttons
|
|
|
|
const button1 = document.getElementById('button1');
|
|
|
|
const button2 = document.getElementById('button2');
|
|
|
|
const button3 = document.getElementById('button3');
|
|
|
|
|
|
|
|
// Create variables that will get populated by loadContent() later
|
2018-03-14 12:46:37 +00:00
|
|
|
var page1 = "pages/about.html";
|
|
|
|
var page2 = "pages/about.html";
|
|
|
|
var page3 = "pages/about.html";
|
|
|
|
|
|
|
|
const spinner = '<i class="fas fa-spinner loading"></i>';
|
2018-03-14 07:16:21 +00:00
|
|
|
|
|
|
|
// Very bad function to get rid of the "active" class wherever it is atm
|
|
|
|
function resetButtons() {
|
|
|
|
button1.className = "nav-button";
|
|
|
|
button2.className = "nav-button";
|
|
|
|
button3.className = "nav-button";
|
|
|
|
}
|
|
|
|
|
|
|
|
function setContent(navbutt, payload) {
|
2018-03-14 12:46:37 +00:00
|
|
|
document.getElementById("page").innerHTML = spinner;
|
2018-03-14 07:16:21 +00:00
|
|
|
resetButtons();
|
|
|
|
navbutt.className += " active";
|
|
|
|
}
|
|
|
|
|
2018-03-14 12:46:37 +00:00
|
|
|
function initialContent() {
|
2018-03-14 07:16:21 +00:00
|
|
|
|
|
|
|
// Slap on all the event listeners
|
|
|
|
button1.addEventListener('click', function() {
|
2018-03-14 12:46:37 +00:00
|
|
|
setContent(button1, page1);
|
2018-03-14 07:16:21 +00:00
|
|
|
}, false);
|
|
|
|
button2.addEventListener('click', function() {
|
2018-03-14 12:46:37 +00:00
|
|
|
setContent(button2, page2);
|
2018-03-14 07:16:21 +00:00
|
|
|
}, false);
|
|
|
|
button3.addEventListener('click', function() {
|
2018-03-14 12:46:37 +00:00
|
|
|
setContent(button3, page3);
|
2018-03-14 07:16:21 +00:00
|
|
|
}, false);
|
2018-03-14 09:08:50 +00:00
|
|
|
}
|