Don't load the client if teams fail to load

If teams fail to load due to some bug, the user may lose their teams
permanently if they save their teams. In avoid to avoid a catastrophe,
we now decline to load the client if teams fail to load.

This should never happen unless a bug is introduced that breaks team
loading.
This commit is contained in:
Cathy J. Fitzpatrick
2013-02-19 01:07:18 -07:00
parent 278479865e
commit dfb58aed59
2 changed files with 5 additions and 2 deletions

View File

@@ -205,6 +205,7 @@ if (!$challengeresponse) {
<script src="/js/sim.js?"></script>
<script>
if (!teams) Config.down = true;
if (Config.down) overlay('down');
</script>

View File

@@ -39,7 +39,7 @@ var curRoom = null;
var curTitle = 'Showdown!';
var battles = {};
var formats = [''];
var teams = [];
var teams = null;
var isAndroid = navigator.userAgent.toLowerCase().indexOf("android") > -1 && navigator.userAgent.toLowerCase().indexOf("firefox") <= -1;
@@ -3170,8 +3170,9 @@ function init() {
}
var cookieTeams = true;
(function () {
teams = (function() {
var savedTeam = $.parseJSON($.cookie('showdown_team1'));
var teams = [];
if (savedTeam) {
teams.push(savedTeam);
}
@@ -3188,6 +3189,7 @@ var cookieTeams = true;
var teamString = localStorage.getItem('showdown_teams');
if (teamString) teams = JSON.parse(teamString);
}
return teams;
})();
// time to connect