Merge pull request #453 from urkerab/fragment-title

Update the window title as the fragment changes
This commit is contained in:
Guangcong Luo
2015-08-26 21:51:03 -04:00
3 changed files with 16 additions and 2 deletions

View File

@@ -98,6 +98,7 @@
if (log.length && log[0].substr(0, 7) === '|title|') {
this.title = log[0].substr(7);
log.shift();
app.roomTitleChanged(this);
}
if (this.battle.activityQueue.length) return;
this.battle.activityQueue = log;
@@ -150,6 +151,7 @@
}
} else if (logLine.substr(0, 7) === '|title|') {
this.title = logLine.substr(7);
app.roomTitleChanged(this);
} else if (logLine.substr(0, 6) === '|chat|' || logLine.substr(0, 3) === '|c|' || logLine.substr(0, 9) === '|chatmsg|' || logLine.substr(0, 10) === '|inactive|') {
this.battle.instantAdd(logLine);
} else {

View File

@@ -1105,6 +1105,7 @@
case 'title':
this.title = row[1];
app.roomTitleChanged(this);
app.topbar.updateTabbar();
break;

View File

@@ -859,9 +859,10 @@
if (location.search && window.history) {
history.replaceState(null, null, '/');
}
fragment = toRoomid(fragment || '');
this.fragment = fragment = toRoomid(fragment || '');
if (this.initialFragment === undefined) this.initialFragment = fragment;
this.tryJoinRoom(fragment);
this.updateTitle(this.rooms[fragment]);
},
/**
* Send to sim server
@@ -1389,7 +1390,11 @@
}
this.curRoom = window.room = room;
this.updateLayout();
if (this.curRoom.id === id) this.navigate(id);
if (this.curRoom.id === id) {
this.fragment = id;
this.navigate(id);
this.updateTitle(this.curRoom);
}
}
room.focus();
@@ -1530,6 +1535,12 @@
return false;
}
},
roomTitleChanged: function (room) {
if (room.id === this.fragment) updateTitle(room);
},
updateTitle: function (room) {
document.title = room.title ? room.title + " - Showdown!" : "Showdown!";
},
updateAutojoin: function () {
if (Config.server.id !== 'showdown') return;
var autojoins = [];