forked from keiichico/DIGIGIT
-
Notifications
You must be signed in to change notification settings - Fork 3
/
besties.html
172 lines (152 loc) · 3.45 KB
/
besties.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dorm Placment Generator</title>
</head>
<body>
<script>
boys = new Array();
girls = new Array();
// Hard Coded Arrays
boy_1 = new Array()
boy_1[0]="boy_2";
boy_1[1]="boy_6";
boy_1[2]="boy_28";
boy_1[3]="boy_23";
// ----------------------
boy_2 = new Array()
boy_2[0]="boy_30";
boy_2[1]="boy_12";
boy_2[2]="boy_7";
boy_2[3]="boy_21";
// ----------------------
boy_3 = new Array()
boy_3[0]="boy_11";
boy_3[1]="boy_18";
boy_3[2]="boy_9";
boy_3[3]="boy_5";
// ----------------------
boy_4 = new Array()
boy_4[0]="boy_2";
boy_4[1]="boy_9";
boy_4[2]="boy_10";
boy_4[3]="boy_13";
// ----------------------
boy_5 = new Array()
boy_5[0]="boy_3";
boy_5[1]="boy_29";
boy_5[2]="boy_19";
boy_5[3]="boy_24";
// ----------------------
boy_6 = new Array()
boy_6[0]="boy_2";
boy_6[1]="boy_8";
boy_6[2]="boy_16";
boy_6[3]="boy_30";
// ----------------------
boy_7 = new Array()
boy_6[0]="boy_3";
boy_6[1]="boy_24";
boy_6[2]="boy_11";
boy_6[3]="boy_10";
// ----------------------
boy_8 = new Array()
boy_6[0]="boy_7";
boy_6[1]="boy_3";
boy_6[2]="boy_5";
boy_6[3]="boy_28";
// ----------------------
boy_9 = new Array()
boy_6[0]="boy_0";
boy_6[1]="boy_1";
boy_6[2]="boy_4";
boy_6[3]="boy_6";
// ----------------------
boy_10 = new Array()
boy_6[0]="boy_3";
boy_6[1]="boy_9";
boy_6[2]="boy_12";
boy_6[3]="boy_15";
// ----------------------
bestieList = new Array();
function populate_arrays()
{
// Populate Boys Array
for (var i=0;i<31;i++)
{
var ID = 'boy_' + i;
boys.push(ID);
}
alert(boys.length + ' boys');
// Populate Girls Array
for (var i=0;i<29;i++)
{
var ID = 'girl_' + i;
girls.push(ID);
}
alert(girls.length+' girls');
}
function generate_besties_list(start,limit)
{
alert('Generating Besties List');
for (var i=start;i<limit;i++)
{
//console.log('Adding list for: '+boys[i]);
setTimeout( "add_bestie(boys[0],boys)", 500 );
}
}
function print_to_console(list)
{
for (var i=0;i<boys.length;i++)
{
//console.log('Adding list for: '+boys[i]);
/*
if(i <= boys.length)
{
setTimeout( "add_bestie(boys[i],boys)", 500 );
}
*/
add_bestie(boys[i],boys);
}
return true;
}
function add_bestie(self, list)
{
bestieList = [];
list.remove(self);
console.log(list.length);
// Generate Random ID
var x =0;
while(x<4)
{
addRandomID(list);
x++;
}
console.log('Finished adding ' + bestieList.length + ' IDs to besties list');
console.log(self+"'s bestie list contains: ");
for (var ii=0;ii<bestieList.length;ii++)
{
console.log(bestieList[ii]);
}
}
function addRandomID(list)
{
var randID = getRandomID(0, list.length);
console.log('Added : '+list[randID]);
// Add Random ID to Current IDs Bestie Array
bestieList.push(list[randID]);
return true;
}
function getRandomID (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
Array.prototype.remove = function(value) {
this.splice(this.indexOf(value), 1);
return true;
};
</script>
<input type="button" value="Populate Arrays" onclick="populate_arrays()" /> </br>
<input type="button" value="Generate Bestie Lists" onclick="generate_besties_list(0,30)" /> </br>
</body>
</html>