function eraseCategories(){
let cat = document.querySelectorAll(`.element`)
cat.forEach(cat_element => {
cat_element.style.display = "none"
});
}
function selectCategory(category){
eraseCategories()
if (category == 'all'){
let cat = document.querySelectorAll(`.element`)
cat.forEach(cat_element => {
cat_element.style.display = "flex"
});
} else {
let cat = document.querySelectorAll(`.${category}`)
cat.forEach(cat_element => {
cat_element.style.display = "flex"
});
}
bo()
}
function bo(){
let projs = document.querySelectorAll('.element')
projs.forEach(proj => {
proj.addEventListener("mouseenter", () => {
let titl = proj.appendChild(document.createElement('a'))
// let pic = proj.querySelector('img').getAttribute('src')
proj.querySelector('img').style.opacity = '0.5'
// titl.style.backgroundImage = "url(" + pic +")"
titl.href = proj.dataset.slug
titl.innerHTML = proj.dataset.title
titl.classList.add('overed')
})
proj.addEventListener("mouseleave", () => {
proj.querySelector('img').style.opacity = '1'
document.querySelector('.overed').remove()
})
});
}
var x = window.matchMedia("(max-width: 1050px)")
if (!x.matches) { // If media query matches
bo()
}
// DA TENERE
// let opening_pics = ['_DSC7702.JPG','Buoni_a_nulla.JPG','Ido.jpg','Ido2.jpg','Sito.JPG']
// let i = 0;
// let x;
// let y;
// function addPic(event) {
// x = event.clientX;
// y = event.clientY;
// r = Math.floor(Math.random() * (10 - (-10)) + (-10))
// document.querySelector(".presentazione").innerHTML+=``
// i++
// if (i >= opening_pics.length){
// i = 0
// }
// }
// document.querySelector(".presentazione").addEventListener("click", addPic)
function toggleMenu(tog){
if (toggle){
document.querySelector(".burger").style.display = "flex"
document.querySelector("#fakeBackground").style.display = "block"
document.querySelector("#toggle").innerHTML = ''
} else {
document.querySelector(".burger").style.display = "none"
document.querySelector("#fakeBackground").style.display = "none"
document.querySelector("#toggle").innerHTML = ''
}
toggle = !toggle
}
let toggle = true
document.querySelector("#toggle").addEventListener("click", ()=>{
toggleMenu()
})
let egg = document.getElementById("egg")
let toggleEgg = false
egg.addEventListener("click", ()=>{
egg.style.zIndex = 100
setTimeout(() => {
toggleEgg = !toggleEgg
}, 100);
})
document.body.addEventListener('click', ()=>{
if (toggleEgg == true){
egg.style.zIndex = -10
}
})
var swiper = new Swiper(".swiper", {
loop: true,
// autoplay: true,
clickable: true,
// autoplay: {
// delay: 2500,
// disableOnInteraction: false,
// },
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
pagination: {
el: ".swiper-pagination",
dynamicBullets: true,
},
});
function openFriends(){
document.querySelector("#friends").style.display = 'inline'
// toggleMenu(false)
}
function closeFriends(){
document.querySelector("#friends").style.display = 'none'
// window.href = ''
}
function lightingNews(){
document.querySelector('footer').classList += 'animated'
setTimeout(() => {
document.querySelector('footer').classList.remove("animated")
}, 1500);
}
// when window resize close the burger menu if it's opened
window.onresize = function(event) {
if (document.querySelector(".burger").style.display = "flex"){
document.querySelector(".burger").style.display = "none"
document.querySelector("#fakeBackground").style.display = "none"
document.querySelector("#toggle").innerHTML = ''
}
};
// if (x.matches) { // If media query matches
// window.location.href = 'https://lorenzoponte.com'
// }
// document.querySelectorAll('marquee').forEach(marquee => {
// if (!x.matches) { // If media query matches
// marquee.addEventListener('mouseover', () => {
// this.stop()
// })
// marquee.addEventListener('mouse', () => {
// this.start()
// })
// }
// });
// const listStyles = ['disc', 'circle', 'square', 'armenian', 'disclosure-closed', 'disclosure-open','ethiopic-numeric', 'decimal', 'lower-roman', 'lower-alpha', 'upper-alpha', 'none'];
// // Function to get a random list style
// function getRandomListStyle() {
// const randomIndex = Math.floor(Math.random() * listStyles.length);
// return listStyles[randomIndex];
// }
// // Function to apply the random list style to the list
// function randomizeListStyle() {
// const lists = document.querySelectorAll('ul');
// const randomStyle = getRandomListStyle();
// lists.forEach(list => {
// list.style.listStyleType = randomStyle;
// });
// }
// // Optional: Automatically change the list style every few seconds
// setInterval(randomizeListStyle, 500);