Commit e3525841 authored by Dominik V. Salonen's avatar Dominik V. Salonen

Please for the love of god, work

parent 00840634
......@@ -12,6 +12,8 @@ var page1 = "pages/about.html";
var page2 = "pages/about.html";
var page3 = "pages/about.html";
const contentArea = document.getElementById("page");
const spinner = '<i class="fas fa-spinner loading"></i>';
// Very bad function to get rid of the "active" class wherever it is atm
......@@ -21,22 +23,37 @@ function resetButtons() {
button3.className = "nav-button";
}
function setContent(navbutt, payload) {
document.getElementById("page").innerHTML = spinner;
function httpGet(myUrl, callback) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(contentArea, xmlHttp.responseText);
}
xmlHttp.open("GET", myUrl, true);
xmlHttp.send(null);
}
function activatePage(navbutt, source) {
contentArea.innerHTML = spinner;
resetButtons();
navbutt.className += " active";
httpGet(source, setContent);
}
function setContent(target, payload) {
target.innerHTML = payload;
}
function initialContent() {
// Slap on all the event listeners
button1.addEventListener('click', function() {
setContent(button1, page1);
activatePage(button1, page1);
}, false);
button2.addEventListener('click', function() {
setContent(button2, page2);
activatePage(button2, page2);
}, false);
button3.addEventListener('click', function() {
setContent(button3, page3);
activatePage(button3, page3);
}, false);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment