Show error message for having no teams

This commit is contained in:
Guangcong Luo
2013-05-20 18:48:18 -05:00
parent 9e85fcb81b
commit 956f2473d6

View File

@@ -342,9 +342,14 @@
var $pmWindow = $(target).closest('.pm-window');
var userid = $pmWindow.data('userid');
var format = $pmWindow.find('button[name=format]').val();
var teamIndex = $pmWindow.find('button[name=team]').val();
var team = null;
if (app.user.teams[teamIndex]) team = app.user.teams[teamIndex].team;
if (!window.BattleFormats[format].team && !team) {
app.addPopupMessage("You need to go into the Teambuilder and build a team for this format.");
return;
}
$(target).closest('.challenge').remove();
app.send('/utm '+(team?$.toJSON(team):'null'));
@@ -360,11 +365,15 @@
var $pmWindow = $(target).closest('.pm-window');
var userid = $pmWindow.data('userid');
var name = $pmWindow.data('name');
var format = $pmWindow.find('button[name=format]').val();
var format = $pmWindow.find('button[name=format]').val();
var teamIndex = $pmWindow.find('button[name=team]').val();
var team = null;
if (app.user.teams[teamIndex]) team = app.user.teams[teamIndex].team;
if (!window.BattleFormats[format].team && !team) {
app.addPopupMessage("You need to go into the Teambuilder and build a team for this format.");
return;
}
var buf = '<form class="battleform pending"><p>Challenging '+Tools.escapeHTML(name)+'...</p>';
buf += '<p><label class="label">Format:</label>'+this.renderFormats(format, true)+'</p>';
@@ -470,6 +479,10 @@
var teamIndex = $teamButton.val();
var team = null;
if (app.user.teams[teamIndex]) team = app.user.teams[teamIndex].team;
if (!window.BattleFormats[format].team && !team) {
app.addPopupMessage("You need to go into the Teambuilder and build a team for this format.");
return;
}
$formatButton.addClass('preselected')[0].disabled = true;
$teamButton.addClass('preselected')[0].disabled = true;