-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
183 lines (160 loc) · 5.77 KB
/
Copy pathscript.js
File metadata and controls
183 lines (160 loc) · 5.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
var typing = false;
$(document).ready(function () {
var pull = $('#pull');
menu = $('nav ul');
menuHeight = menu.height();
$(pull).on('click', function(e) {
e.preventDefault();
pull.toggleClass("open");
menu.slideToggle();
});
updateContainer();
$(window).resize(function() {
updateContainer();
});
//make output text responsive
$('#mouth-bottom').fitText(1.2);
// print("Hello, World! Ready to build awesome stuff!?");
$('nav ul li a').click(function(){
//clear timeouts
var id = window.setTimeout(function() {}, 0);
while (id--) {
window.clearTimeout(id); // will do nothing if no timeout with id is present
}
//if menu is open, close it
if(pull.hasClass("open")){
pull.removeClass("open");
menu.slideToggle();
}
if(!typing){
think($(this).html().toLowerCase());
}
});
print("If you want to find the");
setInterval(function () {
print("If you want to find the");
}, 16000);
setTimeout(function () {
print("secrets of the Universe");
setInterval(function () {
print("secrets of the Universe");
}, 16000);
}, 4000);
setTimeout(function () {
print("think in terms of energy");
setInterval(function () {
print("think in terms of energy");
}, 16000);
}, 8000);
setTimeout(function () {
print("frequency & vibration");
setInterval(function () {
print("frequency & vibration");
}, 16000);
}, 12000);
});
function updateContainer() {
//responsive menu icon
var w = $(window).width();
if(w > 600 && menu.is(':hidden')) {
menu.removeAttr('style');
}
//get viewport height and width
var height = $(window).height();
var width = $(window).width();
//get max
var minDimension = Math.min(height, width);
var $leftEye = $('#eye-left');
var $rightEye = $('#eye-right');
var $middleMouth = $('#mouth-bottom');
var $leftMouth = $('#mouth-left');
var $rightMouth = $('#mouth-right');
//set the sizes
$leftEye.height(Math.ceil(minDimension * 3 / 16));
$leftEye.width(Math.ceil(minDimension * 3 / 16));
$rightEye.height(Math.ceil(minDimension * 3 / 16));
$rightEye.width(Math.ceil(minDimension * 3 / 16));
$middleMouth.height(Math.ceil(minDimension * 2 / 16));
$middleMouth.width(Math.ceil(minDimension * 12 / 16));
$leftMouth.height(Math.ceil(minDimension * 4 / 16));
$leftMouth.width(Math.ceil(minDimension * 2 / 16));
$rightMouth.height(Math.ceil(minDimension * 4 / 16));
$rightMouth.width(Math.ceil(minDimension * 2 / 16));
if(width > height){
//landscape
var extra = width - height;
var topEyes = Math.ceil(minDimension * 3 / 16);
var topBottomMouth = Math.ceil(minDimension * 11 / 16);
var topLeftMouth = Math.ceil(minDimension * 9 / 16);
var topRightMouth = Math.ceil(minDimension * 9 / 16);
var leftLeftEye = Math.ceil(minDimension * 4 / 16 + (extra / 2));
var leftRightEye = Math.ceil(minDimension * 9 / 16 + (extra / 2));
var leftBottomMouth = Math.ceil(minDimension * 2 / 16 + (extra / 2));
var leftLeftMouth = Math.ceil(minDimension * 2 / 16 + (extra / 2));
var leftRightMouth = Math.ceil(minDimension * 12 / 16 + (extra / 2));
} else {
//portrait
var extra = height - width;
var topEyes = Math.ceil(minDimension * 3 / 16 + (extra / 2));
var topBottomMouth = Math.ceil(minDimension * 11 / 16 + (extra / 2));
var topLeftMouth = Math.ceil(minDimension * 9 / 16 + (extra / 2));
var topRightMouth = Math.ceil(minDimension * 9 / 16 + (extra / 2));
var leftLeftEye = Math.ceil(minDimension * 4 / 16);
var leftRightEye = Math.ceil(minDimension * 9 / 16);
var leftBottomMouth = Math.ceil(minDimension * 2 / 16);
var leftLeftMouth = Math.ceil(minDimension * 2 / 16);
var leftRightMouth = Math.ceil(minDimension * 12 / 16);
}
$leftEye.offset({ top: topEyes, left: leftLeftEye});
$rightEye.offset({ top: topEyes, left: leftRightEye});
$middleMouth.offset({ top: topBottomMouth, left: leftBottomMouth});
$leftMouth.offset({ top: topLeftMouth, left: leftLeftMouth});
$rightMouth.offset({ top: topRightMouth, left: leftRightMouth});
var $output = $('#output');
$output.css('border-right-width', minDimension * 1 / 200 + "px");
// $output.width(Math.ceil(minDimension * 12 / 16));
}
function print(output) {
//first, clear the output span
$('#output').html(">");
//iterate through the output
(function myLoop (i, speed) {
speed = speed * (Math.random() * (1.1 - .9) + .9); //random percent change or %110 through 90%
setTimeout(function () {
type( output[output.length - (i)] );
if (--i){
myLoop(i, Math.max(Math.min(speed, 150), 50)); //put a boundary on slow typing speed
} else {
$('#output').html(">" + output);
}
}, speed);
})(output.length, 75);
}
function type(character){
$('#output').html($('#output').html() + character);
}
function think(input){
switch(input)
{
case "about":
print("I'm Scott Lowe.");
setTimeout(function(){print("I like riding bikes");
setTimeout(function(){print("and playing guitar!");
setTimeout(function(){print("Generally Irrelevant,");
setTimeout(function(){print("Wrecklessly Idealistic,");
setTimeout(function(){print("Lover of life.");
setTimeout(function(){print("It's nice to meet you.");
}, 3000);
}, 3000);
}, 3000);
}, 3000);
}, 3000);
}, 3000);
break;
case "email":
print('me@scottdlowe.com');
break;
default:
print("bye!");
}
}