-
Notifications
You must be signed in to change notification settings - Fork 0
/
404.js
137 lines (110 loc) · 4.69 KB
/
404.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
var cursor = true;
var speed = 250;
setInterval(() => {
if('new-output') {
document.getElementByClass('new-output').style.opacity = 0;
cursor = false;
}else {
document.getElementByClass('cursor').style.opacity = 1;
cursor = true;
}
}, speed);
var inputReady = true;
var input = $('.404-input');
input.focus();
$('.container').on('click', function(e){
input.focus();
});
input.on('keyup', function(e){
$('.new-output').text(input.val());
// console.log(inputReady);
});
$('.four-oh-four-form').on('submit', function(e){
e.preventDefault();
var val = $(this).children($('.404-input')).val().toLowerCase();
var href;
if (val === 'puppies'){
showKittens();
}
else if(val === 'get me back'){
window.location = 'https://arnavvashisthcodingaccountnew.github.io'
}
else {
resetForm();
}
});
function resetForm(withKittens){
var message = "Sorry that command is not recognized."
var input = $('.404-input');
if (withKittens){
$('.kittens').removeClass('kittens');
message = "Huzzzzzah Kittehs!"
}
$('.new-output').removeClass('new-output');
input.val('');
$('.terminal').append('<p class="prompt">' + message + '</p><p class="prompt output new-output"></p>');
$('.new-output').velocity(
'scroll'
), {duration: 100}
}
function showKittens(){
$('.terminal').append("<div class='kittens'>"+
"<p class='prompt'> ,----, ,----, ,---,</p>" +
"<p class='prompt'> ,--. ,/ .`| ,/ .`| ,--. ,`--.' |</p>" +
"<p class='prompt'> ,--/ /| ,---, ,` .' : ,` .' : ,---,. ,--.'| .--.--. | : :</p>" +
"<p class='prompt'>,---,': / ' ,`--.' | ; ; / ; ; / ,' .' | ,--,: : | / / '. ' ' ;</p>" +
"<p class='prompt'>: : '/ / | : : .'___,/ ,' .'___,/ ,' ,---.' | ,`--.'`| ' : | : /`. / | | |</p>" +
"<p class='prompt'>| ' , : | ' | : | | : | | | .' | : : | | ; | |--` ' : ;</p>" +
"<p class='prompt'>' | / | : | ; |.'; ; ; |.'; ; : : |-, : | \\ | : | : ;_ | | '</p>" +
"<p class='prompt'>| ; ; ' ' ; `----' | | `----' | | : | ;/| | : ' '; | \\ \\ `. ' : |</p>" +
"<p class='prompt'>: ' \\ | | | ' : ; ' : ; | : .' ' ' ;. ; `----. \\ ; | ;</p>" +
"<p class='prompt'>' : |. \\ | | ' ' : | ' : | ' : ;/| ' : | ; .' / /`--' / `--..`; </p>" +
"<p class='prompt'>| | '_\\.' ' : | ; |.' ; |.' | | \\ | | '`--' '--'. / .--,_ </p>" +
"<p class='prompt'>' : | ; |.' '---' '---' | : .' ' : | `--'---' | |`. </p>" +
"<p class='prompt'>; |,' '---' | | ,' ; |.' `-- -`, ; </p>" +
"<p class='prompt'>'---' `----' '---' '---`'</p>" +
"<p class='prompt'> </p></div>");
var lines = $('.kittens p');
$.each(lines, function(index, line){
setTimeout(function(){
$(line).css({
"opacity": 1
});
textEffect($(line))
}, index * 100);
});
$('.new-output').velocity(
'scroll'
), {duration: 100}
}
function textEffect(line){
var alpha = [';', '.', ',', ':', ';', '~', '`'];
var animationSpeed = 10;
var index = 0;
var string = line.text();
var splitString = string.split("");
var copyString = splitString.slice(0);
var emptyString = copyString.map(function(el){
return [alpha[Math.floor(Math.random() * (alpha.length))], index++];
})
emptyString = shuffle(emptyString);
$.each(copyString, function(i, el){
var newChar = emptyString[i];
toUnderscore(copyString, line, newChar);
setTimeout(function(){
fromUnderscore(copyString, splitString, newChar, line);
},i * animationSpeed);
})
}
function toUnderscore(copyString, line, newChar){
copyString[newChar[1]] = newChar[0];
line.text(copyString.join(''));
}
function fromUnderscore(copyString, splitString, newChar, line){
copyString[newChar[1]] = splitString[newChar[1]];
line.text(copyString.join(""));
}
function shuffle(o){
for(var j, x, i = o.length; i; j = Math.floor(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};