-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
201 lines (175 loc) · 4.92 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
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
// Loader
var loader = true
minimumLoading = () => {
document.body.style.overflow = 'hidden'
setTimeout(() => {
document.getElementById('loading').classList.add('removeLoader')
}, 4000)
}
removeLoader = () => {
setTimeout(() => {
document.getElementById('loading').style.display = 'none'
loader = false
}, 5000)
}
window.onload = (event) => {
minimumLoading()
removeLoader()
document.body.style.overflow = 'scroll'
}
// --------------------------------------------------------------------------------
// Handling Pop-Up On Mobile View
var modal = document.getElementById('popup')
var btn = document.getElementById('btn')
var span = document.getElementsByClassName('close')[0]
btn.onclick = function () {
modal.classList.add('show')
document.body.style.overflow = 'hidden'
}
span.onclick = function () {
modal.classList.remove('show')
document.body.style.overflow = 'scroll'
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function (event) {
if (event.target == modal) {
modal.classList.remove('show')
document.body.style.overflow = 'scroll'
}
}
//---------------------------------------------------------------------------------
// increase the height of message box automatically
$('textarea')
.each(function () {
this.setAttribute(
'style',
'height:' + this.scrollHeight + 'px;overflow-y:hidden;'
)
})
.on('input', function () {
this.style.height = 'auto'
this.style.height = this.scrollHeight + 'px'
})
// --------------------------------------------------------------------------------
// hide the url from showing
$(function () {
$('a').each(function (index, element) {
var href = $(this).attr('href')
$(this).attr('hiddenhref', href)
$(this).removeAttr('href')
})
$('.social-icons a, .resume, .pLinks').click(function () {
url = $(this).attr('hiddenhref')
window.open(url, '_blank')
})
$('.modal-container a, .nav-menu a , .otherLinks').click(function () {
url = $(this).attr('hiddenhref')
window.location.href = url
})
})
// --------------------------------------------------------------------------------
//submit form
$('form').on('submit', function (e) {
e.preventDefault()
let name = $('#SenderName').val()
let subject = $('#SenderSubject').val()
let message = $('#SenderMessage')
.val()
.replace(/(\r\n|\n|\r)/gm, '%0D%0A')
location.href =
'mailto:[email protected]' +
('?subject=' + subject) +
('&body=' + message)
$('#SenderName').val('')
$('#SenderSubject').val('')
$('#SenderMessage').val('')
})
//auto fill skills section ----------
let skillsLoaded = false
$(window).on('scroll', function (event) {
var scroll = $(window).scrollTop()
if (
scroll > 550 &&
scroll < 1000 &&
loader === false &&
skillsLoaded === false
) {
skillsLoaded = true
$('.f85').addClass('eighty-five-percent')
$('.f80').addClass('eighty-percent')
$('.f70').addClass('seventy-percent')
}
if (
scroll > 2500 &&
scroll < 3000 &&
loader === false &&
laptopOn === false
) {
turnOnLaptop()
}
})
$('.skillsLoading').on('click', function () {
if (skillsLoaded === false) {
setTimeout(() => {
$('.f85').addClass('eighty-five-percent')
$('.f80').addClass('eighty-percent')
$('.f70').addClass('seventy-percent')
skillsLoaded = true
}, 1000)
}
})
// ----------------------------------------------------------------------
// projects
var projects = ['ipod', 'descode', 'netflix']
let pid = 0
var laptopOn = false
let position = document
.getElementsByClassName('display')[0]
.getBoundingClientRect()
$('.project').each(function () {
const self = this
$(self).on('click', function () {
loadNewVideo(self)
removePreviousProperty()
addnewProperty($(this).children()[1], self)
})
})
const loadNewVideo = (self) => {
let index = parseInt($(self).attr('data-id'))
if (pid === index) return
else pid = index
let video = document.getElementById('player')
let source = document.getElementById('source')
video.pause()
source.removeAttribute('src')
source.setAttribute('src', `projects/${projects[index]}.mp4`)
video.load()
}
const addnewProperty = (children, self) => {
$(children).removeClass('none')
$(self).addClass('left-border')
}
const removePreviousProperty = () => {
$('.visit').addClass('none')
$('.project').removeClass('left-border')
}
const turnOnLaptop = () => {
laptopOn = true
setTimeout(() => {
$('.screen').addClass('fadeIn')
setTimeout(() => {
$('.icon').addClass('bounce')
setTimeout(() => {
$('.browser-container').addClass('b-fadeIn')
$('.browser-container').removeClass('none')
$('.project:first-child a').removeClass('none')
$('.project:first-child').addClass('left-border')
}, 1200)
}, 1000)
}, 1000)
}
setTimeout(() => {
if (position.top > 0 && position.top < 200) {
turnOnLaptop()
}
}, 5000)