mirror of
https://github.com/jech/galene.git
synced 2024-11-23 00:55:58 +01:00
Sort usernames case-insensitively in user interface.
This commit is contained in:
parent
90ba4814c8
commit
2b4372ad87
1 changed files with 21 additions and 2 deletions
|
@ -1067,6 +1067,25 @@ function resizePeers() {
|
||||||
/** @type{Object<string,string>} */
|
/** @type{Object<string,string>} */
|
||||||
let users = {};
|
let users = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lexicographic order, with case differences secondary.
|
||||||
|
* @param{string} a
|
||||||
|
* @param{string} b
|
||||||
|
*/
|
||||||
|
function stringCompare(a, b) {
|
||||||
|
let la = a.toLowerCase()
|
||||||
|
let lb = b.toLowerCase()
|
||||||
|
if(la < lb)
|
||||||
|
return -1;
|
||||||
|
else if(la > lb)
|
||||||
|
return +1;
|
||||||
|
else if(a < b)
|
||||||
|
return -1;
|
||||||
|
else if(a > b)
|
||||||
|
return +1;
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} id
|
* @param {string} id
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
|
@ -1088,8 +1107,8 @@ function addUser(id, name) {
|
||||||
let us = div.children;
|
let us = div.children;
|
||||||
for(let i = 0; i < us.length; i++) {
|
for(let i = 0; i < us.length; i++) {
|
||||||
let child = us[i];
|
let child = us[i];
|
||||||
let childname = users[child.id.slice('user-'.length)];
|
let childname = users[child.id.slice('user-'.length)] || null;
|
||||||
if(!childname || childname > name) {
|
if(!childname || stringCompare(childname, name) > 0) {
|
||||||
div.insertBefore(user, child);
|
div.insertBefore(user, child);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue