forked from nutomic/joinpeertube
Merge branch 'feature/continue-joinpeertube' into 'master'
Shuffle instances See merge request framasoft/joinpeertube!7
This commit is contained in:
commit
9eee486ae5
1 changed files with 11 additions and 1 deletions
|
@ -10,7 +10,7 @@ $(function () {
|
||||||
|
|
||||||
$.get(instancesApi, data)
|
$.get(instancesApi, data)
|
||||||
.done(function (res) {
|
.done(function (res) {
|
||||||
const instances = res.data
|
const instances = shuffle(res.data)
|
||||||
|
|
||||||
const lis = []
|
const lis = []
|
||||||
instances.forEach(function (instance) {
|
instances.forEach(function (instance) {
|
||||||
|
@ -80,4 +80,14 @@ $(function () {
|
||||||
|
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Thanks https://stackoverflow.com/a/6274381
|
||||||
|
function shuffle (a) {
|
||||||
|
for (var i = a.length - 1; i > 0; i--) {
|
||||||
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
[a[i], a[j]] = [a[j], a[i]]
|
||||||
|
}
|
||||||
|
|
||||||
|
return a
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue