(function($) { var MainMenuRoom = this.MainMenuRoom = this.Room.extend({ type: 'mainmenu', tinyWidth: 340, bestWidth: 628, events: { 'keydown textarea': 'keyPress', 'click .username': 'clickUsername', 'click .closebutton': 'closePM', 'click .minimizebutton': 'minimizePM', 'click .pm-window': 'clickPMBackground', 'focus textarea': 'onFocusPM', 'blur textarea': 'onBlurPM', 'click button.formatselect': 'selectFormat', 'click button.teamselect': 'selectTeam' }, initialize: function() { this.$el.addClass('scrollable'); // left menu 2 (high-res: right, low-res: top) // (created during page load) // left menu 1 (high-res: left, low-res: bottom) var buf = ''; if (app.down) { buf += ''; } else { buf += ''; } buf += ''; if (!app.down) buf += ''; this.$('.mainmenu').html(buf); // right menu if (!app.down) { if (document.location.hostname === 'play.pokemonshowdown.com') { this.$('.rightmenu').html(''); } else { this.$('.rightmenu').html(''); } } // footer // (created during page load) this.$activityMenu = this.$('.activitymenu'); this.$pmBox = this.$activityMenu.find('.pmbox'); app.on('init:formats', this.updateFormats, this); this.updateFormats(); app.user.on('saveteams', this.updateTeams, this); }, addPseudoPM: function(options) { if (!options) return; options.title = options.title || ''; options.html = options.html || ''; options.cssClass = options.cssClass || ''; options.height = options.height || 'auto'; options.maxHeight = options.maxHeight || ''; options.attributes = options.attributes || ''; options.append = options.append || false; options.noMinimize = options.noMinimize || false; this.$pmBox[options.append ? 'append' : 'prepend']('

' + (!options.noMinimize ? '' : '') + options.title + '

' + options.html + '
'); }, // news addNews: function() { var newsId = '1990'; if (newsId === ''+Tools.prefs('readnews')) return; this.addPseudoPM({ title: 'Latest News', html: '', attributes: 'data-newsid="'+newsId+'"', cssClass: 'news-embed', height: 400, noMinimize: true }); }, /********************************************************* * PMs *********************************************************/ addPM: function(name, message, target) { var userid = toUserid(name); if (app.ignore[userid] && name.substr(0, 1) in {' ':1, '!':1, '‽':1}) return; if (app.curSideRoom && app.curSideRoom.addPM && !Tools.prefs('nolobbypm')) { app.curSideRoom.addPM(name, message, target); } var oName = name; if (toId(name) === app.user.get('userid')) { oName = target; } else { this.notifyOnce("PM from "+oName, "\""+message+"\"", 'pm'); } Storage.logChat('pm-'+toId(oName), ''+name+': '+message); var $pmWindow = this.openPM(oName, true); var $chatFrame = $pmWindow.find('.pm-log'); var $chat = $pmWindow.find('.inner'); var autoscroll = false; if ($chatFrame.scrollTop() + 60 >= $chat.height() - $chatFrame.height()) { autoscroll = true; } var timestamp = ChatRoom.getTimestamp('pms'); var color = hashColor(toId(name)); var clickableName = '' + Tools.escapeHTML(name.substr(1)) + ''; if (name.substr(0, 1) !== ' ') clickableName = '' + Tools.escapeHTML(name.substr(0, 1)) + ''+clickableName; if (message.substr(0,4) === '/me ') { $chat.append('
' + timestamp + ' ' + clickableName + ' ' + Tools.parseMessage(message.substr(4), name) + '
'); } else if (message.substr(0,5) === '/mee ') { $chat.append('
' + timestamp + ' ' + clickableName + '' + Tools.parseMessage(message.substr(5), name) + '
'); } else if (message.substr(0,8) === '/invite ') { var roomid = toRoomid(message.substr(8)); $chat.append('
' + timestamp + '' + clickableName + ' invited you to join the room "'+roomid+'"
'); $chat.append('
'); } else if (message.substr(0,10) === '/announce ') { $chat.append('
' + timestamp + '' + clickableName + ': ' + Tools.parseMessage(message.substr(10), name) + '
'); } else if (message.substr(0,14) === '/data-pokemon ') { $chat.append('
'); } else if (message.substr(0,11) === '/data-item ') { $chat.append('
'); } else if (message.substr(0,14) === '/data-ability ') { $chat.append('
'); } else if (message.substr(0,11) === '/data-move ') { $chat.append('
'); } else { // Normal chat message. if (message.substr(0,2) === '//') message = message.substr(1); $chat.append('
' + timestamp + '' + clickableName + ': ' + Tools.parseMessage(message, name) + '
'); } if (autoscroll) { $chatFrame.scrollTop($chat.height()); } if ($pmWindow.data('minimized') && name.substr(1) !== app.user.get('name')) { $pmWindow.find('h3').addClass('pm-notifying'); } }, openPM: function(name, dontFocus) { var userid = toId(name); var $pmWindow = this.$pmBox.find('.pm-window-'+userid); if (!$pmWindow.length) { var group = name.charAt(0); if (group === ' ') { group = ''; } else { group = ''+Tools.escapeHTML(group)+''; } var buf = '
'; buf += '

'; buf += ''; buf += group+Tools.escapeHTML(name.substr(1))+'

'; buf += '
'; buf += '
'; $pmWindow = $(buf).prependTo(this.$pmBox); $pmWindow.find('textarea').autoResize({ animate: false, extraSpace: 0 }); } else { $pmWindow.show(); if (!dontFocus) { var $chatFrame = $pmWindow.find('.pm-log'); var $chat = $pmWindow.find('.inner'); $chatFrame.scrollTop($chat.height()); } } if (!dontFocus) this.$el.scrollTop(0); return $pmWindow; }, closePM: function(e) { var userid; if (e.currentTarget) { e.preventDefault(); e.stopPropagation(); userid = $(e.currentTarget).closest('.pm-window').data('userid'); } else { userid = toId(e); } var $pmWindow; if (!userid) { // not a true PM; just close the window $pmWindow = $(e.currentTarget).closest('.pm-window'); var newsId = $pmWindow.data('newsid'); if (newsId) { $.cookie('showdown_readnews', ''+newsId, {expires: 365}); } $pmWindow.remove(); return; } $pmWindow = this.$pmBox.find('.pm-window-'+userid); $pmWindow.hide(); var $rejectButton = $pmWindow.find('button[name=rejectChallenge]'); if ($rejectButton.length) { this.rejectChallenge(userid, $rejectButton); } $rejectButton = $pmWindow.find('button[name=cancelChallenge]'); if ($rejectButton.length) { this.cancelChallenge(userid, $rejectButton); } var $next = $pmWindow.next(); while ($next.length && $next.css('display') === 'none') { $next = $next.next(); } if ($next.length) { $next.find('textarea[name=message]').focus(); return; } $next = $pmWindow.prev(); while ($next.length && $next.css('display') === 'none') { $next = $next.prev(); } if ($next.length) { $next.find('textarea[name=message]').focus(); return; } if (app.curSideRoom) app.curSideRoom.focus(); }, minimizePM: function(e) { var $pmWindow; if (e.currentTarget) { e.preventDefault(); e.stopPropagation(); $pmWindow = $(e.currentTarget).closest('.pm-window'); } if (!$pmWindow) { return; } var $pmHeader = $pmWindow.find('h3'); var $pmContent = $pmWindow.find('.pm-log, .pm-log-add'); if (!$pmWindow.data('minimized')) { $pmContent.hide(); $pmHeader.addClass('pm-minimized'); $pmWindow.data('minimized', true); } else { $pmContent.show(); $pmHeader.removeClass('pm-minimized'); $pmWindow.data('minimized', false); } $pmWindow.find('h3').removeClass('pm-notifying'); }, focusPM: function(name) { this.openPM(name).prependTo(this.$pmBox).find('textarea[name=message]').focus(); }, onFocusPM: function(e) { $(e.currentTarget).closest('.pm-window').addClass('focused'); }, onBlurPM: function(e) { $(e.currentTarget).closest('.pm-window').removeClass('focused'); }, keyPress: function(e) { if (e.keyCode === 13 && !e.shiftKey) { // Enter var $target = $(e.currentTarget); e.preventDefault(); e.stopPropagation(); var text; if ((text = $target.val())) { // this.tabComplete.reset(); // this.chatHistory.push(text); var userid = $target.closest('.pm-window').data('userid'); text = ('\n'+text).replace(/\n/g, '\n/pm '+userid+', ').substr(1); this.send(text); $(e.currentTarget).val(''); } } else if (e.keyCode === 27) { // Esc this.closePM(e); } else if (e.keyCode === 9 && !e.shiftKey && !e.ctrlKey) { // Tab key var handlerRoom = app.curSideRoom; if (!handlerRoom) { for (var roomid in app.rooms) { if (!app.rooms[roomid].handleTabComplete) continue; handlerRoom = app.rooms[roomid]; break; } } if (handlerRoom && handlerRoom.handleTabComplete && handlerRoom.handleTabComplete($(e.currentTarget))) { e.preventDefault(); e.stopPropagation(); } } }, clickUsername: function(e) { e.stopPropagation(); var name = $(e.currentTarget).data('name'); app.addPopup(UserPopup, {name: name, sourceEl: e.currentTarget}); }, clickPMBackground: function(e) { if (!e.shiftKey && !e.cmdKey && !e.ctrlKey) { if (window.getSelection && !window.getSelection().isCollapsed) { return; } app.dismissPopups(); var $target = $(e.currentTarget); if ($target.data('minimized')) { this.minimizePM(e); } $target.find('textarea[name=message]').focus(); } }, // support for buttons that can be sent by the server: joinRoom: function(room) { app.joinRoom(room); }, avatars: function() { app.addPopup(AvatarsPopup); }, openSounds: function() { app.addPopup(SoundsPopup, {type:'semimodal'}); }, openOptions: function() { app.addPopup(OptionsPopup, {type:'semimodal'}); }, // challenges and searching challengesFrom: null, challengeTo: null, resetPending: function() { this.updateSearch(); var self = this; this.$('form.pending').closest('.pm-window').each(function(i, el) { $(el).find('.challenge').remove(); self.challenge($(el).data('userid')); }); this.$('button[name=acceptChallenge]').each(function(i, el) { el.disabled = false; }); }, searching: false, updateSearch: function(data) { if (data) this.searching = data.searching; var $searchForm = $('.mainmenu button.big').closest('form'); var $formatButton = $searchForm.find('button[name=format]'); var $teamButton = $searchForm.find('button[name=team]'); if (this.searching) { $formatButton.addClass('preselected')[0].disabled = true; $teamButton.addClass('preselected')[0].disabled = true; $searchForm.find('button.big').html(' Searching...').addClass('disabled'); } else { var format = $formatButton.val(); var teamIndex = $teamButton.val(); $formatButton.replaceWith(this.renderFormats(format)); $teamButton.replaceWith(this.renderTeams(format, teamIndex)); $searchForm.find('button.big').html('Look for a battle').removeClass('disabled'); $searchForm.find('button.cancelSearch').html('Look for a battle').removeClass('disabled'); $searchForm.find('p.cancel').remove(); } }, updateChallenges: function(data) { this.challengesFrom = data.challengesFrom; this.challengeTo = data.challengeTo; for (var i in data.challengesFrom) { if (app.ignore[i]) { delete data.challengesFrom[i]; continue; } this.openPM(' '+i, true); } var self = this; this.$('.pm-window').each(function(i, el) { var $pmWindow = $(el); var userid = $pmWindow.data('userid'); var name = $pmWindow.data('name'); if (data.challengesFrom[userid]) { var format = data.challengesFrom[userid]; if (!$pmWindow.find('.challenge').length) { self.notifyOnce("Challenge from "+name, "Format: "+Tools.escapeFormat(format), 'challenge:'+userid); } var $challenge = self.openChallenge(name, $pmWindow); var buf = '

'+Tools.escapeHTML(name)+' wants to battle!

'; buf += '

'+self.renderFormats(format, true)+'

'; buf += '

'+self.renderTeams(format)+'

'; buf += '

'; $challenge.html(buf); } else { var $challenge = $pmWindow.find('.challenge'); if ($challenge.length) { var $acceptButton = $challenge.find('button[name=acceptChallenge]'); if ($acceptButton.length) { if ($acceptButton[0].disabled) { // You accepted someone's challenge and it started $challenge.remove(); } else { // Someone was challenging you, but cancelled their challenge $challenge.html('

The challenge was cancelled.

'); } } else if ($challenge.find('button[name=cancelChallenge]').length) { // You were challenging someone else, and they either accepted // or rejected it $challenge.remove(); } self.closeNotification('challenge:'+userid); } } }); if (data.challengeTo) { var challenge = data.challengeTo; var name = challenge.to; var userid = toId(name); var $challenge = this.openChallenge(name); var buf = '

Waiting for '+Tools.escapeHTML(name)+'...

'; buf += '

'+this.renderFormats(challenge.format, true)+'

'; buf += '

'; $challenge.html(buf); } }, openChallenge: function(name, $pmWindow) { var userid = toId(name); if (!$pmWindow) $pmWindow = this.openPM(name, true); var $challenge = $pmWindow.find('.challenge'); if (!$challenge.length) { $challenge = $('
').insertAfter($pmWindow.find('h3')); } return $challenge; }, updateFormats: function() { if (!window.BattleFormats) { this.$('.mainmenu button.big').html('Connecting...').addClass('disabled'); return; } if (!this.searching) this.$('.mainmenu button.big').html('Look for a battle').removeClass('disabled'); var self = this; this.$('button[name=format]').each(function(i, el) { var val = el.value; var $teamButton = $(el).closest('form').find('button[name=team]'); $(el).replaceWith(self.renderFormats(val)); $teamButton.replaceWith(self.renderTeams(val)); }); }, updateTeams: function() { if (!window.BattleFormats) return; var teams = Storage.teams; var self = this; this.$('button[name=team]').each(function(i, el) { var val = el.value; if (val === 'random') return; var format = $(el).closest('form').find('button[name=format]').val(); $(el).replaceWith(self.renderTeams(format, val)); }); }, updateRightMenu: function() { if (app.sideRoom) { this.$('.rightmenu').hide(); } else { this.$('.rightmenu').show(); } }, // challenge buttons challenge: function(name, format, team) { var userid = toId(name); var $challenge = this.$('.pm-window-'+userid+' .challenge'); if ($challenge.length && !$challenge.find('button[name=dismissChallenge]').length) { return; } if (format) format = toId(format); var teamIndex; if (Storage.teams && team) { team = toId(team); for (var i = 0; i < Storage.teams.length; i++) { if (team === toId(Storage.teams[i].name || '')) { teamIndex = i; break; } } } $challenge = this.openChallenge(name); var buf = '

Challenge '+Tools.escapeHTML(name)+'?

'; buf += '

'+this.renderFormats(format)+'

'; buf += '

'+this.renderTeams(format, teamIndex)+'

'; buf += '

'; $challenge.html(buf); }, acceptChallenge: function(i, target) { this.requestNotifications(); 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 (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; } target.disabled = true; app.sendTeam(team); app.send('/accept '+userid); }, rejectChallenge: function(i, target) { var userid = $(target).closest('.pm-window').data('userid'); $(target).closest('.challenge').remove(); app.send('/reject '+userid); }, makeChallenge: function(i, target) { this.requestNotifications(); 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 teamIndex = $pmWindow.find('button[name=team]').val(); var team = null; 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; } var buf = '

Challenging '+Tools.escapeHTML(name)+'...

'; buf += '

'+this.renderFormats(format, true)+'

'; buf += '

'; $(target).closest('.challenge').html(buf); app.sendTeam(team); app.send('/challenge '+userid+', '+format); }, cancelChallenge: function(i, target) { var userid = $(target).closest('.pm-window').data('userid'); $(target).closest('.challenge').remove(); app.send('/cancelchallenge '+userid); }, dismissChallenge: function(i, target) { $(target).closest('.challenge').remove(); }, format: function(format, button) { if (window.BattleFormats) app.addPopup(FormatPopup, {format: format, sourceEl: button}); }, team: function(team, button) { var format = $(button).closest('form').find('button[name=format]').val(); app.addPopup(TeamPopup, {team: team, format: format, sourceEl: button}); }, // format/team selection curFormat: '', renderFormats: function(formatid, noChoice) { if (!window.BattleFormats) { return ''; } if (_.isEmpty(BattleFormats)) { return ''; } if (!noChoice) { this.curFormat = formatid; if (!this.curFormat) { if (BattleFormats['randombattle']) { this.curFormat = 'randombattle'; } else for (var i in BattleFormats) { if (!BattleFormats[i].searchShow || !BattleFormats[i].challengeShow) continue; this.curFormat = i; break; } } formatid = this.curFormat; } return ''; }, curTeamFormat: '', curTeamIndex: -1, renderTeams: function(formatid, teamIndex) { if (!Storage.teams || !window.BattleFormats) { return ''; } if (!formatid) formatid = this.curFormat; if (!window.BattleFormats[formatid]) { return ''; } if (window.BattleFormats[formatid].team) { return ''; } var teams = Storage.teams; if (!teams.length) { return ''; } if (teamIndex === undefined) { teamIndex = 0; if (this.curTeamIndex >= 0) { teamIndex = this.curTeamIndex; } if (this.curTeamFormat !== formatid) { for (var i=0; i'+TeamPopup.renderTeam(teamIndex)+''; }, // buttons search: function(i, button) { if (!window.BattleFormats) return; this.requestNotifications(); var $searchForm = $(button).closest('form'); if ($searchForm.find('.cancel').length) { return; } if (!app.user.get('named')) { app.addPopup(LoginPopup); return; } var $formatButton = $searchForm.find('button[name=format]'); var $teamButton = $searchForm.find('button[name=team]'); var format = $formatButton.val(); var teamIndex = $teamButton.val(); var team = null; 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; } $formatButton.addClass('preselected')[0].disabled = true; $teamButton.addClass('preselected')[0].disabled = true; $searchForm.find('button.big').html(' Connecting...').addClass('disabled'); $searchForm.append('

'); app.sendTeam(team); app.send('/search '+format); }, cancelSearch: function() { app.send('/cancelsearch'); this.searching = false; this.updateSearch(); }, credits: function() { app.addPopup(CreditsPopup); }, roomlist: function() { app.addPopup(BattleListPopup); } }); var FormatPopup = this.FormatPopup = this.Popup.extend({ initialize: function(data) { var curFormat = data.format; var selectType = (this.sourceEl.closest('form').data('search') ? 'search' : 'challenge'); var bufs = []; var curBuf = 0; var curSection = ''; for (var i in BattleFormats) { var format = BattleFormats[i]; var selected = false; if (format.effectType !== 'Format') continue; if (selectType && !format[selectType + 'Show']) continue; if (format.section && format.section !== curSection) { curSection = format.section; if (!BattleFormats._supportsColumns) { curBuf = (curSection === 'Doubles' || curSection === 'Past Generations') ? 2 : 1; } else { curBuf = format.column || 1; } if (!bufs[curBuf]) { bufs[curBuf] = ''; } bufs[curBuf] += '
  • '+Tools.escapeHTML(curSection)+'

  • '; } bufs[curBuf] += '
  • '; } var html = ''; for (var i = 1, l = bufs.length; i < l; i++) { html += ''; } html += '
    '; this.$el.html(html); }, selectFormat: function(format) { var $teamButton = this.sourceEl.closest('form').find('button[name=team]'); this.sourceEl.val(format).html(Tools.escapeFormat(format)); $teamButton.replaceWith(app.rooms[''].renderTeams(format)); app.rooms[''].curFormat = format; this.close(); } }); var TeamPopup = this.TeamPopup = this.Popup.extend({ initialize: function(data) { var bufs = ['','','','','']; var curBuf = 0; var teams = Storage.teams; var bufBoundary = 128; if (teams.length > 128 && $(window).width() > 1080) { bufBoundary = Math.ceil(teams.length/5); } else if (teams.length > 81) { bufBoundary = Math.ceil(teams.length/4); } else if (teams.length > 54) { bufBoundary = Math.ceil(teams.length/3); } else if (teams.length > 27) { bufBoundary = Math.ceil(teams.length/2); } var format = BattleFormats[data.format]; if (!teams.length) { bufs[curBuf] = '
  • You have no teams
  • '; } else { var curTeam = +data.team; var teamFormat = (format.teambuilderFormat || (format.isTeambuilderFormat ? data.format : false)); var count = 0; if (teamFormat) { bufs[curBuf] = '
  • '+Tools.escapeFormat(teamFormat)+' teams

  • '; for (var i = 0; i < teams.length; i++) { if ((!teams[i].format && !teamFormat) || teams[i].format === teamFormat) { var selected = (i === curTeam); bufs[curBuf] += '
  • '; count++; if (count % bufBoundary == 0 && curBuf < 4) curBuf++; } } if (!count) bufs[curBuf] += '
  • You have no '+Tools.escapeFormat(teamFormat)+' teams
  • '; bufs[curBuf] += '
  • Other teams

  • '; } else { bufs[curBuf] = '
  • All teams

  • '; } for (var i = 0; i < teams.length; i++) { if (teamFormat && teams[i].format === teamFormat) continue; var selected = (i === curTeam); bufs[curBuf] += '
  • '; count++; if (count % bufBoundary == 0 && curBuf < 4) curBuf++; } } if (format.canUseRandomTeam) { bufs[curBuf] += '
  • '; } if (bufs[1]) { while (!bufs[bufs.length-1]) bufs.pop(); this.$el.html('
    '); } else { this.$el.html(''); } }, selectTeam: function(i) { var formatid = this.sourceEl.closest('form').find('button[name=format]').val(); i = +i; this.sourceEl.val(i).html(TeamPopup.renderTeam(i)); app.rooms[''].curTeamIndex = i; app.rooms[''].curTeamFormat = formatid; this.close(); } }, { renderTeam: function(i) { if (i === 'random') { var buf = 'Random team
    '; for (var i=0; i<6; i++) { buf += ''; } return buf; } var team = Storage.teams[i]; if (!team) return 'Error: Corrupted team'; var buf = ''+Tools.escapeHTML(team.name)+'
    '; for (var i=0; i'; } return buf; } }); var BattleListPopup = this.BattleListPopup = Popup.extend({ type: 'semimodal', initialize: function() { var buf = '

    '; buf += '

    '; buf += '

    Loading...

    '; buf += '
    '; this.$el.html(buf); this.$list = this.$('.list'); app.on('init:formats', this.initialize, this); app.on('response:roomlist', this.update, this); app.send('/cmd roomlist'); this.update(); }, events: { 'click .ilink': 'clickLink', 'change select': 'changeFormat' }, format: '', changeFormat: function(e) { this.format = e.currentTarget.value; this.update(); }, update: function(data) { if (!data && !this.data) { this.$list.html('

    Loading...

    '); return; } this.$('button[name=refresh]')[0].disabled = false; if (!data) { data = this.data; } else { this.data = data; } var buf = ''; var i = 0; for (var id in data.rooms) { var roomData = data.rooms[id]; var matches = ChatRoom.parseBattleID(id); if (!matches) { continue; // bogus room ID could be used to inject JavaScript } var format = (matches[1]||''); if (this.format && format !== this.format) continue; var formatBuf = (format ? '[' + Tools.escapeFormat(format) + ']
    ' : ''); var roomDesc = formatBuf + '' + Tools.escapeHTML(roomData.p1) + ' vs. ' + Tools.escapeHTML(roomData.p2) + ''; if (!roomData.p1) { matches = id.match(/[^0-9]([0-9]*)$/); roomDesc = formatBuf + 'empty room ' + matches[1]; } else if (!roomData.p2) { roomDesc = formatBuf + '' + Tools.escapeHTML(roomData.p1) + ''; } buf += '
    ' + roomDesc + '
    '; i++; } if (!i) { buf = '

    No '+Tools.escapeFormat(this.format)+' battles are going on right now.

    '; } else { buf = '

    '+i+' '+Tools.escapeFormat(this.format)+' '+(i === 1 ? 'battle' : 'battles')+'

    ' + buf; } this.$list.html(buf); }, clickLink: function(e) { if (e.cmdKey || e.metaKey || e.ctrlKey) return; e.preventDefault(); e.stopPropagation(); this.close(); var roomid = $(e.currentTarget).attr('href').substr(app.root.length); app.tryJoinRoom(roomid); }, refresh: function(i, button) { button.disabled = true; app.send('/cmd roomlist'); } }); var CreditsPopup = this.CreditsPopup = Popup.extend({ type: 'semimodal', initialize: function() { var buf = ''; buf += '

    Pokémon Showdown (beta)

    '; if (Config.version) buf += '

    Version '+Config.version+'

    '; buf += '

    Owner

    '; buf += ''; buf += '

    Staff

    '; buf += ''; buf += '

    Retired Staff

    '; buf += ''; buf += '

    Contributors

    '; buf += ''; buf += '

    More

    '; buf += ''; buf += '

    '; this.$el.addClass('credits').html(buf); } }); }).call(this, jQuery);