-
Notifications
You must be signed in to change notification settings - Fork 0
/
arrays.js
200 lines (157 loc) · 2.58 KB
/
arrays.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
// new media
var buzzfeed_array = [
"Buzzfeed",
103,
];
var vice_array = [
"Vice",
215,
]
var huffington_post_array = [
"Huffington Post",
102,
];
var diply_array = [
"Diply",
62,
];
var new_media_array = [
buzzfeed_array,
vice_array,
huffington_post_array,
diply_array,
]
// old media
var new_york_times_array = [
"New York Times",
101,
];
var guardian_array = [
"The Guardian",
153,
];
var bbc_array = [
"The BBC",
70,
];
var fox_news_array = [
"Fox News",
214,
]
var old_media_array = [
new_york_times_array,
guardian_array,
bbc_array,
fox_news_array,
];
// u.s. site
var linked_in_array = [
"LinkedIn",
13,
];
var instagram_array = [
"Instagram",
33,
];
var ebay_array = [
"Ebay",
18,
];
var yahoo_array = [
"Yahoo",
4,
];
var us_sites_array = [
linked_in_array,
instagram_array,
ebay_array,
yahoo_array,
];
// non-u.s. site
var vk_array = [
"Vkontakte",
32,
];
var weibo_array = [
"Weibo",
15,
];
var taobao_array = [
"Taobao",
8,
];
var baidu_array = [
"Baidu",
5,
];
var non_us_sites_array = [
vk_array,
weibo_array,
taobao_array,
baidu_array,
];
// googles
var google_india = [
"Google India",
11,
];
var google_japan = [
"Google Japan",
19,
];
var google_germany = [
"Google Germany",
21,
];
var google_uk = [
"Google UK",
26,
];
var google_france = [
"Google France",
34,
];
var google_poland = [
"Google Poland",
82,
];
var google_turkey = [
"Google Turkey",
71,
];
var google_brazil = [
"Google Brazil",
31,
];
// this could be done better, so that on every turn the programme picks two completely random google_countries to match against each other.
var europe_googles_array = [
google_germany,
google_uk,
google_france,
google_poland,
];
var non_europe_googles_array = [
google_india,
google_japan,
google_brazil,
google_turkey,
];
// All the arrays together, in matched pairs
var ultimate_array = [
[new_media_array, old_media_array],
[us_sites_array, non_us_sites_array],
[europe_googles_array, non_europe_googles_array],
];
// pick a random element from array
function select_random(array){
return array[Math.floor(Math.random() * array.length)];
};
// pick a pseudorandom element from
function select_pseudo_random(array){
random_index = Math.floor(Math.random() * (array.length - 1));
selected_element = array[random_index];
array.splice(random_index, 1);
array.push(selected_element);
return selected_element;
};
// technically this pseudorandom generator has a problem in our ussage because on-page-load the last item in each array is never selected. This doesn't seem important, though.