-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
68 lines (59 loc) · 2.74 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<script>
let isLeftMenuVisible = false;
let isRightContainerVisible = false;
let isRightContainer1Visible = false;
const toggleVisibility = (element, isVisible) => {
element.style.display = isVisible ? 'block' : 'none';
};
const handleMenuClick = (event, container, isVisibleFlag) => {
event.preventDefault();
toggleVisibility(container, !isVisibleFlag);
isVisibleFlag = !isVisibleFlag;
event.target.classList.toggle('selected', isVisibleFlag);
history.pushState({}, '', window.location.pathname + (isVisibleFlag ? `?selected=${event.target.id}` : ''));
return isVisibleFlag;
};
window.addEventListener('load', () => {
const urlParams = new URLSearchParams(window.location.search);
const selected = urlParams.get('selected');
if (selected) {
const selectedItem = document.getElementById(selected);
if (selectedItem) {
selectedItem.classList.add('selected');
}
}
});
document.getElementById('ghaf-24.09.0').addEventListener('click', event => {
event.preventDefault();
const leftMenu = document.getElementById('left-menu');
const rightContainer = document.querySelector('.right-container');
const rightContainer1 = document.querySelector('.right-container-1');
isLeftMenuVisible = !isLeftMenuVisible;
toggleVisibility(leftMenu, isLeftMenuVisible);
toggleVisibility(rightContainer, false);
toggleVisibility(rightContainer1, false);
isRightContainerVisible = false;
isRightContainer1Visible = false;
document.getElementById('ghaf-24.09').classList.remove('selected');
document.getElementById('ghaf-24.09.1').classList.remove('selected');
});
document.getElementById('ghaf-24.09').addEventListener('click', event => {
isRightContainerVisible = handleMenuClick(event, document.querySelector('.right-container'), isRightContainerVisible);
toggleVisibility(document.querySelector('.right-container-1'), false);
isRightContainer1Visible = false;
document.getElementById('ghaf-24.09.1').classList.remove('selected');
});
document.getElementById('ghaf-24.09.1').addEventListener('click', event => {
isRightContainer1Visible = handleMenuClick(event, document.querySelector('.right-container-1'), isRightContainer1Visible);
toggleVisibility(document.querySelector('.right-container'), false);
isRightContainerVisible = false;
document.getElementById('ghaf-24.09').classList.remove('selected');
});
document.querySelectorAll('.menu a').forEach(link => {
link.addEventListener('click', function() {
document.querySelectorAll('.menu a').forEach(link => link.classList.remove('selected'));
this.classList.add('selected');
history.pushState({}, '', window.location.pathname + `?selected=${this.id}`);
});
});
</script>