-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
340 lines (277 loc) · 9.06 KB
/
Copy pathmain.js
File metadata and controls
340 lines (277 loc) · 9.06 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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
function reset1(){
if(window.matchMedia("(min-width: 1199px)").matches){
head = document.getElementById("header");
var attri=document.createAttribute("style");
attri.value = "left:0px;";
head.setAttributeNode(attri);
document.getElementById("header").setAttribute("name","after");
}
}
function bars(){
if( document.getElementById("header").getAttribute("name")=='initial'){
head = document.getElementById("header");
var attri=document.createAttribute("style");
attri.value = "left:0px;";
head.setAttributeNode(attri);
document.getElementById("header").setAttribute("name","after");
}
else if( document.getElementById("header").getAttribute("name")=='after'){
head = document.getElementById("header");
var attri=document.createAttribute("style");
attri.value = "left:-300px;";
head.setAttributeNode(attri);
document.getElementById("header").setAttribute("name","initial");
}
}
var slider = document.querySelector(".items");
var slides = document.querySelectorAll(".item");
var button = document.querySelectorAll(".button");
var current = 0;
var prev = 2;
var next = 1;
for (var i = 0; i < button.length; i++) {
button[i].addEventListener("click", () => i == 0 ? gotoPrev() : gotoNext());
}
var gotoPrev = () => current > 0 ? gotoNum(current - 1) : gotoNum(slides.length - 1);
var gotoNext = () => current < 2 ? gotoNum(current + 1) : gotoNum(0);
var gotoNum = number => {
current = number;
prev = current - 1;
next = current + 1;
for (var i = 0; i < slides.length; i++) {
slides[i].classList.remove("active");
slides[i].classList.remove("prev");
slides[i].classList.remove("next");
}
if (next == 3) {
next = 0;
}
if (prev == -1) {
prev = 2;
}
slides[current].classList.add("active");
slides[prev].classList.add("prev");
slides[next].classList.add("next");
}
// typewriter effect Start
var TxtType = function(el, toRotate, period) {
this.toRotate = toRotate;
this.el = el;
this.loopNum = 0;
this.period = parseInt(period, 10) || 2000;
this.txt = '';
this.tick();
this.isDeleting = false;
};
TxtType.prototype.tick = function() {
var i = this.loopNum % this.toRotate.length;
var fullTxt = this.toRotate[i];
if (this.isDeleting) {
this.txt = fullTxt.substring(0, this.txt.length - 1);
} else {
this.txt = fullTxt.substring(0, this.txt.length + 1);
}
this.el.innerHTML = '<span class="wrap">'+this.txt+'</span>';
var that = this;
var delta = 200 - Math.random() * 100;
if (this.isDeleting) { delta /= 2; }
if (!this.isDeleting && this.txt === fullTxt) {
delta = this.period;
this.isDeleting = true;
} else if (this.isDeleting && this.txt === '') {
this.isDeleting = false;
this.loopNum++;
delta = 500;
}
setTimeout(function() {
that.tick();
}, delta);
};
window.onload = function() {
var elements = document.getElementsByClassName('typewrite');
for (var i=0; i<elements.length; i++) {
var toRotate = elements[i].getAttribute('data-type');
var period = elements[i].getAttribute('data-period');
if (toRotate) {
new TxtType(elements[i], JSON.parse(toRotate), period);
}
}
// INJECT CSS
var css = document.createElement("style");
css.type = "text/css";
css.innerHTML = ".typewrite > .wrap { border-right: 0.08em solid #fff}";
document.body.appendChild(css);
};
// typwriter effect end
//smooth scrolling and options highlighting
var section = document.querySelectorAll(".scroll");
var sections = {};
var i = 0;
Array.prototype.forEach.call(section, function(e) {
sections[e.id] = e.offsetTop;
});
window.onscroll = function() {
var scrollPosition = document.documentElement.scrollTop || document.body.scrollTop;
for (i in sections) {
if (sections[i] <= scrollPosition) {
document.querySelector('.active').setAttribute('class', ' ');
document.querySelector('a[href*=' + i + ']').setAttribute('class', 'active');
}
}
};
//end of smooth scrolling
//start of skills script
function count(A,B){
var x=document.getElementById("skill");
var p=document.getElementById(A);
var z=p.textContent;
var i;
if(elementInViewport2(x) && z==0){
for(i=0;i<B;i++){
setTimeout(function() {z++;
p.textContent=z+"%";
},i*5000/B);
}
}
if(!elementInViewport2(x)){
p.textContent=0;
z=0;
}
}
function progress_bar(Z){
var ele = document.getElementsByName(Z);
var attri2=document.createAttribute("class");
var attri1 = document.createAttribute("id");
if(elementInViewport2(document.getElementById("skill"))){
attri1.value = "mybar";
attri2.value = "progress-bar progress-bar-striped progress-bar-animated";
ele[0].setAttributeNode(attri2);
ele[0].setAttributeNode(attri1);
}
else{
attri1.value = "";
attri2.value = "";
ele[0].setAttributeNode(attri2);
ele[0].setAttributeNode(attri1);
}
}
//end of skills script
function elementInViewport2(el) {
var top = el.offsetTop;
var left = el.offsetLeft;
var width = el.offsetWidth;
var height = el.offsetHeight;
while(el.offsetParent) {
el = el.offsetParent;
top += el.offsetTop;
left += el.offsetLeft;
}
return (
top < (window.pageYOffset + window.innerHeight) &&
left < (window.pageXOffset + window.innerWidth) &&
(top + height) > window.pageYOffset &&
(left + width) > window.pageXOffset
);
}
//auto updating age and year of copyright
document.getElementById("autodate").innerHTML = new Date().getFullYear();
var age = new Date().getFullYear() - 2001;
var mon = new Date().getMonth() - 7 + 1;
if (mon < 0) {
--age;
}
else if (mon === 0) {
var day = new Date().getDate() - 7;
if (day < 0) --age;
}
document.getElementById("autoage").innerHTML = age;
//end of auto update
//review stars
function review1(w){
for(var i=1;i<=w;i++){
var num=i;
num=num.toString();
document.getElementsByName("star"+num)[0].classList.remove("unchecked");
document.getElementsByName("star"+num)[0].classList.add("checked");
}
}
function review2(w){
for(var i=5;i>w;i--){
var num=i;
num=num.toString();
document.getElementsByName("star"+num)[0].classList.remove("checked");
document.getElementsByName("star"+num)[0].classList.add("unchecked");
}
}
function compli(w){
switch(w){
case 1:
document.getElementById("compliments").innerHTML = "😔 Will Try To Improve!";
break;
case 2:
document.getElementById("compliments").innerHTML = "😌 Will Try To Improve!";
break;
case 3:
document.getElementById("compliments").innerHTML = "😊 Thank You!";
break;
case 4:
document.getElementById("compliments").innerHTML = "😄 Thank You So Much!";
break;
case 5:
document.getElementById("compliments").innerHTML = "😍 Glad You Liked It!";
break;
}
}
// Create a "close" button and append it to each list item
var myNodelist = document.getElementById("myUL").children;
var i;
for (i = 0; i < myNodelist.length; i++) {
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close2";
span.appendChild(txt);
myNodelist[i].appendChild(span);
}
// Click on a close button to hide the current list item
var close = document.getElementsByClassName("close2");
var i;
for (i = 0; i < close.length; i++) {
close[i].onclick = function() {
var div = this.parentElement;
div.style.display = "none";
}
}
// Add a "checked" symbol when clicking on a list item
var list = document.querySelector('#myUL');
list.addEventListener('click', function(ev) {
if (ev.target.tagName === 'LI') {
ev.target.classList.toggle('checked');
}
}, false);
// Create a new list item when clicking on the "Add" button
function newElement() {
var att = document.createAttribute("name");
att.value = "LI";
var li = document.createElement("li");
li.setAttributeNode(att);
var inputValue = document.getElementById("myInput").value;
var t = document.createTextNode(inputValue);
li.appendChild(t);
if (inputValue === '') {
alert("You must write something!");
} else {
document.getElementById("myUL").appendChild(li);
}
document.getElementById("myInput").value = "";
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close2";
span.appendChild(txt);
li.appendChild(span);
for (i = 0; i < close.length; i++) {
close[i].onclick = function() {
var div = this.parentElement;
div.style.display = "none";
}
}
}