mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-10-01 23:32:02 -05:00
Update the window title as the fragment changes
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -1105,6 +1105,7 @@
|
||||
|
||||
case 'title':
|
||||
this.title = row[1];
|
||||
app.roomTitleChanged(this);
|
||||
app.topbar.updateTabbar();
|
||||
break;
|
||||
|
||||
|
||||
15
js/client.js
15
js/client.js
@@ -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 = [];
|
||||
|
||||
Reference in New Issue
Block a user