Files
portfolio/scripts/main.js
2023-11-01 21:41:58 +01:00

52 lines
1.4 KiB
JavaScript

AOS.init({
anchorPlacement: 'top-left',
duration: 1000
});
document.querySelector('.avatar').addEventListener('mouseenter', () => {
document.querySelector('.cover-bg').style.backgroundColor = 'var(--secondaryColor)';
});
document.querySelector('.avatar').addEventListener('mouseleave', () => {
document.querySelector('.cover-bg').style.backgroundColor = '';
});
async function loadTable() {
const response = await fetch('./articles.json', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});
const data = await response.json();
data.forEach(entry => {
const row = document.getElementById('myTable').querySelector('tbody').insertRow();
const dateCell = row.insertCell();
dateCell.textContent = entry.date;
const nameCell = row.insertCell();
nameCell.textContent = entry.name;
const descCell = row.insertCell();
descCell.textContent = entry.description;
});
}
loadTable()
window.onscroll = function() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
document.querySelector('.back-to-top').style.display = 'block';
} else {
document.querySelector('.back-to-top').style.display = 'none';
}
};
document.querySelector('.back-to-top').addEventListener('click', function() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
});