-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
120 lines (106 loc) · 4.11 KB
/
script.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var currentUrl = window.location.href;
var newUrl = currentUrl;
if (currentUrl.includes("github.io")) {
if (currentUrl.endsWith("index.html") || currentUrl.endsWith("index")) {
newUrl = currentUrl.replace(/index\.html$|index$/, '');
} else if (window.location.pathname.endsWith(".html")) {
newUrl = currentUrl.replace(/\.html$/, '');
}
if (newUrl !== currentUrl) {
window.history.replaceState(null, null, newUrl);
}
}
const typedTitle = document.getElementById('typed-text');
const typedDescription = document.getElementById('typed-description');
const buttons = document.querySelector('.buttons');
const typewriterEffect = (text, element) => {
let charIndex = 0;
const typeInterval = setInterval(() => {
if (charIndex === text.length) {
clearInterval(typeInterval);
return;
}
element.textContent += text[charIndex];
charIndex++;
}, 50);
};
window.addEventListener('load', () => {
if (typedTitle) {
const title = typedTitle.getAttribute('data-typed');
typewriterEffect(title, typedTitle);
}
if (typedDescription) {
const description = typedDescription.getAttribute('data-typed');
typewriterEffect(description, typedDescription);
}
if (buttons) {
setTimeout(() => {
buttons.classList.add('fade-visible');
}, 1000);
}
});
document.addEventListener("DOMContentLoaded", function() {
var profilePic = document.querySelector('.profile-pic');
if (profilePic) {
if (profilePic.complete) {
profilePic.classList.add('loaded');
} else {
profilePic.onload = function() {
profilePic.classList.add('loaded');
};
}
}
});
document.addEventListener("DOMContentLoaded", function() {
var blackRegion = document.querySelector('.black-region');
var fadeInSection = document.querySelector('.fade-in-page-title');
var header = document.querySelector('header');
if (blackRegion && fadeInSection) {
blackRegion.style.opacity = '1';
blackRegion.style.height = '25vh';
fadeInSection.classList.add('show');
}
if (header) {
header.classList.add('show');
}
});
document.addEventListener("DOMContentLoaded", function() {
const projects = document.querySelectorAll('.project');
let currentExpandedProject = null;
projects.forEach(project => {
const fullDescription = project.querySelector('.full-description');
const buttons = project.querySelector('.project-buttons');
project.addEventListener('click', () => {
if (project.classList.contains('expanded')) {
fullDescription.style.maxHeight = null;
project.classList.remove('expanded');
if (buttons) {
buttons.style.maxHeight = "0";
buttons.style.overflow = "hidden";
console.log("Buttons hidden");
}
currentExpandedProject = null;
} else {
if (currentExpandedProject) {
const prevFullDescription = currentExpandedProject.querySelector('.full-description');
prevFullDescription.style.maxHeight = null;
currentExpandedProject.classList.remove('expanded');
const prevButtons = currentExpandedProject.querySelector('.project-buttons');
if (prevButtons) {
prevButtons.style.maxHeight = "0";
prevButtons.style.overflow = "hidden";
console.log("Previous buttons hidden");
}
}
fullDescription.style.maxHeight = fullDescription.scrollHeight + "px";
project.classList.add('expanded');
if (buttons) {
buttons.style.maxHeight = "100%";
buttons.style.overflow = "visible";
console.log("Buttons shown");
}
currentExpandedProject = project;
}
});
});
});