homepage/res/index.js

49 lines
1.3 KiB
JavaScript
Raw Normal View History

let selectedButtonId = 'button-home';
2020-10-04 23:56:12 +03:00
const changeSelected = (buttonId) => {
A(`#${selectedButtonId}`).removeClass('button-selected');
2020-10-04 23:56:12 +03:00
A(`#${buttonId}`).addClass('button-selected');
selectedButtonId = buttonId;
2020-10-04 23:56:12 +03:00
};
2020-10-04 22:40:10 +03:00
const onButtonClick = (buttonId) => {
if (selectedButtonId === buttonId) {
return;
}
2020-10-04 23:56:12 +03:00
changeSelected(buttonId);
2020-10-04 22:40:10 +03:00
switch (buttonId) {
case 'button-home': {
A('#content-container').load('/pages/home.html');
break;
}
case 'button-file-server': {
2020-10-05 00:00:20 +03:00
A('#content-container').load('/pages/upload.html');
2020-10-04 22:40:10 +03:00
break;
}
case 'button-git-server': {
2020-10-04 22:55:27 +03:00
window.location.href = 'https://git.hippoz.xyz/';
2020-10-04 22:40:10 +03:00
break;
}
2020-10-04 22:48:57 +03:00
case 'button-about-me': {
A('#content-container').load('/pages/about.html');
break;
}
case 'button-contact-me': {
A('#content-container').load('/pages/contact.html');
break;
}
2020-10-04 23:56:12 +03:00
default: {
console.error('Invalid button id');
return;
}
2020-10-04 22:40:10 +03:00
}
};
A(() => {
2020-10-04 22:48:57 +03:00
A('#content-container').load('/pages/home.html');
2020-10-04 22:40:10 +03:00
A('.navigation-buttons .button-default').each((el) => {
A(el).on('click', () => {
onButtonClick(el.id);
});
})
});