Randomize the clusters
Signed-off-by: James Ketrenos <james_gitlab@ketrenos.com>
This commit is contained in:
parent
0db1181851
commit
f0ae806fbb
14
clusters-pre
14
clusters-pre
@ -40,6 +40,18 @@ function createFace(faceId, photoId) {
|
||||
return div;
|
||||
}
|
||||
|
||||
function shuffle(array) {
|
||||
var i = array.length, tmp, random;
|
||||
while (i > 0) {
|
||||
random = Math.floor(Math.random() * i);
|
||||
i--;
|
||||
tmp = array[i];
|
||||
array[i] = array[random];
|
||||
array[random] = tmp;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
var div = document.createElement("div");
|
||||
div.textContent = "There are " + clusters.length + " clusters.";
|
||||
@ -57,6 +69,8 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
||||
div.innerHTML = html;
|
||||
clusterBlock.appendChild(div);
|
||||
|
||||
shuffle(cluster);
|
||||
|
||||
cluster.forEach((tuple, index) => {
|
||||
if (index >= 10) {
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user