Prevent random choosing the same person

This commit is contained in:
Jake 2021-04-08 17:42:41 +01:00
parent e7fb4c8a38
commit 7197acae41
Signed by: jakew
GPG Key ID: 2B83DC56C147243B
1 changed files with 7 additions and 0 deletions

View File

@ -10,6 +10,13 @@
window.onload = function() {
var users = [ {{ range .Users }} "{{ . }}", {{ end }} ];
var current = window.location.search.substr(1);
var index = users.indexOf(current);
if (index >= 0) {
users.splice(index, 1);
}
var user = users[Math.floor(Math.random() * users.length)];
window.location.href = "https://southlondon.cc/~" + user;