-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
45 lines (42 loc) · 1.61 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
$(document).ready(function() {
// $('#eventsPageContainer').load('./events.html');
window.scrollTo(0,0);
let cUrl = window.location.href;
let urlAndSections = cUrl.split('#');
if(urlAndSections.length !== 1){
let section = urlAndSections[1];
$('.section-container').hide();
$('#' + section).show();
$('.nav-link').removeClass('active');
$('.nav-link[data-page="' + section + '"]').addClass('active');
}else{
$('.section-container').hide();
$('#index').show();
$('.nav-link').removeClass('active');
$('.nav-link[data-page="index"]').addClass('active');
}
$('.nav-link').click(function() {
let section = $(this).attr('data-page');
if (section == "external-link"){
return true;
}
$('.nav-link').removeClass('active');
$(this).addClass('active');
$('.section-container').hide();
$('#' + section).show();
let cUrl = window.location.href;
let newUrl = cUrl.split('#')[0];
window.history.pushState(null, null, newUrl + '#' + section);
});
$('.footer-link').click(function() {
let section = $(this).attr('data-page');
$('.section-container').hide();
$('#' + section).show();
let cUrl = window.location.href;
let newUrl = cUrl.split('#')[0];
window.history.pushState(null, null, newUrl + '#' + section);
$('.nav-link').removeClass('active');
$('.nav-link[data-page="' + section + '"]').addClass('active');
window.scrollTo(0,0);
});
});