-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
83 lines (61 loc) · 2.42 KB
/
scripts.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
69
70
71
72
73
74
75
76
77
78
79
80
// Adding an event to detect when the page is scrolled
window.onscroll = function() {
var topBar = document.querySelector('.top-bar');
if (window.scrollY > 0) {
topBar.classList.add('scrolled'); // Adds the .scrolled class when scrolling
} else {
topBar.classList.remove('scrolled'); // Removes the class when at the top of the page
}
};
function toggleMenu() {
const menu = document.getElementById('menu');
const overlay = document.getElementById('menu-overlay');
// Toggle the menu and overlay
const isVisible = menu.classList.toggle('show');
overlay.style.display = isVisible ? 'block' : 'none';
}
// Close the menu when clicking on the overlay
document.getElementById('menu-overlay').addEventListener('click', () => {
const menu = document.getElementById('menu');
const overlay = document.getElementById('menu-overlay');
menu.classList.remove('show');
overlay.style.display = 'none';
});
// Optional: Close the menu when clicking on a menu link
document.querySelectorAll('.menu a').forEach(link => {
link.addEventListener('click', () => {
const menu = document.getElementById('menu');
const overlay = document.getElementById('menu-overlay');
menu.classList.remove('show');
overlay.style.display = 'none';
});
});
document.addEventListener("DOMContentLoaded", function () {
function loadSection(sectionId, filePath) {
fetch(filePath)
.then(response => response.text())
.then(data => document.getElementById(sectionId).innerHTML = data)
.catch(error => console.log('Erreur de chargement:', error));
}
loadSection('introduction', 'sections/introduction.html');
});
let currentPage = 1;
const totalPages = 4;
function changePage(direction) {
currentPage += direction;
// Si la page actuelle dépasse les limites, on recommence depuis le début ou on va à la fin
if (currentPage < 1) {
currentPage = totalPages;
} else if (currentPage > totalPages) {
currentPage = 1;
}
// Cache toutes les pages et affiche la page correspondante
for (let i = 1; i <= totalPages; i++) {
document.getElementById('page' + i).style.display = 'none';
}
document.getElementById('page' + currentPage).style.display = 'flex';
}
// Initialiser la première page
document.addEventListener('DOMContentLoaded', function() {
changePage(0);
});