diff --git a/js/client-mainmenu.js b/js/client-mainmenu.js
index 17d46f6e8..1fd2ec129 100644
--- a/js/client-mainmenu.js
+++ b/js/client-mainmenu.js
@@ -409,6 +409,7 @@
}
bufs[curBuf] += '
';
}
+
if (bufs[1]) {
this.$el.html('');
} else {
@@ -426,36 +427,56 @@
var TeamPopup = this.TeamPopup = this.Popup.extend({
initialize: function(data) {
- var buf = '';
+ var bufs = ['','',''];
+ var curBuf = 0;
var teams = app.user.teams;
+
+ var bufBoundary = 27;
+ var bufBoundary2 = 54;
+ if (teams.length > 54) {
+ bufBoundary2 = Math.floor(2*teams.length/3);
+ bufBoundary = Math.floor(teams.length/3);
+ } else if (teams.length > 27) {
+ bufBoundary = Math.floor(teams.length/2);
+ }
+
if (!teams.length) {
- buf = 'You have no teams';
+ bufs[curBuf] = 'You have no teams';
} else {
var format = BattleFormats[data.format];
var curTeam = +data.team;
var teamFormat = (format.teambuilderFormat || (format.isTeambuilderFormat ? data.format : false));
- buf = ''+Tools.escapeFormat(teamFormat)+' teams
';
- var atLeastOne = false;
+ bufs[curBuf] = ''+Tools.escapeFormat(teamFormat)+' teams
';
+ var count = 0;
for (var i = 0; i < teams.length; i++) {
if ((!teams[i].format && !teamFormat) || teams[i].format === teamFormat) {
var selected = (i === curTeam);
- buf += '';
- atLeastOne = true;
+ bufs[curBuf] += '';
+ count++;
+ if (count === bufBoundary) curBuf = 1;
+ if (count === bufBoundary2) curBuf = 2;
}
}
- if (!atLeastOne) buf += 'You have no '+Tools.escapeFormat(teamFormat)+' teams';
- buf += 'Other teams
';
+ if (!count) bufs[curBuf] += 'You have no '+Tools.escapeFormat(teamFormat)+' teams';
+ bufs[curBuf] += 'Other teams
';
for (var i = 0; i < teams.length; i++) {
if ((!teams[i].format && !teamFormat) || teams[i].format === teamFormat) continue;
var selected = (i === curTeam);
- buf += '';
+ bufs[curBuf] += '';
+ count++;
+ if (count === bufBoundary) curBuf = 1;
+ if (count === bufBoundary2) curBuf = 2;
}
}
if (format.canUseRandomTeam) {
- buf += '';
+ bufs[curBuf] += '';
}
- this.$el.html('');
+ if (bufs[1]) {
+ this.$el.html('');
+ } else {
+ this.$el.html('');
+ }
},
selectTeam: function(i) {
var formatid = this.sourceEl.closest('form').find('button[name=format]').val();