ntphuc149 commited on
Commit
b049770
·
verified ·
1 Parent(s): 224cc08

Create script.js

Browse files
Files changed (1) hide show
  1. script.js +123 -0
script.js ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // ===== THEME TOGGLE =====
2
+ function toggleTheme() {
3
+ const html = document.documentElement;
4
+ const currentTheme = html.getAttribute("data-theme");
5
+ const newTheme = currentTheme === "dark" ? "light" : "dark";
6
+ const themeIcon = document.getElementById("themeIcon");
7
+
8
+ html.setAttribute("data-theme", newTheme);
9
+ localStorage.setItem("theme", newTheme);
10
+ themeIcon.className = newTheme === "dark" ? "ri-sun-fill" : "ri-moon-fill";
11
+ }
12
+
13
+ // ===== MOBILE MENU TOGGLE =====
14
+ function toggleMenu() {
15
+ const navLinks = document.getElementById("navLinks");
16
+ navLinks.classList.toggle("active");
17
+ }
18
+
19
+ // ===== LOAD SAVED THEME =====
20
+ window.addEventListener("DOMContentLoaded", () => {
21
+ const savedTheme = localStorage.getItem("theme") || "light";
22
+ const themeIcon = document.getElementById("themeIcon");
23
+ document.documentElement.setAttribute("data-theme", savedTheme);
24
+ themeIcon.className = savedTheme === "dark" ? "ri-sun-fill" : "ri-moon-fill";
25
+ });
26
+
27
+ // ===== SMOOTH SCROLL WITH OFFSET =====
28
+ document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
29
+ anchor.addEventListener("click", function (e) {
30
+ e.preventDefault();
31
+ const target = document.querySelector(this.getAttribute("href"));
32
+ if (target) {
33
+ const offset = 80;
34
+ const targetPosition = target.offsetTop - offset;
35
+ window.scrollTo({
36
+ top: targetPosition,
37
+ behavior: "smooth",
38
+ });
39
+ // Close mobile menu if open
40
+ document.getElementById("navLinks").classList.remove("active");
41
+ }
42
+ });
43
+ });
44
+
45
+ // ===== SCROLL ANIMATION =====
46
+ const observerOptions = {
47
+ threshold: 0.1,
48
+ rootMargin: "0px 0px -100px 0px",
49
+ };
50
+
51
+ const observer = new IntersectionObserver((entries) => {
52
+ entries.forEach((entry) => {
53
+ if (entry.isIntersecting) {
54
+ entry.target.style.opacity = "1";
55
+ entry.target.style.transform = "translateY(0)";
56
+ }
57
+ });
58
+ }, observerOptions);
59
+
60
+ document.querySelectorAll(".glass-card, .timeline-item").forEach((el) => {
61
+ el.style.opacity = "0";
62
+ el.style.transform = "translateY(20px)";
63
+ el.style.transition = "all 0.6s ease";
64
+ observer.observe(el);
65
+ });
66
+
67
+ // ===== SOCIAL LINKS PLACEHOLDERS =====
68
+ // Update these with your actual links
69
+ const socialLinks = {
70
+ scholar: "https://scholar.google.com/citations?user=h126goIAAAAJ", // Add your Google Scholar URL here
71
+ github: "https://github.com/ntphuc149", // Add your GitHub URL here
72
+ linkedin: "https://www.linkedin.com/in/ntphuc149/", // Add your LinkedIn URL here
73
+ };
74
+
75
+ document.getElementById("scholarLink").addEventListener("click", (e) => {
76
+ if (!socialLinks.scholar) {
77
+ e.preventDefault();
78
+ alert("Please update your Google Scholar link in the script.js file");
79
+ } else {
80
+ window.open(socialLinks.scholar, "_blank");
81
+ }
82
+ });
83
+
84
+ document.getElementById("githubLink").addEventListener("click", (e) => {
85
+ if (!socialLinks.github) {
86
+ e.preventDefault();
87
+ alert("Please update your GitHub link in the script.js file");
88
+ } else {
89
+ window.open(socialLinks.github, "_blank");
90
+ }
91
+ });
92
+
93
+ document.getElementById("linkedinLink").addEventListener("click", (e) => {
94
+ if (!socialLinks.linkedin) {
95
+ e.preventDefault();
96
+ alert("Please update your LinkedIn link in the script.js file");
97
+ } else {
98
+ window.open(socialLinks.linkedin, "_blank");
99
+ }
100
+ });
101
+
102
+ // ===== EXPERIENCE TABS SWITCHING =====
103
+ function switchTab(tabName) {
104
+ // Get all tab buttons and contents
105
+ const tabButtons = document.querySelectorAll(".tab-btn");
106
+ const tabContents = document.querySelectorAll(".tab-content");
107
+
108
+ // Remove active class from all buttons and contents
109
+ tabButtons.forEach((btn) => btn.classList.remove("active"));
110
+ tabContents.forEach((content) => content.classList.remove("active"));
111
+
112
+ // Add active class to clicked button
113
+ const clickedButton = event.target.closest(".tab-btn");
114
+ if (clickedButton) {
115
+ clickedButton.classList.add("active");
116
+ }
117
+
118
+ // Show corresponding tab content
119
+ const targetTab = document.getElementById(tabName + "-tab");
120
+ if (targetTab) {
121
+ targetTab.classList.add("active");
122
+ }
123
+ }