From 6a554831a17918b017be6002a8e46efec6b24ddf Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Sat, 12 Sep 2020 15:23:38 +0200 Subject: [PATCH] Sort users lexicographically. --- static/sfu.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/static/sfu.js b/static/sfu.js index 75d627d..a65cf06 100644 --- a/static/sfu.js +++ b/static/sfu.js @@ -767,6 +767,18 @@ function addUser(id, name) { user.id = 'user-' + id; user.classList.add("user-p"); user.textContent = name ? name : '(anon)'; + + if(name) { + let us = div.children; + for(let i = 0; i < us.length; i++) { + let child = us[i]; + let childname = users[child.id.slice('user-'.length)]; + if(!childname || childname > name) { + div.insertBefore(user, child); + return; + } + } + } div.appendChild(user); }