-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
80 lines (68 loc) · 2.41 KB
/
script.js
File metadata and controls
80 lines (68 loc) · 2.41 KB
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
// Fungsi untuk toggle mode gelap
function toggleDarkMode() {
const body = document.body;
body.classList.toggle("dark-mode");
}
// Fungsi untuk mengatur visibilitas elemen berdasarkan ukuran layar
function checkScreenSize() {
const screenWidth = window.innerWidth;
const someElement = document.getElementById('someElement');
if (screenWidth < 768) {
someElement.style.display = 'none';
} else {
someElement.style.display = 'block';
}
}
function updateClock() {
const now = new Date();
const hours = now.getHours();
const minutes = now.getMinutes();
const seconds = now.getSeconds();
// Kode untuk jam digital
const options = {
timeZone: 'Asia/Makassar',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
};
const formattedTime = now.toLocaleString('id-ID', options);
document.getElementById('digital-clock').textContent = formattedTime;
}
setInterval(updateClock, 1000);
updateClock();
// Event listeners untuk ukuran layar
window.addEventListener('load', checkScreenSize);
window.addEventListener('resize', checkScreenSize);
// Untuk navigasi titik tiga
const menuToggle = document.querySelector('.menu-toggle');
const sidebar = document.querySelector('.sidebar');
menuToggle.addEventListener('click', () => {
sidebar.classList.toggle('show');
menuToggle.setAttribute('aria-expanded', sidebar.classList.contains('show'));
});
// Untuk pop-up tooltips
const links = document.querySelectorAll('.link');
links.forEach(link => {
link.addEventListener('mouseover', () => {
const tooltip = document.createElement('div');
tooltip.classList.add('tooltip');
tooltip.textContent = link.dataset.tooltip;
document.body.appendChild(tooltip);
const rect = link.getBoundingClientRect();
tooltip.style.left = `${rect.left + rect.width / 2 - tooltip.offsetWidth / 2}px`;
tooltip.style.top = `${rect.bottom + 10}px`;
});
link.addEventListener('mouseout', () => {
const tooltip = document.querySelector('.tooltip');
if (tooltip) {
document.body.removeChild(tooltip);
}
});
});
// Menambahkan efek parallax pada bagian "About Me"
window.addEventListener('scroll', function() {
const aboutMeSection = document.querySelector('.about-me');
const scrollPosition = window.pageYOffset;
const parallaxValue = scrollPosition / 2;
aboutMeSection.style.backgroundPosition = 'center ' + parallaxValue + 'px';
});