Skip to content

Instantly share code, notes, and snippets.

@felipenmoura
Last active December 8, 2015 11:23
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save felipenmoura/2a004604ca4cef39cc80 to your computer and use it in GitHub Desktop.
Save felipenmoura/2a004604ca4cef39cc80 to your computer and use it in GitHub Desktop.
Função utilizada para sortear entre os participantes na lista da eventick (em checkin.eventick.com.br)
function selectOne(){
var x= [].slice.call(document.querySelectorAll('.tml-attendees-checked td:nth-child(2) strong')).map(function (cur){return cur.innerText;});
var picked = x[ Math.ceil(Math.random() * x.length) ];
console.log("%c" + picked, "font-weight: bold; color: red; font-size: 40px;");
return picked;
}
function selectAsMany(howMany){
var picked = [],
lastSelected,
cur = 0,
limit = 100;
while(picked.length < howMany){
cur++;
lastSelected = selectOne();
if(picked.indexOf(lastSelected) < 0){
picked.push(lastSelected);
}
if(cur >= limit){
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment