From 4c7eb9a3cd5a9dc76e46a67dcd7c44714f235824 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Sat, 14 Sep 2013 20:06:55 -0500 Subject: [PATCH] Move some team storage functionality to storage.js --- js/client-mainmenu.js | 16 +++++------ js/client-teambuilder.js | 61 ++++++---------------------------------- js/client.js | 43 +++++----------------------- js/storage.js | 46 ++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 96 deletions(-) diff --git a/js/client-mainmenu.js b/js/client-mainmenu.js index 496c363a1..fde115212 100644 --- a/js/client-mainmenu.js +++ b/js/client-mainmenu.js @@ -384,7 +384,7 @@ }, updateTeams: function() { if (!window.BattleFormats) return; - var teams = app.user.teams; + var teams = Storage.teams; var self = this; this.$('button[name=team]').each(function(i, el) { @@ -424,7 +424,7 @@ 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 (Storage.teams[teamIndex]) team = Storage.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; @@ -448,7 +448,7 @@ 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 (Storage.teams[teamIndex]) team = Storage.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; @@ -505,7 +505,7 @@ curTeamFormat: '', curTeamIndex: -1, renderTeams: function(formatid, teamIndex) { - if (!app.user.teams || !window.BattleFormats) { + if (!Storage.teams || !window.BattleFormats) { return ''; } if (!formatid) formatid = this.curFormat; @@ -515,7 +515,7 @@ if (window.BattleFormats[formatid].team) { return ''; } - var teams = app.user.teams; + var teams = Storage.teams; if (!teams.length) { return '' } @@ -558,7 +558,7 @@ var format = $formatButton.val(); var teamIndex = $teamButton.val(); var team = null; - if (app.user.teams[teamIndex]) team = app.user.teams[teamIndex].team; + if (Storage.teams[teamIndex]) team = Storage.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; @@ -628,7 +628,7 @@ initialize: function(data) { var bufs = ['','','','','']; var curBuf = 0; - var teams = app.user.teams; + var teams = Storage.teams; var bufBoundary = 128; if (teams.length > 128 && $(window).width() > 1080) { @@ -699,7 +699,7 @@ } return buf; } - var team = app.user.teams[i]; + var team = Storage.teams[i]; if (!team) return 'Error: Corrupted team'; var buf = ''+Tools.escapeHTML(team.name)+'
'; for (var i=0; i' buf += '

aww thanks I\'m glad you like it :)

' buf += '