Improve spectator scoreboard panels
Players will now always be inserted above spectators (ie. spectators will always appear last), making it easier to see who is actually playing.
This commit is contained in:
parent
4ac0de4ff6
commit
81268d9e1d
|
@ -58,6 +58,14 @@ cah.Game = function(id) {
|
|||
this.scoreboardElement_.id = "scoreboard_" + id;
|
||||
$(this.scoreboardElement_).removeClass("hide");
|
||||
|
||||
/**
|
||||
* The first spectator element within the scoreboard.
|
||||
*
|
||||
* @type {HTMLDivElement}
|
||||
* @private
|
||||
*/
|
||||
this.firstSpectatorElement_ = null;
|
||||
|
||||
/**
|
||||
* The element for the chat room for this game
|
||||
*
|
||||
|
@ -786,7 +794,11 @@ cah.Game.prototype.updateUserStatus = function(playerInfo) {
|
|||
if (!panel) {
|
||||
// new score panel
|
||||
panel = new cah.GameScorePanel(playerName);
|
||||
if (this.firstSpectatorElement_) {
|
||||
$(this.firstSpectatorElement_).before(panel.getElement());
|
||||
} else {
|
||||
$(this.scoreboardElement_).append(panel.getElement());
|
||||
}
|
||||
this.scoreCards_[playerName] = panel;
|
||||
}
|
||||
var oldStatus = panel.getStatus();
|
||||
|
@ -858,6 +870,9 @@ cah.Game.prototype.updateSpectator = function(spectator) {
|
|||
panel = new cah.GameScorePanel(spectator);
|
||||
$(this.scoreboardElement_).append(panel.getElement());
|
||||
this.scoreCards_[spectator] = panel;
|
||||
if (!this.firstSpectatorElement_) {
|
||||
this.firstSpectatorElement_ = panel.getElement();
|
||||
}
|
||||
}
|
||||
panel.update(-1, cah.$.GamePlayerStatus.SPECTATOR);
|
||||
|
||||
|
@ -1198,6 +1213,9 @@ cah.Game.prototype.spectatorLeave = function(spectator) {
|
|||
}
|
||||
var scorecard = this.scoreCards_[spectator];
|
||||
if (scorecard) {
|
||||
if (this.firstSpectatorElement_ == scorecard.getElement()) {
|
||||
this.firstSpectatorElement_ = this.firstSpectatorElement_.nextSibling;
|
||||
}
|
||||
$(scorecard.getElement()).remove();
|
||||
}
|
||||
delete this.scoreCards_[spectator];
|
||||
|
|
Loading…
Reference in New Issue