Fix to handle name or color might get undefined error

This commit is contained in:
Wu Cheng-Han 2016-10-12 17:48:28 +08:00
parent bd6d69d7a7
commit 12b7646f24
1 changed files with 4 additions and 4 deletions

View File

@ -2792,14 +2792,14 @@ function sortOnlineUserList(list) {
else if (usera.idle && !userb.idle) else if (usera.idle && !userb.idle)
return 1; return 1;
else { else {
if (usera.name.toLowerCase() < userb.name.toLowerCase()) { if (usera.name && usera.name.toLowerCase() < userb.name.toLowerCase()) {
return -1; return -1;
} else if (usera.name.toLowerCase() > userb.name.toLowerCase()) { } else if (usera.name && usera.name.toLowerCase() > userb.name.toLowerCase()) {
return 1; return 1;
} else { } else {
if (usera.color.toLowerCase() < userb.color.toLowerCase()) if (usera.color && usera.color.toLowerCase() < userb.color.toLowerCase())
return -1; return -1;
else if (usera.color.toLowerCase() > userb.color.toLowerCase()) else if (usera.color && usera.color.toLowerCase() > userb.color.toLowerCase())
return 1; return 1;
else else
return 0; return 0;