-
Notifications
You must be signed in to change notification settings - Fork 1
/
bubbles.js
38 lines (32 loc) · 1.12 KB
/
bubbles.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
var bubbles = [
"<a href='/art' class=bubble>Artful</a>",
"<a href='/learn2code' class=bubble>Thoughtful</a>",
"<a href='/art/live' class=bubble>Clever</a>",
"<a href='/code' class=bubble>Experienced</a>",
"<a href='/pikachu' class=bubble>Silly</a>",
"<a href='/slides' class=bubble>Presentable</a>",
"<a href='/resume' class=bubble>Employable</a>",
"<a href='/basic' class=bubble>Passionate</a>",
"<a href='/robots' class=bubble>Fun</a>",
];
function shuffle(array) {
let currentIndex = array.length, randomIndex;
// While there remain elements to shuffle...
while (currentIndex != 0) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;
// And swap it with the current element.
[array[currentIndex], array[randomIndex]] = [
array[randomIndex], array[currentIndex]];
}
return array;
}
function randomize_bubbles() {
var bubble_list = shuffle(bubbles);
for(var i=0; i<9;i+=1) {
var bubble_id = "bubble" + i;
var content = bubble_list[i];
$("#"+ bubble_id).html(content);
}
}