Main Website's Javascript
Written by Simone
I'm not very familiar with javascript when it come to websites - a bit better is node.js, but that's another story..
I just wanted to give credit to my Steam friend andrei-kom (Thanks Andrei) for this piece of javascript he wrote to enhance the side menu of my main website. Now the buttons are highlighted not just on press but also when scrolling the page up and down! Woo-hoo 😀
Here's the code:
$(document).ready(function () {
$('a').on('click', function (e) {
$('a').removeClass('w3-hover-black-activated');
$(this).addClass('w3-hover-black-activated');
});
$('#home').addClass('contentBlock');
$('.w3-content').addClass('contentBlock');
$(window).scroll(function () {
var pageOffset = window.pageYOffset + 64;
$('.contentBlock').each(function () {
var contentBlockOffset = $(this).offset().top;
var id = $(this).attr('id');
if (id == 'home') {
id = '';
}
if (pageOffset >= contentBlockOffset) {
$('a.w3-button').removeClass('w3-hover-black-activated');
$('a.w3-button[href="#' + id + '"]').addClass('w3-hover-black-activated');
}
});
});
});