This repository has been archived by the owner on Aug 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
joeypc.js
382 lines (348 loc) · 11.8 KB
/
joeypc.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
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
// joeypc JS/jQuery framework http://danmckeown.info/code/joeypc version 0.1.4 //
// https://github.com/pacificpelican/joeypc //
// copyright May-July 2015 by Dan McKeown http://danmckeown.info //
// Licensed under MIT license //
;function joeypc() {
console.log('joeypc runnning');
}
function joeypc_change_text_color(color) {
console.log('joeypc user-set text color changer runnning');
var randomNumber = color;
$( "body" ).css( "color", randomNumber );
console.log("changing text color to " + randomNumber);
}
function joeypc_change_link_color(color) {
console.log('joeypc user-set link color background changer runnning');
var randomNumber = color;
$( "a" ).css( "color", randomNumber );
console.log("changing link color to " + randomNumber);
}
function joeypc_change_background(color) {
console.log('joeypc user-set background changer runnning');
var randomNumber = color;
$( "body" ).css( "background-color", randomNumber );
console.log("changing background to " + randomNumber);
}
function joeypc_random_text() {
var randomNumber = "#";
console.log('joeypc random text color runnning');
for (i = 0; i < 6; i++) {
var digit = Math.floor((Math.random() * 9) + 0);
randomNumber = randomNumber + digit;
}
$( "body" ).css( "color", randomNumber );
console.log("changing text color to " + randomNumber);
}
function joeypc_make_random_light_text() {
var randomNumber = "#E";
console.log('joeypc make random light text runnning');
for (i = 0; i < 1; i++) {
var digit = joeypc_random_digit();
randomNumber = randomNumber + digit;
}
randomNumber = randomNumber + "E";
for (i = 0; i < 1; i++) {
var digit = joeypc_random_digit();
randomNumber = randomNumber + digit;
}
randomNumber = randomNumber + "E";
for (i = 0; i < 1; i++) {
var digit = joeypc_random_digit();
randomNumber = randomNumber + digit;
}
$( "body" ).css( "color", randomNumber );
console.log("changing text color to " + randomNumber);
}
function joeypc_random_dark_text() {
var randomNumber = "#2222";
console.log('joeypc random dark text runnning');
for (i = 0; i < 2; i++) {
var digit = Math.floor((Math.random() * 9) + 1);
randomNumber = randomNumber + digit;
}
$( "body" ).css( "color", randomNumber );
console.log("changing text color to " + randomNumber);
}
function joeypc_random_yellow_text() {
var randomNumber = "#FFFF";
console.log('joeypc random yellow text runnning');
for (i = 0; i < 2; i++) {
var digit = Math.floor((Math.random() * 9) + 1);
randomNumber = randomNumber + digit;
}
$( "body" ).css( "color", randomNumber );
console.log("changing text color to " + randomNumber);
}
function joeypc_random_reddish_text() {
var randomNumber = "#FF";
while (randomNumber.length != 7) {
console.log('joeypc random reddish text runnning');
var randomNumber = "#FF";
for (i = 0; i < 3; i++) {
var digit = Math.floor((Math.random() * 9) + 5);
randomNumber = randomNumber + digit;
}
$( "body" ).css( "color", randomNumber );
console.log("changing text color to " + randomNumber);
}
}
function joeypc_random_link_color() {
var randomNumber = "#";
console.log('joeypc random link color runnning');
for (i = 0; i < 6; i++) {
var digit = Math.floor((Math.random() * 9) + 0);
randomNumber = randomNumber + digit;
}
$( "a" ).css( "color", randomNumber );
console.log("changing text color to " + randomNumber);
}
function joeypc_random_dark_links() {
var randomNumber = "#2222";
console.log('joeypc random dark link runnning');
for (i = 0; i < 2; i++) {
var digit = Math.floor((Math.random() * 9) + 1);
randomNumber = randomNumber + digit;
}
$( "a" ).css( "color", randomNumber );
console.log("changing link color to " + randomNumber);
}
function joeypc_make_random_light_links() {
var randomNumber = "#E";
console.log('joeypc make random light links runnning');
for (i = 0; i < 1; i++) {
var digit = joeypc_random_digit();
randomNumber = randomNumber + digit;
}
randomNumber = randomNumber + "E";
for (i = 0; i < 1; i++) {
var digit = joeypc_random_digit();
randomNumber = randomNumber + digit;
}
randomNumber = randomNumber + "E";
for (i = 0; i < 1; i++) {
var digit = joeypc_random_digit();
randomNumber = randomNumber + digit;
}
$( "a" ).css( "color", randomNumber );
console.log("changing link color to " + randomNumber);
}
function joeypc_random_background() {
console.log('joeypc random background runnning');
var randomNumber = "#";
for (i = 0; i < 6; i++) {
var digit = Math.floor((Math.random() * 9) + 0);
randomNumber = randomNumber + digit;
}
$( "body" ).css( "background-color", randomNumber );
console.log("changing background to " + randomNumber);
}
function joeypc_make_random_dark_background() {
var randomNumber = "#1";
console.log('joeypc new random dark background runnning');
for (i = 0; i < 1; i++) {
var digit = joeypc_random_digit();
randomNumber = randomNumber + digit;
}
randomNumber = randomNumber + "1";
for (i = 0; i < 1; i++) {
var digit = joeypc_random_digit();
randomNumber = randomNumber + digit;
}
randomNumber = randomNumber + "1";
for (i = 0; i < 1; i++) {
var digit = joeypc_random_digit();
randomNumber = randomNumber + digit;
}
$( "body" ).css( "background-color", randomNumber );
console.log("changing background color to " + randomNumber);
}
function joeypc_make_random_bluish_dark_background() {
var randomNumber = "#1";
console.log('joeypc new random dark background runnning');
for (i = 0; i < 1; i++) {
var digit = joeypc_random_number_1_to_10();
randomNumber = randomNumber + digit;
}
randomNumber = randomNumber + "1";
for (i = 0; i < 1; i++) {
var digit = joeypc_random_number_1_to_10();
randomNumber = randomNumber + digit;
}
randomNumber = randomNumber + "2";
for (i = 0; i < 1; i++) {
var digit = joeypc_random_number_1_to_10();
randomNumber = randomNumber + digit;
}
$( "body" ).css( "background-color", randomNumber );
console.log("changing background color to " + randomNumber);
}
function joeypc_random_light_background() {
var randomNumber = "#F";
console.log('joeypc new random light background runnning');
for (i = 0; i < 1; i++) {
var digit = Math.floor((Math.random() * 9) + 1);
randomNumber = randomNumber + digit;
}
randomNumber = randomNumber + "F";
for (i = 0; i < 1; i++) {
var digit = Math.floor((Math.random() * 9) + 1);
randomNumber = randomNumber + digit;
}
randomNumber = randomNumber + "F";
for (i = 0; i < 1; i++) {
var digit = Math.floor((Math.random() * 9) + 1);
randomNumber = randomNumber + digit;
}
$( "body" ).css( "background-color", randomNumber );
console.log("changing background color to " + randomNumber);
}
function joeypc_random_reddish_light_background() {
var randomNumber = "#FF";
while (randomNumber.length != 7) {
console.log('joeypc random reddish background runnning');
var randomNumber = "#FF";
for (i = 0; i < 3; i++) {
var digit = Math.floor((Math.random() * 9) + 5);
randomNumber = randomNumber + digit;
}
$( "body" ).css( "background-color", randomNumber );
console.log("changing background to " + randomNumber);
}
}
function joeypc_random_yellow_background() {
var randomNumber = "#FFFF";
console.log('joeypc random yellow background runnning');
for (i = 0; i < 2; i++) {
var digit = Math.floor((Math.random() * 9) + 1);
randomNumber = randomNumber + digit;
}
$( "body" ).css( "background-color", randomNumber );
console.log("changing background to " + randomNumber);
}
function joeypc_random_pink_background() {
var randomNumber = "#F";
console.log('joeypc new random light background runnning');
for (i = 0; i < 1; i++) {
var digit = Math.floor((Math.random() * 9) + 1);
randomNumber = randomNumber + digit;
}
randomNumber = randomNumber + "F";
$( "body" ).css( "background-color", randomNumber );
console.log("changing text color to " + randomNumber);
}
function joeypc_random_dark_text_on_light_background_with_dark_links() {
joeypc_random_dark_text();
joeypc_random_light_background();
joeypc_random_dark_links();
}
function joeypc_random_colors_yellow_red() {
joeypc_random_yellow_text();
joeypc_random_reddish_light_background();
var randomNumber = "#FFFF";
console.log('joeypc random yellow link color (subroutine) runnning');
for (i = 0; i < 2; i++) {
var digit = Math.floor((Math.random() * 9) + 1);
randomNumber = randomNumber + digit;
}
$( "a" ).css( "color", randomNumber );
console.log("changing link text color to " + randomNumber);
}
function joeypc_reload_page() {
document.location.reload(true);
}
function joeypc_old_random_light_background() {
var randomNumber = "#FFF";
console.log('joeypc random light background runnning');
for (i = 0; i < 3; i++) {
var digit = Math.floor((Math.random() * 9) + 1);
randomNumber = randomNumber + digit;
}
$( "body" ).css( "background-color", randomNumber );
console.log("changing background color to " + randomNumber);
}
function joeypc_random_number() {
var newdigit = Math.floor((Math.random() * 9) + 1);
return newdigit;
// deprecated in favor of below 2 functions:
}
function joeypc_random_number_1_to_10() {
var newdigit = Math.floor((Math.random() * 9) + 1);
return newdigit;
}
function joeypc_random_digit() {
var newdigit = Math.floor((Math.random() * 9) + 1);
return newdigit;
}
function joeypc_random_light_text_on_dark_background_with_light_links() {
joeypc_make_random_dark_background();
joeypc_make_random_light_text();
joeypc_make_random_light_links();
}
function joeypc_random() {
console.log('joeypc random runnning ');
var d = new Date();
var n = d.getSeconds();
var digit = Math.floor((Math.random() * 67) + 0) + n;
console.log(digit + " ");
return digit;
}
function joeypc_get_longest_word_in_sentence(string) {
var string1 = string;
var leng = string1.length
var wordbox = [];
var wordboxcount = 0;
for (i=0; i<leng; i++) {
if (string1[i] == " ") {
// mark this as space between the end of a word, beginning of another
wordboxcount++;
}
if (string1[i] != " ") {
// absorb this string into the current word
if (wordbox[wordboxcount]) {
wordbox[wordboxcount] = wordbox[wordboxcount] + string1[i];
}
else {
wordbox[wordboxcount] = string1[i];
}
}
}
var leng2 = wordbox.length;
var currentMax = 0;
var longest;
var newlimit = 0;
for (i=0; i<leng2; i++) {
if (wordbox[i]) {
leng3 = wordbox[i].length;
if (leng3 > currentMax) {
longest = wordbox[i];
currentMax = wordbox[i].length;
}
}
}
return longest;
}
function joeypc_maxMinAvg(arr) {
console.log('joeypc maxMinAvg runnning');
var max = arr[0];
var min = arr[0];
var sum = 0;
var avg;
for (i = 0; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
sum = sum + arr[i]
}
else if (arr[i] < min) {
min = arr[i];
sum = sum + arr[i]
}
else {
sum = sum + arr[i];
}
}
avg = sum/arr.length
var result = "max: " + max + " " + "min: " + min + " " + "avg: " + avg ;
console.log("returning " + result);
return result;
}
joeypc();