-
Notifications
You must be signed in to change notification settings - Fork 0
/
CYP_BINGO_BUTTONSv2.js
244 lines (208 loc) · 7.48 KB
/
CYP_BINGO_BUTTONSv2.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
function VER5_Check() {
var b = navigator.appName;
if (b == "Netscape") this.b = "NS";
else if (b == "Microsoft Internet Explorer") this.b = "IE";
this.v = parseInt(navigator.appVersion);
this.IE5 = (navigator.userAgent.indexOf('MSIE 5') > 0);
this.NS5 = (this.b >= "NS" && this.v >= 5);
this.VER5 = (this.IE5 || this.NS5);
}
is = new VER5_Check();
var jargonSelect = new Array();
var c2=0;
function highlight(myId) {
var myCell = document.getElementById(myId);
myCell.style.backgroundColor = "#00ffc0";
jargonSelect[c2]=myId;
if(jargonSelect.length>=5){
//alert("check to see if its a winner");
var row=new Array();
var row2=new Array();
var row3=new Array();
var row4=new Array();
var row5=new Array();
var rowCount=0;
var row2Count=0;
var row3Count=0;
var row4Count=0;
var row5Count=0;
var column=new Array();
var column2=new Array();
var column3=new Array();
var column4=new Array();
var column5=new Array();
var colCount=0;
var col2Count=0;
var col3Count=0;
var col4Count=0;
var col5Count=0;
var diagonal=new Array();
var diagonal2=new Array();
var diagCount=0;
diag2Count=0;
for(i=0;i<jargonSelect.length;++i){
//Checking for diagonal match
// 02.22.2016 tasks remaining: change alert type to remove reload on confirmation; add "i've run out of privilege button" , tabulate "points"
if(jargonSelect[i]=="5:1" || jargonSelect[i]=="4:2" || jargonSelect[i]=="3:3" || jargonSelect[i]=="2:4" || jargonSelect[i]=="1:5"){
diagonal[diagCount]=jargonSelect[i];
diagCount++;
if(diagonal.length==5){
alert("BINGO");
// document.location.reload(1);
}
}
if(jargonSelect[i]=="1:1" || jargonSelect[i]=="2:2" || jargonSelect[i]=="3:3" || jargonSelect[i]=="4:4" || jargonSelect[i]=="5:5"){
diagonal2[diag2Count]=jargonSelect[i];
diag2Count++;
if(diagonal2.length==5){
alert("BINGO");
// document.location.reload(1);
}
}
//Checking for column match
if(jargonSelect[i]=="1:1" || jargonSelect[i]=="2:1" || jargonSelect[i]=="3:1" || jargonSelect[i]=="4:1" || jargonSelect[i]=="5:1"){
column[colCount]=jargonSelect[i];
colCount++;
if(column.length==5){
alert("BINGO");
// document.location.reload(1);
}
}
if(jargonSelect[i]=="1:2" || jargonSelect[i]=="2:2" || jargonSelect[i]=="3:2" || jargonSelect[i]=="4:2" || jargonSelect[i]=="5:2"){
column2[col2Count]=jargonSelect[i];
col2Count++;
if(column2.length==5){
alert("BINGO");
// document.location.reload(1);
}
}
if(jargonSelect[i]=="1:3" || jargonSelect[i]=="2:3" || jargonSelect[i]=="3:3" || jargonSelect[i]=="4:3" || jargonSelect[i]=="5:3"){
column3[col3Count]=jargonSelect[i];
col3Count++;
if(column3.length==5){
alert("BINGO");
// document.location.reload(1);
}
}
if(jargonSelect[i]=="1:4" || jargonSelect[i]=="2:4" || jargonSelect[i]=="3:4" || jargonSelect[i]=="4:4" || jargonSelect[i]=="5:4"){
column4[col4Count]=jargonSelect[i];
col4Count++;
if(column4.length==5){
alert("BINGO");
//document.location.reload(1);
}
}
if(jargonSelect[i]=="1:5" || jargonSelect[i]=="2:5" || jargonSelect[i]=="3:5" || jargonSelect[i]=="4:5" || jargonSelect[i]=="5:5"){
column5[col5Count]=jargonSelect[i];
col5Count++;
if(column5.length==5){
alert("BINGO");
// document.location.reload(1);
}
}
//Checking for row match
if(jargonSelect[i]=="1:1" || jargonSelect[i]=="1:2" || jargonSelect[i]=="1:3" || jargonSelect[i]=="1:4" || jargonSelect[i]=="1:5"){
row[rowCount]=jargonSelect[i];
rowCount++;
if(row.length==5){
alert("BINGO");
//document.location.reload(1);
}
}
if(jargonSelect[i]=="2:1" || jargonSelect[i]=="2:2" || jargonSelect[i]=="2:3" || jargonSelect[i]=="2:4" || jargonSelect[i]=="2:5"){
row2[row2Count]=jargonSelect[i];
row2Count++;
if(row2.length==5){
alert("BINGO");
//document.location.reload(1);
}
}
if(jargonSelect[i]=="3:1" || jargonSelect[i]=="3:2" || jargonSelect[i]=="3:3" || jargonSelect[i]=="3:4" || jargonSelect[i]=="3:5"){
row3[row3Count]=jargonSelect[i];
row3Count++;
if(row3.length==5){
alert("BINGO");
//document.location.reload(1);
}
}
if(jargonSelect[i]=="4:1" || jargonSelect[i]=="4:2" || jargonSelect[i]=="4:3" || jargonSelect[i]=="4:4" || jargonSelect[i]=="4:5"){
row4[row4Count]=jargonSelect[i];
row4Count++;
if(row4.length==5){
alert("BINGO");
//document.location.reload(1);
}
}
if(jargonSelect[i]=="5:1" || jargonSelect[i]=="5:2" || jargonSelect[i]=="5:3" || jargonSelect[i]=="5:4" || jargonSelect[i]=="5:5"){
row5[row5Count]=jargonSelect[i];
row5Count++;
if(row5.length==5){
alert("BINGO");
// document.location.reload(1);
}
}
}
}
c2++;
}
var _id;
var _ff = 0;
var _rawId = null;
var _pages = 0;
var _chgFlag = null;
_cellZero = null;
var jargon = new Array( 'Native English\nSpeaker',
'Male',
'Standard\naccent',
'Support mainstream\npolitical party',
'Employed',
'Cis',
'White',
'No criminal\nrecord',
'Adult',
'First-world',
'Thin',
'Attractive',
'Born in country\nof residence',
'Well-conneted family',
'No speech\nimpediment',
'Heterosexual',
'Tall',
'Wealthy',
'Not a\nred-head',
'Christian',
'Able-bodied',
'Mentally\nHealthy',
'Intelligent',
'Educated'
);
var _tableData = new Array();
/* Generate array of words for placement */
function randArray() {
var count = 0;
while (jargon.length != 0) {
var f = Math.round(Math.random() * (jargon.length - 1));
_tableData[count]=jargon[f];
jargon[f] = jargon[jargon.length - 1];
jargon.length -= 1;
count++;
}
}
/*Called on page load*/
function loadJargon() {
randArray();
count=0;
for(i = 1; i < 6; ++i) {
for(j = 1; j < 6; ++j) {
cellId=i+":"+j;
/* Populates all cellIDs except for cellID = 3:3 (3:3 auto populated as freespace within HTML) */
if (cellId=="3:3"){
document.getElementById("3:3").value = "Human";
}
else{
cell=document.getElementById(cellId);
cell.appendChild(document.createTextNode(_tableData[count]));
document.getElementById(cellId).value = _tableData[count];
count++;}; }
}
}