-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
170 lines (134 loc) · 4.27 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
(function () {
"use strict";
/**
* Easy event listener function
*/
const on = (type, el, listener, all = false) => {
let selectEl = select(el, all);
if (selectEl) {
if (all) {
selectEl.forEach((e) => e.addEventListener(type, listener));
} else {
selectEl.addEventListener(type, listener);
}
}
};
/**
* Easy selector helper function
*/
const select = (el, all = false) => {
el = el.trim();
if (all) {
return [...document.querySelectorAll(el)];
} else {
return document.querySelector(el);
}
};
on("click", ".mobile-nav-toggle", function (e) {
select("body").classList.toggle("mobile-nav-active");
this.classList.toggle("bi-list");
this.classList.toggle("bi-x");
});
/*Nav-list active class changer */
const navLinks = document.querySelectorAll(".nav-link");
navLinks.forEach((link) => {
link.addEventListener("click", function (e) {
navLinks.forEach((link) => {
link.classList.remove("active");
});
link.classList.add("active");
});
});
const typed = select(".typed");
if (typed) {
let typed_strings = typed.getAttribute("data-typed-items");
typed_strings = typed_strings.split(",");
new Typed(".typed", {
strings: typed_strings,
loop: true,
typeSpeed: 100,
backSpeed: 50,
backDelay: 2000,
});
}
const textElement = document.querySelector(".typing-text");
const textToType = "a web developer.";
let charIndex = 0;
(function () {
const textElement = document.querySelector(".typing-text");
const phrases = ["web developer", "designer.", "self learner."];
let currentPhraseIndex = 0;
let charIndex = 0;
function typeText() {
if (currentPhraseIndex >= phrases.length) {
currentPhraseIndex = 0;
textElement.textContent = "";
}
if (charIndex < phrases[currentPhraseIndex].length) {
textElement.textContent +=
phrases[currentPhraseIndex].charAt(charIndex);
charIndex++;
setTimeout(typeText, 50); // Adjust the typing speed here (in milliseconds)
} else {
setTimeout(eraseText, 1000); // Display each phrase for 1 second
}
}
function eraseText() {
if (charIndex >= 0) {
textElement.textContent = phrases[currentPhraseIndex].substring(
0,
charIndex
);
charIndex--;
setTimeout(eraseText, 20); // Adjust the erasing speed here (in milliseconds)
} else {
currentPhraseIndex++;
setTimeout(typeText, 500); // Wait for 0.5 seconds before typing the next phrase
}
}
typeText();
})();
/**Projects section nav links action */
const tiles = Array.from(document.querySelectorAll(".projects-item"));
const filterBtn = Array.from(document.querySelectorAll(".filter"));
filterBtn.forEach((item, i, arr) => {
item.addEventListener("click", function () {
arr.forEach(val => {
val.classList.remove("active");
})
item.classList.add("active");
tiles.forEach(ele => {
ele.style.display = "block"
})
let clsname = item.className.split(' ');
let newArr = tiles.filter(value => {
if (!(value.className.includes(`${clsname[1]}`))) {
return value;
}
})
newArr.forEach(item => {
item.style.display = "none";
})
})
})
})();
function sendMail() {
var params = {
name: document.getElementById("name").value,
email: document.getElementById("email").value,
subject: document.getElementById("subject").value,
message: document.getElementById("message").value,
};
const serviceID = "service_yjojcxh";
const templateID = "template_hp67bdg";
emailjs
.send(serviceID, templateID, params)
.then((res) => {
document.getElementById("name").value = "";
document.getElementById("email").value = "";
document.getElementById("subject").value = "";
document.getElementById("message").value = "";
alert("your message sent successfully,Thank you.");
})
.catch((err) => console.log(err));
}