-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript.js
41 lines (36 loc) · 1.35 KB
/
javascript.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
// Mobile menu toggle
window.onload = function () {
const menu_btn = document.querySelector('.hamburger');
const mobile_menu = document.querySelector('.mobile-nav');
menu_btn.addEventListener('click', function () {
menu_btn.classList.toggle('is-active');
mobile_menu.classList.toggle('is-active');
});
}
var currentPage = window.location.pathname;
console.log(currentPage);
// Background image randomization
if (currentPage === '/berserk' || currentPage === '/cowboy' || currentPage === '/gate' || currentPage === '/fullmetal') {
document.addEventListener("DOMContentLoaded", function () {
function pic() {
var bgm = [
'/images/img1.webp',
'/images/img2.webp',
'/images/img3.webp',
'/images/img4.webp',
'/images/img5.webp',
'/images/img6.webp',
'/images/img7.webp',
'/images/img8.webp',
];
// Get a random index from the array
var randomIndex = Math.floor(Math.random() * bgm.length);
// Set the background image of the body
document.body.style.background = 'url(' + bgm[randomIndex] + ') no-repeat';
document.body.style.backgroundSize = 'cover';
document.body.style.backgroundAttachment = 'fixed';
document.body.style.backgroundColor = 'black';
}
pic();
});
}