homepage/res/index.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-10-04 23:56:12 +03:00
let selected = 'button-home';
const changeSelected = (buttonId) => {
console.log(buttonId);
A(`#${selected}`).removeClass('button-selected');
A(`#${buttonId}`).addClass('button-selected');
selected = buttonId;
};
2020-10-04 22:40:10 +03:00
const onButtonClick = (buttonId) => {
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-04 22:55:27 +03:00
window.location.href = 'https://files.hippoz.xyz/';
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);
});
})
});