(function ($) { var HTMLRoom = this.HTMLRoom = this.Room.extend({ type: 'html', title: 'Page', initialize: function () { this.$el.addClass('ps-room-light').addClass('scrollable'); this.$el.html('

Page unavailable

'); }, send: function (data) { // HTML rooms don't actually exist server side, so send globally app.send(data); }, receive: function (data) { this.add(data); }, add: function (log) { if (typeof log === 'string') log = log.split('\n'); for (var i = 0; i < log.length; i++) { this.addRow(log[i]); } }, join: function () { app.send('/join ' + this.id); }, leave: function () { app.send('/leave ' + this.id); }, login: function () { app.addPopup(LoginPopup); }, addRow: function (line) { if (!line || typeof line !== 'string') return; if (line.charAt(0) !== '|') line = '||' + line; var pipeIndex = line.indexOf('|', 1); var row; if (pipeIndex >= 0) { row = [line.slice(1, pipeIndex), line.slice(pipeIndex + 1)]; } else { row = [line.slice(1), '']; } switch (row[0]) { case 'init': // ignore (handled elsewhere) break; case 'title': this.title = row[1]; app.roomTitleChanged(this); app.topbar.updateTabbar(); break; case 'pagehtml': this.$el.html(BattleLog.sanitizeHTML(row[1])); this.subtleNotifyOnce(); break; case 'selectorhtml': var pipeIndex2 = row[1].indexOf('|'); if (pipeIndex2 < 0) return; this.$(row[1].slice(0, pipeIndex2)).html(BattleLog.sanitizeHTML(row[1].slice(pipeIndex2 + 1))); this.subtleNotifyOnce(); break; case 'notify': app.playNotificationSound(); this.notifyOnce(row[1], row.slice(2).join('|'), 'highlight'); break; case 'tempnotify': var notifyOnce = row[4] !== '!'; if (!this.notifications) app.playNotificationSound(); this.notify(row[2], row[3], row[1], notifyOnce); break; case 'tempnotifyoff': this.closeNotification(row[1]); break; } } }); this.LadderRoom = HTMLRoom.extend({ events: { 'submit .search': 'submitSearch' }, type: 'ladder', title: 'Ladder', initialize: function () { this.$el.addClass('ps-room-light').addClass('scrollable'); app.on('init:formats', this.update, this); this.update(); app.on('response:laddertop', function (data) { var buf = '

'; if (!data) { this.$el.html(buf + '

error

'); return; } if (this.curFormat !== data[0]) return; buf += BattleLog.sanitizeHTML(data[1]) + ''; this.$el.html(buf); }, this); }, curFormat: '', curSearchVal: '', join: function () {}, leave: function () {}, update: function () { if (!this.curFormat) { var buf = '

See a user\'s ranking with User lookup

' + //'

I\'m really really sorry, but as a warning: we\'re going to reset the ladder again soon to fix some more ladder bugs.

' + '

(btw if you couldn\'t tell the ladder screens aren\'t done yet; they\'ll look nicer than this once I\'m done.)

' + '

' + BattleLog.escapeHTML(curSection) + '

'; this.$el.html(buf); } else if (this.curFormat === 'help') { this.showHelp(); } else { var format = this.curFormat; var self = this; var prefix = this.curSearchVal && toID(this.curSearchVal); this.$el.html('

Loading...

'); if (app.localLadder) { app.send('/cmd laddertop ' + format + (prefix ? ' ,' + prefix : '')); } else { $.get('/ladder.php', { format: format, server: Config.server.id.split(':')[0], output: 'html', prefix: prefix }, function (data) { if (self.curFormat !== format) return; var buf = '

'; buf += '

'; buf += '

' + BattleLog.escapeFormat(format) + ' Top ' + BattleLog.escapeHTML(self.curSearchVal ? "- '" + self.curSearchVal + "'" : '500') + '

'; buf += data + '
'; self.$el.html(buf); }, 'html'); } } }, submitSearch: function (e) { e.preventDefault(); this.curSearchVal = this.$('input[name=searchval]').val(); this.update(); }, showHelp: function () { var buf = '

'; buf += '

How the ladder works

'; buf += '

Our ladder displays three ratings: Elo, GXE, and Glicko-1.

'; buf += '

Elo is the main ladder rating. It\'s a pretty normal ladder rating: goes up when you win and down when you lose.

'; buf += '

GXE (Glicko X-Act Estimate) is an estimate of your win chance against an average ladder player.

'; buf += '

Glicko-1 is a different rating system. It has rating and deviation values.

'; buf += '

Note that win/loss should not be used to estimate skill, since who you play against is much more important than how many times you win or lose. Our other stats like Elo and GXE are much better for estimating skill.

'; buf += '
'; this.$el.html(buf); }, selectFormat: function (format) { this.curFormat = format; this.update(); }, refresh: function () { this.$('button[name=refresh]').addClass('disabled').prop('disabled', true); this.update(); } }); }).call(this, jQuery);