-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
63 lines (54 loc) · 1.66 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
let hamburger = document.querySelector(".hamburger");
let navLinks = document.getElementById("nav-links");
let links = document.querySelectorAll(".links");
let words = ["Web Developer", "Designer", "Programmer", "Engineer"];
let typingDiv = document.getElementById("typing-text");
let wordIndex = 0;
let word = words[wordIndex];
let typingSpeed = 500;
setInterval(() => {
wordIndex++;
if (wordIndex >= words.length) {
wordIndex = 0;
}
typingDiv.style.fontSize = "34px";
typingDiv.style.color = "#f1c40f";
typingDiv.style.marginTop = "10%";
word = words[wordIndex];
typingDiv.innerHTML = word;
}, 2500);
hamburger.addEventListener("click", () => {
navLinks.classList.toggle("hide");
hamburger.classList.toggle("lines-rotate");
});
for (let i = 0; i < links.length; i++) {
links[i].addEventListener("click", () => {
navLinks.classList.toggle("hide");
});
}
// DYNAMIC YEAR
let year = document.getElementById("year");
let dynamicYear = new Date().getFullYear();
year.innerHTML = dynamicYear;
// dark theme
document.addEventListener("DOMContentLoaded", (event) => {
const recaptcha = document.querySelector(".g-recaptcha");
recaptcha.setAttribute("data-theme", "dark");
});
// for multi title
let alertShow = false;
setInterval(() => {
document.title = alertShow ? "Portfolio" : "Gagan Arora";
alertShow = !alertShow;
}, 3000);
//current time
function displayCurrentTime() {
var date = new Date();
var time = date.toLocaleTimeString();
document.getElementById("current-time").innerHTML = time;
}
// Update the time every second
setInterval(displayCurrentTime, 1000);
function scrollToTop() {
window.scrollTo({ top: 0, behavior: "smooth" });
}