Created
January 18, 2022 20:13
-
-
Save keevie/9259d81c4fa493191ba3caf17af6139c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fill(name) { | |
const rooms = document.querySelectorAll('.sidebar .table'); | |
if (name) { | |
var room = [...rooms].find(r => r.innerHTML.match(name)); | |
} else { | |
var room = rooms[Math.random() * rooms.length | 0]; | |
} | |
let seat = room.querySelector('.participant.is-empty'); | |
if (!seat) { | |
const oldSeat = room.querySelector('.participant'); | |
seat = oldSeat.cloneNode(oldSeat); | |
seat.removeChild(seat.querySelector(".avatar")); | |
oldSeat.parentNode.appendChild(seat); | |
} | |
seat.style.backgroundImage = `url(https://randomuser.me/api/portraits/${Math.random() > 0.5 ? 'men' : 'women'}/${Math.random() * 100 | 0}.jpg)`; | |
seat.classList.remove('is-empty'); | |
seat.style.backgroundSize = 'cover'; | |
} | |
for (let i=0; i< 100; i++) {fill()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment