-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.coffee
More file actions
252 lines (235 loc) · 6.77 KB
/
main.coffee
File metadata and controls
252 lines (235 loc) · 6.77 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
# Set Variables For Typing Effect
fpstext = 2
fpscursor = 1
sitetitles = [
[
'> '
'cd '
'~/'
'Apps/'
'NekoVault/'
]
[
'> '
'firefox '
'-new-tab '
'techadvancedcyborg.'
'github.'
'io'
]
[
'> '
'echo '
'Converting '
'caffeine '
'to '
'code...'
]
[
'> '
'cd '
'~/'
'Apps/'
'TTACT-s'
'-Anime'
'-Player'
'-Revamped/'
]
[
'> '
'echo '
'Why '
'did '
'the '
'chicken '
'cross '
'the '
'road?'
]
[
'> '
'echo '
'Fix '
'the '
'cause, '
'not '
'the '
'symptom. '
'– '
'Steve '
'Maguire'
]
[
'> '
'echo '
'Talk '
'is '
'cheap. '
'Show '
'me '
'the '
'code. '
'― '
'Linus '
'Torvalds'
]
[
'> '
'ping '
'1.'
'1.'
'1.'
'1'
]
]
#System Variables
slice = 0
typing = true
sitetitle = sitetitles[Math.round(window.crypto.getRandomValues(new Uint32Array(1))[0] / 4294967296 * (sitetitles.length - 1))]
cursorstate = true
deletetypingchars = (elem) ->
elem.remove()
return
#Text Rendering Loop
updatetypingeffect = ->
#Set Cursor String Accordingly
cursor = ' '
if cursorstate
cursor = '_'
#Type
if typing
#Set text in page
char = document.createElement('div')
charc = sitetitle[slice]
if charc == ' '
charc = ' '
char.innerHTML = charc
char.className = 'typing-text-char'
document.getElementsByClassName('typing-text')[0].append char
slice++
else
#Set text in page
document.getElementsByClassName('typing-text')[0].children[slice - 1].className = 'typing-text-char-remove'
setInterval deletetypingchars, 200, document.getElementsByClassName('typing-text')[0].children[slice - 1]
slice += 0 - 1
#Reverse When At End of String
if slice > sitetitle.length - 1
typing = false
#Reverse When At Start of String
if slice < 1
typing = true
sitetitle = sitetitles[Math.round(window.crypto.getRandomValues(new Uint32Array(1))[0] / 4294967296 * (sitetitles.length - 1))]
return
setInterval updatetypingeffect, 1000 / fpstext
#Cursor State Loop
setInterval (->
#Reverse cursorstate variable
if cursorstate
cursorstate = false
else
cursorstate = true
return
), 1000 / fpscursor
# Days and Seconds Since DOB Render Loop
setInterval (->
`var i`
try
#Set Dates
timezoneoffset = (new Date).getTimezoneOffset() * 60000
now = new Date
birth = new Date('2007/02/13 00:00:00')
#Born within February 13 2007 00:00:00 to February 13 2007 01:00:00 UTC+00:00
lastbirthday = new Date('2020/02/12')
nextbirthday = new Date('2021/02/12')
#Calculate Differences
diffsecs = Math.floor((now - birth + timezoneoffset) / 1000)
diffdays = Math.floor((now - birth + timezoneoffset) / (1000 * 3600 * 24))
# Render Different Units Progress Bars
###
birthdayprogress = (now-lastbirthday)/(nextbirthday-lastbirthday);
birthdaytotaldays = (nextbirthday-lastbirthday)/86400000;
birthdaymonthprogress = (birthdayprogress*12)-Math.floor(birthdayprogress*12);
birthdaydayprogress = (birthdayprogress*birthdaytotaldays)-Math.floor(birthdayprogress*birthdaytotaldays);
birthdayhourprogress = (birthdayprogress*birthdaytotaldays*24)-Math.floor(birthdayprogress*birthdaytotaldays*24);
birthdayminuteprogress = (now.getSeconds()/60)-Math.floor(now.getSeconds()/60);
document.getElementsByClassName("time-progress-minutes")[0].style.width = String(birthdayminuteprogress*100)+"%";
document.getElementsByClassName("time-progress-hours")[0].style.width = String(birthdayhourprogress*100)+"%";
document.getElementsByClassName("time-progress-days")[0].style.width = String(birthdaydayprogress*100)+"%";
document.getElementsByClassName("time-progress-months")[0].style.width = String(birthdaymonthprogress*100)+"%";
document.getElementsByClassName("time-progress-years")[0].style.width = String(birthdayprogress*100)+"%";
###
#Render Text
informationelement = document.getElementById('information')
ageelement = document.getElementsByClassName('age')[0]
stringage = diffdays.toString() + ' days or ' + diffsecs.toString() + ' seconds old.'
if ageelement.innerHTML == ''
i = 0
while i < stringage.length
ageelement.innerHTML += '<span class="agestring">' + stringage.charAt(i) + '</span>'
i++
else
i = 0
while i < stringage.length
if ageelement.getElementsByClassName('agestring')[i].innerHTML != stringage[i]
document.getElementsByClassName('age')[0].children[i].innerHTML = stringage[i]
document.getElementsByClassName('age')[0].children[i].style.padding = '0px 10px 0px 10px'
else
document.getElementsByClassName('age')[0].children[i].style.padding = '0%'
i++
style = getComputedStyle(document.body)
ageelement.style.color = style.getPropertyValue('--text-color-light')
informationelement.style.transform = 'none'
informationelement.style.color = style.getPropertyValue('--text-color-light')
catch e
#Catch Error (if element is not loaded yet)
console.log 'error'
console.log e.toString()
return
), 200
#On Page Finish Loading
#Start Animation
setTimeout (->
document.getElementsByClassName('typing-text')[0].style.width = '98.7%'
return
), 1000
setTimeout (->
document.getElementsByClassName('typing-text')[0].style.color = getComputedStyle(document.body).getPropertyValue('--text-color-light')
return
), 2000
# Gnome Easter Egg
state = 0
audio = new Audio('./assets/audio/gnome.webm')
document.addEventListener 'keydown', (event) ->
switch state
when 0
if event.keyCode == 71
state++
else
state = 0
when 1
if event.keyCode == 78
state++
else
state = 0
when 2
if event.keyCode == 79
state++
else
state = 0
when 3
if event.keyCode == 77
state++
else
state = 0
when 4
if event.keyCode == 69
audio.play()
document.getElementsByClassName('gnome-easter-egg')[0].style.transform = 'translate(-4vw,-4vw)'
setTimeout (->
document.getElementsByClassName('gnome-easter-egg')[0].style.transform = 'translate(-20vw,-20vw)'
return
), 200
state = 0
else
state = 0
return