From dfb58aed591801918b00f6b2fa924f7fd78fcd2e Mon Sep 17 00:00:00 2001 From: "Cathy J. Fitzpatrick" Date: Tue, 19 Feb 2013 01:07:18 -0700 Subject: [PATCH] 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. --- index.php.template.txt | 1 + js/sim.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/index.php.template.txt b/index.php.template.txt index 760a6b70f..a7de9ddfa 100644 --- a/index.php.template.txt +++ b/index.php.template.txt @@ -205,6 +205,7 @@ if (!$challengeresponse) { diff --git a/js/sim.js b/js/sim.js index e4ba6c81b..83c6c8950 100644 --- a/js/sim.js +++ b/js/sim.js @@ -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