mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Factorise out setUserStatus.
This commit is contained in:
parent
d8db7567e4
commit
7527aeba3d
1 changed files with 20 additions and 16 deletions
|
@ -2107,12 +2107,7 @@ function addUser(id, userinfo) {
|
||||||
let user = document.createElement('div');
|
let user = document.createElement('div');
|
||||||
user.id = 'user-' + id;
|
user.id = 'user-' + id;
|
||||||
user.classList.add("user-p");
|
user.classList.add("user-p");
|
||||||
user.textContent = userinfo.username ? userinfo.username : '(anon)';
|
setUserStatus(id, user, userinfo);
|
||||||
if (userinfo.data.raisehand)
|
|
||||||
user.classList.add('user-status-raisehand');
|
|
||||||
else
|
|
||||||
user.classList.remove('user-status-raisehand');
|
|
||||||
|
|
||||||
user.addEventListener('click', function(e) {
|
user.addEventListener('click', function(e) {
|
||||||
let elt = e.target;
|
let elt = e.target;
|
||||||
if(!elt || !(elt instanceof HTMLElement))
|
if(!elt || !(elt instanceof HTMLElement))
|
||||||
|
@ -2153,16 +2148,25 @@ function addUser(id, userinfo) {
|
||||||
* @param {user} userinfo
|
* @param {user} userinfo
|
||||||
*/
|
*/
|
||||||
function changeUser(id, userinfo) {
|
function changeUser(id, userinfo) {
|
||||||
let user = document.getElementById('user-' + id);
|
let elt = document.getElementById('user-' + id);
|
||||||
if(!user) {
|
if(!elt) {
|
||||||
console.warn('Unknown user ' + id);
|
console.warn('Unknown user ' + id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.textContent = userinfo.username ? userinfo.username : '(anon)';
|
setUserStatus(id, elt, userinfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} id
|
||||||
|
* @param {HTMLElement} elt
|
||||||
|
* @param {user} userinfo
|
||||||
|
*/
|
||||||
|
function setUserStatus(id, elt, userinfo) {
|
||||||
|
elt.textContent = userinfo.username ? userinfo.username : '(anon)';
|
||||||
if(userinfo.data.raisehand)
|
if(userinfo.data.raisehand)
|
||||||
user.classList.add('user-status-raisehand');
|
elt.classList.add('user-status-raisehand');
|
||||||
else
|
else
|
||||||
user.classList.remove('user-status-raisehand');
|
elt.classList.remove('user-status-raisehand');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue