(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]);
}
},
addRow: function (line) {
var name, name2, room, action, silent, oldid;
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(Tools.sanitizeHTML(row[1]));
this.subtleNotifyOnce();
break;
case 'selectorhtml':
var pipeIndex2 = row[1].indexOf('|');
if (pipeIndex2 < 0) return;
this.$(row[1].slice(0, pipeIndex2)).html(Tools.sanitizeHTML(row[1].slice(pipeIndex2 + 1)));
this.subtleNotifyOnce();
break;
}
}
});
var LadderRoom = this.LadderRoom = HTMLRoom.extend({
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 += Tools.sanitizeHTML(data[1]) + '';
this.$el.html(buf);
}, this);
},
curFormat: '',
update: function () {
if (!this.curFormat) {
var buf = '
See a user\'s ranking with /ranking username
' +
//'
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.)
' +
'
';
if (!window.BattleFormats) {
this.$el.html('
Loading...
');
return;
}
var curSection = '';
for (var i in BattleFormats) {
var format = BattleFormats[i];
if (format.section && format.section !== curSection) {
curSection = format.section;
buf += '
';
this.$el.html(buf);
} else if (this.curFormat === 'help') {
this.showHelp();
} else {
var format = this.curFormat;
var self = this;
this.$el.html('
Loading...
');
if (app.localLadder) {
app.send('/cmd laddertop ' + format);
} else {
$.get('/ladder.php', {
format: format,
server: Config.server.id.split(':')[0],
output: 'html'
}, function (data) {
if (self.curFormat !== format) return;
var buf = '
';
buf += '
' + Tools.escapeFormat(format) + ' Top 500
';
buf += data + '
';
self.$el.html(buf);
}, 'html');
}
}
},
showHelp: function () {
var buf = '
';
buf += '
How the ladder works
';
buf += '
Our ladder displays four ratings: Elo, GXE, Glicko-1, and COIL.
';
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 += '
COIL (Converging Order Invariant Ladder) is mainly used for suspect tests. It goes up as you play games, but not too many games.
';
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.