mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-05-09 04:23:01 -05:00
Miscellaneous style changes
This commit is contained in:
parent
7e9bdaf6fd
commit
4d242777c1
238
js/battle.js
238
js/battle.js
|
|
@ -30,7 +30,7 @@ $.extend($.easing, {
|
|||
});
|
||||
|
||||
var BattleSoundLibrary = (function () {
|
||||
function BattleSoundLibrary () {
|
||||
function BattleSoundLibrary() {
|
||||
// effects
|
||||
this.effectCache = {};
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ var BattleSoundLibrary = (function () {
|
|||
this.bgm.play();
|
||||
}
|
||||
}
|
||||
} catch(e) {}
|
||||
} catch (e) {}
|
||||
};
|
||||
BattleSoundLibrary.prototype.pauseBgm = function () {
|
||||
if (this.bgm) {
|
||||
|
|
@ -156,7 +156,7 @@ var BattleSoundLibrary = (function () {
|
|||
var BattleSound = new BattleSoundLibrary();
|
||||
|
||||
var Pokemon = (function () {
|
||||
function Pokemon (species, side) {
|
||||
function Pokemon(species, side) {
|
||||
this.side = side;
|
||||
|
||||
this.atk = 0;
|
||||
|
|
@ -212,27 +212,27 @@ var Pokemon = (function () {
|
|||
return '';
|
||||
};
|
||||
Pokemon.prototype.getPixelRange = function (pixels, color) {
|
||||
var epsilon = 0.5/714;
|
||||
var epsilon = 0.5 / 714;
|
||||
|
||||
if (pixels === 0) return [0, 0];
|
||||
if (pixels === 1) return [0 + epsilon, 2/48 - epsilon];
|
||||
if (pixels === 1) return [0 + epsilon, 2 / 48 - epsilon];
|
||||
if (pixels === 9) {
|
||||
if (color === 'y') { // ratio is > 0.2
|
||||
return [0.2 + epsilon, 10/48 - epsilon];
|
||||
return [0.2 + epsilon, 10 / 48 - epsilon];
|
||||
} else { // ratio is <= 0.2
|
||||
return [9/48, 0.2];
|
||||
return [9 / 48, 0.2];
|
||||
}
|
||||
}
|
||||
if (pixels === 24) {
|
||||
if (color === 'g') { // ratio is > 0.5
|
||||
return [0.5 + epsilon, 25/48 - epsilon];
|
||||
return [0.5 + epsilon, 25 / 48 - epsilon];
|
||||
} else { // ratio is exactly 0.5
|
||||
return [0.5, 0.5];
|
||||
}
|
||||
}
|
||||
if (pixels === 48) return [1, 1];
|
||||
if (pixels === 48) return [1, 1];
|
||||
|
||||
return [pixels/48, (pixels + 1)/48 - epsilon];
|
||||
return [pixels / 48, (pixels + 1) / 48 - epsilon];
|
||||
};
|
||||
Pokemon.prototype.getFormattedRange = function (range, precision, separator) {
|
||||
if (range[0] === range[1]) {
|
||||
|
|
@ -302,10 +302,10 @@ var Pokemon = (function () {
|
|||
var pixels = Math.ceil(damage * 48 / 100);
|
||||
return [pixels, 48, percent];
|
||||
}
|
||||
if (hpstring.substr(hpstring.length-1) !== ')') {
|
||||
if (hpstring.substr(hpstring.length - 1) !== ')') {
|
||||
return false;
|
||||
}
|
||||
hpstring = hpstring.substr(parenIndex+1, hpstring.length-parenIndex-2);
|
||||
hpstring = hpstring.substr(parenIndex + 1, hpstring.length - parenIndex - 2);
|
||||
}
|
||||
|
||||
var hp = hpstring.split(' ');
|
||||
|
|
@ -370,8 +370,8 @@ var Pokemon = (function () {
|
|||
return (details === this.details.replace(/-[A-Za-z0-9*]+(, |$)/, '$1'));
|
||||
};
|
||||
Pokemon.prototype.getIdent = function () {
|
||||
var slots = ['a','b','c','d','e','f'];
|
||||
return this.ident.substr(0,2) + slots[this.slot] + this.ident.substr(2);
|
||||
var slots = ['a', 'b', 'c', 'd', 'e', 'f'];
|
||||
return this.ident.substr(0, 2) + slots[this.slot] + this.ident.substr(2);
|
||||
};
|
||||
Pokemon.prototype.removeVolatile = function (volatile) {
|
||||
if (!this.hasVolatile(volatile)) return;
|
||||
|
|
@ -711,7 +711,7 @@ var Pokemon = (function () {
|
|||
})();
|
||||
|
||||
var Sprite = (function () {
|
||||
function Sprite (spriteData, x, y, z, battle, siden) {
|
||||
function Sprite(spriteData, x, y, z, battle, siden) {
|
||||
this.battle = battle;
|
||||
this.siden = siden;
|
||||
this.forme = '';
|
||||
|
|
@ -776,7 +776,10 @@ var Sprite = (function () {
|
|||
Sprite.prototype.animTransform = function (species) {
|
||||
if (!this.oldsp) this.oldsp = this.sp;
|
||||
if (species.volatiles && species.volatiles.formechange) species = species.volatiles.formechange[2];
|
||||
sp = Tools.getSpriteData(species, this.isBackSprite ? 0 : 1, {afd: this.battle.tier === "[Seasonal] Fools Festival", gen: this.battle.gen});
|
||||
sp = Tools.getSpriteData(species, this.isBackSprite ? 0 : 1, {
|
||||
afd: this.battle.tier === "[Seasonal] Fools Festival",
|
||||
gen: this.battle.gen
|
||||
});
|
||||
this.sp = sp;
|
||||
var self = this;
|
||||
var battle = this.battle;
|
||||
|
|
@ -1155,7 +1158,7 @@ var Sprite = (function () {
|
|||
})();
|
||||
|
||||
var Side = (function () {
|
||||
function Side (battle, n) {
|
||||
function Side(battle, n) {
|
||||
this.battle = battle;
|
||||
this.name = '';
|
||||
this.id = '';
|
||||
|
|
@ -1220,7 +1223,10 @@ var Side = (function () {
|
|||
for (var i = 0; i < this.pokemon.length; i++) {
|
||||
var poke = this.pokemon[i];
|
||||
poke.sprite.destroy();
|
||||
poke.sprite = new Sprite(Tools.getSpriteData(poke, this.n, {afd: this.battle.tier === "[Seasonal] Fools Festival", gen: this.battle.gen}), this.x, this.y, this.z, this.battle, this.n);
|
||||
poke.sprite = new Sprite(Tools.getSpriteData(poke, this.n, {
|
||||
afd: this.battle.tier === "[Seasonal] Fools Festival",
|
||||
gen: this.battle.gen
|
||||
}), this.x, this.y, this.z, this.battle, this.n);
|
||||
}
|
||||
};
|
||||
Side.prototype.setSprite = function (spriteid) {
|
||||
|
|
@ -1228,7 +1234,7 @@ var Side = (function () {
|
|||
this.updateSidebar();
|
||||
};
|
||||
Side.prototype.setName = function (name, spriteid) {
|
||||
if (name) this.name = (name||'');
|
||||
if (name) this.name = (name || '');
|
||||
this.id = toId(this.name);
|
||||
if (spriteid) {
|
||||
this.spriteid = spriteid;
|
||||
|
|
@ -1271,15 +1277,15 @@ var Side = (function () {
|
|||
pokemonhtml = '<div class="teamicons">' + pokemonhtml + '</div>';
|
||||
if (this.n === 1) {
|
||||
if (this.initialized) {
|
||||
this.battle.rightbarElem.html('<div class="trainer"><strong>' + Tools.escapeHTML(this.name) + '</strong><div class="trainersprite" style="background-image:url(' + Tools.resolveAvatar(this.spriteid) + ')"></div>' + pokemonhtml + '</div>').find('.trainer').css('opacity',1);
|
||||
this.battle.rightbarElem.html('<div class="trainer"><strong>' + Tools.escapeHTML(this.name) + '</strong><div class="trainersprite" style="background-image:url(' + Tools.resolveAvatar(this.spriteid) + ')"></div>' + pokemonhtml + '</div>').find('.trainer').css('opacity', 1);
|
||||
} else {
|
||||
this.battle.rightbarElem.find('.trainer').css('opacity',0.4);
|
||||
this.battle.rightbarElem.find('.trainer').css('opacity', 0.4);
|
||||
}
|
||||
} else {
|
||||
if (this.initialized) {
|
||||
this.battle.leftbarElem.html('<div class="trainer"><strong>' + Tools.escapeHTML(this.name) + '</strong><div class="trainersprite" style="background-image:url(' + Tools.resolveAvatar(this.spriteid) + ')"></div>' + pokemonhtml + '</div>').find('.trainer').css('opacity',1);
|
||||
this.battle.leftbarElem.html('<div class="trainer"><strong>' + Tools.escapeHTML(this.name) + '</strong><div class="trainersprite" style="background-image:url(' + Tools.resolveAvatar(this.spriteid) + ')"></div>' + pokemonhtml + '</div>').find('.trainer').css('opacity', 1);
|
||||
} else {
|
||||
this.battle.leftbarElem.find('.trainer').css('opacity',0.4);
|
||||
this.battle.leftbarElem.find('.trainer').css('opacity', 0.4);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1509,7 +1515,10 @@ var Side = (function () {
|
|||
if (!poke.ability && poke.baseAbility) poke.ability = poke.baseAbility;
|
||||
poke.id = id;
|
||||
poke.reset();
|
||||
poke.sprite = new Sprite(Tools.getSpriteData(poke, this.n, {afd: this.battle.tier === "[Seasonal] Fools Festival", gen: this.battle.gen}), this.x, this.y, this.z, this.battle, this.n);
|
||||
poke.sprite = new Sprite(Tools.getSpriteData(poke, this.n, {
|
||||
afd: this.battle.tier === "[Seasonal] Fools Festival",
|
||||
gen: this.battle.gen
|
||||
}), this.x, this.y, this.z, this.battle, this.n);
|
||||
|
||||
if (typeof replaceSlot !== 'undefined') {
|
||||
this.pokemon[replaceSlot] = poke;
|
||||
|
|
@ -1522,19 +1531,19 @@ var Side = (function () {
|
|||
|
||||
// the other possibility is Illusion, which we'll assume
|
||||
var existingTable = {};
|
||||
for (var i=0; i<6; i++) {
|
||||
for (var i = 0; i < 6; i++) {
|
||||
var poke1 = this.pokemon[i];
|
||||
if (existingTable[poke1.searchid]) {
|
||||
var j = existingTable[poke1.searchid];
|
||||
var poke2 = this.pokemon[j];
|
||||
if (this.active.indexOf(poke1) >= 0) {
|
||||
this.pokemon.splice(j,1);
|
||||
this.pokemon.splice(j, 1);
|
||||
} else if (this.active.indexOf(poke2) >= 0) {
|
||||
this.pokemon.splice(i,1);
|
||||
this.pokemon.splice(i, 1);
|
||||
} else if (poke1.fainted && !poke2.fainted) {
|
||||
this.pokemon.splice(j,1);
|
||||
this.pokemon.splice(j, 1);
|
||||
} else {
|
||||
this.pokemon.splice(i,1);
|
||||
this.pokemon.splice(i, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1947,7 +1956,7 @@ var Side = (function () {
|
|||
var $prevhp = pokemon.statbarElem.find('.prevhp');
|
||||
$prevhp.css('width', pokemon.hpWidth(150) + 1);
|
||||
if (hpcolor === 'g') $prevhp.removeClass('prevhp-yellow prevhp-red');
|
||||
else if (hpcolor ==='y' ) $prevhp.removeClass('prevhp-red').addClass('prevhp-yellow');
|
||||
else if (hpcolor === 'y') $prevhp.removeClass('prevhp-red').addClass('prevhp-yellow');
|
||||
else $prevhp.addClass('prevhp-red');
|
||||
}
|
||||
var status = '';
|
||||
|
|
@ -2068,7 +2077,7 @@ var Side = (function () {
|
|||
})();
|
||||
|
||||
var Battle = (function () {
|
||||
function Battle (frame, logFrame, noPreload) {
|
||||
function Battle(frame, logFrame, noPreload) {
|
||||
frame.addClass('battle');
|
||||
|
||||
this.turn = 0;
|
||||
|
|
@ -2200,7 +2209,7 @@ var Battle = (function () {
|
|||
Battle.prototype.updateGen = function () {
|
||||
if (this.gen < 3) this.backdropImage = 'bg-gen1.png';
|
||||
else if (this.gen < 6) this.backdropImage = 'bg.jpg';
|
||||
if (this.bgElem) this.bgElem.css('background-image','url(' + Tools.resourcePrefix + 'fx/' + this.backdropImage + ')');
|
||||
if (this.bgElem) this.bgElem.css('background-image', 'url(' + Tools.resourcePrefix + 'fx/' + this.backdropImage + ')');
|
||||
};
|
||||
Battle.prototype.reset = function (dontResetSound) {
|
||||
// battle state
|
||||
|
|
@ -2351,7 +2360,7 @@ var Battle = (function () {
|
|||
left += (410 - 190) * (loc.z / 200);
|
||||
top += (135 - 245) * (loc.z / 200);
|
||||
left += Math.floor(loc.x * scale);
|
||||
top -= Math.floor(loc.y * scale /* - loc.x * scale / 4 */ );
|
||||
top -= Math.floor(loc.y * scale /* - loc.x * scale / 4 */);
|
||||
width = Math.floor(obj.w * scale * loc.xscale);
|
||||
height = Math.floor(obj.h * scale * loc.yscale);
|
||||
left -= Math.floor(width / 2);
|
||||
|
|
@ -2581,7 +2590,7 @@ var Battle = (function () {
|
|||
};
|
||||
Battle.prototype.setTurn = function (turnnum) {
|
||||
turnnum = parseInt(turnnum);
|
||||
if (turnnum == this.turn+1) {
|
||||
if (turnnum == this.turn + 1) {
|
||||
this.endLastTurnPending = true;
|
||||
}
|
||||
this.turn = turnnum;
|
||||
|
|
@ -2703,7 +2712,7 @@ var Battle = (function () {
|
|||
this.log('<div><small>' + newWeather.upkeepMessage + '</small></div>');
|
||||
this.weatherTimeLeft = 0;
|
||||
this.weatherMinTimeLeft = 0;
|
||||
} else if (weather === 'deltastream' || weather === 'desolateland' || weather === 'primordialsea'){
|
||||
} else if (weather === 'deltastream' || weather === 'desolateland' || weather === 'primordialsea') {
|
||||
this.message('<small>' + newWeather.startMessage + '</small>');
|
||||
this.weatherTimeLeft = 0;
|
||||
this.weatherMinTimeLeft = 0;
|
||||
|
|
@ -2805,7 +2814,7 @@ var Battle = (function () {
|
|||
}
|
||||
if (weather) {
|
||||
if (this.fastForward) {
|
||||
this.weatherElem.css({opacity:.4});
|
||||
this.weatherElem.css({opacity: .4});
|
||||
return;
|
||||
}
|
||||
this.weatherElem.animate({
|
||||
|
|
@ -2928,7 +2937,7 @@ var Battle = (function () {
|
|||
if (fromeffect.id === 'magiccoat') {
|
||||
pokemon.addTurnstatus('magiccoat');
|
||||
}
|
||||
this.message(target.getName() + "'s " + move.name + " was bounced back by " + fromeffect.name + "!");
|
||||
this.message(target.getName() + "'s " + move.name + " was bounced back by " + fromeffect.name + "!");
|
||||
break;
|
||||
case 'metronome':
|
||||
this.message('Waggling a finger let it use <strong>' + move.name + '</strong>!');
|
||||
|
|
@ -2975,9 +2984,9 @@ var Battle = (function () {
|
|||
var buttons = ["A", "B", "START", "SELECT", "UP", "DOWN", "LEFT", "RIGHT", "DEMOCRACY", "ANARCHY"];
|
||||
var people = ["Zarel", "The Immortal", "Diatom", "Nani Man", "shaymin", "apt-get", "sirDonovan", "Arcticblast", "Goddess Briyella"];
|
||||
var button;
|
||||
for (var i=0; i<10; i++) {
|
||||
var name = people[Math.floor(Math.random()*people.length)];
|
||||
if (!button) button = buttons[Math.floor(Math.random()*buttons.length)];
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var name = people[Math.floor(Math.random() * people.length)];
|
||||
if (!button) button = buttons[Math.floor(Math.random() * buttons.length)];
|
||||
this.log('<div class="chat"><strong style="' + hashColor(toUserid(name)) + '" class="username" data-name="' + Tools.escapeHTML(name) + '">' + Tools.escapeHTML(name) + ':</strong> <em>' + button + '</em></div>');
|
||||
button = (name === 'Diatom' ? "thanks diatom" : null);
|
||||
}
|
||||
|
|
@ -3084,7 +3093,7 @@ var Battle = (function () {
|
|||
this.message('<small>' + pokemon.getName() + (move.name ? ' can\'t use ' + move.name + '' : ' can\'t move') + '!</small>');
|
||||
break;
|
||||
}
|
||||
pokemon.sprite.anim({time:1});
|
||||
pokemon.sprite.anim({time: 1});
|
||||
};
|
||||
Battle.prototype.prepareMove = function (pokemon, move, target) {
|
||||
if (!move.prepareAnim) return;
|
||||
|
|
@ -3287,13 +3296,12 @@ var Battle = (function () {
|
|||
case '-sethp':
|
||||
var effect = Tools.getEffect(kwargs.from);
|
||||
var poke, ofpoke;
|
||||
for (var k=0; k<2; k++)
|
||||
{
|
||||
var cpoke = this.getPokemon(args[1+2*k]);
|
||||
for (var k = 0; k < 2; k++) {
|
||||
var cpoke = this.getPokemon(args[1 + 2 * k]);
|
||||
if (cpoke) {
|
||||
var oldhp = cpoke.hp;
|
||||
cpoke.healthParse(args[2+2*k]);
|
||||
var diff = parseFloat(args[2+2*k]);
|
||||
cpoke.healthParse(args[2 + 2 * k]);
|
||||
var diff = parseFloat(args[2 + 2 * k]);
|
||||
if (isNaN(diff)) {
|
||||
diff = cpoke.hp - oldhp;
|
||||
}
|
||||
|
|
@ -3303,8 +3311,8 @@ var Battle = (function () {
|
|||
this.damageAnim(cpoke, -diff, animDelay);
|
||||
}
|
||||
}
|
||||
if (k==0) poke = cpoke;
|
||||
if (k==1) ofpoke = cpoke;
|
||||
if (k == 0) poke = cpoke;
|
||||
if (k == 1) ofpoke = cpoke;
|
||||
}
|
||||
switch (effect.id) {
|
||||
case 'painsplit':
|
||||
|
|
@ -3339,7 +3347,7 @@ var Battle = (function () {
|
|||
if (effect.effectType === 'Item') {
|
||||
actions += "The " + effect.name + amountString + " raised " + poke.getLowerName() + "'s " + BattleStats[stat] + "!";
|
||||
} else {
|
||||
actions += "" + poke.getName() + "'s " + effect.name +amountString + " raised its " + BattleStats[stat] + "!";
|
||||
actions += "" + poke.getName() + "'s " + effect.name + amountString + " raised its " + BattleStats[stat] + "!";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -3387,7 +3395,7 @@ var Battle = (function () {
|
|||
var effect = Tools.getEffect(kwargs.from);
|
||||
var ofpoke = this.getPokemon(kwargs.of);
|
||||
poke.boosts[stat] = amount;
|
||||
this.resultAnim(poke, poke.getBoost(stat), (amount>0?'good':'bad'), animDelay);
|
||||
this.resultAnim(poke, poke.getBoost(stat), (amount > 0 ? 'good' : 'bad'), animDelay);
|
||||
|
||||
if (kwargs.silent) {
|
||||
// do nothing
|
||||
|
|
@ -3405,10 +3413,9 @@ var Battle = (function () {
|
|||
case '-swapboost':
|
||||
var poke = this.getPokemon(args[1]);
|
||||
var poke2 = this.getPokemon(args[2]);
|
||||
var stats = args[3]?args[3].split(', '):['atk','def','spa','spd','spe','accuracy','evasion'];
|
||||
var stats = args[3] ? args[3].split(', ') : ['atk', 'def', 'spa', 'spd', 'spe', 'accuracy', 'evasion'];
|
||||
var effect = Tools.getEffect(kwargs.from);
|
||||
for (var i=0; i<stats.length; i++)
|
||||
{
|
||||
for (var i = 0; i < stats.length; i++) {
|
||||
var tmp = poke.boosts[stats[i]];
|
||||
poke.boosts[stats[i]] = poke2.boosts[stats[i]];
|
||||
if (!poke.boosts[stats[i]]) delete poke.boosts[stats[i]];
|
||||
|
|
@ -3448,10 +3455,9 @@ var Battle = (function () {
|
|||
case '-copyboost':
|
||||
var poke = this.getPokemon(args[1]);
|
||||
var frompoke = this.getPokemon(args[2]);
|
||||
var stats = args[3]?args[3].split(', '):['atk','def','spa','spd','spe','accuracy','evasion'];
|
||||
var stats = args[3] ? args[3].split(', ') : ['atk', 'def', 'spa', 'spd', 'spe', 'accuracy', 'evasion'];
|
||||
var effect = Tools.getEffect(kwargs.from);
|
||||
for (var i=0; i<stats.length; i++)
|
||||
{
|
||||
for (var i = 0; i < stats.length; i++) {
|
||||
poke.boosts[stats[i]] = frompoke.boosts[stats[i]];
|
||||
if (!poke.boosts[stats[i]]) delete poke.boosts[stats[i]];
|
||||
}
|
||||
|
|
@ -3489,7 +3495,7 @@ var Battle = (function () {
|
|||
}
|
||||
break;
|
||||
case '-clearallboost':
|
||||
for (var slot=0; slot<this.mySide.active.length; slot++) {
|
||||
for (var slot = 0; slot < this.mySide.active.length; slot++) {
|
||||
if (this.mySide.active[slot]) {
|
||||
this.mySide.active[slot].boosts = {};
|
||||
this.resultAnim(this.mySide.active[slot], 'Stats reset', 'neutral', animDelay);
|
||||
|
|
@ -3509,21 +3515,21 @@ var Battle = (function () {
|
|||
|
||||
case '-crit':
|
||||
var poke = this.getPokemon(args[1]);
|
||||
for (var j=1; !poke && j<10; j++) poke = this.getPokemon(minors[i+j][0][1]);
|
||||
for (var j = 1; !poke && j < 10; j++) poke = this.getPokemon(minors[i + j][0][1]);
|
||||
if (poke) this.resultAnim(poke, 'Critical hit', 'bad', animDelay);
|
||||
actions += "A critical hit! ";
|
||||
break;
|
||||
|
||||
case '-supereffective':
|
||||
var poke = this.getPokemon(args[1]);
|
||||
for (var j=1; !poke && j<10; j++) poke = this.getPokemon(minors[i+j][0][1]);
|
||||
for (var j = 1; !poke && j < 10; j++) poke = this.getPokemon(minors[i + j][0][1]);
|
||||
if (poke) this.resultAnim(poke, 'Super-effective', 'bad', animDelay);
|
||||
actions += "It's super effective! ";
|
||||
break;
|
||||
|
||||
case '-resisted':
|
||||
var poke = this.getPokemon(args[1]);
|
||||
for (var j=1; !poke && j<10; j++) poke = this.getPokemon(minors[i+j][0][1]);
|
||||
for (var j = 1; !poke && j < 10; j++) poke = this.getPokemon(minors[i + j][0][1]);
|
||||
if (poke) this.resultAnim(poke, 'Resisted', 'neutral', animDelay);
|
||||
actions += "It's not very effective... ";
|
||||
break;
|
||||
|
|
@ -4358,7 +4364,7 @@ var Battle = (function () {
|
|||
break;
|
||||
case 'skydrop':
|
||||
if (kwargs.interrupt) {
|
||||
poke.sprite.anim({time:100});
|
||||
poke.sprite.anim({time: 100});
|
||||
}
|
||||
actions += "" + poke.getName() + " was freed from the Sky Drop!";
|
||||
break;
|
||||
|
|
@ -4624,7 +4630,7 @@ var Battle = (function () {
|
|||
actions += "" + poke.getName() + " couldn't stay airborne because of gravity!";
|
||||
poke.removeVolatile('magnetrise');
|
||||
poke.removeVolatile('telekinesis');
|
||||
poke.sprite.anim({time:100});
|
||||
poke.sprite.anim({time: 100});
|
||||
break;
|
||||
case 'magnitude':
|
||||
actions += "Magnitude " + Tools.escapeHTML(args[3]) + "!";
|
||||
|
|
@ -5047,25 +5053,21 @@ var Battle = (function () {
|
|||
output.level = 100;
|
||||
output.shiny = false;
|
||||
output.gender = '';
|
||||
output.ident = (name?pokemonid:'');
|
||||
output.searchid = (name?(pokemonid + '|' + details):'');
|
||||
output.ident = (name ? pokemonid : '');
|
||||
output.searchid = (name ? (pokemonid + '|' + details) : '');
|
||||
var splitDetails = details.split(', ');
|
||||
if (splitDetails[splitDetails.length-1] === 'shiny')
|
||||
{
|
||||
if (splitDetails[splitDetails.length - 1] === 'shiny') {
|
||||
output.shiny = true;
|
||||
splitDetails.pop();
|
||||
}
|
||||
if (splitDetails[splitDetails.length-1] === 'M' || splitDetails[splitDetails.length-1] === 'F')
|
||||
{
|
||||
output.gender = splitDetails[splitDetails.length-1];
|
||||
if (splitDetails[splitDetails.length - 1] === 'M' || splitDetails[splitDetails.length - 1] === 'F') {
|
||||
output.gender = splitDetails[splitDetails.length - 1];
|
||||
splitDetails.pop();
|
||||
}
|
||||
if (splitDetails[1])
|
||||
{
|
||||
if (splitDetails[1]) {
|
||||
output.level = parseInt(splitDetails[1].substr(1)) || 100;
|
||||
}
|
||||
if (splitDetails[0])
|
||||
{
|
||||
if (splitDetails[0]) {
|
||||
output.species = splitDetails[0];
|
||||
}
|
||||
return output;
|
||||
|
|
@ -5079,7 +5081,7 @@ var Battle = (function () {
|
|||
//var position = 0; // todo: use for position in doubles/triples
|
||||
var getfoe = false;
|
||||
var slot; // if there is an explicit slot for this pokemon
|
||||
var slotChart = {a:0,b:1,c:2,d:3,e:4,f:5};
|
||||
var slotChart = {a: 0, b: 1, c: 2, d: 3, e: 4, f: 5};
|
||||
if (typeof pokemonid === 'undefined' || name === '??') return null;
|
||||
if (name.substr(0, 5) === 'foe: ') {
|
||||
name = name.substr(5);
|
||||
|
|
@ -5109,12 +5111,12 @@ var Battle = (function () {
|
|||
siden = this.p1.n;
|
||||
name = name.substr(4);
|
||||
} else if (name.substr(0, 2) === 'p2' && name.substr(3, 2) === ': ') {
|
||||
slot = slotChart[name.substr(2,1)];
|
||||
slot = slotChart[name.substr(2, 1)];
|
||||
siden = this.p2.n;
|
||||
name = name.substr(5);
|
||||
pokemonid = 'p2: ' + name;
|
||||
} else if (name.substr(0, 2) === 'p1' && name.substr(3, 2) === ': ') {
|
||||
slot = slotChart[name.substr(2,1)];
|
||||
slot = slotChart[name.substr(2, 1)];
|
||||
siden = this.p1.n;
|
||||
name = name.substr(5);
|
||||
pokemonid = 'p1: ' + name;
|
||||
|
|
@ -5148,8 +5150,7 @@ var Battle = (function () {
|
|||
if (pokemon == this.p1.lastPokemon && !this.p1.active[slot]) continue;
|
||||
}
|
||||
if (pokemon.searchid === searchid || (!pokemon.searchid && pokemon.checkDetails(details)) || (!searchid && pokemon.ident === pokemonid)) {
|
||||
if (!pokemon.searchid)
|
||||
{
|
||||
if (!pokemon.searchid) {
|
||||
pokemon.name = name;
|
||||
pokemon.searchid = searchid;
|
||||
pokemon.ident = pokemonid;
|
||||
|
|
@ -5175,8 +5176,7 @@ var Battle = (function () {
|
|||
if (pokemon == this.p2.lastPokemon && !this.p2.active[slot]) continue;
|
||||
}
|
||||
if (pokemon.searchid === searchid || (!pokemon.searchid && pokemon.checkDetails(details)) || (!searchid && pokemon.ident === pokemonid)) {
|
||||
if (!pokemon.searchid)
|
||||
{
|
||||
if (!pokemon.searchid) {
|
||||
pokemon.name = name;
|
||||
pokemon.searchid = searchid;
|
||||
pokemon.ident = pokemonid;
|
||||
|
|
@ -5195,12 +5195,12 @@ var Battle = (function () {
|
|||
if (siden < 0) siden = this.p1.n;
|
||||
if (details) {
|
||||
var splitDetails = details.split(', ');
|
||||
if (splitDetails[splitDetails.length-1] === 'shiny') {
|
||||
if (splitDetails[splitDetails.length - 1] === 'shiny') {
|
||||
shiny = true;
|
||||
splitDetails.pop();
|
||||
}
|
||||
if (splitDetails[splitDetails.length-1] === 'M' || splitDetails[splitDetails.length-1] === 'F') {
|
||||
gender = splitDetails[splitDetails.length-1];
|
||||
if (splitDetails[splitDetails.length - 1] === 'M' || splitDetails[splitDetails.length - 1] === 'F') {
|
||||
gender = splitDetails[splitDetails.length - 1];
|
||||
splitDetails.pop();
|
||||
}
|
||||
if (splitDetails[1]) {
|
||||
|
|
@ -5214,8 +5214,8 @@ var Battle = (function () {
|
|||
species: species,
|
||||
details: details,
|
||||
name: name,
|
||||
ident: (name?pokemonid:''),
|
||||
searchid: (name?(pokemonid + '|' + details):''),
|
||||
ident: (name ? pokemonid : ''),
|
||||
searchid: (name ? (pokemonid + '|' + details) : ''),
|
||||
level: level,
|
||||
gender: gender,
|
||||
shiny: shiny,
|
||||
|
|
@ -5224,8 +5224,8 @@ var Battle = (function () {
|
|||
return pokemon;
|
||||
};
|
||||
Battle.prototype.getSide = function (sidename) {
|
||||
if (sidename === 'p1' || sidename.substr(0,3)==='p1:') return this.p1;
|
||||
if (sidename === 'p2' || sidename.substr(0,3)==='p2:') return this.p2;
|
||||
if (sidename === 'p1' || sidename.substr(0, 3) === 'p1:') return this.p1;
|
||||
if (sidename === 'p2' || sidename.substr(0, 3) === 'p2:') return this.p2;
|
||||
if (this.mySide.id == sidename) return this.mySide;
|
||||
if (this.yourSide.id == sidename) return this.yourSide;
|
||||
if (this.mySide.name == sidename) return this.mySide;
|
||||
|
|
@ -5272,15 +5272,18 @@ var Battle = (function () {
|
|||
for (var i = 0; i < this.sides[k].pokemon.length; i++) {
|
||||
var pokemon = this.sides[k].pokemon[i];
|
||||
|
||||
var spriteData = Tools.getSpriteData(pokemon, k, {afd: this.tier === "[Seasonal] Fools Festival", gen: this.gen});
|
||||
var spriteData = Tools.getSpriteData(pokemon, k, {
|
||||
afd: this.tier === "[Seasonal] Fools Festival",
|
||||
gen: this.gen
|
||||
});
|
||||
var y = 0;
|
||||
var x = 0;
|
||||
if (k) {
|
||||
y = Math.floor(96-spriteData.h)/2 + 50 + 3 * (i + 6 - this.sides[k].pokemon.length);
|
||||
x = Math.floor(96-spriteData.w)/2 + 180 + 50 * (i + 6 - this.sides[k].pokemon.length);
|
||||
y = Math.floor(96 - spriteData.h) / 2 + 50 + 3 * (i + 6 - this.sides[k].pokemon.length);
|
||||
x = Math.floor(96 - spriteData.w) / 2 + 180 + 50 * (i + 6 - this.sides[k].pokemon.length);
|
||||
} else {
|
||||
y = Math.floor(96-spriteData.h)/2 + 200 + 3 * i;
|
||||
x = Math.floor(96-spriteData.w)/2 + 100 + 50 * i;
|
||||
y = Math.floor(96 - spriteData.h) / 2 + 200 + 3 * i;
|
||||
x = Math.floor(96 - spriteData.w) / 2 + 100 + 50 * i;
|
||||
}
|
||||
if (teamText) teamText += ' / ';
|
||||
teamText += pokemon.species;
|
||||
|
|
@ -5329,7 +5332,7 @@ var Battle = (function () {
|
|||
break;
|
||||
case 'rule':
|
||||
var ruleArgs = args[1].split(': ');
|
||||
this.log('<div><small><em>' + Tools.escapeHTML(ruleArgs[0]) + (ruleArgs[1]?':':'') + '</em> ' + Tools.escapeHTML(ruleArgs[1]||'') + '</div>');
|
||||
this.log('<div><small><em>' + Tools.escapeHTML(ruleArgs[0]) + (ruleArgs[1] ? ':' : '') + '</em> ' + Tools.escapeHTML(ruleArgs[1] || '') + '</div>');
|
||||
break;
|
||||
case 'rated':
|
||||
this.rated = true;
|
||||
|
|
@ -5350,18 +5353,18 @@ var Battle = (function () {
|
|||
clickableName = Tools.escapeHTML(name);
|
||||
}
|
||||
var message = args.join('|');
|
||||
if (message.substr(0,2) === '//') {
|
||||
if (message.substr(0, 2) === '//') {
|
||||
this.log('<div class="chat chatmessage-' + toId(name) + '"><strong style="' + hashColor(toUserid(name)) + '">' + clickableName + ':</strong> <em>' + Tools.parseMessage(message.substr(1)) + '</em></div>', preempt);
|
||||
} else if (message.substr(0,4).toLowerCase() === '/me ') {
|
||||
} else if (message.substr(0, 4).toLowerCase() === '/me ') {
|
||||
this.log('<div class="chat chatmessage-' + toId(name) + '"><strong style="' + hashColor(toUserid(name)) + '">•</strong> <em>' + clickableName + ' <i>' + Tools.parseMessage(message.substr(4)) + '</i></em></div>', preempt);
|
||||
} else if (message.substr(0,14).toLowerCase() === '/data-pokemon ') {
|
||||
if (window.Chart) this.log('<div class="chat"><ul class=\"utilichart\">' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>', preempt);
|
||||
} else if (message.substr(0,11).toLowerCase() === '/data-item ') {
|
||||
if (window.Chart) this.log('<div class="chat"><ul class=\"utilichart\">' + Chart.itemRow(Tools.getItem(message.substr(11)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>', preempt);
|
||||
} else if (message.substr(0,14).toLowerCase() === '/data-ability ') {
|
||||
if (window.Chart) this.log('<div class="chat"><ul class=\"utilichart\">' + Chart.abilityRow(Tools.getAbility(message.substr(14)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>', preempt);
|
||||
} else if (message.substr(0,11).toLowerCase() === '/data-move ') {
|
||||
if (window.Chart) this.log('<div class="chat"><ul class=\"utilichart\">' + Chart.moveRow(Tools.getMove(message.substr(11)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>', preempt);
|
||||
} else if (message.substr(0, 14).toLowerCase() === '/data-pokemon ') {
|
||||
if (window.Chart) this.log('<div class="chat"><ul class=\"utilichart\">' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>', preempt);
|
||||
} else if (message.substr(0, 11).toLowerCase() === '/data-item ') {
|
||||
if (window.Chart) this.log('<div class="chat"><ul class=\"utilichart\">' + Chart.itemRow(Tools.getItem(message.substr(11)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>', preempt);
|
||||
} else if (message.substr(0, 14).toLowerCase() === '/data-ability ') {
|
||||
if (window.Chart) this.log('<div class="chat"><ul class=\"utilichart\">' + Chart.abilityRow(Tools.getAbility(message.substr(14)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>', preempt);
|
||||
} else if (message.substr(0, 11).toLowerCase() === '/data-move ') {
|
||||
if (window.Chart) this.log('<div class="chat"><ul class=\"utilichart\">' + Chart.moveRow(Tools.getMove(message.substr(11)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>', preempt);
|
||||
} else {
|
||||
this.log('<div class="chat chatmessage-' + toId(name) + '"><strong style="' + hashColor(toUserid(name)) + '" class="username" data-name="' + Tools.escapeHTML(name) + '">' + clickableName + ':</strong> <em>' + Tools.parseMessage(message) + '</em></div>', preempt);
|
||||
}
|
||||
|
|
@ -5425,7 +5428,7 @@ var Battle = (function () {
|
|||
case 'clearpoke':
|
||||
this.p1.pokemon = [];
|
||||
this.p2.pokemon = [];
|
||||
for (var i=0; i<this.p1.active.length; i++) {
|
||||
for (var i = 0; i < this.p1.active.length; i++) {
|
||||
this.p1.active[i] = null;
|
||||
this.p2.active[i] = null;
|
||||
}
|
||||
|
|
@ -5476,8 +5479,7 @@ var Battle = (function () {
|
|||
var slot = poke.slot;
|
||||
poke.healthParse(args[3]);
|
||||
if (args[0] === 'switch') {
|
||||
if (poke.side.active[slot])
|
||||
{
|
||||
if (poke.side.active[slot]) {
|
||||
poke.side.switchOut(poke.side.active[slot]);
|
||||
if (this.waitForResult()) return;
|
||||
}
|
||||
|
|
@ -5577,7 +5579,7 @@ var Battle = (function () {
|
|||
return;
|
||||
}
|
||||
if (!str) return;
|
||||
if (str.charAt(0) !== '|' || str.substr(0,2) === '||') {
|
||||
if (str.charAt(0) !== '|' || str.substr(0, 2) === '||') {
|
||||
if (str.charAt(0) === '|') str = str.substr(2);
|
||||
this.log('<div class="chat">' + Tools.escapeHTML(str) + '</div>', preempt);
|
||||
} else {
|
||||
|
|
@ -5585,37 +5587,37 @@ var Battle = (function () {
|
|||
if (str !== '|') {
|
||||
args = str.substr(1).split('|');
|
||||
}
|
||||
while (args[args.length-1] && args[args.length-1].substr(0,1) === '[') {
|
||||
var bracketPos = args[args.length-1].indexOf(']');
|
||||
while (args[args.length - 1] && args[args.length - 1].substr(0, 1) === '[') {
|
||||
var bracketPos = args[args.length - 1].indexOf(']');
|
||||
if (bracketPos <= 0) break;
|
||||
var argstr = args.pop();
|
||||
// default to '.' so it evaluates to boolean true
|
||||
kwargs[argstr.substr(1,bracketPos-1)] = ($.trim(argstr.substr(bracketPos+1)) || '.');
|
||||
kwargs[argstr.substr(1, bracketPos - 1)] = ($.trim(argstr.substr(bracketPos + 1)) || '.');
|
||||
}
|
||||
|
||||
// parse the next line if it's a minor: runMinor needs it parsed to determine when to merge minors
|
||||
var nextLine = '', nextArgs = [''], nextKwargs = {};
|
||||
nextLine = this.activityQueue[this.activityStep+1];
|
||||
if (nextLine && nextLine.substr(0,2) === '|-') {
|
||||
nextLine = this.activityQueue[this.activityStep + 1];
|
||||
if (nextLine && nextLine.substr(0, 2) === '|-') {
|
||||
nextLine = $.trim(nextLine.substr(1));
|
||||
nextArgs = nextLine.split('|');
|
||||
while (nextArgs[nextArgs.length-1] && nextArgs[nextArgs.length-1].substr(0,1) === '[') {
|
||||
var bracketPos = nextArgs[nextArgs.length-1].indexOf(']');
|
||||
while (nextArgs[nextArgs.length - 1] && nextArgs[nextArgs.length - 1].substr(0, 1) === '[') {
|
||||
var bracketPos = nextArgs[nextArgs.length - 1].indexOf(']');
|
||||
if (bracketPos <= 0) break;
|
||||
var argstr = nextArgs.pop();
|
||||
// default to '.' so it evaluates to boolean true
|
||||
nextKwargs[argstr.substr(1,bracketPos-1)] = ($.trim(argstr.substr(bracketPos+1)) || '.');
|
||||
nextKwargs[argstr.substr(1, bracketPos - 1)] = ($.trim(argstr.substr(bracketPos + 1)) || '.');
|
||||
}
|
||||
}
|
||||
|
||||
if (this.debug) {
|
||||
if (args[0].substr(0,1) === '-') {
|
||||
if (args[0].substr(0, 1) === '-') {
|
||||
this.runMinor(args, kwargs, preempt, nextArgs, nextKwargs);
|
||||
} else {
|
||||
this.runMajor(args, kwargs, preempt);
|
||||
}
|
||||
} else try {
|
||||
if (args[0].substr(0,1) === '-') {
|
||||
if (args[0].substr(0, 1) === '-') {
|
||||
this.runMinor(args, kwargs, preempt, nextArgs, nextKwargs);
|
||||
} else {
|
||||
this.runMajor(args, kwargs, preempt);
|
||||
|
|
@ -5624,7 +5626,7 @@ var Battle = (function () {
|
|||
this.log('<div class="chat">Error parsing: ' + Tools.escapeHTML(str) + '</div>', preempt);
|
||||
if (e.stack) {
|
||||
var stack = '' + e.stack;
|
||||
stack = stack.split("\n").slice(0,2).join("\n");
|
||||
stack = stack.split("\n").slice(0, 2).join("\n");
|
||||
this.log('<div class="chat" style="white-space:pre-wrap">' + Tools.escapeHTML(stack) + '</div>', preempt);
|
||||
} else {
|
||||
this.log('<div class="chat">Error: ' + Tools.escapeHTML('' + e) + '</div>', preempt);
|
||||
|
|
|
|||
111
js/battledata.js
111
js/battledata.js
|
|
@ -43,7 +43,7 @@ for (var i=0; i<text.length; i++)
|
|||
|
||||
// ES5 indexOf
|
||||
if (!Array.prototype.indexOf) {
|
||||
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
|
||||
Array.prototype.indexOf = function (searchElement /*, fromIndex */) {
|
||||
"use strict";
|
||||
if (this == null) {
|
||||
throw new TypeError();
|
||||
|
|
@ -118,7 +118,7 @@ function toUserid(text) {
|
|||
return text.toLowerCase().replace(/[^a-z0-9]+/g, '');
|
||||
}
|
||||
|
||||
function toName (name) {
|
||||
function toName(name) {
|
||||
if (typeof name === 'number') return '' + name;
|
||||
if (typeof name !== 'string') return '';
|
||||
name = name.replace(/[\|\s\[\]\,]+/g, ' ').trim();
|
||||
|
|
@ -317,8 +317,7 @@ var linkRegex = new RegExp(
|
|||
')?' +
|
||||
')?' +
|
||||
'|[a-z0-9.]+\\b@' + domainRegex + '[.][a-z]{2,3}' +
|
||||
')'
|
||||
,
|
||||
')',
|
||||
'ig'
|
||||
);
|
||||
|
||||
|
|
@ -368,13 +367,13 @@ var Tools = {
|
|||
|
||||
// ``code``
|
||||
str = str.replace(/\`\`([^< ](?:[^<`]*?[^< ])??)\`\`/g,
|
||||
options.hidemonospace ? '$1' : '<code>$1</code>');
|
||||
options.hidemonospace ? '$1' : '<code>$1</code>');
|
||||
// ~~strikethrough~~
|
||||
str = str.replace(/\~\~([^< ](?:[^<]*?[^< ])??)\~\~/g,
|
||||
options.hidestrikethrough ? '$1' : '<s>$1</s>');
|
||||
options.hidestrikethrough ? '$1' : '<s>$1</s>');
|
||||
// <<roomid>>
|
||||
str = str.replace(/<<([a-z0-9-]+)>>/g,
|
||||
options.hidelinks ? '«$1»' : '«<a href="/$1">$1</a>»');
|
||||
options.hidelinks ? '«$1»' : '«<a href="/$1">$1</a>»');
|
||||
// linking of URIs
|
||||
if (!options.hidelinks) {
|
||||
str = str.replace(linkRegex, function (uri) {
|
||||
|
|
@ -397,11 +396,11 @@ var Tools = {
|
|||
} else {
|
||||
event = 'Interstice link';
|
||||
fulluri = Tools.escapeHTML(Tools.interstice.getURI(
|
||||
Tools.unescapeHTML(fulluri)
|
||||
Tools.unescapeHTML(fulluri)
|
||||
));
|
||||
}
|
||||
onclick = 'if (window.ga) ga(\'send\', \'event\', \'' +
|
||||
event + '\', \'' + Tools.escapeQuotes(fulluri) + '\');';
|
||||
event + '\', \'' + Tools.escapeQuotes(fulluri) + '\');';
|
||||
}
|
||||
if (uri.substr(0, 24) === 'https://docs.google.com/' || uri.substr(0, 16) === 'docs.google.com/') {
|
||||
if (uri.slice(0, 5) === 'https') uri = uri.slice(8);
|
||||
|
|
@ -447,12 +446,12 @@ var Tools = {
|
|||
str = str.replace(/\[\[([^< ](?:[^<`]*?[^< ])??)\]\]/ig, function (p0, p1) {
|
||||
var q = Tools.escapeHTML(encodeURIComponent(Tools.unescapeHTML(p1)));
|
||||
return '<a href="http://www.google.com/search?ie=UTF-8&btnI&q=' + q +
|
||||
'" target="_blank">' + p1 +'</a>';
|
||||
'" target="_blank">' + p1 + '</a>';
|
||||
});
|
||||
}
|
||||
// __italics__
|
||||
str = str.replace(/\_\_([^< ](?:[^<]*?[^< ])??)\_\_(?![^<]*?<\/a)/g,
|
||||
options.hideitalics ? '$1' : '<i>$1</i>');
|
||||
options.hideitalics ? '$1' : '<i>$1</i>');
|
||||
// **bold**
|
||||
str = str.replace(/\*\*([^< ](?:[^<]*?[^< ])??)\*\*/g,
|
||||
options.hidebold ? '$1' : '<b>$1</b>');
|
||||
|
|
@ -496,14 +495,14 @@ var Tools = {
|
|||
},
|
||||
|
||||
escapeHTML: function (str, jsEscapeToo) {
|
||||
str = (str?'' + str:'');
|
||||
str = (str ? '' + str : '');
|
||||
str = str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
if (jsEscapeToo) str = str.replace(/'/g, '\\\'');
|
||||
return str;
|
||||
},
|
||||
|
||||
unescapeHTML: function (str) {
|
||||
str = (str?'' + str:'');
|
||||
str = (str ? '' + str : '');
|
||||
return str.replace(/"/g, '"').replace(/>/g, '>').
|
||||
replace(/</g, '<').replace(/&/g, '&');
|
||||
},
|
||||
|
|
@ -513,7 +512,7 @@ var Tools = {
|
|||
},
|
||||
|
||||
escapeQuotes: function (str) {
|
||||
str = (str?'' + str:'');
|
||||
str = (str ? '' + str : '');
|
||||
str = str.replace(/'/g, '\\\'');
|
||||
return str;
|
||||
},
|
||||
|
|
@ -668,12 +667,12 @@ var Tools = {
|
|||
|
||||
getEffect: function (effect) {
|
||||
if (!effect || typeof effect === 'string') {
|
||||
var name = $.trim(effect||'');
|
||||
if (name.substr(0,5) === 'item:') {
|
||||
var name = $.trim(effect || '');
|
||||
if (name.substr(0, 5) === 'item:') {
|
||||
return Tools.getItem(name.substr(5));
|
||||
} else if (name.substr(0,8) === 'ability:') {
|
||||
} else if (name.substr(0, 8) === 'ability:') {
|
||||
return Tools.getAbility(name.substr(8));
|
||||
} else if (name.substr(0,5) === 'move:') {
|
||||
} else if (name.substr(0, 5) === 'move:') {
|
||||
return Tools.getMove(name.substr(5));
|
||||
}
|
||||
var id = toId(name);
|
||||
|
|
@ -715,12 +714,12 @@ var Tools = {
|
|||
|
||||
getMove: function (move) {
|
||||
if (!move || typeof move === 'string') {
|
||||
var name = $.trim(move||'');
|
||||
var name = $.trim(move || '');
|
||||
var id = toId(name);
|
||||
move = (window.BattleMovedex && window.BattleMovedex[id]) || {};
|
||||
if (move.name) move.exists = true;
|
||||
|
||||
if (!move.exists && id.substr(0,11) === 'hiddenpower' && id.length > 11) {
|
||||
if (!move.exists && id.substr(0, 11) === 'hiddenpower' && id.length > 11) {
|
||||
var matches = /([a-z]*)([0-9]*)/.exec(id);
|
||||
move = (window.BattleMovedex && window.BattleMovedex[matches[1]]) || {};
|
||||
move = $.extend({}, move);
|
||||
|
|
@ -746,7 +745,7 @@ var Tools = {
|
|||
|
||||
getItem: function (item) {
|
||||
if (!item || typeof item === 'string') {
|
||||
var name = $.trim(item||'');
|
||||
var name = $.trim(item || '');
|
||||
var id = toId(name);
|
||||
item = (window.BattleItems && window.BattleItems[id]) || {};
|
||||
if (item.name) item.exists = true;
|
||||
|
|
@ -760,7 +759,7 @@ var Tools = {
|
|||
|
||||
getAbility: function (ability) {
|
||||
if (!ability || typeof ability === 'string') {
|
||||
var name = $.trim(ability||'');
|
||||
var name = $.trim(ability || '');
|
||||
var id = toId(name);
|
||||
ability = (window.BattleAbilities && window.BattleAbilities[id]) || {};
|
||||
if (ability.name) ability.exists = true;
|
||||
|
|
@ -789,12 +788,12 @@ var Tools = {
|
|||
template.forme = id.substr(k.length);
|
||||
}
|
||||
}
|
||||
if (id !== 'yanmega' && id.substr(id.length-4) === 'mega') {
|
||||
template.baseSpecies = id.substr(0, id.length-4);
|
||||
template.forme = id.substr(id.length-4);
|
||||
} else if (id.substr(id.length-6) === 'primal') {
|
||||
template.baseSpecies = id.substr(0, id.length-6);
|
||||
template.forme = id.substr(id.length-6);
|
||||
if (id !== 'yanmega' && id.substr(id.length - 4) === 'mega') {
|
||||
template.baseSpecies = id.substr(0, id.length - 4);
|
||||
template.forme = id.substr(id.length - 4);
|
||||
} else if (id.substr(id.length - 6) === 'primal') {
|
||||
template.baseSpecies = id.substr(0, id.length - 6);
|
||||
template.forme = id.substr(id.length - 6);
|
||||
}
|
||||
template.exists = false;
|
||||
}
|
||||
|
|
@ -855,7 +854,7 @@ var Tools = {
|
|||
getType: function (type) {
|
||||
if (!type || typeof type === 'string') {
|
||||
var id = toId(type);
|
||||
id = id.substr(0,1).toUpperCase() + id.substr(1);
|
||||
id = id.substr(0, 1).toUpperCase() + id.substr(1);
|
||||
type = (window.BattleTypeChart && window.BattleTypeChart[id]) || {};
|
||||
if (type.damageTaken) type.exists = true;
|
||||
if (!type.id) type.id = id;
|
||||
|
|
@ -936,7 +935,7 @@ var Tools = {
|
|||
name += '-f';
|
||||
spriteType += 'f';
|
||||
}
|
||||
if (!Tools.prefs('noanim') && gen in {'bw':1, 'xy':1}) {
|
||||
if (!Tools.prefs('noanim') && gen in {'bw': 1, 'xy': 1}) {
|
||||
spriteType = 'ani' + spriteType;
|
||||
dir = gen + 'ani' + dir;
|
||||
|
||||
|
|
@ -947,7 +946,7 @@ var Tools = {
|
|||
}
|
||||
}
|
||||
// if there is no entry or enough data in pokedex-mini.js or the animations are disabled or past gen, use the proper sprites
|
||||
gen = (gen === 'xy')? 'bw' : gen;
|
||||
gen = (gen === 'xy') ? 'bw' : gen;
|
||||
dir = gen + dir;
|
||||
|
||||
spriteData.url += dir + '/' + name + '.png';
|
||||
|
|
@ -1047,26 +1046,26 @@ var Tools = {
|
|||
"kyogreprimal": 909,
|
||||
"groudonprimal": 910,
|
||||
"rayquazamega": 911,
|
||||
"syclant": 832+0,
|
||||
"revenankh": 832+1,
|
||||
"pyroak": 832+2,
|
||||
"fidgit": 832+3,
|
||||
"stratagem": 832+4,
|
||||
"arghonaut": 832+5,
|
||||
"kitsunoh": 832+6,
|
||||
"cyclohm": 832+7,
|
||||
"colossoil": 832+8,
|
||||
"krilowatt": 832+9,
|
||||
"voodoom": 832+10,
|
||||
"tomohawk": 832+11,
|
||||
"necturna": 832+12,
|
||||
"mollux": 832+13,
|
||||
"aurumoth": 832+14,
|
||||
"malaconda": 832+15,
|
||||
"cawmodore": 832+16,
|
||||
"volkraken": 832+17,
|
||||
"plasmanta": 832+18,
|
||||
"naviathan": 832+19
|
||||
"syclant": 832 + 0,
|
||||
"revenankh": 832 + 1,
|
||||
"pyroak": 832 + 2,
|
||||
"fidgit": 832 + 3,
|
||||
"stratagem": 832 + 4,
|
||||
"arghonaut": 832 + 5,
|
||||
"kitsunoh": 832 + 6,
|
||||
"cyclohm": 832 + 7,
|
||||
"colossoil": 832 + 8,
|
||||
"krilowatt": 832 + 9,
|
||||
"voodoom": 832 + 10,
|
||||
"tomohawk": 832 + 11,
|
||||
"necturna": 832 + 12,
|
||||
"mollux": 832 + 13,
|
||||
"aurumoth": 832 + 14,
|
||||
"malaconda": 832 + 15,
|
||||
"cawmodore": 832 + 16,
|
||||
"volkraken": 832 + 17,
|
||||
"plasmanta": 832 + 18,
|
||||
"naviathan": 832 + 19
|
||||
};
|
||||
if (altNums[id]) {
|
||||
num = altNums[id];
|
||||
|
|
@ -1080,7 +1079,7 @@ var Tools = {
|
|||
|
||||
var top = 8 + Math.floor(num / 16) * 32;
|
||||
var left = (num % 16) * 32;
|
||||
var fainted = (pokemon && pokemon.fainted?';opacity:.4':'');
|
||||
var fainted = (pokemon && pokemon.fainted ? ';opacity:.4' : '');
|
||||
return 'background:transparent url(' + Tools.resourcePrefix + 'sprites/bwicons-sheet.png?g6) no-repeat scroll -' + left + 'px -' + top + 'px' + fainted;
|
||||
},
|
||||
|
||||
|
|
@ -1099,9 +1098,9 @@ var Tools = {
|
|||
if (Tools.getTemplate(pokemon.species).exists === false) {
|
||||
return 'background-image:url(' + Tools.resourcePrefix + 'sprites/bw/0.png)';
|
||||
}
|
||||
var shiny = (pokemon.shiny?'-shiny':'');
|
||||
var shiny = (pokemon.shiny ? '-shiny' : '');
|
||||
if (BattlePokemonSprites && BattlePokemonSprites[id] && BattlePokemonSprites[id].front && BattlePokemonSprites[id].front.anif && pokemon.gender === 'F') {
|
||||
id+='-f';
|
||||
id += '-f';
|
||||
}
|
||||
return 'background-image:url(' + Tools.resourcePrefix + 'sprites/bw' + shiny + '/' + id + '.png)';
|
||||
},
|
||||
|
|
@ -1118,7 +1117,7 @@ var Tools = {
|
|||
|
||||
getTypeIcon: function (type, b) { // b is just for utilichart.js
|
||||
if (!type) return '';
|
||||
var sanitizedType = type.replace(/\?/g,'%3f');
|
||||
return '<img src="' + Tools.resourcePrefix + 'sprites/types/' + sanitizedType + '.png" alt="' + type + '" height="14" width="32"' + (b?' class="b"':'') + ' />';
|
||||
var sanitizedType = type.replace(/\?/g, '%3f');
|
||||
return '<img src="' + Tools.resourcePrefix + 'sprites/types/' + sanitizedType + '.png" alt="' + type + '" height="14" width="32"' + (b ? ' class="b"' : '') + ' />';
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@
|
|||
},
|
||||
init: function (data) {
|
||||
var log = data.split('\n');
|
||||
if (data.substr(0,6) === '|init|') log.shift();
|
||||
if (data.substr(0, 6) === '|init|') log.shift();
|
||||
if (log.length && log[0].substr(0, 7) === '|title|') {
|
||||
this.title = log[0].substr(7);
|
||||
log.shift();
|
||||
|
|
@ -87,10 +87,10 @@
|
|||
},
|
||||
add: function (data) {
|
||||
if (!data) return;
|
||||
if (data.substr(0,6) === '|init|') {
|
||||
if (data.substr(0, 6) === '|init|') {
|
||||
return this.init(data);
|
||||
}
|
||||
if (data.substr(0,9) === '|request|') {
|
||||
if (data.substr(0, 9) === '|request|') {
|
||||
return this.receiveRequest($.parseJSON(data.substr(9)));
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +295,7 @@
|
|||
this.choice.choices.push('pass');
|
||||
}
|
||||
}
|
||||
var pos = this.choice.choices.length - (type === 'movetarget'?1:0);
|
||||
var pos = this.choice.choices.length - (type === 'movetarget' ? 1 : 0);
|
||||
|
||||
// hp bar
|
||||
var hpbar = '';
|
||||
|
|
@ -335,23 +335,23 @@
|
|||
|
||||
var myActive = this.battle.mySide.active;
|
||||
var yourActive = this.battle.yourSide.active;
|
||||
var yourSlot = yourActive.length-1-pos;
|
||||
for (var i = yourActive.length-1; i >= 0; i--) {
|
||||
var yourSlot = yourActive.length - 1 - pos;
|
||||
for (var i = yourActive.length - 1; i >= 0; i--) {
|
||||
var pokemon = yourActive[i];
|
||||
|
||||
var disabled = false;
|
||||
if (moveTarget === 'adjacentAlly' || moveTarget === 'adjacentAllyOrSelf') {
|
||||
disabled = true;
|
||||
} else if (moveTarget === 'normal' || moveTarget === 'adjacentFoe') {
|
||||
if (Math.abs(yourSlot-i) > 1) disabled = true;
|
||||
if (Math.abs(yourSlot - i) > 1) disabled = true;
|
||||
}
|
||||
|
||||
if (disabled) {
|
||||
controls += '<button disabled="disabled" style="visibility:hidden"></button> ';
|
||||
} else if (!pokemon || pokemon.zerohp) {
|
||||
controls += '<button class="disabled" name="chooseMoveTarget" value="' + (i+1) + '"><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon('missingno') + '"></span></button> ';
|
||||
controls += '<button class="disabled" name="chooseMoveTarget" value="' + (i + 1) + '"><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon('missingno') + '"></span></button> ';
|
||||
} else {
|
||||
controls += '<button name="chooseMoveTarget" value="' + (i+1) + '"' + this.tooltipAttrs(pokemon.getIdent(), 'pokemon', true, 'foe') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + '<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp*92/pokemon.maxhp)||1) + 'px"></span></span>' + (pokemon.status?'<span class="status ' + pokemon.status + '"></span>':'') + '</button> ';
|
||||
controls += '<button name="chooseMoveTarget" value="' + (i + 1) + '"' + this.tooltipAttrs(pokemon.getIdent(), 'pokemon', true, 'foe') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + '<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp * 92 / pokemon.maxhp) || 1) + 'px"></span></span>' + (pokemon.status ? '<span class="status ' + pokemon.status + '"></span>' : '') + '</button> ';
|
||||
}
|
||||
}
|
||||
controls += '<div style="clear:both"></div> </div><div class="switchmenu" style="display:block">';
|
||||
|
|
@ -362,16 +362,16 @@
|
|||
if (moveTarget === 'adjacentFoe') {
|
||||
disabled = true;
|
||||
} else if (moveTarget === 'normal' || moveTarget === 'adjacentAlly' || moveTarget === 'adjacentAllyOrSelf') {
|
||||
if (Math.abs(pos-i) > 1) disabled = true;
|
||||
if (Math.abs(pos - i) > 1) disabled = true;
|
||||
}
|
||||
if (moveTarget !== 'adjacentAllyOrSelf' && pos == i) disabled = true;
|
||||
|
||||
if (disabled) {
|
||||
controls += '<button disabled="disabled" style="visibility:hidden"></button> ';
|
||||
} else if (!pokemon || pokemon.zerohp) {
|
||||
controls += '<button class="disabled" name="chooseMoveTarget" value="' + (-(i+1)) + '"><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon('missingno') + '"></span></button> ';
|
||||
controls += '<button class="disabled" name="chooseMoveTarget" value="' + (-(i + 1)) + '"><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon('missingno') + '"></span></button> ';
|
||||
} else {
|
||||
controls += '<button name="chooseMoveTarget" value="' + (-(i+1)) + '"' + this.tooltipAttrs(i, 'sidepokemon') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) +'"></span>' + Tools.escapeHTML(pokemon.name) + '<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp*92/pokemon.maxhp)||1) + 'px"></span></span>' + (pokemon.status?'<span class="status ' + pokemon.status + '"></span>':'') + '</button> ';
|
||||
controls += '<button name="chooseMoveTarget" value="' + (-(i + 1)) + '"' + this.tooltipAttrs(i, 'sidepokemon') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + '<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp * 92 / pokemon.maxhp) || 1) + 'px"></span></span>' + (pokemon.status ? '<span class="status ' + pokemon.status + '"></span>' : '') + '</button> ';
|
||||
}
|
||||
}
|
||||
controls += '</div>';
|
||||
|
|
@ -407,7 +407,7 @@
|
|||
movebuttons += '<button disabled="disabled"' + this.tooltipAttrs(moveData.move, 'move') + '>';
|
||||
hasDisabled = true;
|
||||
} else {
|
||||
movebuttons += '<button class="type-' + move.type + '" name="chooseMove" value="' + (i+1) + '" data-move="' + Tools.escapeHTML(moveData.move) + '"' + this.tooltipAttrs(moveData.move, 'move') + '>';
|
||||
movebuttons += '<button class="type-' + move.type + '" name="chooseMove" value="' + (i + 1) + '" data-move="' + Tools.escapeHTML(moveData.move) + '"' + this.tooltipAttrs(moveData.move, 'move') + '>';
|
||||
hasMoves = true;
|
||||
}
|
||||
movebuttons += name + '<br /><small class="type">' + (move.type || "Unknown") + '</small> <small class="pp">' + pp + '</small> </button> ';
|
||||
|
|
@ -437,9 +437,9 @@
|
|||
var pokemon = switchables[i];
|
||||
pokemon.name = pokemon.ident.substr(4);
|
||||
if (pokemon.zerohp || i < this.battle.mySide.active.length || this.choice.switchFlags[i]) {
|
||||
controls += '<button class="disabled" name="chooseDisabled" value="' + pokemon.name + (pokemon.zerohp ? ',fainted' : i < this.battle.mySide.active.length ? ',active' : '') + '"' + this.tooltipAttrs(i, 'sidepokemon') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + (!pokemon.zerohp?'<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp*92/pokemon.maxhp)||1) + 'px"></span></span>' + (pokemon.status?'<span class="status ' + pokemon.status + '"></span>':''):'') +'</button> ';
|
||||
controls += '<button class="disabled" name="chooseDisabled" value="' + pokemon.name + (pokemon.zerohp ? ',fainted' : i < this.battle.mySide.active.length ? ',active' : '') + '"' + this.tooltipAttrs(i, 'sidepokemon') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + (!pokemon.zerohp ? '<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp * 92 / pokemon.maxhp) || 1) + 'px"></span></span>' + (pokemon.status ? '<span class="status ' + pokemon.status + '"></span>' : '') : '') + '</button> ';
|
||||
} else {
|
||||
controls += '<button name="chooseSwitch" value="' + i + '"' + this.tooltipAttrs(i, 'sidepokemon') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + '<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp*92/pokemon.maxhp)||1) + 'px"></span></span>' + (pokemon.status?'<span class="status ' + pokemon.status + '"></span>':'') +'</button> ';
|
||||
controls += '<button name="chooseSwitch" value="' + i + '"' + this.tooltipAttrs(i, 'sidepokemon') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + '<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp * 92 / pokemon.maxhp) || 1) + 'px"></span></span>' + (pokemon.status ? '<span class="status ' + pokemon.status + '"></span>' : '') + '</button> ';
|
||||
}
|
||||
}
|
||||
if (this.finalDecisionSwitch && this.battle.gen > 2) {
|
||||
|
|
@ -477,7 +477,7 @@
|
|||
}
|
||||
// Place selector
|
||||
if (type === 'switchposition') {
|
||||
var pos = this.choice.choices.length - (type === 'movetarget'?1:0);
|
||||
var pos = this.choice.choices.length - (type === 'movetarget' ? 1 : 0);
|
||||
|
||||
// TODO? hpbar
|
||||
controls += 'Which Pokémon will it switch in for?</div>';
|
||||
|
|
@ -489,11 +489,11 @@
|
|||
pokemon = this.battle.mySide.pokemon[i];
|
||||
|
||||
if (pokemon && !pokemon.zerohp || this.choice.switchOutFlags[i]) {
|
||||
controls += '<button disabled' + this.tooltipAttrs(pokemon.getIdent(), 'pokemon', true, 'foe') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + (!pokemon.zerohp?'<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp*92/pokemon.maxhp)||1) + 'px"></span></span>' + (pokemon.status?'<span class="status ' + pokemon.status + '"></span>':''):'') + '</button> ';
|
||||
controls += '<button disabled' + this.tooltipAttrs(pokemon.getIdent(), 'pokemon', true, 'foe') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + (!pokemon.zerohp ? '<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp * 92 / pokemon.maxhp) || 1) + 'px"></span></span>' + (pokemon.status ? '<span class="status ' + pokemon.status + '"></span>' : '') : '') + '</button> ';
|
||||
} else if (!pokemon) {
|
||||
controls += '<button disabled></button> ';
|
||||
} else {
|
||||
controls += '<button name="chooseSwitchTarget" value="' + i + '"' + this.tooltipAttrs(pokemon.getIdent(), 'pokemon', true, 'foe') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) +'"></span>' + Tools.escapeHTML(pokemon.name) + '<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp*92/pokemon.maxhp)||1) + 'px"></span></span>' + (pokemon.status?'<span class="status ' + pokemon.status + '"></span>':'') + '</button> ';
|
||||
controls += '<button name="chooseSwitchTarget" value="' + i + '"' + this.tooltipAttrs(pokemon.getIdent(), 'pokemon', true, 'foe') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + '<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp * 92 / pokemon.maxhp) || 1) + 'px"></span></span>' + (pokemon.status ? '<span class="status ' + pokemon.status + '"></span>' : '') + '</button> ';
|
||||
}
|
||||
}
|
||||
controls += '</div>';
|
||||
|
|
@ -514,7 +514,7 @@
|
|||
} else {
|
||||
controls += '<button name="chooseSwitch" value="' + i + '"' + this.tooltipAttrs(i, 'sidepokemon') + '>';
|
||||
}
|
||||
controls += '<span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + (!pokemon.zerohp?'<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp*92/pokemon.maxhp)||1) + 'px"></span></span>' + (pokemon.status?'<span class="status ' + pokemon.status + '"></span>':''):'') + '</button> ';
|
||||
controls += '<span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + (!pokemon.zerohp ? '<span class="hpbar' + pokemon.getHPColorClass() + '"><span style="width:' + (Math.round(pokemon.hp * 92 / pokemon.maxhp) || 1) + 'px"></span></span>' + (pokemon.status ? '<span class="status ' + pokemon.status + '"></span>' : '') : '') + '</button> ';
|
||||
}
|
||||
controls += '</div></div></div>';
|
||||
this.$controls.html(controls);
|
||||
|
|
@ -525,7 +525,7 @@
|
|||
var controls = '<div class="controls"><div class="whatdo">';
|
||||
if (!this.choice || !this.choice.done) {
|
||||
this.choice = {
|
||||
teamPreview: [1,2,3,4,5,6].slice(0,switchables.length),
|
||||
teamPreview: [1, 2, 3, 4, 5, 6].slice(0, switchables.length),
|
||||
done: 0,
|
||||
count: 0
|
||||
};
|
||||
|
|
@ -547,20 +547,20 @@
|
|||
}
|
||||
controls += '<button name="chooseTeamPreview" value="' + i + '"' + this.tooltipAttrs(i, 'sidepokemon') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + '</button> ';
|
||||
}
|
||||
if (this.battle.teamPreviewCount) this.choice.count = parseInt(this.battle.teamPreviewCount,10);
|
||||
if (this.battle.teamPreviewCount) this.choice.count = parseInt(this.battle.teamPreviewCount, 10);
|
||||
controls += '</div>';
|
||||
} else {
|
||||
controls += '<button name="clearChoice">Back</button> What about the rest of your team?</div>';
|
||||
controls += '<div class="switchcontrols"><div class="switchselect"><button name="selectSwitch">Choose a Pokémon for slot ' + (this.choice.done+1) +'</button></div><div class="switchmenu">';
|
||||
controls += '<div class="switchcontrols"><div class="switchselect"><button name="selectSwitch">Choose a Pokémon for slot ' + (this.choice.done + 1) + '</button></div><div class="switchmenu">';
|
||||
for (var i = 0; i < switchables.length; i++) {
|
||||
var pokemon = switchables[this.choice.teamPreview[i]-1];
|
||||
var pokemon = switchables[this.choice.teamPreview[i] - 1];
|
||||
if (i >= 6) {
|
||||
break;
|
||||
}
|
||||
if (i < this.choice.done) {
|
||||
controls += '<button disabled="disabled"' + this.tooltipAttrs(i, 'sidepokemon') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) +'"></span>' + Tools.escapeHTML(pokemon.name) + '</button> ';
|
||||
controls += '<button disabled="disabled"' + this.tooltipAttrs(i, 'sidepokemon') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + '</button> ';
|
||||
} else {
|
||||
controls += '<button name="chooseTeamPreview" value="' + i + '"' + this.tooltipAttrs(this.choice.teamPreview[i]-1, 'sidepokemon') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) +'"></span>' + Tools.escapeHTML(pokemon.name) + '</button> ';
|
||||
controls += '<button name="chooseTeamPreview" value="' + i + '"' + this.tooltipAttrs(this.choice.teamPreview[i] - 1, 'sidepokemon') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(pokemon) + '"></span>' + Tools.escapeHTML(pokemon.name) + '</button> ';
|
||||
}
|
||||
}
|
||||
controls += '</div>';
|
||||
|
|
@ -735,12 +735,12 @@
|
|||
chooseMove: function (pos, e) {
|
||||
var myActive = this.battle.mySide.active;
|
||||
this.hideTooltip();
|
||||
var isMega = !!(this.$('input[name=megaevo]')[0]||'').checked;
|
||||
var isMega = !!(this.$('input[name=megaevo]')[0] || '').checked;
|
||||
if (pos !== undefined) {
|
||||
var move = e.getAttribute('data-move');
|
||||
var target = Tools.getMove(move).target;
|
||||
var choosableTargets = {normal:1, any:1, adjacentAlly:1, adjacentAllyOrSelf:1, adjacentFoe:1};
|
||||
this.choice.choices.push('move ' + pos + (isMega?' mega':''));
|
||||
var choosableTargets = {normal: 1, any: 1, adjacentAlly: 1, adjacentAllyOrSelf: 1, adjacentFoe: 1};
|
||||
this.choice.choices.push('move ' + pos + (isMega ? ' mega' : ''));
|
||||
if (myActive.length > 1 && target in choosableTargets) {
|
||||
this.choice.type = 'movetarget';
|
||||
this.choice.moveTarget = target;
|
||||
|
|
@ -765,7 +765,7 @@
|
|||
this.updateControlsForPlayer();
|
||||
},
|
||||
chooseMoveTarget: function (posString) {
|
||||
this.choice.choices[this.choice.choices.length-1] += ' ' + posString;
|
||||
this.choice.choices[this.choice.choices.length - 1] += ' ' + posString;
|
||||
this.chooseMove();
|
||||
},
|
||||
chooseShift: function () {
|
||||
|
|
@ -800,7 +800,7 @@
|
|||
}
|
||||
// Default: left to right.
|
||||
this.choice.switchOutFlags[this.choice.choices.length] = true;
|
||||
this.choice.choices.push('switch ' + (parseInt(pos,10)+1));
|
||||
this.choice.choices.push('switch ' + (parseInt(pos, 10) + 1));
|
||||
if (this.request && this.request.requestType === 'move' && this.battle.mySide.active.length > this.choice.choices.length) {
|
||||
this.choice.type = 'move2';
|
||||
this.updateControlsForPlayer();
|
||||
|
|
@ -846,17 +846,17 @@
|
|||
chooseSwitchTarget: function (posString) {
|
||||
var indexSwitchIn = -1;
|
||||
for (var i in this.choice.switchFlags) {
|
||||
if (this.choice.choices.indexOf('switch ' + (parseInt(i,10)+1)) === -1) {
|
||||
if (this.choice.choices.indexOf('switch ' + (parseInt(i, 10) + 1)) === -1) {
|
||||
indexSwitchIn = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.choice.choices[posString] = 'switch ' + (parseInt(indexSwitchIn,10)+1);
|
||||
this.choice.choices[posString] = 'switch ' + (parseInt(indexSwitchIn, 10) + 1);
|
||||
this.choice.switchOutFlags[posString] = true;
|
||||
this.chooseSwitch();
|
||||
},
|
||||
chooseTeamPreview: function (pos) {
|
||||
pos = parseInt(pos,10);
|
||||
pos = parseInt(pos, 10);
|
||||
this.hideTooltip();
|
||||
if (this.choice.count) {
|
||||
var temp = this.choice.teamPreview[pos];
|
||||
|
|
@ -872,7 +872,7 @@
|
|||
}
|
||||
pos = this.choice.teamPreview.join('');
|
||||
} else {
|
||||
pos = pos+1;
|
||||
pos = pos + 1;
|
||||
}
|
||||
|
||||
this.sendDecision('/team ' + (pos));
|
||||
|
|
@ -1043,7 +1043,7 @@
|
|||
var exacthp = '';
|
||||
if (pokemon.maxhp != 100 && pokemon.maxhp != 1000 && pokemon.maxhp != 48) exacthp = ' (' + pokemon.hp + '/' + pokemon.maxhp + ')';
|
||||
if (pokemon.maxhp == 48 && isActive) exacthp = ' <small>(' + pokemon.hp + '/' + pokemon.maxhp + ' pixels)</small>';
|
||||
text += '<p>HP: ' + pokemon.hpDisplay() +exacthp+(pokemon.status?' <span class="status ' + pokemon.status + '">' + pokemon.status.toUpperCase() + '</span>':'') +'</p>';
|
||||
text += '<p>HP: ' + pokemon.hpDisplay() + exacthp + (pokemon.status ? ' <span class="status ' + pokemon.status + '">' + pokemon.status.toUpperCase() + '</span>' : '') + '</p>';
|
||||
if (this.battle.gen > 2) {
|
||||
if (!pokemon.baseAbility && !pokemon.ability) {
|
||||
if (template.abilities) {
|
||||
|
|
@ -1073,11 +1073,11 @@
|
|||
var minSpe;
|
||||
var maxSpe;
|
||||
if (this.battle.tier === 'Random Battle') {
|
||||
minSpe = Math.floor(Math.floor(2*template.baseStats['spe']+(0)+Math.floor((0)/4))*pokemon.level / 100 + 5);
|
||||
maxSpe = Math.floor(Math.floor(2*template.baseStats['spe']+(31)+Math.floor((85)/4))*pokemon.level / 100 + 5);
|
||||
minSpe = Math.floor(Math.floor(2 * template.baseStats['spe'] + (0) + Math.floor((0) / 4)) * pokemon.level / 100 + 5);
|
||||
maxSpe = Math.floor(Math.floor(2 * template.baseStats['spe'] + (31) + Math.floor((85) / 4)) * pokemon.level / 100 + 5);
|
||||
} else {
|
||||
minSpe = Math.floor(Math.floor(Math.floor(2*template.baseStats['spe']+(0)+Math.floor((0)/4))*pokemon.level / 100 + 5) * 0.9);
|
||||
maxSpe = Math.floor(Math.floor(Math.floor(2*template.baseStats['spe']+(31)+Math.floor((252)/4))*pokemon.level / 100 + 5) * 1.1);
|
||||
minSpe = Math.floor(Math.floor(Math.floor(2 * template.baseStats['spe'] + (0) + Math.floor((0) / 4)) * pokemon.level / 100 + 5) * 0.9);
|
||||
maxSpe = Math.floor(Math.floor(Math.floor(2 * template.baseStats['spe'] + (31) + Math.floor((252) / 4)) * pokemon.level / 100 + 5) * 1.1);
|
||||
}
|
||||
text += '<p>' + minSpe + ' to ' + maxSpe + ' Spe (before items/abilities/modifiers)</p>';
|
||||
}
|
||||
|
|
|
|||
7
js/client-chat-tournament.js
Normal file → Executable file
7
js/client-chat-tournament.js
Normal file → Executable file
|
|
@ -282,7 +282,7 @@
|
|||
case 'start':
|
||||
if (!this.info.isJoined) {
|
||||
this.toggleBoxVisibility(false);
|
||||
} else if (this.info.format.substr(0, 4) === 'gen5' && !Tools.loadedSpriteData['bw']){
|
||||
} else if (this.info.format.substr(0, 4) === 'gen5' && !Tools.loadedSpriteData['bw']) {
|
||||
Tools.loadSpriteData('bw');
|
||||
}
|
||||
this.room.$chat.append("<div class=\"notice tournament-message-start\">The tournament has started!</div>");
|
||||
|
|
@ -392,8 +392,7 @@
|
|||
}
|
||||
|
||||
this.$noMatches.toggleClass('active',
|
||||
this.info.challenges.length === 0 && this.info.challengeBys.length === 0 &&
|
||||
!this.info.challenging && !this.info.challenged);
|
||||
this.info.challenges.length === 0 && this.info.challengeBys.length === 0 && !this.info.challenging && !this.info.challenged);
|
||||
}
|
||||
|
||||
this.updates = {};
|
||||
|
|
@ -435,7 +434,7 @@
|
|||
var type = endData.generator;
|
||||
this.room.$chat.append("<div class=\"notice tournament-message-end-winner\">Congratulations to " + Tools.escapeHTML(arrayToPhrase(endData.results[0])) + " for winning the " + Tools.escapeHTML(format) + " " + Tools.escapeHTML(type) + " Tournament!</div>");
|
||||
if (endData.results[1])
|
||||
this.room.$chat.append("<div class=\"notice tournament-message-end-runnerup\">Runner-up" + (endData.results[1].length > 1 ? "s" : "") +": " + Tools.escapeHTML(arrayToPhrase(endData.results[1])) + "</div>");
|
||||
this.room.$chat.append("<div class=\"notice tournament-message-end-runnerup\">Runner-up" + (endData.results[1].length > 1 ? "s" : "") + ": " + Tools.escapeHTML(arrayToPhrase(endData.results[1])) + "</div>");
|
||||
|
||||
// Fallthrough
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@
|
|||
}
|
||||
},
|
||||
keyPress: function (e) {
|
||||
var cmdKey = (((e.cmdKey || e.metaKey)?1:0) + (e.ctrlKey?1:0) + (e.altKey?1:0) === 1);
|
||||
var cmdKey = (((e.cmdKey || e.metaKey) ? 1 : 0) + (e.ctrlKey ? 1 : 0) + (e.altKey ? 1 : 0) === 1);
|
||||
var textbox = e.currentTarget;
|
||||
if (e.keyCode === 13 && !e.shiftKey) { // Enter key
|
||||
this.submit(e);
|
||||
|
|
@ -113,31 +113,31 @@
|
|||
var end = textbox.selectionEnd;
|
||||
|
||||
// make sure start and end aren't midway through the syntax
|
||||
if (value.charAt(start) === '_' && value.charAt(start-1) === '_' &&
|
||||
value.charAt(start-2) !== '_') {
|
||||
if (value.charAt(start) === '_' && value.charAt(start - 1) === '_' &&
|
||||
value.charAt(start - 2) !== '_') {
|
||||
start++;
|
||||
}
|
||||
if (value.charAt(end) === '_' && value.charAt(end-1) === '_' &&
|
||||
value.charAt(end-2) !== '_') {
|
||||
if (value.charAt(end) === '_' && value.charAt(end - 1) === '_' &&
|
||||
value.charAt(end - 2) !== '_') {
|
||||
end--;
|
||||
}
|
||||
|
||||
// wrap in __
|
||||
value = value.substr(0,start) + '__' + value.substr(start,end-start) + '__' + value.substr(end);
|
||||
value = value.substr(0, start) + '__' + value.substr(start, end - start) + '__' + value.substr(end);
|
||||
start += 2, end += 2;
|
||||
|
||||
// prevent nesting
|
||||
if (value.substr(start-4, 4) === '____') {
|
||||
value = value.substr(0, start-4) + value.substr(start);
|
||||
if (value.substr(start - 4, 4) === '____') {
|
||||
value = value.substr(0, start - 4) + value.substr(start);
|
||||
start -= 4, end -= 4;
|
||||
} else if (start !== end && value.substr(start-2, 4) === '____') {
|
||||
value = value.substr(0, start-2) + value.substr(start+2);
|
||||
} else if (start !== end && value.substr(start - 2, 4) === '____') {
|
||||
value = value.substr(0, start - 2) + value.substr(start + 2);
|
||||
start -= 2, end -= 4;
|
||||
}
|
||||
if (value.substr(end, 4) === '____') {
|
||||
value = value.substr(0, end) + value.substr(end+4);
|
||||
} else if (start !== end && value.substr(end-2, 4) === '____') {
|
||||
value = value.substr(0, end-2) + value.substr(end+2);
|
||||
value = value.substr(0, end) + value.substr(end + 4);
|
||||
} else if (start !== end && value.substr(end - 2, 4) === '____') {
|
||||
value = value.substr(0, end - 2) + value.substr(end + 2);
|
||||
end -= 2;
|
||||
}
|
||||
|
||||
|
|
@ -150,31 +150,31 @@
|
|||
var end = textbox.selectionEnd;
|
||||
|
||||
// make sure start and end aren't midway through the syntax
|
||||
if (value.charAt(start) === '*' && value.charAt(start-1) === '*' &&
|
||||
value.charAt(start-2) !== '*') {
|
||||
if (value.charAt(start) === '*' && value.charAt(start - 1) === '*' &&
|
||||
value.charAt(start - 2) !== '*') {
|
||||
start++;
|
||||
}
|
||||
if (value.charAt(end) === '*' && value.charAt(end-1) === '*' &&
|
||||
value.charAt(end-2) !== '*') {
|
||||
if (value.charAt(end) === '*' && value.charAt(end - 1) === '*' &&
|
||||
value.charAt(end - 2) !== '*') {
|
||||
end--;
|
||||
}
|
||||
|
||||
// wrap in **
|
||||
value = value.substr(0,start) + '**' + value.substr(start,end-start) + '**' + value.substr(end);
|
||||
value = value.substr(0, start) + '**' + value.substr(start, end - start) + '**' + value.substr(end);
|
||||
start += 2, end += 2;
|
||||
|
||||
// prevent nesting
|
||||
if (value.substr(start-4, 4) === '****') {
|
||||
value = value.substr(0, start-4) + value.substr(start);
|
||||
if (value.substr(start - 4, 4) === '****') {
|
||||
value = value.substr(0, start - 4) + value.substr(start);
|
||||
start -= 4, end -= 4;
|
||||
} else if (start !== end && value.substr(start-2, 4) === '****') {
|
||||
value = value.substr(0, start-2) + value.substr(start+2);
|
||||
} else if (start !== end && value.substr(start - 2, 4) === '****') {
|
||||
value = value.substr(0, start - 2) + value.substr(start + 2);
|
||||
start -= 2, end -= 4;
|
||||
}
|
||||
if (value.substr(end, 4) === '****') {
|
||||
value = value.substr(0, end) + value.substr(end+4);
|
||||
} else if (start !== end && value.substr(end-2, 4) === '****') {
|
||||
value = value.substr(0, end-2) + value.substr(end+2);
|
||||
value = value.substr(0, end) + value.substr(end + 4);
|
||||
} else if (start !== end && value.substr(end - 2, 4) === '****') {
|
||||
value = value.substr(0, end - 2) + value.substr(end + 2);
|
||||
end -= 2;
|
||||
}
|
||||
|
||||
|
|
@ -237,10 +237,10 @@
|
|||
app.addPopup(AvatarsPopup);
|
||||
},
|
||||
openSounds: function () {
|
||||
app.addPopup(SoundsPopup, {type:'semimodal'});
|
||||
app.addPopup(SoundsPopup, {type: 'semimodal'});
|
||||
},
|
||||
openOptions: function () {
|
||||
app.addPopup(OptionsPopup, {type:'semimodal'});
|
||||
app.addPopup(OptionsPopup, {type: 'semimodal'});
|
||||
},
|
||||
|
||||
// highlight
|
||||
|
|
@ -352,7 +352,7 @@
|
|||
var idx = $textbox.prop('selectionStart');
|
||||
if (idx === 0) return false;
|
||||
|
||||
var users = this.users || (app.rooms['lobby']?app.rooms['lobby'].users:{});
|
||||
var users = this.users || (app.rooms['lobby'] ? app.rooms['lobby'].users : {});
|
||||
|
||||
var text = $textbox.val();
|
||||
|
||||
|
|
@ -414,11 +414,11 @@
|
|||
parseCommand: function (text) {
|
||||
var cmd = '';
|
||||
var target = '';
|
||||
if (text.substr(0,2) !== '//' && text.substr(0,1) === '/') {
|
||||
if (text.substr(0, 2) !== '//' && text.substr(0, 1) === '/') {
|
||||
var spaceIndex = text.indexOf(' ');
|
||||
if (spaceIndex > 0) {
|
||||
cmd = text.substr(1, spaceIndex-1);
|
||||
target = text.substr(spaceIndex+1);
|
||||
cmd = text.substr(1, spaceIndex - 1);
|
||||
target = text.substr(spaceIndex + 1);
|
||||
} else {
|
||||
cmd = text.substr(1);
|
||||
target = '';
|
||||
|
|
@ -433,7 +433,7 @@
|
|||
var self = this;
|
||||
var challenge = function (targets) {
|
||||
target = toId(targets[0]);
|
||||
self.challengeData = { userid: target, format: targets[1] || '', team: targets[2] || '' };
|
||||
self.challengeData = {userid: target, format: targets[1] || '', team: targets[2] || ''};
|
||||
app.on('response:userdetails', self.challengeUserdetails, self);
|
||||
app.send('/cmd userdetails ' + target);
|
||||
};
|
||||
|
|
@ -673,12 +673,12 @@
|
|||
if (target.indexOf(',') > -1) {
|
||||
var targets = target.match(/[^,]+(,\d*}[^,]*)?/g);
|
||||
// trim the targets to be safe
|
||||
for (var i=0, len=targets.length; i<len; i++) {
|
||||
for (var i = 0, len = targets.length; i < len; i++) {
|
||||
targets[i] = targets[i].replace(/\n/g, '').trim();
|
||||
}
|
||||
switch (targets[0]) {
|
||||
case 'add':
|
||||
for (var i=1, len=targets.length; i<len; i++) {
|
||||
for (var i = 1, len = targets.length; i < len; i++) {
|
||||
if (/[\\^$*+?()|{}[\]]/.test(targets[i])) {
|
||||
// Catch any errors thrown by newly added regular expressions so they don't break the entire highlight list
|
||||
try {
|
||||
|
|
@ -695,7 +695,7 @@
|
|||
break;
|
||||
case 'delete':
|
||||
var newHls = [];
|
||||
for (var i=0, len=highlights.length; i<len; i++) {
|
||||
for (var i = 0, len = highlights.length; i < len; i++) {
|
||||
if (targets.indexOf(highlights[i]) === -1) {
|
||||
newHls.push(highlights[i]);
|
||||
}
|
||||
|
|
@ -760,7 +760,7 @@
|
|||
buffer += '<tr><th>Format</th><th><abbr title="Elo rating">Elo</abbr></th><th><abbr title="user\'s percentage chance of winning a random battle (aka GLIXARE)">GXE</abbr></th><th><abbr title="Glicko-1 rating: rating±deviation">Glicko-1</abbr></th><th>COIL</th><th>W</th><th>L</th><th>T</th></tr>';
|
||||
var hiddenFormats = [];
|
||||
var formatLength = data.length;
|
||||
for (var i=0; i<formatLength; i++) {
|
||||
for (var i = 0; i < formatLength; i++) {
|
||||
var row = data[i];
|
||||
if (!formatTargeting || formats[row.formatid]) {
|
||||
buffer += '<tr>';
|
||||
|
|
@ -768,27 +768,27 @@
|
|||
buffer += '<tr class="hidden">';
|
||||
hiddenFormats.push(row.formatid);
|
||||
}
|
||||
buffer += '<td>' + row.formatid + '</td><td><strong>' + Math.round(row.acre) + '</strong></td><td>' + Math.round(row.gxe,1) + '</td><td>';
|
||||
buffer += '<td>' + row.formatid + '</td><td><strong>' + Math.round(row.acre) + '</strong></td><td>' + Math.round(row.gxe, 1) + '</td><td>';
|
||||
if (row.rprd > 100) {
|
||||
buffer += '<span><em>' + Math.round(row.rpr) + '<small> ± ' + Math.round(row.rprd) + '</small></em> <small>(provisional)</small></span>';
|
||||
} else {
|
||||
buffer += '<em>' + Math.round(row.rpr) + '<small> ± ' + Math.round(row.rprd) + '</small></em>';
|
||||
}
|
||||
var N=parseInt(row.w)+parseInt(row.l)+parseInt(row.t);
|
||||
var N = parseInt(row.w) + parseInt(row.l) + parseInt(row.t);
|
||||
if (row.formatid === 'oususpecttest') {
|
||||
buffer += '<td>' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-17.0/N),0) + '</td>';
|
||||
buffer += '<td>' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -17.0 / N), 0) + '</td>';
|
||||
} else if (row.formatid === 'uberssuspecttest') {
|
||||
buffer += '<td>' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-29.0/N),0) + '</td>';
|
||||
buffer += '<td>' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -29.0 / N), 0) + '</td>';
|
||||
} else if (row.formatid === 'uususpecttest') {
|
||||
buffer += '<td>' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-20.0/N),0) + '</td>';
|
||||
buffer += '<td>' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -20.0 / N), 0) + '</td>';
|
||||
} else if (row.formatid === 'rususpecttest') {
|
||||
buffer += '<td>' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-9.0/N),0) + '</td>';
|
||||
buffer += '<td>' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -9.0 / N), 0) + '</td>';
|
||||
} else if (row.formatid === 'nususpecttest') {
|
||||
buffer += '<td>' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-20.0/N),0) + '</td>';
|
||||
buffer += '<td>' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -20.0 / N), 0) + '</td>';
|
||||
} else if (row.formatid === 'lcsuspecttest') {
|
||||
buffer += '<td>' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-43.0/N),0) + '</td>';
|
||||
buffer += '<td>' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -43.0 / N), 0) + '</td>';
|
||||
} else if (row.formatid === 'doublesoucurrent' || row.formatid === 'doublesoususpecttest') {
|
||||
buffer += '<td>' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-16.0/N),0) + '</td>';
|
||||
buffer += '<td>' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -16.0 / N), 0) + '</td>';
|
||||
} else {
|
||||
buffer += '<td>--</td>';
|
||||
}
|
||||
|
|
@ -804,7 +804,7 @@
|
|||
}
|
||||
buffer += '</table></div>';
|
||||
self.add('|raw|' + buffer);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
self.add('|raw|Error: corrupted ranking data');
|
||||
}
|
||||
}), 'text');
|
||||
|
|
@ -1046,7 +1046,7 @@
|
|||
}
|
||||
var userlist = '';
|
||||
for (var i = 0; i < log.length; i++) {
|
||||
if (log[i].substr(0,7) === '|users|') {
|
||||
if (log[i].substr(0, 7) === '|users|') {
|
||||
userlist = log[i];
|
||||
} else {
|
||||
this.addRow(log[i]);
|
||||
|
|
@ -1058,7 +1058,7 @@
|
|||
}
|
||||
var $children = this.$chat.children();
|
||||
if ($children.length > 900) {
|
||||
$children.slice(0,100).remove();
|
||||
$children.slice(0, 100).remove();
|
||||
}
|
||||
},
|
||||
addPM: function (user, message, pm) {
|
||||
|
|
@ -1074,7 +1074,7 @@
|
|||
addRow: function (line) {
|
||||
var name, name2, room, action, silent, oldid;
|
||||
if (line && typeof line === 'string') {
|
||||
if (line.substr(0,1) !== '|') line = '||' + line;
|
||||
if (line.substr(0, 1) !== '|') line = '||' + line;
|
||||
var row = line.substr(1).split('|');
|
||||
switch (row[0]) {
|
||||
case 'init':
|
||||
|
|
@ -1093,11 +1093,11 @@
|
|||
break;
|
||||
|
||||
case ':':
|
||||
this.timeOffset = ~~(Date.now()/1000) - parseInt(row[1], 10);
|
||||
this.timeOffset = ~~(Date.now() / 1000) - parseInt(row[1], 10);
|
||||
break;
|
||||
case 'c:':
|
||||
if (/[a-zA-Z0-9]/.test(row[2].charAt(0))) row[2] = ' ' + row[2];
|
||||
var deltaTime = ~~(Date.now()/1000) - this.timeOffset - parseInt(row[1], 10);
|
||||
var deltaTime = ~~(Date.now() / 1000) - this.timeOffset - parseInt(row[1], 10);
|
||||
this.addChat(row[2], row.slice(3).join('|'), false, deltaTime);
|
||||
break;
|
||||
|
||||
|
|
@ -1218,9 +1218,9 @@
|
|||
this.users = {};
|
||||
var commaIndex = userList.indexOf(',');
|
||||
if (commaIndex >= 0) {
|
||||
this.userCount.users = parseInt(userList.substr(0,commaIndex),10);
|
||||
var users = userList.substr(commaIndex+1).split(',');
|
||||
for (var i=0,len=users.length; i<len; i++) {
|
||||
this.userCount.users = parseInt(userList.substr(0, commaIndex), 10);
|
||||
var users = userList.substr(commaIndex + 1).split(',');
|
||||
for (var i = 0, len = users.length; i < len; i++) {
|
||||
if (users[i]) this.users[toId(users[i])] = users[i];
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1363,7 +1363,7 @@
|
|||
var oName = pm;
|
||||
if (pmuserid === app.user.get('userid')) oName = name;
|
||||
this.$chat.append('<div class="chat chatmessage-' + toId(name) + '">' + timestamp + '<strong style="' + color + '">' + clickableName + ':</strong> <span class="message-pm"><i class="pmnote" data-name="' + Tools.escapeHTML(oName) + '">(Private to ' + Tools.escapeHTML(pm) + ')</i> ' + Tools.parseMessage(message) + '</span></div>');
|
||||
} else if (message.substr(0,4) === '/me ') {
|
||||
} else if (message.substr(0, 4) === '/me ') {
|
||||
message = message.substr(4);
|
||||
if (showme) {
|
||||
this.$chat.append(chatDiv + timestamp + '<strong style="' + color + '">•</strong> <em' + (name.substr(1) === app.user.get('name') ? ' class="mine"' : '') + '>' + clickableName + ' <i>' + Tools.parseMessage(message) + '</i></em></div>');
|
||||
|
|
@ -1371,7 +1371,7 @@
|
|||
outputChat();
|
||||
}
|
||||
Storage.logChat(this.id, '* ' + name + ' ' + message);
|
||||
} else if (message.substr(0,5) === '/mee ') {
|
||||
} else if (message.substr(0, 5) === '/mee ') {
|
||||
message = message.substr(5);
|
||||
if (showme) {
|
||||
this.$chat.append(chatDiv + timestamp + '<strong style="' + color + '">•</strong> <em' + (name.substr(1) === app.user.get('name') ? ' class="mine"' : '') + '>' + clickableName + '<i>' + Tools.parseMessage(message) + '</i></em></div>');
|
||||
|
|
@ -1379,20 +1379,20 @@
|
|||
outputChat();
|
||||
}
|
||||
Storage.logChat(this.id, '* ' + name + message);
|
||||
} else if (message.substr(0,10) === '/announce ') {
|
||||
} else if (message.substr(0, 10) === '/announce ') {
|
||||
this.$chat.append(chatDiv + timestamp + '<strong style="' + color + '">' + clickableName + ':</strong> <span class="message-announce">' + Tools.parseMessage(message.substr(10)) + '</span></div>');
|
||||
Storage.logChat(this.id, '' + name + ': /announce ' + message);
|
||||
} else if (message.substr(0,14) === '/data-pokemon ') {
|
||||
this.$chat.append('<div class="message"><ul class="utilichart">' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0,11) === '/data-item ') {
|
||||
this.$chat.append('<div class="message"><ul class="utilichart">' + Chart.itemRow(Tools.getItem(message.substr(11)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0,14) === '/data-ability ') {
|
||||
this.$chat.append('<div class="message"><ul class="utilichart">' + Chart.abilityRow(Tools.getAbility(message.substr(14)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0,11) === '/data-move ') {
|
||||
this.$chat.append('<div class="message"><ul class="utilichart">' + Chart.moveRow(Tools.getMove(message.substr(11)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0, 14) === '/data-pokemon ') {
|
||||
this.$chat.append('<div class="message"><ul class="utilichart">' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0, 11) === '/data-item ') {
|
||||
this.$chat.append('<div class="message"><ul class="utilichart">' + Chart.itemRow(Tools.getItem(message.substr(11)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0, 14) === '/data-ability ') {
|
||||
this.$chat.append('<div class="message"><ul class="utilichart">' + Chart.abilityRow(Tools.getAbility(message.substr(14)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0, 11) === '/data-move ') {
|
||||
this.$chat.append('<div class="message"><ul class="utilichart">' + Chart.moveRow(Tools.getMove(message.substr(11)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else {
|
||||
// Normal chat message.
|
||||
if (message.substr(0,2) === '//') message = message.substr(1);
|
||||
if (message.substr(0, 2) === '//') message = message.substr(1);
|
||||
outputChat();
|
||||
Storage.logChat(this.id, '' + name + ': ' + message);
|
||||
}
|
||||
|
|
@ -1408,7 +1408,7 @@
|
|||
} else {
|
||||
date = new Date();
|
||||
}
|
||||
var components = [ date.getHours(), date.getMinutes() ];
|
||||
var components = [date.getHours(), date.getMinutes()];
|
||||
if (sectionPref === 'seconds') {
|
||||
components.push(date.getSeconds());
|
||||
}
|
||||
|
|
@ -1443,7 +1443,7 @@
|
|||
return self.comparator(a, b);
|
||||
});
|
||||
}
|
||||
for (var i=0, len=users.length; i<users.length; i++) {
|
||||
for (var i = 0, len = users.length; i < users.length; i++) {
|
||||
var userid = users[i];
|
||||
buf += this.constructItem(userid);
|
||||
}
|
||||
|
|
@ -1527,10 +1527,10 @@
|
|||
var text = '';
|
||||
// Sanitising the `userid` here is probably unnecessary, because
|
||||
// IDs can't contain anything dangerous.
|
||||
text += '<li' + (this.room.userForm === userid ? ' class="cur"' : '') + ' id="' + this.room.id +'-userlist-user-' + Tools.escapeHTML(userid) + '">';
|
||||
text += '<li' + (this.room.userForm === userid ? ' class="cur"' : '') + ' id="' + this.room.id + '-userlist-user-' + Tools.escapeHTML(userid) + '">';
|
||||
text += '<button class="userbutton username" data-name="' + Tools.escapeHTML(name) + '">';
|
||||
var group = name.charAt(0);
|
||||
text += '<em class="group' + (this.ranks[group]===2 ? ' staffgroup' : '') + '">' + Tools.escapeHTML(group) + '</em>';
|
||||
text += '<em class="group' + (this.ranks[group] === 2 ? ' staffgroup' : '') + '">' + Tools.escapeHTML(group) + '</em>';
|
||||
if (group === '~' || group === '&' || group === '#') {
|
||||
text += '<strong><em style="' + hashColor(userid) + '">' + Tools.escapeHTML(name.substr(1)) + '</em></strong>';
|
||||
} else if (group === '%' || group === '@') {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
format: format,
|
||||
server: Config.server.id.split(':')[0],
|
||||
output: 'html'
|
||||
}, _.bind(function (data){
|
||||
}, _.bind(function (data) {
|
||||
if (this.curFormat !== format) return;
|
||||
var buf = '<div class="ladder pad"><p><button name="selectFormat"><i class="icon-chevron-left"></i> Format List</button></p>';
|
||||
buf += '<h3>' + format + ' Top 500</h3>';
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@
|
|||
if (newsId === '' + Tools.prefs('readnews')) return;
|
||||
this.addPseudoPM({
|
||||
title: 'Latest News',
|
||||
html: '<iframe src="/news-embed.php?news' + (window.nodewebkit || document.location.protocol === 'https:'?'&https':'') + '" width="270" height="400" border="0" style="border:0;width:100%;height:400px"></iframe>',
|
||||
html: '<iframe src="/news-embed.php?news' + (window.nodewebkit || document.location.protocol === 'https:' ? '&https' : '') + '" width="270" height="400" border="0" style="border:0;width:100%;height:400px"></iframe>',
|
||||
attributes: 'data-newsid="' + newsId + '"',
|
||||
cssClass: 'news-embed',
|
||||
height: 400,
|
||||
|
|
@ -113,7 +113,7 @@
|
|||
|
||||
addPM: function (name, message, target) {
|
||||
var userid = toUserid(name);
|
||||
if (app.ignore[userid] && name.substr(0, 1) in {' ':1, '!':1, '‽':1}) return;
|
||||
if (app.ignore[userid] && name.substr(0, 1) in {' ': 1, '!': 1, '‽': 1}) return;
|
||||
|
||||
if (app.curSideRoom && app.curSideRoom.addPM && Tools.prefs('inchatpm')) {
|
||||
app.curSideRoom.addPM(name, message, target);
|
||||
|
|
@ -142,33 +142,33 @@
|
|||
var clickableName = '<span class="username" data-name="' + Tools.escapeHTML(name) + '">' + Tools.escapeHTML(name.substr(1)) + '</span>';
|
||||
if (name.substr(0, 1) !== ' ') clickableName = '<small>' + Tools.escapeHTML(name.substr(0, 1)) + '</small>' + clickableName;
|
||||
|
||||
if (message.substr(0,4) === '/me ') {
|
||||
if (message.substr(0, 4) === '/me ') {
|
||||
$chat.append('<div class="chat chatmessage-' + toId(name) + '">' + timestamp + '<strong style="' + color + '">•</strong> <em' + (name.substr(1) === app.user.get('name') ? ' class="mine"' : '') + '>' + clickableName + ' <i>' + Tools.parseMessage(message.substr(4)) + '</i></em></div>');
|
||||
} else if (message.substr(0,5) === '/mee ') {
|
||||
} else if (message.substr(0, 5) === '/mee ') {
|
||||
$chat.append('<div class="chat chatmessage-' + toId(name) + '">' + timestamp + '<strong style="' + color + '">•</strong> <em' + (name.substr(1) === app.user.get('name') ? ' class="mine"' : '') + '>' + clickableName + '<i>' + Tools.parseMessage(message.substr(5)) + '</i></em></div>');
|
||||
} else if (message.substr(0,8) === '/invite ') {
|
||||
} else if (message.substr(0, 8) === '/invite ') {
|
||||
var roomid = toRoomid(message.substr(8));
|
||||
$chat.append('<div class="chat">' + timestamp + '<em>' + clickableName + ' invited you to join the room "' + roomid + '"</em></div>');
|
||||
$chat.append('<div class="notice"><button name="joinRoom" value="' + roomid + '">Join ' + roomid + '</button></div>');
|
||||
} else if (message.substr(0,10) === '/announce ') {
|
||||
} else if (message.substr(0, 10) === '/announce ') {
|
||||
$chat.append('<div class="chat chatmessage-' + toId(name) + '">' + timestamp + '<strong style="' + color + '">' + clickableName + ':</strong> <span class="message-announce">' + Tools.parseMessage(message.substr(10)) + '</span></div>');
|
||||
} else if (message.substr(0,14) === '/data-pokemon ') {
|
||||
$chat.append('<div class="message"><ul class="utilichart">' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0,11) === '/data-item ') {
|
||||
$chat.append('<div class="message"><ul class="utilichart">' + Chart.itemRow(Tools.getItem(message.substr(11)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0,14) === '/data-ability ') {
|
||||
$chat.append('<div class="message"><ul class="utilichart">' + Chart.abilityRow(Tools.getAbility(message.substr(14)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0,11) === '/data-move ') {
|
||||
$chat.append('<div class="message"><ul class="utilichart">' + Chart.moveRow(Tools.getMove(message.substr(11)),'',{},false,true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0,6) === '/text ') {
|
||||
} else if (message.substr(0, 14) === '/data-pokemon ') {
|
||||
$chat.append('<div class="message"><ul class="utilichart">' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0, 11) === '/data-item ') {
|
||||
$chat.append('<div class="message"><ul class="utilichart">' + Chart.itemRow(Tools.getItem(message.substr(11)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0, 14) === '/data-ability ') {
|
||||
$chat.append('<div class="message"><ul class="utilichart">' + Chart.abilityRow(Tools.getAbility(message.substr(14)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0, 11) === '/data-move ') {
|
||||
$chat.append('<div class="message"><ul class="utilichart">' + Chart.moveRow(Tools.getMove(message.substr(11)), '', {}, false, true) + '<li style=\"clear:both\"></li></ul></div>');
|
||||
} else if (message.substr(0, 6) === '/text ') {
|
||||
$chat.append('<div class="chat">' + Tools.escapeHTML(message.substr(6)) + '</div>');
|
||||
} else if (message.substr(0,7) === '/error ') {
|
||||
} else if (message.substr(0, 7) === '/error ') {
|
||||
$chat.append('<div class="chat message-error">' + Tools.escapeHTML(message.substr(7)) + '</div>');
|
||||
} else if (message.substr(0,6) === '/html ') {
|
||||
} else if (message.substr(0, 6) === '/html ') {
|
||||
$chat.append('<div class="chat">' + Tools.sanitizeHTML(message.substr(6)) + '</div>');
|
||||
} else {
|
||||
// Normal chat message.
|
||||
if (message.substr(0,2) === '//') message = message.substr(1);
|
||||
if (message.substr(0, 2) === '//') message = message.substr(1);
|
||||
$chat.append('<div class="chat chatmessage-' + toId(name) + '">' + timestamp + '<strong style="' + color + '">' + clickableName + ':</strong> <em' + (target === oName ? ' class="mine"' : '') + '>' + Tools.parseMessage(message) + '</em></div>');
|
||||
}
|
||||
|
||||
|
|
@ -357,10 +357,10 @@
|
|||
app.addPopup(AvatarsPopup);
|
||||
},
|
||||
openSounds: function () {
|
||||
app.addPopup(SoundsPopup, {type:'semimodal'});
|
||||
app.addPopup(SoundsPopup, {type: 'semimodal'});
|
||||
},
|
||||
openOptions: function () {
|
||||
app.addPopup(OptionsPopup, {type:'semimodal'});
|
||||
app.addPopup(OptionsPopup, {type: 'semimodal'});
|
||||
},
|
||||
|
||||
// challenges and searching
|
||||
|
|
@ -628,7 +628,7 @@
|
|||
}
|
||||
formatid = this.curFormat;
|
||||
}
|
||||
return '<button class="select formatselect' + (noChoice?' preselected':'') + '" name="format" value="' + formatid + '"' + (noChoice?' disabled':'') + '>' + Tools.escapeFormat(formatid) + '</button>';
|
||||
return '<button class="select formatselect' + (noChoice ? ' preselected' : '') + '" name="format" value="' + formatid + '"' + (noChoice ? ' disabled' : '') + '>' + Tools.escapeFormat(formatid) + '</button>';
|
||||
},
|
||||
curTeamFormat: '',
|
||||
curTeamIndex: -1,
|
||||
|
|
@ -653,7 +653,7 @@
|
|||
teamIndex = this.curTeamIndex;
|
||||
}
|
||||
if (this.curTeamFormat !== formatid) {
|
||||
for (var i=0; i<teams.length; i++) {
|
||||
for (var i = 0; i < teams.length; i++) {
|
||||
if (teams[i].format === formatid) {
|
||||
teamIndex = i;
|
||||
break;
|
||||
|
|
@ -715,7 +715,7 @@
|
|||
app.addPopupPrompt("Username", "Open", function (target) {
|
||||
if (!target) return;
|
||||
if (toId(target) === 'zarel') {
|
||||
app.addPopup(Popup, {htmlMessage:"Zarel is very busy; please don't contact him this way. If you're looking for help, try <a href=\"/help\">joining the Help room</a>?"});
|
||||
app.addPopup(Popup, {htmlMessage: "Zarel is very busy; please don't contact him this way. If you're looking for help, try <a href=\"/help\">joining the Help room</a>?"});
|
||||
return;
|
||||
}
|
||||
app.addPopup(UserPopup, {name: target});
|
||||
|
|
@ -777,19 +777,19 @@
|
|||
|
||||
var TeamPopup = this.TeamPopup = this.Popup.extend({
|
||||
initialize: function (data) {
|
||||
var bufs = ['','','','',''];
|
||||
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);
|
||||
bufBoundary = Math.ceil(teams.length / 5);
|
||||
} else if (teams.length > 81) {
|
||||
bufBoundary = Math.ceil(teams.length/4);
|
||||
bufBoundary = Math.ceil(teams.length / 4);
|
||||
} else if (teams.length > 54) {
|
||||
bufBoundary = Math.ceil(teams.length/3);
|
||||
bufBoundary = Math.ceil(teams.length / 3);
|
||||
} else if (teams.length > 27) {
|
||||
bufBoundary = Math.ceil(teams.length/2);
|
||||
bufBoundary = Math.ceil(teams.length / 2);
|
||||
}
|
||||
|
||||
var format = BattleFormats[data.format];
|
||||
|
|
@ -804,7 +804,7 @@
|
|||
for (var i = 0; i < teams.length; i++) {
|
||||
if ((!teams[i].format && !teamFormat) || teams[i].format === teamFormat) {
|
||||
var selected = (i === curTeam);
|
||||
bufs[curBuf] += '<li><button name="selectTeam" value="' + i + '"' + (selected?' class="sel"':'') + '>' + Tools.escapeHTML(teams[i].name) + '</button></li>';
|
||||
bufs[curBuf] += '<li><button name="selectTeam" value="' + i + '"' + (selected ? ' class="sel"' : '') + '>' + Tools.escapeHTML(teams[i].name) + '</button></li>';
|
||||
count++;
|
||||
if (count % bufBoundary == 0 && curBuf < 4) curBuf++;
|
||||
}
|
||||
|
|
@ -817,7 +817,7 @@
|
|||
for (var i = 0; i < teams.length; i++) {
|
||||
if (teamFormat && teams[i].format === teamFormat) continue;
|
||||
var selected = (i === curTeam);
|
||||
bufs[curBuf] += '<li><button name="selectTeam" value="' + i + '"' + (selected?' class="sel"':'') + '>' + Tools.escapeHTML(teams[i].name) + '</button></li>';
|
||||
bufs[curBuf] += '<li><button name="selectTeam" value="' + i + '"' + (selected ? ' class="sel"' : '') + '>' + Tools.escapeHTML(teams[i].name) + '</button></li>';
|
||||
count++;
|
||||
if (count % bufBoundary == 0 && curBuf < 4) curBuf++;
|
||||
}
|
||||
|
|
@ -827,7 +827,7 @@
|
|||
}
|
||||
|
||||
if (bufs[1]) {
|
||||
while (!bufs[bufs.length-1]) bufs.pop();
|
||||
while (!bufs[bufs.length - 1]) bufs.pop();
|
||||
this.$el.html('<ul class="popupmenu" style="float:left">' + bufs.join('</ul><ul class="popupmenu" style="float:left;padding-left:5px">') + '</ul><div style="clear:left"></div>');
|
||||
} else {
|
||||
this.$el.html('<ul class="popupmenu">' + bufs[0] + '</ul>');
|
||||
|
|
@ -845,7 +845,7 @@
|
|||
renderTeam: function (i) {
|
||||
if (i === 'random') {
|
||||
var buf = 'Random team<br />';
|
||||
for (var i=0; i<6; i++) {
|
||||
for (var i = 0; i < 6; i++) {
|
||||
buf += '<span class="pokemonicon" style="float:left;' + Tools.getIcon() + '"></span>';
|
||||
}
|
||||
return buf;
|
||||
|
|
@ -867,7 +867,7 @@
|
|||
if (window.BattleFormats) {
|
||||
for (var i in BattleFormats) {
|
||||
if (BattleFormats[i].searchShow) {
|
||||
var activeFormat = (this.format === i?' selected=':'');
|
||||
var activeFormat = (this.format === i ? ' selected=' : '');
|
||||
buf += '<option value="' + i + '"' + activeFormat + '>' + BattleFormats[i].name + '</option>';
|
||||
}
|
||||
}
|
||||
|
|
@ -912,7 +912,7 @@
|
|||
if (!matches) {
|
||||
continue; // bogus room ID could be used to inject JavaScript
|
||||
}
|
||||
var format = (matches[1]||'');
|
||||
var format = (matches[1] || '');
|
||||
if (this.format && format !== this.format) continue;
|
||||
var formatBuf = (format ? '<small>[' + Tools.escapeFormat(format) + ']</small><br />' : '');
|
||||
var roomDesc = formatBuf + '<em class="p1">' + Tools.escapeHTML(roomData.p1) + '</em> <small class="vs">vs.</small> <em class="p2">' + Tools.escapeHTML(roomData.p2) + '</em>';
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
this.update();
|
||||
},
|
||||
focus: function () {
|
||||
if (new Date().getTime() - this.lastUpdate > 60*1000) {
|
||||
if (new Date().getTime() - this.lastUpdate > 60 * 1000) {
|
||||
app.send('/cmd rooms');
|
||||
this.lastUpdate = new Date().getTime();
|
||||
}
|
||||
|
|
@ -73,26 +73,26 @@
|
|||
var userCount = Number(rooms.userCount);
|
||||
var battleCount = Number(rooms.battleCount);
|
||||
buf += '<p style="height:60px">';
|
||||
buf += '<span style="float:left;width:200px;height:50px;padding:3px 8px;text-align:center"><strong style="display:block;font-size:18pt;font-weight:normal">' + userCount + '</strong> ' + (userCount==1?'user':'users') + ' online</span> ';
|
||||
buf += '<span style="float:left;width:200px;height:50px;padding:3px 8px;text-align:center"><strong style="display:block;font-size:18pt;font-weight:normal">' + battleCount + '</strong> active ' + (battleCount==1?'battle':'battles') + '</span>';
|
||||
buf += '<span style="float:left;width:200px;height:50px;padding:3px 8px;text-align:center"><strong style="display:block;font-size:18pt;font-weight:normal">' + userCount + '</strong> ' + (userCount == 1 ? 'user' : 'users') + ' online</span> ';
|
||||
buf += '<span style="float:left;width:200px;height:50px;padding:3px 8px;text-align:center"><strong style="display:block;font-size:18pt;font-weight:normal">' + battleCount + '</strong> active ' + (battleCount == 1 ? 'battle' : 'battles') + '</span>';
|
||||
buf += '</p>';
|
||||
}
|
||||
|
||||
buf += '<h2 style="clear:left">Official chat rooms</h2>';
|
||||
for (var i=0; i<rooms.official.length; i++) {
|
||||
for (var i = 0; i < rooms.official.length; i++) {
|
||||
var roomData = rooms.official[i];
|
||||
var id = toId(roomData.title);
|
||||
buf += '<div><a href="' + app.root + id + '" class="ilink"><small style="float:right">(' + Number(roomData.userCount) + ' users)</small><strong><i class="icon-comment-alt"></i> ' + Tools.escapeHTML(roomData.title) + '<br /></strong><small>' + Tools.escapeHTML(roomData.desc||'') + '</small></a></div>';
|
||||
buf += '<div><a href="' + app.root + id + '" class="ilink"><small style="float:right">(' + Number(roomData.userCount) + ' users)</small><strong><i class="icon-comment-alt"></i> ' + Tools.escapeHTML(roomData.title) + '<br /></strong><small>' + Tools.escapeHTML(roomData.desc || '') + '</small></a></div>';
|
||||
}
|
||||
|
||||
buf += '<h2>Chat rooms</h2>';
|
||||
rooms.chat.sort(function (a, b) {
|
||||
return b.userCount - a.userCount;
|
||||
});
|
||||
for (var i=0; i<rooms.chat.length; i++) {
|
||||
for (var i = 0; i < rooms.chat.length; i++) {
|
||||
var roomData = rooms.chat[i];
|
||||
var id = toId(roomData.title);
|
||||
var escapedDesc = Tools.escapeHTML(roomData.desc||'');
|
||||
var escapedDesc = Tools.escapeHTML(roomData.desc || '');
|
||||
buf += '<div><a href="' + app.root + id + '" class="ilink"><small style="float:right">(' + Number(roomData.userCount) + ' users)</small><strong><i class="icon-comment-alt"></i> ' + Tools.escapeHTML(roomData.title) + '<br /></strong><small>' + escapedDesc + '</small></a></div>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@
|
|||
buf += '<li><em>you don\'t have any teams lol</em></li>';
|
||||
} else {
|
||||
buf += '<li><button name="newTop"><i class="icon-plus-sign"></i> New team</button></li>';
|
||||
for (var i=0; i<teams.length+1; i++) {
|
||||
for (var i = 0; i < teams.length + 1; i++) {
|
||||
if (i === this.deletedTeamLoc) {
|
||||
buf += '<li><button name="undoDelete"><i class="icon-undo"></i> Undo Delete</button></li>';
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@
|
|||
}
|
||||
if (!team) {
|
||||
buf += '<li>Error: A corrupted team was dropped</li>';
|
||||
teams.splice(i,1);
|
||||
teams.splice(i, 1);
|
||||
i--;
|
||||
if (this.deletedTeamLoc && this.deletedTeamLoc > i) this.deletedTeamLoc--;
|
||||
continue;
|
||||
|
|
@ -241,17 +241,17 @@
|
|||
},
|
||||
"new": function () {
|
||||
var newTeam = {
|
||||
name: 'Untitled ' + (teams.length+1),
|
||||
name: 'Untitled ' + (teams.length + 1),
|
||||
format: '',
|
||||
team: '',
|
||||
iconCache: ''
|
||||
};
|
||||
teams.push(newTeam);
|
||||
this.edit(teams.length-1);
|
||||
this.edit(teams.length - 1);
|
||||
},
|
||||
newTop: function () {
|
||||
var newTeam = {
|
||||
name: 'Untitled ' + (teams.length+1),
|
||||
name: 'Untitled ' + (teams.length + 1),
|
||||
format: '',
|
||||
team: '',
|
||||
iconCache: ''
|
||||
|
|
@ -432,14 +432,14 @@
|
|||
return;
|
||||
}
|
||||
var name = file.name;
|
||||
if (name.slice(name.length-4).toLowerCase() === '.txt') {
|
||||
name = name.substr(0, name.length-4);
|
||||
if (name.slice(name.length - 4).toLowerCase() === '.txt') {
|
||||
name = name.substr(0, name.length - 4);
|
||||
}
|
||||
var format = '';
|
||||
var bracketIndex = name.indexOf(']');
|
||||
if (bracketIndex >= 0) {
|
||||
format = name.substr(1, bracketIndex-1);
|
||||
name = $.trim(name.substr(bracketIndex+1));
|
||||
format = name.substr(1, bracketIndex - 1);
|
||||
name = $.trim(name.substr(bracketIndex + 1));
|
||||
}
|
||||
Storage.teams.push({
|
||||
name: name,
|
||||
|
|
@ -472,15 +472,15 @@
|
|||
buf += '<div class="teamchartbox">';
|
||||
buf += '<ol class="teamchart">';
|
||||
buf += '<li>' + this.clipboardHTML() + '</li>';
|
||||
var i=0;
|
||||
if (this.curSetList.length && !this.curSetList[this.curSetList.length-1].species) {
|
||||
this.curSetList.splice(this.curSetList.length-1, 1);
|
||||
var i = 0;
|
||||
if (this.curSetList.length && !this.curSetList[this.curSetList.length - 1].species) {
|
||||
this.curSetList.splice(this.curSetList.length - 1, 1);
|
||||
}
|
||||
if (exports.BattleFormats) {
|
||||
buf += '<li class="format-select"><label>Format:</label><select name="format"><option value="">(None)</option>';
|
||||
for (var i in BattleFormats) {
|
||||
if (BattleFormats[i].isTeambuilderFormat) {
|
||||
var activeFormat = (this.curTeam.format === i?' selected="selected"':'');
|
||||
var activeFormat = (this.curTeam.format === i ? ' selected="selected"' : '');
|
||||
buf += '<option value="' + i + '"' + activeFormat + '>' + BattleFormats[i].name + '</option>';
|
||||
}
|
||||
}
|
||||
|
|
@ -489,7 +489,7 @@
|
|||
if (!this.curSetList.length) {
|
||||
buf += '<li><em>you have no pokemon lol</em></li>';
|
||||
}
|
||||
for (i=0; i<this.curSetList.length; i++) {
|
||||
for (i = 0; i < this.curSetList.length; i++) {
|
||||
if (this.curSetList.length < 6 && this.deletedSet && i === this.deletedSetLoc) {
|
||||
buf += '<li><button name="undeleteSet"><i class="icon-undo"></i> Undo Delete</button></li>';
|
||||
}
|
||||
|
|
@ -522,7 +522,7 @@
|
|||
}
|
||||
buf += '<div class="setmenu"><button name="copySet"><i class="icon-copy"></i>Copy</button> <button name="importSet"><i class="icon-upload-alt"></i>Import/Export</button> <button name="moveSet"><i class="icon-move"></i>Move</button> <button name="deleteSet"><i class="icon-trash"></i>Delete</button></div>';
|
||||
buf += '<div class="setchart-nickname">';
|
||||
buf += '<label>Nickname</label><input type="text" value="' + Tools.escapeHTML(set.name||set.species) + '" name="nickname" />';
|
||||
buf += '<label>Nickname</label><input type="text" value="' + Tools.escapeHTML(set.name || set.species) + '" name="nickname" />';
|
||||
buf += '</div>';
|
||||
buf += '<div class="setchart">';
|
||||
|
||||
|
|
@ -543,10 +543,10 @@
|
|||
'F': 'Female',
|
||||
'N': '—'
|
||||
};
|
||||
buf += '<span class="detailcell detailcell-first"><label>Level</label>' + (set.level||100) + '</span>';
|
||||
buf += '<span class="detailcell"><label>Gender</label>' + GenderChart[template.gender||set.gender||'N'] + '</span>';
|
||||
buf += '<span class="detailcell"><label>Happiness</label>' + (typeof set.happiness === 'number'?set.happiness:255) + '</span>';
|
||||
buf += '<span class="detailcell"><label>Shiny</label>' + (set.shiny?'Yes':'No') + '</span>';
|
||||
buf += '<span class="detailcell detailcell-first"><label>Level</label>' + (set.level || 100) + '</span>';
|
||||
buf += '<span class="detailcell"><label>Gender</label>' + GenderChart[template.gender || set.gender || 'N'] + '</span>';
|
||||
buf += '<span class="detailcell"><label>Happiness</label>' + (typeof set.happiness === 'number' ? set.happiness : 255) + '</span>';
|
||||
buf += '<span class="detailcell"><label>Shiny</label>' + (set.shiny ? 'Yes' : 'No') + '</span>';
|
||||
|
||||
buf += '</button></div>';
|
||||
buf += '</div><div class="setrow">';
|
||||
|
|
@ -575,12 +575,12 @@
|
|||
} else if (BattleNatures[set.nature] && BattleNatures[set.nature].minus === j) {
|
||||
ev += '<small>−</small>';
|
||||
}
|
||||
var width = stats[j]*75/504;
|
||||
if (j=='hp') width = stats[j]*75/704;
|
||||
if (width>75) width = 75;
|
||||
var color = Math.floor(stats[j]*180/714);
|
||||
if (color>360) color = 360;
|
||||
buf += '<span class="statrow"><label>' + BattleStatNames[j]+'</label> <span class="statgraph"><span style="width:' + width + 'px;background:hsl(' + color + ',40%,75%);"></span></span> ' + ev + '</span>';
|
||||
var width = stats[j] * 75 / 504;
|
||||
if (j == 'hp') width = stats[j] * 75 / 704;
|
||||
if (width > 75) width = 75;
|
||||
var color = Math.floor(stats[j] * 180 / 714);
|
||||
if (color > 360) color = 360;
|
||||
buf += '<span class="statrow"><label>' + BattleStatNames[j] + '</label> <span class="statgraph"><span style="width:' + width + 'px;background:hsl(' + color + ',40%,75%);"></span></span> ' + ev + '</span>';
|
||||
}
|
||||
buf += '</button></div></div>';
|
||||
|
||||
|
|
@ -595,7 +595,7 @@
|
|||
addPokemon: function () {
|
||||
if (!this.curTeam) return;
|
||||
var team = this.curSetList;
|
||||
if (!team.length || team[team.length-1].species) {
|
||||
if (!team.length || team[team.length - 1].species) {
|
||||
var newPokemon = {
|
||||
name: '',
|
||||
species: '',
|
||||
|
|
@ -607,8 +607,8 @@
|
|||
};
|
||||
team.push(newPokemon);
|
||||
}
|
||||
this.curSet = team[team.length-1];
|
||||
this.curSetLoc = team.length-1;
|
||||
this.curSet = team[team.length - 1];
|
||||
this.curSetLoc = team.length - 1;
|
||||
this.curChartName = '';
|
||||
this.update();
|
||||
this.$('input[name=pokemon]').select();
|
||||
|
|
@ -631,7 +631,7 @@
|
|||
Storage.saveTeams();
|
||||
},
|
||||
teamNameChange: function (e) {
|
||||
this.curTeam.name = ($.trim(e.currentTarget.value) || 'Untitled ' + (this.curTeamLoc+1));
|
||||
this.curTeam.name = ($.trim(e.currentTarget.value) || 'Untitled ' + (this.curTeamLoc + 1));
|
||||
e.currentTarget.value = this.curTeam.name;
|
||||
this.save();
|
||||
},
|
||||
|
|
@ -710,7 +710,7 @@
|
|||
clipboardExpanded: false,
|
||||
clipboardExpand: function () {
|
||||
var $clipboard = $('.teambuilder-clipboard-data');
|
||||
$clipboard.animate({ height: this.clipboardCount() * 28 }, 500, function () {
|
||||
$clipboard.animate({height: this.clipboardCount() * 28}, 500, function () {
|
||||
setTimeout(function () { $clipboard.focus(); }, 100);
|
||||
});
|
||||
|
||||
|
|
@ -720,7 +720,7 @@
|
|||
},
|
||||
clipboardShrink: function () {
|
||||
var $clipboard = $('.teambuilder-clipboard-data');
|
||||
$clipboard.animate({ height: 26 }, 500);
|
||||
$clipboard.animate({height: 26}, 500);
|
||||
|
||||
setTimeout(function () {
|
||||
this.clipboardExpanded = false;
|
||||
|
|
@ -751,7 +751,7 @@
|
|||
if (this.clipboardCount() === 1) {
|
||||
var $clipboard = $('.teambuilder-clipboard-container').css('opacity', 0);
|
||||
$clipboard.slideDown(250, function () {
|
||||
$clipboard.animate({ opacity: 1 }, 250);
|
||||
$clipboard.animate({opacity: 1}, 250);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -760,7 +760,7 @@
|
|||
|
||||
var self = this;
|
||||
var $clipboard = $('.teambuilder-clipboard-container');
|
||||
$clipboard.animate({ opacity: 0 }, 250, function () {
|
||||
$clipboard.animate({opacity: 0}, 250, function () {
|
||||
$clipboard.slideUp(250, function () {
|
||||
self.clipboardUpdate();
|
||||
});
|
||||
|
|
@ -888,10 +888,10 @@
|
|||
renderTeambar: function () {
|
||||
var buf = '';
|
||||
var isAdd = false;
|
||||
if (this.curSetList.length && !this.curSetList[this.curSetList.length-1].name && this.curSetLoc !== this.curSetList.length-1) {
|
||||
this.curSetList.splice(this.curSetList.length-1, 1);
|
||||
if (this.curSetList.length && !this.curSetList[this.curSetList.length - 1].name && this.curSetLoc !== this.curSetList.length - 1) {
|
||||
this.curSetList.splice(this.curSetList.length - 1, 1);
|
||||
}
|
||||
for (var i=0; i<this.curSetList.length; i++) {
|
||||
for (var i = 0; i < this.curSetList.length; i++) {
|
||||
var set = this.curSetList[i];
|
||||
var pokemonicon = '<span class="pokemonicon pokemonicon-' + i + '" style="' + Tools.getIcon(set) + '"></span>';
|
||||
if (!set.name) {
|
||||
|
|
@ -947,12 +947,12 @@
|
|||
else if (BattleNatures[set.nature] && BattleNatures[set.nature].minus === stat) {
|
||||
ev += '<small>−</small>';
|
||||
}
|
||||
var width = stats[stat]*75/504;
|
||||
if (stat == 'hp') width = stats[stat]*75/704;
|
||||
var width = stats[stat] * 75 / 504;
|
||||
if (stat == 'hp') width = stats[stat] * 75 / 704;
|
||||
if (width > 75) width = 75;
|
||||
var color = Math.floor(stats[stat]*180/714);
|
||||
var color = Math.floor(stats[stat] * 180 / 714);
|
||||
if (color > 360) color = 360;
|
||||
buf += '<span class="statrow"><label>' + BattleStatNames[stat]+'</label> <span class="statgraph"><span style="width:' + width + 'px;background:hsl(' + color + ',40%,75%);"></span></span> ' + ev + '</span>';
|
||||
buf += '<span class="statrow"><label>' + BattleStatNames[stat] + '</label> <span class="statgraph"><span style="width:' + width + 'px;background:hsl(' + color + ',40%,75%);"></span></span> ' + ev + '</span>';
|
||||
}
|
||||
this.$('button[name=stats]').html(buf);
|
||||
|
||||
|
|
@ -967,23 +967,23 @@
|
|||
buf = '<div></div>';
|
||||
var totalev = 0;
|
||||
for (var stat in stats) {
|
||||
var width = stats[stat]*180/504;
|
||||
if (stat == 'hp') width = stats[stat]*180/704;
|
||||
var width = stats[stat] * 180 / 504;
|
||||
if (stat == 'hp') width = stats[stat] * 180 / 704;
|
||||
if (width > 179) width = 179;
|
||||
var color = Math.floor(stats[stat]*180/714);
|
||||
var color = Math.floor(stats[stat] * 180 / 714);
|
||||
if (color > 360) color = 360;
|
||||
buf += '<div><em><span style="width:' + Math.floor(width) + 'px;background:hsl(' + color + ',85%,45%);border-color:hsl(' + color + ',85%,35%)"></span></em></div>';
|
||||
totalev += (set.evs[stat]||0);
|
||||
totalev += (set.evs[stat] || 0);
|
||||
}
|
||||
buf += '<div><em>Remaining:</em></div>';
|
||||
this.$chart.find('.graphcol').html(buf);
|
||||
|
||||
if (totalev <= 510) {
|
||||
this.$chart.find('.totalev').html('<em>' + (totalev>508?0:508-totalev) + '</em>');
|
||||
this.$chart.find('.totalev').html('<em>' + (totalev > 508 ? 0 : 508 - totalev) + '</em>');
|
||||
} else {
|
||||
this.$chart.find('.totalev').html('<b>' + (510-totalev) + '</b>');
|
||||
this.$chart.find('.totalev').html('<b>' + (510 - totalev) + '</b>');
|
||||
}
|
||||
this.$chart.find('select[name=nature]').val(set.nature||'Serious');
|
||||
this.$chart.find('select[name=nature]').val(set.nature || 'Serious');
|
||||
},
|
||||
curChartType: '',
|
||||
curChartName: '',
|
||||
|
|
@ -1080,11 +1080,13 @@
|
|||
buf += ' (Please choose 4 moves to get a suggested spread)</small></p>';
|
||||
} else {
|
||||
guessedEVs = this.guessEVs(role);
|
||||
guessedPlus = guessedEVs.plusStat; delete guessedEVs.plusStat;
|
||||
guessedMinus = guessedEVs.minusStat; delete guessedEVs.minusStat;
|
||||
guessedPlus = guessedEVs.plusStat;
|
||||
delete guessedEVs.plusStat;
|
||||
guessedMinus = guessedEVs.minusStat;
|
||||
delete guessedEVs.minusStat;
|
||||
buf += ' </small><button name="setStatFormGuesses">' + role + ': ';
|
||||
for (var i in guessedEVs) {
|
||||
if (guessedEVs[i]) buf += '' + guessedEVs[i]+' ' + BattleStatNames[i] + ' / ';
|
||||
if (guessedEVs[i]) buf += '' + guessedEVs[i] + ' ' + BattleStatNames[i] + ' / ';
|
||||
}
|
||||
buf += ' (+' + BattleStatNames[guessedPlus] + ', -' + BattleStatNames[guessedMinus] + ')</button></p>';
|
||||
//buf += ' <small>(' + role + ' | bulk: phys ' + Math.round(this.moveCount.physicalBulk/1000) + ' + spec ' + Math.round(this.moveCount.specialBulk/1000) + ' = ' + Math.round(this.moveCount.bulk/1000) + ')</small>';
|
||||
|
|
@ -1121,11 +1123,11 @@
|
|||
buf += '<div class="col graphcol"><div></div>';
|
||||
for (var i in stats) {
|
||||
stats[i] = this.getStat(i);
|
||||
var width = stats[i]*180/504;
|
||||
if (i=='hp') width = Math.floor(stats[i]*180/704);
|
||||
var width = stats[i] * 180 / 504;
|
||||
if (i == 'hp') width = Math.floor(stats[i] * 180 / 704);
|
||||
if (width > 179) width = 179;
|
||||
var color = Math.floor(stats[i]*180/714);
|
||||
if (color>360) color = 360;
|
||||
var color = Math.floor(stats[i] * 180 / 714);
|
||||
if (color > 360) color = 360;
|
||||
buf += '<div><em><span style="width:' + Math.floor(width) + 'px;background:hsl(' + color + ',85%,45%);border-color:hsl(' + color + ',85%,35%)"></span></em></div>';
|
||||
}
|
||||
buf += '<div><em>Remaining:</em></div>';
|
||||
|
|
@ -1136,10 +1138,10 @@
|
|||
this.plus = '';
|
||||
this.minus = '';
|
||||
for (var i in stats) {
|
||||
var width = stats[i]*200/504;
|
||||
if (i=='hp') width = stats[i]*200/704;
|
||||
var width = stats[i] * 200 / 504;
|
||||
if (i == 'hp') width = stats[i] * 200 / 704;
|
||||
if (width > 200) width = 200;
|
||||
var val = '' + (set.evs[i]||'');
|
||||
var val = '' + (set.evs[i] || '');
|
||||
if (nature.plus === i) {
|
||||
val += '+';
|
||||
this.plus = i;
|
||||
|
|
@ -1149,18 +1151,18 @@
|
|||
this.minus = i;
|
||||
}
|
||||
buf += '<div><input type="text" name="stat-' + i + '" value="' + val + '" class="inputform numform" /></div>';
|
||||
totalev += (set.evs[i]||0);
|
||||
totalev += (set.evs[i] || 0);
|
||||
}
|
||||
if (totalev <= 510) {
|
||||
buf += '<div class="totalev"><em>' + (totalev>508?0:508-totalev) + '</em></div>';
|
||||
buf += '<div class="totalev"><em>' + (totalev > 508 ? 0 : 508 - totalev) + '</em></div>';
|
||||
} else {
|
||||
buf += '<div class="totalev"><b>' + (510-totalev) + '</b></div>';
|
||||
buf += '<div class="totalev"><b>' + (510 - totalev) + '</b></div>';
|
||||
}
|
||||
buf += '</div>';
|
||||
|
||||
buf += '<div class="col evslidercol"><div></div>';
|
||||
for (var i in stats) {
|
||||
buf += '<div><input type="slider" name="evslider-' + i + '" value="' + (set.evs[i]||'0') + '" min="0" max="252" step="4" class="evslider" /></div>';
|
||||
buf += '<div><input type="slider" name="evslider-' + i + '" value="' + (set.evs[i] || '0') + '" min="0" max="252" step="4" class="evslider" /></div>';
|
||||
}
|
||||
buf += '</div>';
|
||||
|
||||
|
|
@ -1183,9 +1185,9 @@
|
|||
buf += '<p style="clear:both">Nature: <select name="nature">';
|
||||
for (var i in BattleNatures) {
|
||||
var curNature = BattleNatures[i];
|
||||
buf += '<option value="' + i + '"' + (curNature===nature?'selected="selected"':'') + '>' + i;
|
||||
buf += '<option value="' + i + '"' + (curNature === nature ? 'selected="selected"' : '') + '>' + i;
|
||||
if (curNature.plus) {
|
||||
buf += ' (+' + BattleStatNames[curNature.plus]+', -' + BattleStatNames[curNature.minus] + ')';
|
||||
buf += ' (+' + BattleStatNames[curNature.plus] + ', -' + BattleStatNames[curNature.minus] + ')';
|
||||
}
|
||||
buf += '</option>';
|
||||
}
|
||||
|
|
@ -1217,7 +1219,7 @@
|
|||
},
|
||||
setSlider: function (stat, val) {
|
||||
this.suppressSliderCallback = true;
|
||||
this.$chart.find('input[name=evslider-' + stat + ']').slider('value', val||0);
|
||||
this.$chart.find('input[name=evslider-' + stat + ']').slider('value', val || 0);
|
||||
this.suppressSliderCallback = false;
|
||||
},
|
||||
updateNature: function () {
|
||||
|
|
@ -1242,20 +1244,20 @@
|
|||
var set = this.curSet;
|
||||
if (!set) return;
|
||||
|
||||
if (inputName.substr(0,5) === 'stat-') {
|
||||
if (inputName.substr(0, 5) === 'stat-') {
|
||||
// EV
|
||||
// Handle + and -
|
||||
var stat = inputName.substr(5);
|
||||
if (!set.evs) set.evs = {};
|
||||
|
||||
var lastchar = e.currentTarget.value.charAt(e.target.value.length-1);
|
||||
var lastchar = e.currentTarget.value.charAt(e.target.value.length - 1);
|
||||
var firstchar = e.currentTarget.value.charAt(0);
|
||||
var natureChange = true;
|
||||
if ((lastchar === '+' || firstchar === '+') && stat !== 'hp') {
|
||||
if (this.plus && this.plus !== stat) this.$chart.find('input[name=stat-' + this.plus + ']').val(set.evs[this.plus]||'');
|
||||
if (this.plus && this.plus !== stat) this.$chart.find('input[name=stat-' + this.plus + ']').val(set.evs[this.plus] || '');
|
||||
this.plus = stat;
|
||||
} else if ((lastchar === '-' || lastchar === "\u2212" || firstchar === '-' || firstchar === "\u2212") && stat !== 'hp') {
|
||||
if (this.minus && this.minus !== stat) this.$chart.find('input[name=stat-' + this.minus + ']').val(set.evs[this.minus]||'');
|
||||
if (this.minus && this.minus !== stat) this.$chart.find('input[name=stat-' + this.minus + ']').val(set.evs[this.minus] || '');
|
||||
this.minus = stat;
|
||||
} else if (this.plus === stat) {
|
||||
this.plus = '';
|
||||
|
|
@ -1301,7 +1303,7 @@
|
|||
if (!this.ignoreEVLimits && set.evs) {
|
||||
var total = 0;
|
||||
for (var i in set.evs) {
|
||||
total += (i===stat?val:set.evs[i]);
|
||||
total += (i === stat ? val : set.evs[i]);
|
||||
}
|
||||
if (total > 508 && val - total + 508 >= 0) {
|
||||
// don't allow dragging beyond 508 EVs
|
||||
|
|
@ -1321,7 +1323,7 @@
|
|||
if (!set.evs) set.evs = {};
|
||||
set.evs[stat] = val;
|
||||
|
||||
val = '' + (val||'') + (this.plus===stat?'+':'')+(this.minus===stat?'-':'');
|
||||
val = '' + (val || '') + (this.plus === stat ? '+' : '') + (this.minus === stat ? '-' : '');
|
||||
this.$('input[name=stat-' + stat + ']').val(val);
|
||||
|
||||
this.updateStatGraph();
|
||||
|
|
@ -1335,9 +1337,9 @@
|
|||
}
|
||||
this.plus = '';
|
||||
this.minus = '';
|
||||
var nature = BattleNatures[set.nature||'Serious'];
|
||||
var nature = BattleNatures[set.nature || 'Serious'];
|
||||
for (var i in BattleStatNames) {
|
||||
var val = '' + (set.evs[i]||'');
|
||||
var val = '' + (set.evs[i] || '');
|
||||
if (nature.plus === i) {
|
||||
this.plus = i;
|
||||
val += '+';
|
||||
|
|
@ -1366,24 +1368,24 @@
|
|||
buf += '<h3>Details</h3>';
|
||||
buf += '<form class="detailsform">';
|
||||
|
||||
buf += '<div class="formrow"><label class="formlabel">Level:</label><div><input type="number" min="1" max="100" step="1" name="level" value="' + (set.level||100) + '" class="textbox inputform numform" /></div></div>';
|
||||
buf += '<div class="formrow"><label class="formlabel">Level:</label><div><input type="number" min="1" max="100" step="1" name="level" value="' + (set.level || 100) + '" class="textbox inputform numform" /></div></div>';
|
||||
|
||||
buf += '<div class="formrow"><label class="formlabel">Gender:</label><div>';
|
||||
if (template.gender) {
|
||||
var genderTable = {'M': "Male", 'F': "Female", 'N': "Genderless"};
|
||||
buf += genderTable[template.gender];
|
||||
} else {
|
||||
buf += '<label><input type="radio" name="gender" value="M"' + (set.gender==='M'?' checked':'') + ' /> Male</label> ';
|
||||
buf += '<label><input type="radio" name="gender" value="F"' + (set.gender==='F'?' checked':'') + ' /> Female</label> ';
|
||||
buf += '<label><input type="radio" name="gender" value="N"' + (!set.gender?' checked':'') + ' /> Random</label>';
|
||||
buf += '<label><input type="radio" name="gender" value="M"' + (set.gender === 'M' ? ' checked' : '') + ' /> Male</label> ';
|
||||
buf += '<label><input type="radio" name="gender" value="F"' + (set.gender === 'F' ? ' checked' : '') + ' /> Female</label> ';
|
||||
buf += '<label><input type="radio" name="gender" value="N"' + (!set.gender ? ' checked' : '') + ' /> Random</label>';
|
||||
}
|
||||
buf += '</div></div>';
|
||||
|
||||
buf += '<div class="formrow"><label class="formlabel">Happiness:</label><div><input type="number" min="0" max="255" step="1" name="happiness" value="' + (typeof set.happiness==='number'?set.happiness:255) + '" class="textbox inputform numform" /></div></div>';
|
||||
buf += '<div class="formrow"><label class="formlabel">Happiness:</label><div><input type="number" min="0" max="255" step="1" name="happiness" value="' + (typeof set.happiness === 'number' ? set.happiness : 255) + '" class="textbox inputform numform" /></div></div>';
|
||||
|
||||
buf += '<div class="formrow"><label class="formlabel">Shiny:</label><div>';
|
||||
buf += '<label><input type="radio" name="shiny" value="yes"' + (set.shiny?' checked':'') + ' /> Yes</label> ';
|
||||
buf += '<label><input type="radio" name="shiny" value="no"' + (!set.shiny?' checked':'') + ' /> No</label>';
|
||||
buf += '<label><input type="radio" name="shiny" value="yes"' + (set.shiny ? ' checked' : '') + ' /> Yes</label> ';
|
||||
buf += '<label><input type="radio" name="shiny" value="no"' + (!set.shiny ? ' checked' : '') + ' /> No</label>';
|
||||
buf += '</div></div>';
|
||||
|
||||
buf += '</form>';
|
||||
|
|
@ -1394,12 +1396,12 @@
|
|||
if (!set) return;
|
||||
|
||||
// level
|
||||
var level = parseInt(this.$chart.find('input[name=level]').val(),10);
|
||||
var level = parseInt(this.$chart.find('input[name=level]').val(), 10);
|
||||
if (!level || level > 100 || level < 1) level = 100;
|
||||
if (level !== 100 || set.level) set.level = level;
|
||||
|
||||
// happiness
|
||||
var happiness = parseInt(this.$chart.find('input[name=happiness]').val(),10);
|
||||
var happiness = parseInt(this.$chart.find('input[name=happiness]').val(), 10);
|
||||
if (happiness > 255) happiness = 255;
|
||||
if (happiness < 0) happiness = 255;
|
||||
set.happiness = happiness;
|
||||
|
|
@ -1427,10 +1429,10 @@
|
|||
'F': 'Female',
|
||||
'N': '—'
|
||||
};
|
||||
buf += '<span class="detailcell detailcell-first"><label>Level</label>' + (set.level||100) + '</span>';
|
||||
buf += '<span class="detailcell"><label>Gender</label>' + GenderChart[set.gender||'N'] + '</span>';
|
||||
buf += '<span class="detailcell"><label>Happiness</label>' + (typeof set.happiness==='number'?set.happiness:255) + '</span>';
|
||||
buf += '<span class="detailcell"><label>Shiny</label>' + (set.shiny?'Yes':'No') + '</span>';
|
||||
buf += '<span class="detailcell detailcell-first"><label>Level</label>' + (set.level || 100) + '</span>';
|
||||
buf += '<span class="detailcell"><label>Gender</label>' + GenderChart[set.gender || 'N'] + '</span>';
|
||||
buf += '<span class="detailcell"><label>Happiness</label>' + (typeof set.happiness === 'number' ? set.happiness : 255) + '</span>';
|
||||
buf += '<span class="detailcell"><label>Shiny</label>' + (set.shiny ? 'Yes' : 'No') + '</span>';
|
||||
this.$('button[name=details]').html(buf);
|
||||
|
||||
this.save();
|
||||
|
|
@ -1613,7 +1615,7 @@
|
|||
chooseMove: function (move) {
|
||||
var set = this.curSet;
|
||||
if (!set) return;
|
||||
if (move.substr(0,13) === 'Hidden Power ') {
|
||||
if (move.substr(0, 13) === 'Hidden Power ') {
|
||||
set.ivs = {};
|
||||
for (var i in exports.BattleTypeChart[move.substr(13)].HPivs) {
|
||||
set.ivs[i] = exports.BattleTypeChart[move.substr(13)].HPivs[i];
|
||||
|
|
@ -1626,7 +1628,7 @@
|
|||
var hasHiddenPower = false;
|
||||
var moves = this.curSet.moves;
|
||||
for (var i = 0; i < moves.length; ++i) {
|
||||
if (moves[i].substr(0,13) === 'Hidden Power ') hasHiddenPower = true;
|
||||
if (moves[i].substr(0, 13) === 'Hidden Power ') hasHiddenPower = true;
|
||||
}
|
||||
set.ivs['spe'] = hasHiddenPower ? set.ivs['spe'] % 4 : 0;
|
||||
} else if (move === 'Return') {
|
||||
|
|
@ -1694,7 +1696,7 @@
|
|||
|
||||
if (set.moves.length < 4 && template.id !== 'unown' && template.id !== 'ditto') return '?';
|
||||
|
||||
for (var i=0,len=set.moves.length; i<len; i++) {
|
||||
for (var i = 0, len = set.moves.length; i < len; i++) {
|
||||
var move = Tools.getMove(set.moves[i]);
|
||||
hasMove[move.id] = 1;
|
||||
if (move.category === 'Status') {
|
||||
|
|
@ -1749,8 +1751,8 @@
|
|||
if (hasMove['dragondance'] || hasMove['quiverdance']) moveCount['Ultrafast'] = 1;
|
||||
|
||||
var isFast = (stats.spe > 95);
|
||||
var physicalBulk = (stats.hp+75)*(stats.def+87);
|
||||
var specialBulk = (stats.hp+75)*(stats.spd+87);
|
||||
var physicalBulk = (stats.hp + 75) * (stats.def + 87);
|
||||
var specialBulk = (stats.hp + 75) * (stats.spd + 87);
|
||||
|
||||
if (hasMove['willowisp'] || hasMove['acidarmor'] || hasMove['irondefense'] || hasMove['cottonguard']) {
|
||||
physicalBulk *= 1.6;
|
||||
|
|
@ -1799,17 +1801,17 @@
|
|||
specialBulk *= 1.15;
|
||||
}
|
||||
if (itemid === 'leftovers' || itemid === 'blacksludge') {
|
||||
physicalBulk *= 1 + 0.1*(1+moveCount['Stall']/1.5);
|
||||
specialBulk *= 1 + 0.1*(1+moveCount['Stall']/1.5);
|
||||
physicalBulk *= 1 + 0.1 * (1 + moveCount['Stall'] / 1.5);
|
||||
specialBulk *= 1 + 0.1 * (1 + moveCount['Stall'] / 1.5);
|
||||
}
|
||||
if (hasMove['leechseed']) {
|
||||
physicalBulk *= 1 + 0.1*(1+moveCount['Stall']/1.5);
|
||||
specialBulk *= 1 + 0.1*(1+moveCount['Stall']/1.5);
|
||||
physicalBulk *= 1 + 0.1 * (1 + moveCount['Stall'] / 1.5);
|
||||
specialBulk *= 1 + 0.1 * (1 + moveCount['Stall'] / 1.5);
|
||||
}
|
||||
if ((itemid === 'flameorb' || itemid === 'toxicorb') && abilityid !== 'magicguard') {
|
||||
if (itemid === 'toxicorb' && abilityid === 'poisonheal') {
|
||||
physicalBulk *= 1 + 0.1*(2+moveCount['Stall']);
|
||||
specialBulk *= 1 + 0.1*(2+moveCount['Stall']);
|
||||
physicalBulk *= 1 + 0.1 * (2 + moveCount['Stall']);
|
||||
specialBulk *= 1 + 0.1 * (2 + moveCount['Stall']);
|
||||
} else {
|
||||
physicalBulk *= 0.8;
|
||||
specialBulk *= 0.8;
|
||||
|
|
@ -1845,12 +1847,12 @@
|
|||
moveCount['Ultrafast'] = 2;
|
||||
}
|
||||
if (hasMove['agility'] || hasMove['shellsmash'] || hasMove['autotomize'] || hasMove['shiftgear'] || hasMove['rockpolish']) moveCount['Ultrafast'] = 2;
|
||||
moveCount['Fast'] = isFast?1:0;
|
||||
moveCount['Fast'] = isFast ? 1 : 0;
|
||||
|
||||
this.moveCount = moveCount;
|
||||
this.hasMove = hasMove;
|
||||
|
||||
if (template.id === 'ditto') return abilityid==='imposter'?'Physically Defensive':'Fast Bulky Support';
|
||||
if (template.id === 'ditto') return abilityid === 'imposter' ? 'Physically Defensive' : 'Fast Bulky Support';
|
||||
if (template.id === 'shedinja') return 'Fast Physical Sweeper';
|
||||
|
||||
if (itemid === 'choiceband' && moveCount['PhysicalAttack'] >= 2) {
|
||||
|
|
@ -1882,9 +1884,9 @@
|
|||
else if (stats.spa > stats.atk && moveCount['Special'] > 1) offenseBias = 'Special';
|
||||
else if (moveCount['Special'] > moveCount['Physical']) offenseBias = 'Special';
|
||||
else offenseBias = 'Physical';
|
||||
var offenseStat = stats[offenseBias === 'Special'?'spa':'atk'];
|
||||
var offenseStat = stats[offenseBias === 'Special' ? 'spa' : 'atk'];
|
||||
|
||||
if (moveCount['Stall'] + moveCount['Support']/2 <= 2 && bulk < 135000 && moveCount[offenseBias] >= 1.5) {
|
||||
if (moveCount['Stall'] + moveCount['Support'] / 2 <= 2 && bulk < 135000 && moveCount[offenseBias] >= 1.5) {
|
||||
if (isFast) {
|
||||
if (bulk > 80000 && !moveCount['Ultrafast']) return 'Bulky ' + offenseBias + ' Sweeper';
|
||||
return 'Fast ' + offenseBias + ' Sweeper';
|
||||
|
|
@ -1917,7 +1919,7 @@
|
|||
diff -= change;
|
||||
}
|
||||
if (diff <= 0) return evTotal;
|
||||
var evPriority = {def:1, spd:1, hp:1, atk:1, spa:1, spe:1};
|
||||
var evPriority = {def: 1, spd: 1, hp: 1, atk: 1, spa: 1, spe: 1};
|
||||
for (var i in evPriority) {
|
||||
if (i === stat) continue;
|
||||
if (evs[i] && evs[i] > 128) {
|
||||
|
|
@ -1991,25 +1993,25 @@
|
|||
var evTotal = 0;
|
||||
|
||||
var i = statChart[role][0];
|
||||
var stat = this.getStat(i, null, 252, plusStat===i?1.1:1.0);
|
||||
var stat = this.getStat(i, null, 252, plusStat === i ? 1.1 : 1.0);
|
||||
var ev = 252;
|
||||
while (stat <= this.getStat(i, null, ev-4, plusStat===i?1.1:1.0)) ev -= 4;
|
||||
while (stat <= this.getStat(i, null, ev - 4, plusStat === i ? 1.1 : 1.0)) ev -= 4;
|
||||
evs[i] = ev;
|
||||
evTotal += ev;
|
||||
|
||||
var i = statChart[role][1];
|
||||
if (i === 'hp' && set.level && set.level < 20) i = 'spd';
|
||||
var stat = this.getStat(i, null, 252, plusStat===i?1.1:1.0);
|
||||
var stat = this.getStat(i, null, 252, plusStat === i ? 1.1 : 1.0);
|
||||
var ev = 252;
|
||||
if (i === 'hp' && (hasMove['substitute'] || hasMove['transform']) && stat == Math.floor(stat/4)*4) stat -= 1;
|
||||
while (stat <= this.getStat(i, null, ev-4, plusStat===i?1.1:1.0)) ev -= 4;
|
||||
if (i === 'hp' && (hasMove['substitute'] || hasMove['transform']) && stat == Math.floor(stat / 4) * 4) stat -= 1;
|
||||
while (stat <= this.getStat(i, null, ev - 4, plusStat === i ? 1.1 : 1.0)) ev -= 4;
|
||||
if (ev < 0) ev = 0;
|
||||
evs[i] = ev;
|
||||
evTotal += ev;
|
||||
|
||||
if (set.item !== 'Leftovers' && set.item !== 'Black Sludge') {
|
||||
var hpParity = 1; // 1 = should be odd, 0 = should be even
|
||||
if ((hasMove['substitute'] || hasMove['bellydrum']) && (set.item||'').slice(-5) === 'Berry') {
|
||||
if ((hasMove['substitute'] || hasMove['bellydrum']) && (set.item || '').slice(-5) === 'Berry') {
|
||||
hpParity = 0;
|
||||
}
|
||||
if (this.getStat('hp', null, evs['hp'] || 0, 1) % 2 != hpParity) {
|
||||
|
|
@ -2066,7 +2068,7 @@
|
|||
}
|
||||
|
||||
if (plusStat === minusStat) {
|
||||
minusStat = (plusStat==='spe' ? 'spd' : 'spe');
|
||||
minusStat = (plusStat === 'spe' ? 'spd' : 'spe');
|
||||
}
|
||||
|
||||
evs.plusStat = plusStat;
|
||||
|
|
@ -2108,9 +2110,9 @@
|
|||
|
||||
if (stat === 'hp') {
|
||||
if (template.baseStats['hp'] === 1) return 1;
|
||||
return Math.floor(Math.floor(2*template.baseStats['hp']+(set.ivs['hp']||0)+Math.floor((evOverride||set.evs['hp']||0)/4)+100)*set.level / 100 + 10);
|
||||
return Math.floor(Math.floor(2 * template.baseStats['hp'] + (set.ivs['hp'] || 0) + Math.floor((evOverride || set.evs['hp'] || 0) / 4) + 100) * set.level / 100 + 10);
|
||||
}
|
||||
var val = Math.floor(Math.floor(2*template.baseStats[stat]+(set.ivs[stat]||0)+Math.floor((evOverride||set.evs[stat]||0)/4))*set.level / 100 + 5);
|
||||
var val = Math.floor(Math.floor(2 * template.baseStats[stat] + (set.ivs[stat] || 0) + Math.floor((evOverride || set.evs[stat] || 0) / 4)) * set.level / 100 + 5);
|
||||
if (natureOverride) {
|
||||
val *= natureOverride;
|
||||
} else if (BattleNatures[set.nature] && BattleNatures[set.nature].plus === stat) {
|
||||
|
|
@ -2174,14 +2176,14 @@
|
|||
var buf = '<ul class="popupmenu">';
|
||||
this.i = data.i;
|
||||
this.team = data.team;
|
||||
for (var i=0; i<data.team.length; i++) {
|
||||
for (var i = 0; i < data.team.length; i++) {
|
||||
var set = data.team[i];
|
||||
if (i !== data.i && i !== data.i+1) {
|
||||
if (i !== data.i && i !== data.i + 1) {
|
||||
buf += '<li><button name="moveHere" value="' + i + '"><i class="icon-arrow-right"></i> Move here</button></li>';
|
||||
}
|
||||
buf += '<li' + (i===data.i?' style="opacity:.3"':' style="opacity:.6"') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(set) + '"></span> ' + Tools.escapeHTML(set.name) + '</li>';
|
||||
buf += '<li' + (i === data.i ? ' style="opacity:.3"' : ' style="opacity:.6"') + '><span class="pokemonicon" style="display:inline-block;vertical-align:middle;' + Tools.getIcon(set) + '"></span> ' + Tools.escapeHTML(set.name) + '</li>';
|
||||
}
|
||||
if (i !== data.i && i !== data.i+1) {
|
||||
if (i !== data.i && i !== data.i + 1) {
|
||||
buf += '<li><button name="moveHere" value="' + i + '"><i class="icon-arrow-right"></i> Move here</button></li>';
|
||||
}
|
||||
buf += '</ul>';
|
||||
|
|
|
|||
158
js/client.js
158
js/client.js
|
|
@ -569,7 +569,7 @@
|
|||
document.location.pathname);
|
||||
} */
|
||||
// Renew the `showdown_ssl` cookie.
|
||||
$.cookie('showdown_ssl', 1, {expires: 365*3});
|
||||
$.cookie('showdown_ssl', 1, {expires: 365 * 3});
|
||||
} else if (!$.cookie('showdown_ssl')) {
|
||||
// localStorage is currently located on the HTTP origin.
|
||||
|
||||
|
|
@ -594,7 +594,7 @@
|
|||
} else if (e.data === 'done') {
|
||||
// Set a cookie to indicate that localStorage is now under
|
||||
// the HTTPS origin.
|
||||
$.cookie('showdown_ssl', 1, {expires: 365*3});
|
||||
$.cookie('showdown_ssl', 1, {expires: 365 * 3});
|
||||
localStorage.clear();
|
||||
return document.location.replace('https://' + document.location.hostname +
|
||||
document.location.pathname);
|
||||
|
|
@ -668,7 +668,7 @@
|
|||
return function ($e) {
|
||||
var e = $e.originalEvent;
|
||||
if ((e.origin === 'http://' + Config.origindomain) ||
|
||||
(e.origin === 'https://' + Config.origindomain)) {
|
||||
(e.origin === 'https://' + Config.origindomain)) {
|
||||
origin = e.origin;
|
||||
} else {
|
||||
return; // unauthorised source origin
|
||||
|
|
@ -794,7 +794,7 @@
|
|||
if (self.sendQueue) {
|
||||
var queue = self.sendQueue;
|
||||
delete self.sendQueue;
|
||||
for (var i=0; i<queue.length; i++) {
|
||||
for (var i = 0; i < queue.length; i++) {
|
||||
self.send(queue[i], true);
|
||||
}
|
||||
}
|
||||
|
|
@ -885,13 +885,13 @@
|
|||
receive: function (data) {
|
||||
var roomid = '';
|
||||
var autojoined = false;
|
||||
if (data.substr(0,1) === '>') {
|
||||
if (data.substr(0, 1) === '>') {
|
||||
var nlIndex = data.indexOf('\n');
|
||||
if (nlIndex < 0) return;
|
||||
roomid = toRoomid(data.substr(1,nlIndex-1));
|
||||
data = data.substr(nlIndex+1);
|
||||
roomid = toRoomid(data.substr(1, nlIndex - 1));
|
||||
data = data.substr(nlIndex + 1);
|
||||
}
|
||||
if (data.substr(0,6) === '|init|') {
|
||||
if (data.substr(0, 6) === '|init|') {
|
||||
if (!roomid) roomid = 'lobby';
|
||||
var roomType = data.substr(6);
|
||||
var roomTypeLFIndex = roomType.indexOf('\n');
|
||||
|
|
@ -904,14 +904,14 @@
|
|||
this.joinRoom(roomid, roomType, true);
|
||||
}
|
||||
if (roomType === 'chat') autojoined = true;
|
||||
} else if ((data + '|').substr(0,8) === '|expire|') {
|
||||
} else if ((data + '|').substr(0, 8) === '|expire|') {
|
||||
var room = this.rooms[roomid];
|
||||
if (room) {
|
||||
room.expired = true;
|
||||
if (room.updateUser) room.updateUser();
|
||||
}
|
||||
return;
|
||||
} else if ((data + '|').substr(0,8) === '|deinit|' || (data + '|').substr(0,8) === '|noinit|') {
|
||||
} else if ((data + '|').substr(0, 8) === '|deinit|' || (data + '|').substr(0, 8) === '|noinit|') {
|
||||
if (!roomid) roomid = 'lobby';
|
||||
|
||||
if (this.rooms[roomid] && this.rooms[roomid].expired) {
|
||||
|
|
@ -924,7 +924,7 @@
|
|||
var pipeIndex = data.indexOf('|');
|
||||
var errormessage;
|
||||
if (pipeIndex >= 0) {
|
||||
errormessage = data.substr(pipeIndex+1);
|
||||
errormessage = data.substr(pipeIndex + 1);
|
||||
data = data.substr(0, pipeIndex);
|
||||
}
|
||||
// handle error codes here
|
||||
|
|
@ -990,7 +990,7 @@
|
|||
case 'updateuser':
|
||||
var nlIndex = data.indexOf('\n');
|
||||
if (nlIndex > 0) {
|
||||
this.receive(data.substr(nlIndex+1));
|
||||
this.receive(data.substr(nlIndex + 1));
|
||||
nlIndex = parts[3].indexOf('\n');
|
||||
parts[3] = parts[3].substr(0, nlIndex);
|
||||
}
|
||||
|
|
@ -1013,7 +1013,7 @@
|
|||
break;
|
||||
|
||||
case 'queryresponse':
|
||||
var responseData = JSON.parse(data.substr(16+parts[1].length));
|
||||
var responseData = JSON.parse(data.substr(16 + parts[1].length));
|
||||
app.trigger('response:' + parts[1], responseData);
|
||||
break;
|
||||
|
||||
|
|
@ -1098,7 +1098,7 @@
|
|||
var columnChanged = false;
|
||||
|
||||
BattleFormats = {};
|
||||
for (var j=1; j<formatsList.length; j++) {
|
||||
for (var j = 1; j < formatsList.length; j++) {
|
||||
if (isSection) {
|
||||
section = formatsList[j];
|
||||
isSection = false;
|
||||
|
|
@ -1117,23 +1117,23 @@
|
|||
var challengeShow = true;
|
||||
var team = null;
|
||||
var name = formatsList[j];
|
||||
if (name.substr(name.length-2) === ',#') { // preset teams
|
||||
if (name.substr(name.length - 2) === ',#') { // preset teams
|
||||
team = 'preset';
|
||||
name = name.substr(0,name.length-2);
|
||||
name = name.substr(0, name.length - 2);
|
||||
}
|
||||
if (name.substr(name.length-2) === ',,') { // search-only
|
||||
if (name.substr(name.length - 2) === ',,') { // search-only
|
||||
challengeShow = false;
|
||||
name = name.substr(0,name.length-2);
|
||||
} else if (name.substr(name.length-1) === ',') { // challenge-only
|
||||
name = name.substr(0, name.length - 2);
|
||||
} else if (name.substr(name.length - 1) === ',') { // challenge-only
|
||||
searchShow = false;
|
||||
name = name.substr(0,name.length-1);
|
||||
name = name.substr(0, name.length - 1);
|
||||
}
|
||||
var id = toId(name);
|
||||
var isTeambuilderFormat = searchShow && !team;
|
||||
var teambuilderFormat = '';
|
||||
if (isTeambuilderFormat) {
|
||||
var parenPos = name.indexOf('(');
|
||||
if (parenPos > 0 && name.charAt(name.length-1) === ')') {
|
||||
if (parenPos > 0 && name.charAt(name.length - 1) === ')') {
|
||||
// variation of existing tier
|
||||
teambuilderFormat = toId(name.substr(0, parenPos));
|
||||
if (BattleFormats[teambuilderFormat]) {
|
||||
|
|
@ -1164,7 +1164,7 @@
|
|||
column: column,
|
||||
searchShow: searchShow,
|
||||
challengeShow: challengeShow,
|
||||
rated: searchShow && id.substr(0,7) !== 'unrated',
|
||||
rated: searchShow && id.substr(0, 7) !== 'unrated',
|
||||
teambuilderFormat: teambuilderFormat,
|
||||
isTeambuilderFormat: isTeambuilderFormat,
|
||||
effectType: 'Format'
|
||||
|
|
@ -1223,12 +1223,12 @@
|
|||
resize: function () {
|
||||
if (window.screen && screen.width && screen.width >= 640) {
|
||||
if (this.fixedWidth) {
|
||||
document.getElementById('viewport').setAttribute('content','width=device-width');
|
||||
document.getElementById('viewport').setAttribute('content', 'width=device-width');
|
||||
this.fixedWidth = false;
|
||||
}
|
||||
} else {
|
||||
if (!this.fixedWidth) {
|
||||
document.getElementById('viewport').setAttribute('content','width=640');
|
||||
document.getElementById('viewport').setAttribute('content', 'width=640');
|
||||
this.fixedWidth = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1325,7 +1325,7 @@
|
|||
|
||||
// otherwise, infer the room type
|
||||
if (!type) {
|
||||
if (id.substr(0,7) === 'battle-') {
|
||||
if (id.substr(0, 7) === 'battle-') {
|
||||
type = BattleRoom;
|
||||
} else {
|
||||
type = ChatRoom;
|
||||
|
|
@ -1535,7 +1535,7 @@
|
|||
}
|
||||
if (this.dismissingSource && $(data.sourceEl)[0] === this.dismissingSource) return;
|
||||
while (this.popups.length) {
|
||||
var prevPopup = this.popups[this.popups.length-1];
|
||||
var prevPopup = this.popups[this.popups.length - 1];
|
||||
if (data.sourcePopup === prevPopup) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -1576,7 +1576,7 @@
|
|||
addPopupPrompt: function (message, buttonOrCallback, callback) {
|
||||
var button = (callback ? buttonOrCallback : 'OK');
|
||||
callback = (!callback ? buttonOrCallback : callback);
|
||||
app.addPopup(PromptPopup, { message: message, button: button, callback: callback });
|
||||
app.addPopup(PromptPopup, {message: message, button: button, callback: callback});
|
||||
},
|
||||
closePopup: function (id) {
|
||||
if (this.popups.length) {
|
||||
|
|
@ -1590,7 +1590,7 @@
|
|||
dismissPopups: function () {
|
||||
var source = false;
|
||||
while (this.popups.length) {
|
||||
var popup = this.popups[this.popups.length-1];
|
||||
var popup = this.popups[this.popups.length - 1];
|
||||
if (popup.type !== 'normal') return source;
|
||||
if (popup.sourceEl) source = popup.sourceEl[0];
|
||||
if (!source) source = true;
|
||||
|
|
@ -1624,9 +1624,9 @@
|
|||
var name = ' ' + app.user.get('name');
|
||||
var color = hashColor(app.user.get('userid'));
|
||||
if (app.user.get('named')) {
|
||||
buf = '<span class="username" data-name="' + Tools.escapeHTML(name) + '" style="' + color + '"><i class="icon-user" style="color:#779EC5"></i> ' + Tools.escapeHTML(name) + '</span> <button class="icon" name="openSounds"><i class="' + (Tools.prefs('mute')?'icon-volume-off':'icon-volume-up') + '"></i></button> <button class="icon" name="openOptions"><i class="icon-cog"></i></button>';
|
||||
buf = '<span class="username" data-name="' + Tools.escapeHTML(name) + '" style="' + color + '"><i class="icon-user" style="color:#779EC5"></i> ' + Tools.escapeHTML(name) + '</span> <button class="icon" name="openSounds"><i class="' + (Tools.prefs('mute') ? 'icon-volume-off' : 'icon-volume-up') + '"></i></button> <button class="icon" name="openOptions"><i class="icon-cog"></i></button>';
|
||||
} else {
|
||||
buf = '<button name="login">Choose name</button> <button class="icon" name="openSounds"><i class="' + (Tools.prefs('mute')?'icon-volume-off':'icon-volume-up') + '"></i></button> <button class="icon" name="openOptions"><i class="icon-cog"></i></button>';
|
||||
buf = '<button name="login">Choose name</button> <button class="icon" name="openSounds"><i class="' + (Tools.prefs('mute') ? 'icon-volume-off' : 'icon-volume-up') + '"></i></button> <button class="icon" name="openOptions"><i class="icon-cog"></i></button>';
|
||||
}
|
||||
this.$userbar.html(buf);
|
||||
},
|
||||
|
|
@ -1650,9 +1650,9 @@
|
|||
var curId = (app.curRoom ? app.curRoom.id : '');
|
||||
var curSideId = (app.curSideRoom ? app.curSideRoom.id : '');
|
||||
|
||||
var buf = '<ul><li><a class="button' + (curId===''?' cur':'') + (app.rooms['']&&app.rooms[''].notificationClass||'') + '" href="' + app.root + '"><i class="icon-home"></i> <span>Home</span></a></li>';
|
||||
if (app.rooms['teambuilder']) buf += '<li><a class="button' + (curId==='teambuilder'?' cur':'') + ' closable" href="' + app.root + 'teambuilder"><i class="icon-edit"></i> <span>Teambuilder</span></a><a class="closebutton" href="' + app.root + 'teambuilder"><i class="icon-remove-sign"></i></a></li>';
|
||||
if (app.rooms['ladder']) buf += '<li><a class="button' + (curId==='ladder'?' cur':'') + ' closable" href="' + app.root + 'ladder"><i class="icon-list-ol"></i> <span>Ladder</span></a><a class="closebutton" href="' + app.root + 'ladder"><i class="icon-remove-sign"></i></a></li>';
|
||||
var buf = '<ul><li><a class="button' + (curId === '' ? ' cur' : '') + (app.rooms[''] && app.rooms[''].notificationClass || '') + '" href="' + app.root + '"><i class="icon-home"></i> <span>Home</span></a></li>';
|
||||
if (app.rooms['teambuilder']) buf += '<li><a class="button' + (curId === 'teambuilder' ? ' cur' : '') + ' closable" href="' + app.root + 'teambuilder"><i class="icon-edit"></i> <span>Teambuilder</span></a><a class="closebutton" href="' + app.root + 'teambuilder"><i class="icon-remove-sign"></i></a></li>';
|
||||
if (app.rooms['ladder']) buf += '<li><a class="button' + (curId === 'ladder' ? ' cur' : '') + ' closable" href="' + app.root + 'ladder"><i class="icon-list-ol"></i> <span>Ladder</span></a><a class="closebutton" href="' + app.root + 'ladder"><i class="icon-remove-sign"></i></a></li>';
|
||||
buf += '</ul>';
|
||||
var atLeastOne = false;
|
||||
var sideBuf = '';
|
||||
|
|
@ -1669,8 +1669,8 @@
|
|||
if (app.rooms[id].notifications) notificationCount++;
|
||||
if (!id || id === 'teambuilder' || id === 'ladder') continue;
|
||||
var room = app.rooms[id];
|
||||
var name = '<i class="icon-comment-alt"></i> <span>' + (Tools.escapeHTML(room.title)||(id==='lobby'?'Lobby':id)) + '</span>';
|
||||
if (id.substr(0,7) === 'battle-') {
|
||||
var name = '<i class="icon-comment-alt"></i> <span>' + (Tools.escapeHTML(room.title) || (id === 'lobby' ? 'Lobby' : id)) + '</span>';
|
||||
if (id.substr(0, 7) === 'battle-') {
|
||||
name = Tools.escapeHTML(room.title);
|
||||
var formatid = id.substr(7).split('-')[0];
|
||||
if (!name) {
|
||||
|
|
@ -1688,7 +1688,7 @@
|
|||
}
|
||||
if (room.isSideRoom) {
|
||||
if (id !== 'rooms') {
|
||||
sideBuf += '<li><a class="button' + (curId===id||curSideId===id?' cur':'') + room.notificationClass + ' closable" href="' + app.root + id + '">' + name + '</a><a class="closebutton" href="' + app.root + id + '"><i class="icon-remove-sign"></i></a></li>';
|
||||
sideBuf += '<li><a class="button' + (curId === id || curSideId === id ? ' cur' : '') + room.notificationClass + ' closable" href="' + app.root + id + '">' + name + '</a><a class="closebutton" href="' + app.root + id + '"><i class="icon-remove-sign"></i></a></li>';
|
||||
if (curSideId) {
|
||||
// get left/right for side rooms
|
||||
if (curSideId === id) {
|
||||
|
|
@ -1715,7 +1715,7 @@
|
|||
buf += '<ul>';
|
||||
atLeastOne = true;
|
||||
}
|
||||
buf += '<li><a class="button' + (curId===id?' cur':'') + room.notificationClass + ' closable" href="' + app.root + id + '">' + name + '</a><a class="closebutton" href="' + app.root + id + '"><i class="icon-remove-sign"></i></a></li>';
|
||||
buf += '<li><a class="button' + (curId === id ? ' cur' : '') + room.notificationClass + ' closable" href="' + app.root + id + '">' + name + '</a><a class="closebutton" href="' + app.root + id + '"><i class="icon-remove-sign"></i></a></li>';
|
||||
// get left/right
|
||||
if (curId === id) {
|
||||
passedCurRoom = true;
|
||||
|
|
@ -1729,12 +1729,12 @@
|
|||
if (nwWindow.setBadgeLabel) nwWindow.setBadgeLabel(notificationCount || '');
|
||||
}
|
||||
if (app.supports['rooms']) {
|
||||
sideBuf += '<li><a class="button' + (curId==='rooms'||curSideId==='rooms'?' cur':'') + '" href="' + app.root + 'rooms"><i class="icon-plus" style="margin:7px auto -6px auto"></i> <span> </span></a></li>';
|
||||
sideBuf += '<li><a class="button' + (curId === 'rooms' || curSideId === 'rooms' ? ' cur' : '') + '" href="' + app.root + 'rooms"><i class="icon-plus" style="margin:7px auto -6px auto"></i> <span> </span></a></li>';
|
||||
}
|
||||
if (atLeastOne) buf += '</ul>';
|
||||
if (sideBuf) {
|
||||
if (app.curSideRoom) {
|
||||
buf += '<ul class="siderooms" style="float:none;margin-left:' + (app.curSideRoom.leftWidth-144) + 'px">' + sideBuf + '</ul>';
|
||||
buf += '<ul class="siderooms" style="float:none;margin-left:' + (app.curSideRoom.leftWidth - 144) + 'px">' + sideBuf + '</ul>';
|
||||
} else {
|
||||
buf += '<ul>' + sideBuf + '</ul>';
|
||||
}
|
||||
|
|
@ -1836,7 +1836,7 @@
|
|||
this.$el.css({left: 0, width: leftWidth, right: 'auto'});
|
||||
break;
|
||||
case 'right':
|
||||
this.$el.css({left: leftWidth+1, width: 'auto', right: 0});
|
||||
this.$el.css({left: leftWidth + 1, width: 'auto', right: 0});
|
||||
this.leftWidth = leftWidth;
|
||||
break;
|
||||
case 'full':
|
||||
|
|
@ -2069,7 +2069,7 @@
|
|||
if (this.position === 'right') {
|
||||
|
||||
if (room > offset.top + height + 5 &&
|
||||
(offset.top < room * 2/3 || offset.top + 200 < room)) {
|
||||
(offset.top < room * 2 / 3 || offset.top + 200 < room)) {
|
||||
$el.css('top', offset.top);
|
||||
} else {
|
||||
$el.css('bottom', Math.max(room - offset.top - sourceHeight, 0));
|
||||
|
|
@ -2079,7 +2079,7 @@
|
|||
} else {
|
||||
|
||||
if (room > offset.top + sourceHeight + height + 5 &&
|
||||
(offset.top + sourceHeight < room * 2/3 || offset.top + sourceHeight + 200 < room)) {
|
||||
(offset.top + sourceHeight < room * 2 / 3 || offset.top + sourceHeight + 200 < room)) {
|
||||
$el.css('top', offset.top + sourceHeight);
|
||||
} else if (height + 5 <= offset.top) {
|
||||
$el.css('bottom', Math.max(room - offset.top, 0));
|
||||
|
|
@ -2104,7 +2104,7 @@
|
|||
},
|
||||
initialize: function (data) {
|
||||
if (!this.type) this.type = 'semimodal';
|
||||
this.$el.html('<p style="white-space:pre-wrap;word-wrap:break-word">' + (data.htmlMessage||Tools.parseMessage(data.message)) + '</p><p class="buttonbar"><button name="close" class="autofocus"><strong>OK</strong></button></p>').css('max-width', data.maxWidth || 480);
|
||||
this.$el.html('<p style="white-space:pre-wrap;word-wrap:break-word">' + (data.htmlMessage || Tools.parseMessage(data.message)) + '</p><p class="buttonbar"><button name="close" class="autofocus"><strong>OK</strong></button></p>').css('max-width', data.maxWidth || 480);
|
||||
},
|
||||
|
||||
dispatchClickButton: function (e) {
|
||||
|
|
@ -2124,13 +2124,13 @@
|
|||
e.stopPropagation();
|
||||
var dataArray = $(e.currentTarget).serializeArray();
|
||||
var data = {};
|
||||
for (var i=0, len=dataArray.length; i<len; i++) {
|
||||
for (var i = 0, len = dataArray.length; i < len; i++) {
|
||||
var name = dataArray[i].name, value = dataArray[i].value;
|
||||
if (data[name]) {
|
||||
if (!data[name].push) data[name] = [data[name]];
|
||||
data[name].push(value||'');
|
||||
data[name].push(value || '');
|
||||
} else {
|
||||
data[name] = (value||'');
|
||||
data[name] = (value || '');
|
||||
}
|
||||
}
|
||||
this.submit(data);
|
||||
|
|
@ -2210,7 +2210,7 @@
|
|||
if (group || name.charAt(0) === ' ') name = name.substr(1);
|
||||
|
||||
var buf = '<div class="userdetails">';
|
||||
if (avatar) buf += '<img class="trainersprite' + (userid===app.user.get('userid')?' yours':'') + '" src="' + Tools.resolveAvatar(avatar) + '" />';
|
||||
if (avatar) buf += '<img class="trainersprite' + (userid === app.user.get('userid') ? ' yours' : '') + '" src="' + Tools.resolveAvatar(avatar) + '" />';
|
||||
buf += '<strong><a href="//pokemonshowdown.com/users/' + userid + '" target="_blank">' + Tools.escapeHTML(name) + '</a></strong><br />';
|
||||
buf += '<small>' + (group || ' ') + '</small>';
|
||||
if (data.rooms) {
|
||||
|
|
@ -2219,7 +2219,7 @@
|
|||
for (var i in data.rooms) {
|
||||
if (i === 'global') continue;
|
||||
var roomid = toRoomid(i);
|
||||
if (roomid.substr(0,7) === 'battle-') {
|
||||
if (roomid.substr(0, 7) === 'battle-') {
|
||||
var p1 = data.rooms[i].p1.substr(1);
|
||||
var p2 = data.rooms[i].p2.substr(1);
|
||||
if (!battlebuf) battlebuf = '<br /><em>Battles:</em> ';
|
||||
|
|
@ -2268,7 +2268,7 @@
|
|||
app.focusRoom('');
|
||||
app.rooms[''].focusPM(this.data.name);
|
||||
}
|
||||
},{
|
||||
}, {
|
||||
dataCache: {}
|
||||
});
|
||||
|
||||
|
|
@ -2477,9 +2477,9 @@
|
|||
initialize: function (data) {
|
||||
var buf = '';
|
||||
var muted = !!Tools.prefs('mute');
|
||||
buf += '<p class="effect-volume"><label class="optlabel">Effect volume:</label>' + (muted?'<em>(muted)</em>':'<input type="slider" name="effectvolume" value="' + (Tools.prefs('effectvolume')||50) + '" />') + '</p>';
|
||||
buf += '<p class="music-volume"><label class="optlabel">Music volume:</label>' + (muted?'<em>(muted)</em>':'<input type="slider" name="musicvolume" value="' + (Tools.prefs('musicvolume')||50) + '" />') + '</p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="muted"' + (muted?' checked':'') + ' /> Mute sounds</label></p>';
|
||||
buf += '<p class="effect-volume"><label class="optlabel">Effect volume:</label>' + (muted ? '<em>(muted)</em>' : '<input type="slider" name="effectvolume" value="' + (Tools.prefs('effectvolume') || 50) + '" />') + '</p>';
|
||||
buf += '<p class="music-volume"><label class="optlabel">Music volume:</label>' + (muted ? '<em>(muted)</em>' : '<input type="slider" name="musicvolume" value="' + (Tools.prefs('musicvolume') || 50) + '" />') + '</p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="muted"' + (muted ? ' checked' : '') + ' /> Mute sounds</label></p>';
|
||||
this.$el.html(buf).css('min-width', 160);
|
||||
},
|
||||
events: {
|
||||
|
|
@ -2514,15 +2514,15 @@
|
|||
BattleSound.setMute(muted);
|
||||
|
||||
if (!muted) {
|
||||
this.$('.effect-volume').html('<label class="optlabel">Effect volume:</label><input type="slider" name="effectvolume" value="' + (Tools.prefs('effectvolume')||50) + '" />');
|
||||
this.$('.music-volume').html('<label class="optlabel">Music volume:</label><input type="slider" name="musicvolume" value="' + (Tools.prefs('musicvolume')||50) + '" />');
|
||||
this.$('.effect-volume').html('<label class="optlabel">Effect volume:</label><input type="slider" name="effectvolume" value="' + (Tools.prefs('effectvolume') || 50) + '" />');
|
||||
this.$('.music-volume').html('<label class="optlabel">Music volume:</label><input type="slider" name="musicvolume" value="' + (Tools.prefs('musicvolume') || 50) + '" />');
|
||||
this.domInitialize();
|
||||
} else {
|
||||
this.$('.effect-volume').html('<label class="optlabel">Effect volume:</label><em>(muted)</em>');
|
||||
this.$('.music-volume').html('<label class="optlabel">Music volume:</label><em>(muted)</em>');
|
||||
}
|
||||
|
||||
app.topbar.$('button[name=openSounds]').html('<i class="' + (muted?'icon-volume-off':'icon-volume-up') + '"></i>');
|
||||
app.topbar.$('button[name=openSounds]').html('<i class="' + (muted ? 'icon-volume-off' : 'icon-volume-up') + '"></i>');
|
||||
},
|
||||
setEffectVolume: function (volume) {
|
||||
BattleSound.setEffectVolume(volume);
|
||||
|
|
@ -2559,32 +2559,32 @@
|
|||
var avatar = app.user.get('avatar');
|
||||
|
||||
var buf = '';
|
||||
buf += '<p>' + (avatar?'<img class="trainersprite" src="' + Tools.resolveAvatar(avatar) + '" width="40" height="40" style="vertical-align:middle" />':'') + '<strong>' + Tools.escapeHTML(name) + '</strong></p>';
|
||||
buf += '<p>' + (avatar ? '<img class="trainersprite" src="' + Tools.resolveAvatar(avatar) + '" width="40" height="40" style="vertical-align:middle" />' : '') + '<strong>' + Tools.escapeHTML(name) + '</strong></p>';
|
||||
buf += '<p><button name="avatars">Change avatar</button></p>';
|
||||
|
||||
buf += '<hr />';
|
||||
buf += '<p><label class="optlabel">Background: <select name="bg"><option value="">Charizards</option><option value="#344b6c url(/fx/client-bg-horizon.jpg) no-repeat left center fixed">Horizon</option><option value="#546bac url(/fx/client-bg-3.jpg) no-repeat left center fixed">Waterfall</option><option value="#546bac url(/fx/client-bg-ocean.jpg) no-repeat left center fixed">Ocean</option><option value="#344b6c">Solid blue</option><option value="custom">Custom</option>' + (Tools.prefs('bg')?'<option value="" selected></option>':'') + '</select></label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="noanim"' + (Tools.prefs('noanim')?' checked':'') + ' /> Disable animations</label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="bwgfx"' + (Tools.prefs('bwgfx')?' checked':'') + ' /> Enable BW sprites for XY</label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="nopastgens"' + (Tools.prefs('nopastgens')?' checked':'') + ' /> Use modern sprites for past generations</label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="notournaments"' + (Tools.prefs('notournaments')?' checked':'') + ' /> Ignore tournaments</label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="inchatpm"' + (Tools.prefs('inchatpm')?' checked':'') + ' /> Show PMs in chat rooms</label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="selfhighlight"' + (!Tools.prefs('noselfhighlight')?' checked':'') + '> Highlight when your name is said in chat</label></p>';
|
||||
buf += '<p><label class="optlabel">Background: <select name="bg"><option value="">Charizards</option><option value="#344b6c url(/fx/client-bg-horizon.jpg) no-repeat left center fixed">Horizon</option><option value="#546bac url(/fx/client-bg-3.jpg) no-repeat left center fixed">Waterfall</option><option value="#546bac url(/fx/client-bg-ocean.jpg) no-repeat left center fixed">Ocean</option><option value="#344b6c">Solid blue</option><option value="custom">Custom</option>' + (Tools.prefs('bg') ? '<option value="" selected></option>' : '') + '</select></label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="noanim"' + (Tools.prefs('noanim') ? ' checked' : '') + ' /> Disable animations</label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="bwgfx"' + (Tools.prefs('bwgfx') ? ' checked' : '') + ' /> Enable BW sprites for XY</label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="nopastgens"' + (Tools.prefs('nopastgens') ? ' checked' : '') + ' /> Use modern sprites for past generations</label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="notournaments"' + (Tools.prefs('notournaments') ? ' checked' : '') + ' /> Ignore tournaments</label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="inchatpm"' + (Tools.prefs('inchatpm') ? ' checked' : '') + ' /> Show PMs in chat rooms</label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="selfhighlight"' + (!Tools.prefs('noselfhighlight') ? ' checked' : '') + '> Highlight when your name is said in chat</label></p>';
|
||||
|
||||
if (window.Notification) {
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="temporarynotifications"' + (Tools.prefs('temporarynotifications')?' checked':'') + ' /> Temporary notifications</label></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="temporarynotifications"' + (Tools.prefs('temporarynotifications') ? ' checked' : '') + ' /> Temporary notifications</label></p>';
|
||||
}
|
||||
|
||||
var timestamps = this.timestamps = (Tools.prefs('timestamps') || {});
|
||||
buf += '<p><label class="optlabel">Timestamps in chat rooms: <select name="timestamps-lobby"><option value="off">Off</option><option value="minutes"' + (timestamps.lobby==='minutes'?' selected="selected"':'') + '>[HH:MM]</option><option value="seconds"' + (timestamps.lobby==='seconds'?' selected="selected"':'') + '>[HH:MM:SS]</option></select></label></p>';
|
||||
buf += '<p><label class="optlabel">Timestamps in PMs: <select name="timestamps-pms"><option value="off">Off</option><option value="minutes"' + (timestamps.pms==='minutes'?' selected="selected"':'') + '>[HH:MM]</option><option value="seconds"' + (timestamps.pms==='seconds'?' selected="selected"':'') + '>[HH:MM:SS]</option></select></label></p>';
|
||||
buf += '<p><label class="optlabel">Timestamps in chat rooms: <select name="timestamps-lobby"><option value="off">Off</option><option value="minutes"' + (timestamps.lobby === 'minutes' ? ' selected="selected"' : '') + '>[HH:MM]</option><option value="seconds"' + (timestamps.lobby === 'seconds' ? ' selected="selected"' : '') + '>[HH:MM:SS]</option></select></label></p>';
|
||||
buf += '<p><label class="optlabel">Timestamps in PMs: <select name="timestamps-pms"><option value="off">Off</option><option value="minutes"' + (timestamps.pms === 'minutes' ? ' selected="selected"' : '') + '>[HH:MM]</option><option value="seconds"' + (timestamps.pms === 'seconds' ? ' selected="selected"' : '') + '>[HH:MM:SS]</option></select></label></p>';
|
||||
buf += '<p><label class="optlabel">Chat preferences: <button name="formatting">Edit formatting</button></label></p>';
|
||||
|
||||
if (window.nodewebkit) {
|
||||
buf += '<hr />';
|
||||
buf += '<h3>Desktop app</h3>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="logchat"' + (Tools.prefs('logchat')?' checked':'') + '> Log chat</label></p>';
|
||||
buf += '<p id="openLogFolderButton"' + (Storage.dir?'':' style="display:none"') + '><button name="openLogFolder">Open log folder</button></p>';
|
||||
buf += '<p><label class="optlabel"><input type="checkbox" name="logchat"' + (Tools.prefs('logchat') ? ' checked' : '') + '> Log chat</label></p>';
|
||||
buf += '<p id="openLogFolderButton"' + (Storage.dir ? '' : ' style="display:none"') + '><button name="openLogFolder">Open log folder</button></p>';
|
||||
}
|
||||
|
||||
buf += '<hr />';
|
||||
|
|
@ -2720,9 +2720,9 @@
|
|||
buf += '<p>Choose an avatar or <button name="close">Cancel</button></p>';
|
||||
|
||||
buf += '<div class="avatarlist">';
|
||||
for (var i=1; i<=293; i++) {
|
||||
var offset = '-' + (((i-1)%16)*80) + 'px -' + (Math.floor((i-1)/16)*80) + 'px';
|
||||
buf += '<button name="setAvatar" value="' + i + '" style="background-position:' + offset + '"' + (i===cur?' class="cur"':'') + '></button>';
|
||||
for (var i = 1; i <= 293; i++) {
|
||||
var offset = '-' + (((i - 1) % 16) * 80) + 'px -' + (Math.floor((i - 1) / 16) * 80) + 'px';
|
||||
buf += '<button name="setAvatar" value="' + i + '" style="background-position:' + offset + '"' + (i === cur ? ' class="cur"' : '') + '></button>';
|
||||
}
|
||||
buf += '</div><div style="clear:left"></div>';
|
||||
|
||||
|
|
@ -2764,7 +2764,7 @@
|
|||
var warning = ('warning' in data);
|
||||
var buf = '';
|
||||
if (warning) {
|
||||
buf += '<p><strong style="color:red">' + (Tools.escapeHTML(data.warning)||'You have been warned for breaking the rules.') + '</strong></p>';
|
||||
buf += '<p><strong style="color:red">' + (Tools.escapeHTML(data.warning) || 'You have been warned for breaking the rules.') + '</strong></p>';
|
||||
}
|
||||
buf += '<h2>Pokémon Showdown Rules</h2>';
|
||||
buf += '<b>Global</b><br /><br /><b>1.</b> Be nice to people. Respect people. Don\'t be rude to people.<br /><br /><b>2.</b> PS is based in the US. Follow US laws. Don\'t distribute pirated material, and don\'t slander others. PS is available to users younger than 18, so porn is strictly forbidden.<br /><br /><b>3.</b> No cheating. Don\'t exploit bugs to gain an unfair advantage. Don\'t game the system (by intentionally losing against yourself or a friend in a ladder match, by timerstalling, etc).<br /><b></b><br /><b>4.</b> English only.<br /><br /><b>5.</b> The First Amendment does not apply to PS, since PS is not a government organization.<br /><br /><b>6.</b> Moderators have discretion to punish any behaviour they deem inappropriate, whether or not it\'s on this list. If you disagree with a moderator ruling, appeal to a leader (a user with & next to their name) or Discipline Appeals.<br /><br />';
|
||||
|
|
@ -2793,9 +2793,9 @@
|
|||
var curId = (app.curRoom ? app.curRoom.id : '');
|
||||
var curSideId = (app.curSideRoom ? app.curSideRoom.id : '');
|
||||
|
||||
var buf = '<ul><li><a class="button' + (curId===''?' cur':'') + (app.rooms['']&&app.rooms[''].notificationClass||'') + '" href="' + app.root + '"><i class="icon-home"></i> <span>Home</span></a></li>';
|
||||
if (app.rooms['teambuilder']) buf += '<li><a class="button' + (curId==='teambuilder'?' cur':'') + ' closable" href="' + app.root + 'teambuilder"><i class="icon-edit"></i> <span>Teambuilder</span></a><a class="closebutton" href="' + app.root + 'teambuilder"><i class="icon-remove-sign"></i></a></li>';
|
||||
if (app.rooms['ladder']) buf += '<li><a class="button' + (curId==='ladder'?' cur':'') + ' closable" href="' + app.root + 'ladder"><i class="icon-list-ol"></i> <span>Ladder</span></a><a class="closebutton" href="' + app.root + 'ladder"><i class="icon-remove-sign"></i></a></li>';
|
||||
var buf = '<ul><li><a class="button' + (curId === '' ? ' cur' : '') + (app.rooms[''] && app.rooms[''].notificationClass || '') + '" href="' + app.root + '"><i class="icon-home"></i> <span>Home</span></a></li>';
|
||||
if (app.rooms['teambuilder']) buf += '<li><a class="button' + (curId === 'teambuilder' ? ' cur' : '') + ' closable" href="' + app.root + 'teambuilder"><i class="icon-edit"></i> <span>Teambuilder</span></a><a class="closebutton" href="' + app.root + 'teambuilder"><i class="icon-remove-sign"></i></a></li>';
|
||||
if (app.rooms['ladder']) buf += '<li><a class="button' + (curId === 'ladder' ? ' cur' : '') + ' closable" href="' + app.root + 'ladder"><i class="icon-list-ol"></i> <span>Ladder</span></a><a class="closebutton" href="' + app.root + 'ladder"><i class="icon-remove-sign"></i></a></li>';
|
||||
buf += '</ul>';
|
||||
var atLeastOne = false;
|
||||
var sideBuf = '';
|
||||
|
|
@ -2804,7 +2804,7 @@
|
|||
var room = app.rooms[id];
|
||||
var name = '<i class="icon-comment-alt"></i> <span>' + id + '</span>';
|
||||
if (id === 'lobby') name = '<i class="icon-comments-alt"></i> <span>Lobby</span>';
|
||||
if (id.substr(0,7) === 'battle-') {
|
||||
if (id.substr(0, 7) === 'battle-') {
|
||||
var parts = id.substr(7).split('-');
|
||||
var p1 = (room && room.battle && room.battle.p1 && room.battle.p1.name) || '';
|
||||
var p2 = (room && room.battle && room.battle.p2 && room.battle.p2.name) || '';
|
||||
|
|
@ -2818,17 +2818,17 @@
|
|||
name = '<i class="text">' + parts[0] + '</i><span>' + name + '</span>';
|
||||
}
|
||||
if (room.isSideRoom) {
|
||||
if (room.id !== 'rooms') sideBuf += '<li><a class="button' + (curId===id||curSideId===id?' cur':'') + room.notificationClass + ' closable" href="' + app.root + id + '">' + name + '</a><a class="closebutton" href="' + app.root + id + '"><i class="icon-remove-sign"></i></a></li>';
|
||||
if (room.id !== 'rooms') sideBuf += '<li><a class="button' + (curId === id || curSideId === id ? ' cur' : '') + room.notificationClass + ' closable" href="' + app.root + id + '">' + name + '</a><a class="closebutton" href="' + app.root + id + '"><i class="icon-remove-sign"></i></a></li>';
|
||||
continue;
|
||||
}
|
||||
if (!atLeastOne) {
|
||||
buf += '<ul>';
|
||||
atLeastOne = true;
|
||||
}
|
||||
buf += '<li><a class="button' + (curId===id?' cur':'') + room.notificationClass + ' closable" href="' + app.root + id + '">' + name + '</a><a class="closebutton" href="' + app.root + id + '"><i class="icon-remove-sign"></i></a></li>';
|
||||
buf += '<li><a class="button' + (curId === id ? ' cur' : '') + room.notificationClass + ' closable" href="' + app.root + id + '">' + name + '</a><a class="closebutton" href="' + app.root + id + '"><i class="icon-remove-sign"></i></a></li>';
|
||||
}
|
||||
if (app.supports['rooms']) {
|
||||
sideBuf += '<li><a class="button' + (curId==='rooms'||curSideId==='rooms'?' cur':'') + '" href="' + app.root + 'rooms"><i class="icon-plus"></i> <span> </span></a></li>';
|
||||
sideBuf += '<li><a class="button' + (curId === 'rooms' || curSideId === 'rooms' ? ' cur' : '') + '" href="' + app.root + 'rooms"><i class="icon-plus"></i> <span> </span></a></li>';
|
||||
}
|
||||
if (atLeastOne) buf += '</ul>';
|
||||
if (sideBuf) {
|
||||
|
|
|
|||
67
js/search.js
67
js/search.js
|
|
@ -9,13 +9,14 @@
|
|||
* @author Guangcong Luo <Zarel>
|
||||
*/
|
||||
|
||||
(function (exports, $){
|
||||
(function (exports, $) {
|
||||
'use strict';
|
||||
|
||||
function Search(elem) {
|
||||
this.$el = $(elem);
|
||||
this.el = this.$el[0];
|
||||
}
|
||||
|
||||
Search.prototype.$ = function (query) {
|
||||
return this.$el.find(query);
|
||||
};
|
||||
|
|
@ -58,22 +59,22 @@
|
|||
|
||||
var i = Search.getClosest(query);
|
||||
if (!BattleSearchIndex[i]) i--;
|
||||
if (BattleSearchIndex[i-1] && BattleSearchIndex[i-1] === query) i--;
|
||||
if (BattleSearchIndex[i - 1] && BattleSearchIndex[i - 1] === query) i--;
|
||||
this.exactMatch = (query === BattleSearchIndex[i]);
|
||||
|
||||
var bufs = ['','','',''];
|
||||
var bufs = ['', '', '', ''];
|
||||
var topbufIndex = -1;
|
||||
|
||||
var nearMatch = (BattleSearchIndex[i].substr(0,query.length) !== query);
|
||||
var nearMatch = (BattleSearchIndex[i].substr(0, query.length) !== query);
|
||||
if (nearMatch && i) i--;
|
||||
for (var j=0; j<15; j++) {
|
||||
var id = BattleSearchIndex[i+j];
|
||||
var type = BattleSearchIndexType[i+j];
|
||||
for (var j = 0; j < 15; j++) {
|
||||
var id = BattleSearchIndex[i + j];
|
||||
var type = BattleSearchIndexType[i + j];
|
||||
var matchLength = query.length;
|
||||
|
||||
if (!id) break;
|
||||
if (id.substr(0,query.length) !== query) {
|
||||
if (!(nearMatch && j<=1)) break;
|
||||
if (id.substr(0, query.length) !== query) {
|
||||
if (!(nearMatch && j <= 1)) break;
|
||||
matchLength = 0;
|
||||
}
|
||||
if (j === 0 && this.exactMatch) {
|
||||
|
|
@ -81,7 +82,7 @@
|
|||
}
|
||||
|
||||
if (!bufs[typeTable[type]]) bufs[typeTable[type]] = '<li><h3>' + typeName[type] + '</h3></li>';
|
||||
bufs[typeTable[type]] += Search.renderRow(id, type, 0, matchLength + (BattleSearchIndexOffset[i+j][matchLength-1]||'0').charCodeAt(0)-48);
|
||||
bufs[typeTable[type]] += Search.renderRow(id, type, 0, matchLength + (BattleSearchIndexOffset[i + j][matchLength - 1] || '0').charCodeAt(0) - 48);
|
||||
}
|
||||
|
||||
var topbuf = '';
|
||||
|
|
@ -137,13 +138,13 @@
|
|||
var ability = BattleAbilities[id];
|
||||
return Search.renderAbilityRow(ability, matchStart, matchLength, errorMessage);
|
||||
case 'type':
|
||||
var type = {name: id[0].toUpperCase()+id.substr(1)};
|
||||
var type = {name: id[0].toUpperCase() + id.substr(1)};
|
||||
return Search.renderTypeRow(type, matchStart, matchLength, errorMessage);
|
||||
case 'egggroup':
|
||||
var egggroup = {name: id[0].toUpperCase()+id.substr(1)};
|
||||
var egggroup = {name: id[0].toUpperCase() + id.substr(1)};
|
||||
return Search.renderEggGroupRow(egggroup, matchStart, matchLength, errorMessage);
|
||||
case 'category':
|
||||
var category = {name: id[0].toUpperCase()+id.substr(1)};
|
||||
var category = {name: id[0].toUpperCase() + id.substr(1)};
|
||||
return Search.renderCategoryRow(category, matchStart, matchLength, errorMessage);
|
||||
}
|
||||
return 'Error: not found';
|
||||
|
|
@ -154,7 +155,7 @@
|
|||
var buf = '<li class="result"><a' + attrs + ' data-name="' + Tools.escapeHTML(pokemon.species) + '">';
|
||||
|
||||
// number
|
||||
buf += '<span class="col numcol">' + (pokemon.num>=0 ? pokemon.num : 'CAP') + '</span> ';
|
||||
buf += '<span class="col numcol">' + (pokemon.num >= 0 ? pokemon.num : 'CAP') + '</span> ';
|
||||
|
||||
// icon
|
||||
buf += '<span class="col iconcol">';
|
||||
|
|
@ -163,18 +164,18 @@
|
|||
|
||||
// name
|
||||
var name = pokemon.species;
|
||||
var tagStart = (pokemon.forme ? name.length-pokemon.forme.length-1 : 0);
|
||||
var tagStart = (pokemon.forme ? name.length - pokemon.forme.length - 1 : 0);
|
||||
if (tagStart) name = name.substr(0, tagStart);
|
||||
if (matchLength) {
|
||||
name = name.substr(0, matchStart) + '<b>' + name.substr(matchStart, matchLength) + '</b>' + name.substr(matchStart + matchLength);
|
||||
}
|
||||
if (tagStart) {
|
||||
if (matchLength && matchStart+matchLength > tagStart) {
|
||||
if (matchLength && matchStart + matchLength > tagStart) {
|
||||
if (matchStart < tagStart) {
|
||||
matchLength -= tagStart - matchStart;
|
||||
matchStart = tagStart;
|
||||
}
|
||||
name += '<small>' + pokemon.species.substr(tagStart, matchStart-tagStart) + '<b>' + pokemon.species.substr(matchStart, matchLength) + '</b>' + pokemon.species.substr(matchStart + matchLength) + '</small>';
|
||||
name += '<small>' + pokemon.species.substr(tagStart, matchStart - tagStart) + '<b>' + pokemon.species.substr(matchStart, matchLength) + '</b>' + pokemon.species.substr(matchStart + matchLength) + '</small>';
|
||||
} else {
|
||||
name += '<small>' + pokemon.species.substr(tagStart) + '</small>';
|
||||
}
|
||||
|
|
@ -190,7 +191,7 @@
|
|||
|
||||
// type
|
||||
buf += '<span class="col typecol">';
|
||||
for (var i=0; i<pokemon.types.length; i++) {
|
||||
for (var i = 0; i < pokemon.types.length; i++) {
|
||||
buf += Tools.getTypeIcon(pokemon.types[i]);
|
||||
}
|
||||
buf += '</span> ';
|
||||
|
|
@ -246,7 +247,7 @@
|
|||
|
||||
// name
|
||||
var name = pokemon.species;
|
||||
var tagStart = (pokemon.forme ? name.length-pokemon.forme.length-1 : 0);
|
||||
var tagStart = (pokemon.forme ? name.length - pokemon.forme.length - 1 : 0);
|
||||
if (tagStart) name = name.substr(0, tagStart) + '<small>' + pokemon.species.substr(tagStart) + '</small>';
|
||||
buf += '<span class="col shortpokemonnamecol" style="white-space:nowrap">' + name + '</span> ';
|
||||
|
||||
|
|
@ -259,7 +260,7 @@
|
|||
|
||||
// type
|
||||
buf += '<span class="col typecol">';
|
||||
for (var i=0; i<pokemon.types.length; i++) {
|
||||
for (var i = 0; i < pokemon.types.length; i++) {
|
||||
buf += Tools.getTypeIcon(pokemon.types[i]);
|
||||
}
|
||||
buf += '</span> ';
|
||||
|
|
@ -375,7 +376,7 @@
|
|||
matchLength -= tagStart - matchStart;
|
||||
matchStart = tagStart;
|
||||
}
|
||||
name += '<small>' + move.name.substr(tagStart, matchStart-tagStart) + '<b>' + move.name.substr(matchStart, matchLength) + '</b>' + move.name.substr(matchStart + matchLength) + '</small>';
|
||||
name += '<small>' + move.name.substr(tagStart, matchStart - tagStart) + '<b>' + move.name.substr(matchStart, matchLength) + '</b>' + move.name.substr(matchStart + matchLength) + '</small>';
|
||||
} else {
|
||||
name += '<small>' + move.name.substr(tagStart) + '</small>';
|
||||
}
|
||||
|
|
@ -396,9 +397,9 @@
|
|||
buf += '</span> ';
|
||||
|
||||
// power, accuracy, pp
|
||||
buf += '<span class="col labelcol">' + (move.category!=='Status'?('<em>Power</em><br />' + (move.basePower||'—')):'') + '</span> ';
|
||||
buf += '<span class="col widelabelcol"><em>Accuracy</em><br />' + (move.accuracy && move.accuracy!==true?move.accuracy + '%':'—') + '</span> ';
|
||||
buf += '<span class="col pplabelcol"><em>PP</em><br />' + (move.pp!==1?move.pp*8/5:move.pp) + '</span> ';
|
||||
buf += '<span class="col labelcol">' + (move.category !== 'Status' ? ('<em>Power</em><br />' + (move.basePower || '—')) : '') + '</span> ';
|
||||
buf += '<span class="col widelabelcol"><em>Accuracy</em><br />' + (move.accuracy && move.accuracy !== true ? move.accuracy + '%' : '—') + '</span> ';
|
||||
buf += '<span class="col pplabelcol"><em>PP</em><br />' + (move.pp !== 1 ? move.pp * 8 / 5 : move.pp) + '</span> ';
|
||||
|
||||
// desc
|
||||
buf += '<span class="col movedesccol">' + Tools.escapeHTML(move.shortDesc || move.desc) + '</span> ';
|
||||
|
|
@ -432,9 +433,9 @@
|
|||
buf += '</span> ';
|
||||
|
||||
// power, accuracy, pp
|
||||
buf += '<span class="col labelcol">' + (move.category!=='Status'?('<em>Power</em><br />' + (move.basePower||'—')):'') + '</span> ';
|
||||
buf += '<span class="col widelabelcol"><em>Accuracy</em><br />' + (move.accuracy && move.accuracy!==true?move.accuracy + '%':'—') + '</span> ';
|
||||
buf += '<span class="col pplabelcol"><em>PP</em><br />' + (move.pp!==1?move.pp*8/5:move.pp) + '</span> ';
|
||||
buf += '<span class="col labelcol">' + (move.category !== 'Status' ? ('<em>Power</em><br />' + (move.basePower || '—')) : '') + '</span> ';
|
||||
buf += '<span class="col widelabelcol"><em>Accuracy</em><br />' + (move.accuracy && move.accuracy !== true ? move.accuracy + '%' : '—') + '</span> ';
|
||||
buf += '<span class="col pplabelcol"><em>PP</em><br />' + (move.pp !== 1 ? move.pp * 8 / 5 : move.pp) + '</span> ';
|
||||
|
||||
// desc
|
||||
buf += '<span class="col movedesccol">' + Tools.escapeHTML(move.shortDesc || move.desc) + '</span> ';
|
||||
|
|
@ -470,9 +471,9 @@
|
|||
buf += '</span> ';
|
||||
|
||||
// power, accuracy, pp
|
||||
buf += '<span class="col labelcol">' + (move.category!=='Status'?('<em>Power</em><br />' + (move.basePower||'—')):'') + '</span> ';
|
||||
buf += '<span class="col widelabelcol"><em>Accuracy</em><br />' + (move.accuracy && move.accuracy!==true?move.accuracy + '%':'—') + '</span> ';
|
||||
buf += '<span class="col pplabelcol"><em>PP</em><br />' + (move.pp!==1?move.pp*8/5:move.pp) + '</span> ';
|
||||
buf += '<span class="col labelcol">' + (move.category !== 'Status' ? ('<em>Power</em><br />' + (move.basePower || '—')) : '') + '</span> ';
|
||||
buf += '<span class="col widelabelcol"><em>Accuracy</em><br />' + (move.accuracy && move.accuracy !== true ? move.accuracy + '%' : '—') + '</span> ';
|
||||
buf += '<span class="col pplabelcol"><em>PP</em><br />' + (move.pp !== 1 ? move.pp * 8 / 5 : move.pp) + '</span> ';
|
||||
|
||||
// desc
|
||||
buf += '<span class="col movedesccol">' + Tools.escapeHTML(move.shortDesc || move.desc) + '</span> ';
|
||||
|
|
@ -490,7 +491,7 @@
|
|||
// name
|
||||
var name = type.name;
|
||||
if (matchLength) {
|
||||
name = name.substr(0, matchStart) + '<b>' + name.substr(matchStart, matchLength) + '</b>' + name.substr(matchStart+matchLength);
|
||||
name = name.substr(0, matchStart) + '<b>' + name.substr(matchStart, matchLength) + '</b>' + name.substr(matchStart + matchLength);
|
||||
}
|
||||
buf += '<span class="col namecol">' + name + '</span> ';
|
||||
|
||||
|
|
@ -518,7 +519,7 @@
|
|||
// name
|
||||
var name = category.name;
|
||||
if (matchLength) {
|
||||
name = name.substr(0, matchStart) + '<b>' + name.substr(matchStart, matchLength) + '</b>' + name.substr(matchStart+matchLength);
|
||||
name = name.substr(0, matchStart) + '<b>' + name.substr(matchStart, matchLength) + '</b>' + name.substr(matchStart + matchLength);
|
||||
}
|
||||
buf += '<span class="col namecol">' + name + '</span> ';
|
||||
|
||||
|
|
@ -546,7 +547,7 @@
|
|||
// name
|
||||
var name = egggroup.name;
|
||||
if (matchLength) {
|
||||
name = name.substr(0, matchStart) + '<b>' + name.substr(matchStart, matchLength) + '</b>' + name.substr(matchStart+matchLength);
|
||||
name = name.substr(0, matchStart) + '<b>' + name.substr(matchStart, matchLength) + '</b>' + name.substr(matchStart + matchLength);
|
||||
}
|
||||
buf += '<span class="col namecol">' + name + '</span> ';
|
||||
|
||||
|
|
|
|||
193
js/storage.js
193
js/storage.js
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function Storage() {}
|
||||
|
||||
Storage.initialize = function () {
|
||||
|
|
@ -126,7 +125,7 @@ Storage.packTeam = function (team) {
|
|||
var buf = '';
|
||||
if (!team) return '';
|
||||
|
||||
for (var i=0; i<team.length; i++) {
|
||||
for (var i = 0; i < team.length; i++) {
|
||||
var set = team[i];
|
||||
if (buf) buf += ']';
|
||||
|
||||
|
|
@ -166,12 +165,12 @@ Storage.packTeam = function (team) {
|
|||
}
|
||||
|
||||
// nature
|
||||
buf += '|' + (set.nature||'');
|
||||
buf += '|' + (set.nature || '');
|
||||
|
||||
// evs
|
||||
var evs = '|';
|
||||
if (set.evs) {
|
||||
evs = '|' + (set.evs['hp']||'') + ',' + (set.evs['atk']||'') + ',' + (set.evs['def']||'') + ',' + (set.evs['spa']||'') + ',' + (set.evs['spd']||'') + ',' + (set.evs['spe']||'');
|
||||
evs = '|' + (set.evs['hp'] || '') + ',' + (set.evs['atk'] || '') + ',' + (set.evs['def'] || '') + ',' + (set.evs['spa'] || '') + ',' + (set.evs['spd'] || '') + ',' + (set.evs['spe'] || '');
|
||||
}
|
||||
if (evs === '|,,,,,') {
|
||||
buf += '|';
|
||||
|
|
@ -189,7 +188,7 @@ Storage.packTeam = function (team) {
|
|||
// ivs
|
||||
var ivs = '|';
|
||||
if (set.ivs) {
|
||||
ivs = '|' + (set.ivs['hp']===31||set.ivs['hp']===undefined ? '' : set.ivs['hp']) + ',' + (set.ivs['atk']===31||set.ivs['atk']===undefined ? '' : set.ivs['atk']) + ',' + (set.ivs['def']===31||set.ivs['def']===undefined ? '' : set.ivs['def']) + ',' + (set.ivs['spa']===31||set.ivs['spa']===undefined ? '' : set.ivs['spa']) + ',' + (set.ivs['spd']===31||set.ivs['spd']===undefined ? '' : set.ivs['spd']) + ',' + (set.ivs['spe']===31||set.ivs['spe']===undefined ? '' : set.ivs['spe']);
|
||||
ivs = '|' + (set.ivs['hp'] === 31 || set.ivs['hp'] === undefined ? '' : set.ivs['hp']) + ',' + (set.ivs['atk'] === 31 || set.ivs['atk'] === undefined ? '' : set.ivs['atk']) + ',' + (set.ivs['def'] === 31 || set.ivs['def'] === undefined ? '' : set.ivs['def']) + ',' + (set.ivs['spa'] === 31 || set.ivs['spa'] === undefined ? '' : set.ivs['spa']) + ',' + (set.ivs['spd'] === 31 || set.ivs['spd'] === undefined ? '' : set.ivs['spd']) + ',' + (set.ivs['spe'] === 31 || set.ivs['spe'] === undefined ? '' : set.ivs['spe']);
|
||||
}
|
||||
if (ivs === '|,,,,,') {
|
||||
buf += '|';
|
||||
|
|
@ -235,80 +234,80 @@ Storage.fastUnpackTeam = function (buf) {
|
|||
// name
|
||||
j = buf.indexOf('|', i);
|
||||
set.name = buf.substring(i, j);
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// species
|
||||
j = buf.indexOf('|', i);
|
||||
set.species = buf.substring(i, j) || set.name;
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// item
|
||||
j = buf.indexOf('|', i);
|
||||
set.item = buf.substring(i, j);
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// ability
|
||||
j = buf.indexOf('|', i);
|
||||
var ability = buf.substring(i, j);
|
||||
var template = Tools.getTemplate(set.species);
|
||||
set.ability = (template.abilities && ability in {'':1, 0:1, 1:1, H:1} ? template.abilities[ability||'0'] : ability);
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// moves
|
||||
j = buf.indexOf('|', i);
|
||||
set.moves = buf.substring(i, j).split(',');
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// nature
|
||||
j = buf.indexOf('|', i);
|
||||
set.nature = buf.substring(i, j);
|
||||
if (set.nature === 'undefined') set.nature = undefined;
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// evs
|
||||
j = buf.indexOf('|', i);
|
||||
if (j !== i) {
|
||||
var evs = buf.substring(i, j).split(',');
|
||||
set.evs = {
|
||||
hp: Number(evs[0])||0,
|
||||
atk: Number(evs[1])||0,
|
||||
def: Number(evs[2])||0,
|
||||
spa: Number(evs[3])||0,
|
||||
spd: Number(evs[4])||0,
|
||||
spe: Number(evs[5])||0
|
||||
hp: Number(evs[0]) || 0,
|
||||
atk: Number(evs[1]) || 0,
|
||||
def: Number(evs[2]) || 0,
|
||||
spa: Number(evs[3]) || 0,
|
||||
spd: Number(evs[4]) || 0,
|
||||
spe: Number(evs[5]) || 0
|
||||
};
|
||||
}
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// gender
|
||||
j = buf.indexOf('|', i);
|
||||
if (i !== j) set.gender = buf.substring(i, j);
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// ivs
|
||||
j = buf.indexOf('|', i);
|
||||
if (j !== i) {
|
||||
var ivs = buf.substring(i, j).split(',');
|
||||
set.ivs = {
|
||||
hp: ivs[0]==='' ? 31 : Number(ivs[0]),
|
||||
atk: ivs[1]==='' ? 31 : Number(ivs[1]),
|
||||
def: ivs[2]==='' ? 31 : Number(ivs[2]),
|
||||
spa: ivs[3]==='' ? 31 : Number(ivs[3]),
|
||||
spd: ivs[4]==='' ? 31 : Number(ivs[4]),
|
||||
spe: ivs[5]==='' ? 31 : Number(ivs[5])
|
||||
hp: ivs[0] === '' ? 31 : Number(ivs[0]),
|
||||
atk: ivs[1] === '' ? 31 : Number(ivs[1]),
|
||||
def: ivs[2] === '' ? 31 : Number(ivs[2]),
|
||||
spa: ivs[3] === '' ? 31 : Number(ivs[3]),
|
||||
spd: ivs[4] === '' ? 31 : Number(ivs[4]),
|
||||
spe: ivs[5] === '' ? 31 : Number(ivs[5])
|
||||
};
|
||||
}
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// shiny
|
||||
j = buf.indexOf('|', i);
|
||||
if (i !== j) set.shiny = true;
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// level
|
||||
j = buf.indexOf('|', i);
|
||||
if (i !== j) set.level = parseInt(buf.substring(i, j), 10);
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// happiness
|
||||
j = buf.indexOf(']', i);
|
||||
|
|
@ -319,7 +318,7 @@ Storage.fastUnpackTeam = function (buf) {
|
|||
break;
|
||||
}
|
||||
if (i !== j) set.happiness = Number(buf.substring(i, j));
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
}
|
||||
|
||||
return team;
|
||||
|
|
@ -338,82 +337,82 @@ Storage.unpackTeam = function (buf) {
|
|||
// name
|
||||
j = buf.indexOf('|', i);
|
||||
set.name = buf.substring(i, j);
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// species
|
||||
j = buf.indexOf('|', i);
|
||||
set.species = Tools.getTemplate(buf.substring(i, j)).name || set.name;
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// item
|
||||
j = buf.indexOf('|', i);
|
||||
set.item = Tools.getItem(buf.substring(i, j)).name;
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// ability
|
||||
j = buf.indexOf('|', i);
|
||||
var ability = Tools.getAbility(buf.substring(i, j)).name;
|
||||
var template = Tools.getTemplate(set.species);
|
||||
set.ability = (template.abilities && ability in {'':1, 0:1, 1:1, H:1} ? template.abilities[ability||'0'] : ability);
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// moves
|
||||
j = buf.indexOf('|', i);
|
||||
set.moves = buf.substring(i, j).split(',').map(function (moveid) {
|
||||
return Tools.getMove(moveid).name
|
||||
});
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// nature
|
||||
j = buf.indexOf('|', i);
|
||||
set.nature = buf.substring(i, j);
|
||||
if (set.nature === 'undefined') set.nature = undefined;
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// evs
|
||||
j = buf.indexOf('|', i);
|
||||
if (j !== i) {
|
||||
var evs = buf.substring(i, j).split(',');
|
||||
set.evs = {
|
||||
hp: Number(evs[0])||0,
|
||||
atk: Number(evs[1])||0,
|
||||
def: Number(evs[2])||0,
|
||||
spa: Number(evs[3])||0,
|
||||
spd: Number(evs[4])||0,
|
||||
spe: Number(evs[5])||0
|
||||
hp: Number(evs[0]) || 0,
|
||||
atk: Number(evs[1]) || 0,
|
||||
def: Number(evs[2]) || 0,
|
||||
spa: Number(evs[3]) || 0,
|
||||
spd: Number(evs[4]) || 0,
|
||||
spe: Number(evs[5]) || 0
|
||||
};
|
||||
}
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// gender
|
||||
j = buf.indexOf('|', i);
|
||||
if (i !== j) set.gender = buf.substring(i, j);
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// ivs
|
||||
j = buf.indexOf('|', i);
|
||||
if (j !== i) {
|
||||
var ivs = buf.substring(i, j).split(',');
|
||||
set.ivs = {
|
||||
hp: ivs[0]==='' ? 31 : Number(ivs[0]),
|
||||
atk: ivs[1]==='' ? 31 : Number(ivs[1]),
|
||||
def: ivs[2]==='' ? 31 : Number(ivs[2]),
|
||||
spa: ivs[3]==='' ? 31 : Number(ivs[3]),
|
||||
spd: ivs[4]==='' ? 31 : Number(ivs[4]),
|
||||
spe: ivs[5]==='' ? 31 : Number(ivs[5])
|
||||
hp: ivs[0] === '' ? 31 : Number(ivs[0]),
|
||||
atk: ivs[1] === '' ? 31 : Number(ivs[1]),
|
||||
def: ivs[2] === '' ? 31 : Number(ivs[2]),
|
||||
spa: ivs[3] === '' ? 31 : Number(ivs[3]),
|
||||
spd: ivs[4] === '' ? 31 : Number(ivs[4]),
|
||||
spe: ivs[5] === '' ? 31 : Number(ivs[5])
|
||||
};
|
||||
}
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// shiny
|
||||
j = buf.indexOf('|', i);
|
||||
if (i !== j) set.shiny = true;
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// level
|
||||
j = buf.indexOf('|', i);
|
||||
if (i !== j) set.level = parseInt(buf.substring(i, j), 10);
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
|
||||
// happiness
|
||||
j = buf.indexOf(']', i);
|
||||
|
|
@ -424,7 +423,7 @@ Storage.unpackTeam = function (buf) {
|
|||
break;
|
||||
}
|
||||
if (i !== j) set.happiness = Number(buf.substring(i, j));
|
||||
i = j+1;
|
||||
i = j + 1;
|
||||
}
|
||||
|
||||
return team;
|
||||
|
|
@ -442,7 +441,7 @@ Storage.packedTeamNames = function (buf) {
|
|||
|
||||
team.push(buf.substring(i, buf.indexOf('|', i)) || name);
|
||||
|
||||
for (var k=0; k<9; k++) {
|
||||
for (var k = 0; k < 9; k++) {
|
||||
i = buf.indexOf('|', i) + 1;
|
||||
}
|
||||
|
||||
|
|
@ -500,18 +499,18 @@ Storage.importTeam = function (text, teams) {
|
|||
Storage.teams = [];
|
||||
teams = Storage.teams;
|
||||
}
|
||||
for (var i=0; i<text.length; i++) {
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
var line = $.trim(text[i]);
|
||||
if (line === '' || line === '---') {
|
||||
curSet = null;
|
||||
} else if (line.substr(0, 3) === '===' && teams) {
|
||||
team = [];
|
||||
line = $.trim(line.substr(3, line.length-6));
|
||||
line = $.trim(line.substr(3, line.length - 6));
|
||||
var format = '';
|
||||
var bracketIndex = line.indexOf(']');
|
||||
if (bracketIndex >= 0) {
|
||||
format = line.substr(1, bracketIndex-1);
|
||||
line = $.trim(line.substr(bracketIndex+1));
|
||||
format = line.substr(1, bracketIndex - 1);
|
||||
line = $.trim(line.substr(bracketIndex + 1));
|
||||
}
|
||||
if (teams.length) {
|
||||
teams[teams.length - 1].team = Storage.packTeam(teams[teams.length - 1].team);
|
||||
|
|
@ -527,22 +526,22 @@ Storage.importTeam = function (text, teams) {
|
|||
team.push(curSet);
|
||||
var atIndex = line.lastIndexOf(' @ ');
|
||||
if (atIndex !== -1) {
|
||||
curSet.item = line.substr(atIndex+3);
|
||||
curSet.item = line.substr(atIndex + 3);
|
||||
if (toId(curSet.item) === 'noitem') curSet.item = '';
|
||||
line = line.substr(0, atIndex);
|
||||
}
|
||||
if (line.substr(line.length-4) === ' (M)') {
|
||||
if (line.substr(line.length - 4) === ' (M)') {
|
||||
curSet.gender = 'M';
|
||||
line = line.substr(0, line.length-4);
|
||||
line = line.substr(0, line.length - 4);
|
||||
}
|
||||
if (line.substr(line.length-4) === ' (F)') {
|
||||
if (line.substr(line.length - 4) === ' (F)') {
|
||||
curSet.gender = 'F';
|
||||
line = line.substr(0, line.length-4);
|
||||
line = line.substr(0, line.length - 4);
|
||||
}
|
||||
var parenIndex = line.lastIndexOf(' (');
|
||||
if (line.substr(line.length-1) === ')' && parenIndex !== -1) {
|
||||
line = line.substr(0, line.length-1);
|
||||
curSet.species = Tools.getTemplate(line.substr(parenIndex+2)).name;
|
||||
if (line.substr(line.length - 1) === ')' && parenIndex !== -1) {
|
||||
line = line.substr(0, line.length - 1);
|
||||
curSet.species = Tools.getTemplate(line.substr(parenIndex + 2)).name;
|
||||
line = line.substr(0, parenIndex);
|
||||
curSet.name = line;
|
||||
} else {
|
||||
|
|
@ -570,11 +569,11 @@ Storage.importTeam = function (text, teams) {
|
|||
line = line.substr(5);
|
||||
var evLines = line.split('/');
|
||||
curSet.evs = {hp: 0, atk: 0, def: 0, spa: 0, spd: 0, spe: 0};
|
||||
for (var j=0; j<evLines.length; j++) {
|
||||
for (var j = 0; j < evLines.length; j++) {
|
||||
var evLine = $.trim(evLines[j]);
|
||||
var spaceIndex = evLine.indexOf(' ');
|
||||
if (spaceIndex === -1) continue;
|
||||
var statid = BattleStatIDs[evLine.substr(spaceIndex+1)];
|
||||
var statid = BattleStatIDs[evLine.substr(spaceIndex + 1)];
|
||||
var statval = parseInt(evLine.substr(0, spaceIndex));
|
||||
if (!statid) continue;
|
||||
curSet.evs[statid] = statval;
|
||||
|
|
@ -583,11 +582,11 @@ Storage.importTeam = function (text, teams) {
|
|||
line = line.substr(5);
|
||||
var ivLines = line.split(' / ');
|
||||
curSet.ivs = {hp: 31, atk: 31, def: 31, spa: 31, spd: 31, spe: 31};
|
||||
for (var j=0; j<ivLines.length; j++) {
|
||||
for (var j = 0; j < ivLines.length; j++) {
|
||||
var ivLine = ivLines[j];
|
||||
var spaceIndex = ivLine.indexOf(' ');
|
||||
if (spaceIndex === -1) continue;
|
||||
var statid = BattleStatIDs[ivLine.substr(spaceIndex+1)];
|
||||
var statid = BattleStatIDs[ivLine.substr(spaceIndex + 1)];
|
||||
var statval = parseInt(ivLine.substr(0, spaceIndex));
|
||||
if (!statid) continue;
|
||||
if (isNaN(statval)) statval = 31;
|
||||
|
|
@ -599,12 +598,12 @@ Storage.importTeam = function (text, teams) {
|
|||
if (natureIndex === -1) continue;
|
||||
line = line.substr(0, natureIndex);
|
||||
if (line !== 'undefined') curSet.nature = line;
|
||||
} else if (line.substr(0,1) === '-' || line.substr(0,1) === '~') {
|
||||
} else if (line.substr(0, 1) === '-' || line.substr(0, 1) === '~') {
|
||||
line = line.substr(1);
|
||||
if (line.substr(0,1) === ' ') line = line.substr(1);
|
||||
if (line.substr(0, 1) === ' ') line = line.substr(1);
|
||||
if (!curSet.moves) curSet.moves = [];
|
||||
if (line.substr(0,14) === 'Hidden Power [') {
|
||||
var hptype = line.substr(14, line.length-15);
|
||||
if (line.substr(0, 14) === 'Hidden Power [') {
|
||||
var hptype = line.substr(14, line.length - 15);
|
||||
line = 'Hidden Power ' + hptype;
|
||||
if (!curSet.ivs && window.BattleTypeChart) {
|
||||
curSet.ivs = {};
|
||||
|
|
@ -626,9 +625,9 @@ Storage.importTeam = function (text, teams) {
|
|||
};
|
||||
Storage.exportAllTeams = function () {
|
||||
var buf = '';
|
||||
for (var i=0,len=Storage.teams.length; i<len; i++) {
|
||||
for (var i = 0, len = Storage.teams.length; i < len; i++) {
|
||||
var team = Storage.teams[i];
|
||||
buf += '=== ' + (team.format?'[' + team.format + '] ':'') + team.name + ' ===\n\n';
|
||||
buf += '=== ' + (team.format ? '[' + team.format + '] ' : '') + team.name + ' ===\n\n';
|
||||
buf += Storage.exportTeam(team.team);
|
||||
buf += '\n';
|
||||
}
|
||||
|
|
@ -641,7 +640,7 @@ Storage.exportTeam = function (team) {
|
|||
team = Storage.unpackTeam(team);
|
||||
}
|
||||
var text = '';
|
||||
for (var i=0; i<team.length; i++) {
|
||||
for (var i = 0; i < team.length; i++) {
|
||||
var curSet = team[i];
|
||||
if (curSet.name !== curSet.species) {
|
||||
text += '' + curSet.name + ' (' + curSet.species + ')';
|
||||
|
|
@ -689,16 +688,16 @@ Storage.exportTeam = function (team) {
|
|||
if (curSet.ivs) {
|
||||
var defaultIvs = true;
|
||||
var hpType = false;
|
||||
for (var j=0; j<curSet.moves.length; j++) {
|
||||
for (var j = 0; j < curSet.moves.length; j++) {
|
||||
var move = curSet.moves[j];
|
||||
if (move.substr(0,13) === 'Hidden Power ' && move.substr(0,14) !== 'Hidden Power [') {
|
||||
if (move.substr(0, 13) === 'Hidden Power ' && move.substr(0, 14) !== 'Hidden Power [') {
|
||||
hpType = move.substr(13);
|
||||
if (!exports.BattleTypeChart[hpType].HPivs) {
|
||||
alert("That is not a valid Hidden Power type.");
|
||||
continue;
|
||||
}
|
||||
for (var stat in BattleStatNames) {
|
||||
if ((curSet.ivs[stat]===undefined?31:curSet.ivs[stat]) !== (exports.BattleTypeChart[hpType].HPivs[stat]||31)) {
|
||||
if ((curSet.ivs[stat] === undefined ? 31 : curSet.ivs[stat]) !== (exports.BattleTypeChart[hpType].HPivs[stat] || 31)) {
|
||||
defaultIvs = false;
|
||||
break;
|
||||
}
|
||||
|
|
@ -729,10 +728,10 @@ Storage.exportTeam = function (team) {
|
|||
if (!first) {
|
||||
text += "\n";
|
||||
}
|
||||
if (curSet.moves && curSet.moves) for (var j=0; j<curSet.moves.length; j++) {
|
||||
if (curSet.moves && curSet.moves) for (var j = 0; j < curSet.moves.length; j++) {
|
||||
var move = curSet.moves[j];
|
||||
if (move.substr(0,13) === 'Hidden Power ') {
|
||||
move = move.substr(0,13) + '[' + move.substr(13) + ']';
|
||||
if (move.substr(0, 13) === 'Hidden Power ') {
|
||||
move = move.substr(0, 13) + '[' + move.substr(13) + ']';
|
||||
}
|
||||
text += '- ' + move + "\n";
|
||||
}
|
||||
|
|
@ -749,7 +748,7 @@ Storage.initDirectory = function () {
|
|||
var self = this;
|
||||
|
||||
var dir = process.env.HOME || process.env.USERPROFILE || process.env.HOMEPATH;
|
||||
if (!(dir.charAt(dir.length-1) in {'/':1, '\\':1})) dir += '/';
|
||||
if (!(dir.charAt(dir.length - 1) in {'/': 1, '\\': 1})) dir += '/';
|
||||
fs.stat(dir + 'Documents', function (err, stats) {
|
||||
if (err || !stats.isDirectory()) {
|
||||
fs.stat(dir + 'My Documents', function (err, stats) {
|
||||
|
|
@ -805,7 +804,7 @@ Storage.nwLoadTeams = function () {
|
|||
if (err) return;
|
||||
self.teams = [];
|
||||
self.nwTeamsLeft = files.length;
|
||||
for (var i=0; i<files.length; i++) {
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
self.nwLoadTeamFile(files[i], localApp);
|
||||
}
|
||||
});
|
||||
|
|
@ -814,8 +813,8 @@ Storage.nwLoadTeams = function () {
|
|||
Storage.nwLoadTeamFile = function (filename, localApp) {
|
||||
var self = this;
|
||||
var line = filename;
|
||||
if (line.substr(line.length-4).toLowerCase() === '.txt') {
|
||||
line = line.substr(0, line.length-4);
|
||||
if (line.substr(line.length - 4).toLowerCase() === '.txt') {
|
||||
line = line.substr(0, line.length - 4);
|
||||
} else {
|
||||
// not a team file
|
||||
self.nwTeamsLeft--;
|
||||
|
|
@ -827,8 +826,8 @@ Storage.nwLoadTeamFile = function (filename, localApp) {
|
|||
var format = '';
|
||||
var bracketIndex = line.indexOf(']');
|
||||
if (bracketIndex >= 0) {
|
||||
format = line.substr(1, bracketIndex-1);
|
||||
line = $.trim(line.substr(bracketIndex+1));
|
||||
format = line.substr(1, bracketIndex - 1);
|
||||
line = $.trim(line.substr(bracketIndex + 1));
|
||||
}
|
||||
fs.readFile(this.dir + 'Teams/' + filename, function (err, data) {
|
||||
if (!err) {
|
||||
|
|
@ -868,7 +867,7 @@ Storage.nwDeleteAllTeams = function (callback) {
|
|||
callback();
|
||||
return;
|
||||
}
|
||||
for (var i=0; i<files.length; i++) {
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
self.nwDeleteTeamFile(files[i], callback);
|
||||
}
|
||||
});
|
||||
|
|
@ -877,8 +876,8 @@ Storage.nwDeleteAllTeams = function (callback) {
|
|||
Storage.nwDeleteTeamFile = function (filename, callback) {
|
||||
var self = this;
|
||||
var line = filename;
|
||||
if (line.substr(line.length-4).toLowerCase() === '.txt') {
|
||||
line = line.substr(0, line.length-4);
|
||||
if (line.substr(line.length - 4).toLowerCase() === '.txt') {
|
||||
line = line.substr(0, line.length - 4);
|
||||
} else {
|
||||
// not a team file
|
||||
self.nwTeamsLeft--;
|
||||
|
|
@ -900,7 +899,7 @@ Storage.nwSaveTeam = function (team) {
|
|||
fs.unlink(this.dir + 'Teams/' + team.filename, function () {});
|
||||
}
|
||||
team.filename = filename;
|
||||
fs.writeFile(this.dir + 'Teams/' + filename, Storage.exportTeam(team.team).replace(/\n/g,'\r\n'));
|
||||
fs.writeFile(this.dir + 'Teams/' + filename, Storage.exportTeam(team.team).replace(/\n/g, '\r\n'));
|
||||
};
|
||||
|
||||
Storage.nwDeleteTeam = function (team) {
|
||||
|
|
@ -918,14 +917,14 @@ Storage.nwSaveAllTeams = function () {
|
|||
};
|
||||
|
||||
Storage.nwDoSaveAllTeams = function () {
|
||||
for (var i=0; i<this.teams.length; i++) {
|
||||
for (var i = 0; i < this.teams.length; i++) {
|
||||
var team = this.teams[i];
|
||||
var filename = team.name + '.txt';
|
||||
if (team.format) filename = '[' + team.format + '] ' + filename;
|
||||
filename = $.trim(filename).replace(/[\\\/]+/g, '');
|
||||
|
||||
team.filename = filename;
|
||||
fs.writeFile(this.dir + 'Teams/' + filename, Storage.exportTeam(team.team).replace(/\n/g,'\r\n'));
|
||||
fs.writeFile(this.dir + 'Teams/' + filename, Storage.exportTeam(team.team).replace(/\n/g, '\r\n'));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -933,7 +932,7 @@ Storage.nwDoSaveAllTeams = function () {
|
|||
|
||||
Storage.getLogMonth = function () {
|
||||
var now = new Date();
|
||||
var month = '' + (now.getMonth()+1);
|
||||
var month = '' + (now.getMonth() + 1);
|
||||
if (month.length < 2) month = '0' + month;
|
||||
return '' + now.getFullYear() + '-' + month;
|
||||
};
|
||||
|
|
@ -986,7 +985,7 @@ Storage.nwLogChat = function (roomid, line) {
|
|||
var timestamp = '[' + hours + ':' + minutes + '] ';
|
||||
|
||||
if (!this.chatLogStreams[roomid]) {
|
||||
this.chatLogStreams[roomid] = fs.createWriteStream(this.dir + 'Logs/' + chatLogFdMonth + '/' + roomid + '.txt', {flags:'a'});
|
||||
this.chatLogStreams[roomid] = fs.createWriteStream(this.dir + 'Logs/' + chatLogFdMonth + '/' + roomid + '.txt', {flags: 'a'});
|
||||
this.chatLogStreams[roomid].write('\n\n\nLog starting ' + now + '\n\n');
|
||||
}
|
||||
this.chatLogStreams[roomid].write(timestamp + line + '\n');
|
||||
|
|
|
|||
241
js/utilichart.js
241
js/utilichart.js
|
|
@ -1,5 +1,4 @@
|
|||
function BattleChart()
|
||||
{
|
||||
function BattleChart() {
|
||||
var self = this;
|
||||
|
||||
this.firstResult = '';
|
||||
|
|
@ -10,24 +9,20 @@ function BattleChart()
|
|||
// but these are arrays of pointers, so it's not _horrible_
|
||||
// and this let me cache sorting
|
||||
this.pokemon = [];
|
||||
for (var i in BattlePokedex)
|
||||
{
|
||||
for (var i in BattlePokedex) {
|
||||
BattlePokedex[i].name = BattlePokedex[i].species;
|
||||
this.pokemon.push(BattlePokedex[i]);
|
||||
}
|
||||
this.items = [];
|
||||
for (var i in BattleItems)
|
||||
{
|
||||
for (var i in BattleItems) {
|
||||
this.items.push(BattleItems[i]);
|
||||
}
|
||||
this.abilities = [];
|
||||
for (var i in BattleAbilities)
|
||||
{
|
||||
for (var i in BattleAbilities) {
|
||||
this.abilities.push(BattleAbilities[i]);
|
||||
}
|
||||
this.moves = [];
|
||||
for (var i in BattleMovedex)
|
||||
{
|
||||
for (var i in BattleMovedex) {
|
||||
this.moves.push(BattleMovedex[i]);
|
||||
}
|
||||
|
||||
|
|
@ -46,13 +41,11 @@ function BattleChart()
|
|||
};
|
||||
|
||||
this.row = function (thing, attrs, match, isFirst, dataCommand) {
|
||||
if (isFirst)
|
||||
{
|
||||
if (isFirst) {
|
||||
self.firstResult = thing.name;
|
||||
}
|
||||
attrs = attrs || '';
|
||||
switch (match.thingType)
|
||||
{
|
||||
switch (match.thingType) {
|
||||
case 'pokemon':
|
||||
return self.pokemonRow(thing, attrs, match, isFirst, dataCommand);
|
||||
case 'item':
|
||||
|
|
@ -65,7 +58,7 @@ function BattleChart()
|
|||
};
|
||||
this.pokemonRow = function (pokemon, attrs, match, isFirst, dataCommand) {
|
||||
var tag = dataCommand ? 'div' : 'a';
|
||||
var text = '<li class="result' + (isFirst?' firstresult':'') + '"><' + tag + attrs + ' data-name="' + Tools.escapeHTML(pokemon.species) + '">';
|
||||
var text = '<li class="result' + (isFirst ? ' firstresult' : '') + '"><' + tag + attrs + ' data-name="' + Tools.escapeHTML(pokemon.species) + '">';
|
||||
|
||||
var tier = pokemon.tier;
|
||||
if (!tier) tier = Tools.getTemplate(pokemon.baseSpecies || pokemon.species).tier || 'Illegal';
|
||||
|
|
@ -75,19 +68,15 @@ function BattleChart()
|
|||
var name = Tools.escapeHTML(pokemon.name);
|
||||
|
||||
if (pokemon.forme && pokemon.baseSpecies) name = pokemon.baseSpecies;
|
||||
if (match.name)
|
||||
{
|
||||
name = name.substr(0, match.name.start) + '<b>' + name.substr(match.name.start, match.name.end-match.name.start) + '</b>' + name.substr(match.name.end);
|
||||
if (match.name) {
|
||||
name = name.substr(0, match.name.start) + '<b>' + name.substr(match.name.start, match.name.end - match.name.start) + '</b>' + name.substr(match.name.end);
|
||||
}
|
||||
if (pokemon.forme && pokemon.baseSpecies)
|
||||
{
|
||||
if (match.name && match.name.end > pokemon.baseSpecies.length)
|
||||
{
|
||||
if (match.name.start < pokemon.baseSpecies.length+1) match.name.start = pokemon.baseSpecies.length+1;
|
||||
name += '<small>-' + pokemon.forme.substr(0, match.name.start-(pokemon.baseSpecies.length+1)) + '<b>' + pokemon.name.substr(match.name.start, match.name.end-match.name.start) + '</b>' + pokemon.name.substr(match.name.end) + '</small>';
|
||||
if (pokemon.forme && pokemon.baseSpecies) {
|
||||
if (match.name && match.name.end > pokemon.baseSpecies.length) {
|
||||
if (match.name.start < pokemon.baseSpecies.length + 1) match.name.start = pokemon.baseSpecies.length + 1;
|
||||
name += '<small>-' + pokemon.forme.substr(0, match.name.start - (pokemon.baseSpecies.length + 1)) + '<b>' + pokemon.name.substr(match.name.start, match.name.end - match.name.start) + '</b>' + pokemon.name.substr(match.name.end) + '</small>';
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
name += '<small>-' + pokemon.forme + '</small>';
|
||||
}
|
||||
}
|
||||
|
|
@ -104,38 +93,32 @@ function BattleChart()
|
|||
text += '</span> ';
|
||||
text += '<span class="col pokemonnamecol" style="white-space:nowrap">' + name + '</span> ';
|
||||
|
||||
if (self.illegalBuckets[match.bucket])
|
||||
{
|
||||
if (self.illegalBuckets[match.bucket]) {
|
||||
text += '<span class="col illegalcol"><em>' + self.illegalBuckets[match.bucket] + '</em></span> ';
|
||||
text += '</a></li>';
|
||||
return text;
|
||||
}
|
||||
|
||||
text += '<span class="col typecol">';
|
||||
if (pokemon.types) for (var i=0; i<pokemon.types.length; i++)
|
||||
{
|
||||
text += Tools.getTypeIcon(pokemon.types[i], (match.type&&match.type[i]));
|
||||
if (pokemon.types) for (var i = 0; i < pokemon.types.length; i++) {
|
||||
text += Tools.getTypeIcon(pokemon.types[i], (match.type && match.type[i]));
|
||||
}
|
||||
text += '</span> ';
|
||||
|
||||
text += '<span style="float:left;min-height:26px">';
|
||||
if (pokemon.abilities['1'])
|
||||
{
|
||||
if (pokemon.abilities['1']) {
|
||||
text += '<span class="col twoabilitycol">';
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
text += '<span class="col abilitycol">';
|
||||
}
|
||||
for (var i in pokemon.abilities)
|
||||
{
|
||||
for (var i in pokemon.abilities) {
|
||||
var ability = pokemon.abilities[i];
|
||||
if (!ability) continue;
|
||||
|
||||
if (i === '1') text += '<br />';
|
||||
if (match.ability && match.ability[i])
|
||||
{
|
||||
ability = ability.substr(0, match.ability[i].start) + '<b>' + ability.substr(match.ability[i].start, match.ability[i].end-match.ability[i].start) + '</b>' + ability.substr(match.ability[i].end);
|
||||
if (match.ability && match.ability[i]) {
|
||||
ability = ability.substr(0, match.ability[i].start) + '<b>' + ability.substr(match.ability[i].start, match.ability[i].end - match.ability[i].start) + '</b>' + ability.substr(match.ability[i].end);
|
||||
}
|
||||
if (i == 'H') {
|
||||
ability = '</span><span class="col abilitycol"><em>' + (pokemon.unreleasedHidden ? '<s>' + ability + '</s>' : ability) + '</em>';
|
||||
|
|
@ -163,7 +146,7 @@ function BattleChart()
|
|||
return text;
|
||||
};
|
||||
this.itemRow = function (item, attrs, match, isFirst) {
|
||||
var text = '<li class="result' + (isFirst?' firstresult':'') + '"><a' + attrs + ' data-name="' + Tools.escapeHTML(item.name) + '">';
|
||||
var text = '<li class="result' + (isFirst ? ' firstresult' : '') + '"><a' + attrs + ' data-name="' + Tools.escapeHTML(item.name) + '">';
|
||||
|
||||
var url = item.name.toLowerCase().replace(/ /g, '-').replace(/[^a-z-]+/g, '');
|
||||
url = '/sprites/itemicons/' + url + '.png';
|
||||
|
|
@ -174,14 +157,12 @@ function BattleChart()
|
|||
|
||||
var name = Tools.escapeHTML(item.name);
|
||||
|
||||
if (match.name)
|
||||
{
|
||||
name = name.substr(0, match.name.start) + '<b>' + name.substr(match.name.start, match.name.end-match.name.start) + '</b>' + name.substr(match.name.end);
|
||||
if (match.name) {
|
||||
name = name.substr(0, match.name.start) + '<b>' + name.substr(match.name.start, match.name.end - match.name.start) + '</b>' + name.substr(match.name.end);
|
||||
}
|
||||
text += '<span class="col namecol">' + name + '</span> ';
|
||||
|
||||
if (self.illegalBuckets[match.bucket])
|
||||
{
|
||||
if (self.illegalBuckets[match.bucket]) {
|
||||
text += '<span class="col illegalcol"><em>' + self.illegalBuckets[match.bucket] + '</em></span> ';
|
||||
text += '</a></li>';
|
||||
return text;
|
||||
|
|
@ -194,17 +175,15 @@ function BattleChart()
|
|||
return text;
|
||||
};
|
||||
this.abilityRow = function (ability, attrs, match, isFirst) {
|
||||
var text = '<li class="result' + (isFirst?' firstresult':'') + '"><a' + attrs + ' data-name="' + Tools.escapeHTML(ability.name) + '">';
|
||||
var text = '<li class="result' + (isFirst ? ' firstresult' : '') + '"><a' + attrs + ' data-name="' + Tools.escapeHTML(ability.name) + '">';
|
||||
|
||||
var name = Tools.escapeHTML(ability.name);
|
||||
if (match.name)
|
||||
{
|
||||
name = name.substr(0, match.name.start) + '<b>' + name.substr(match.name.start, match.name.end-match.name.start) + '</b>' + name.substr(match.name.end);
|
||||
if (match.name) {
|
||||
name = name.substr(0, match.name.start) + '<b>' + name.substr(match.name.start, match.name.end - match.name.start) + '</b>' + name.substr(match.name.end);
|
||||
}
|
||||
text += '<span class="col namecol">' + name + '</span> ';
|
||||
|
||||
if (self.illegalBuckets[match.bucket])
|
||||
{
|
||||
if (self.illegalBuckets[match.bucket]) {
|
||||
text += '<span class="col illegalcol"><em>' + self.illegalBuckets[match.bucket] + '</em></span> ';
|
||||
text += '</a></li>';
|
||||
return text;
|
||||
|
|
@ -217,31 +196,26 @@ function BattleChart()
|
|||
return text;
|
||||
};
|
||||
this.moveRow = function (move, attrs, match, isFirst) {
|
||||
var text = '<li class="result' + (isFirst?' firstresult':'') + '"><a' + attrs + ' data-name="' + Tools.escapeHTML(move.name) + '">';
|
||||
var text = '<li class="result' + (isFirst ? ' firstresult' : '') + '"><a' + attrs + ' data-name="' + Tools.escapeHTML(move.name) + '">';
|
||||
|
||||
var name = Tools.escapeHTML(move.name);
|
||||
var hplen = 'Hidden Power'.length;
|
||||
if (name.substr(0, hplen) === 'Hidden Power') name = 'Hidden Power';
|
||||
if (match.name)
|
||||
{
|
||||
name = name.substr(0, match.name.start) + '<b>' + name.substr(match.name.start, match.name.end-match.name.start) + '</b>' + name.substr(match.name.end);
|
||||
if (match.name) {
|
||||
name = name.substr(0, match.name.start) + '<b>' + name.substr(match.name.start, match.name.end - match.name.start) + '</b>' + name.substr(match.name.end);
|
||||
}
|
||||
if (move.name.substr(0, hplen) === 'Hidden Power')
|
||||
{
|
||||
if (match.name && match.name.end > hplen)
|
||||
{
|
||||
if (match.name.start < hplen+1) match.name.start = hplen+1;
|
||||
name += '<small> ' + move.name.substr(hplen+1, match.name.start-(hplen+1)) + '<b>' + move.name.substr(match.name.start, match.name.end-match.name.start) + '</b>' + move.name.substr(match.name.end) + '</small>';
|
||||
if (move.name.substr(0, hplen) === 'Hidden Power') {
|
||||
if (match.name && match.name.end > hplen) {
|
||||
if (match.name.start < hplen + 1) match.name.start = hplen + 1;
|
||||
name += '<small> ' + move.name.substr(hplen + 1, match.name.start - (hplen + 1)) + '<b>' + move.name.substr(match.name.start, match.name.end - match.name.start) + '</b>' + move.name.substr(match.name.end) + '</small>';
|
||||
}
|
||||
else
|
||||
{
|
||||
name += '<small> ' + move.name.substr(hplen+1) +'</small>';
|
||||
else {
|
||||
name += '<small> ' + move.name.substr(hplen + 1) + '</small>';
|
||||
}
|
||||
}
|
||||
text += '<span class="col movenamecol">' + name + '</span> ';
|
||||
|
||||
if (self.illegalBuckets[match.bucket])
|
||||
{
|
||||
if (self.illegalBuckets[match.bucket]) {
|
||||
text += '<span class="col illegalcol"><em>' + self.illegalBuckets[match.bucket] + '</em></span> ';
|
||||
text += '</a></li>';
|
||||
return text;
|
||||
|
|
@ -249,12 +223,12 @@ function BattleChart()
|
|||
|
||||
text += '<span class="col typecol">';
|
||||
text += Tools.getTypeIcon(move.type, match.type);
|
||||
text += '<img src="' + Tools.resourcePrefix + 'sprites/categories/' + move.category + '.png" alt="' + move.category + '" height="14" width="32"' + (match.category?' class="b"':'') + ' />';
|
||||
text += '<img src="' + Tools.resourcePrefix + 'sprites/categories/' + move.category + '.png" alt="' + move.category + '" height="14" width="32"' + (match.category ? ' class="b"' : '') + ' />';
|
||||
text += '</span> ';
|
||||
|
||||
text += '<span class="col labelcol">' + (move.category!=='Status'?('<em>Power</em><br />' + (move.basePower||'—')):'') + '</span> ';
|
||||
text += '<span class="col widelabelcol"><em>Accuracy</em><br />' + (move.accuracy && move.accuracy!==true?move.accuracy + '%':'—') + '</span> ';
|
||||
text += '<span class="col pplabelcol"><em>PP</em><br />' + ((move.pp!==1 && !move.noPPBoosts)?move.pp*8/5:move.pp) + '</span> ';
|
||||
text += '<span class="col labelcol">' + (move.category !== 'Status' ? ('<em>Power</em><br />' + (move.basePower || '—')) : '') + '</span> ';
|
||||
text += '<span class="col widelabelcol"><em>Accuracy</em><br />' + (move.accuracy && move.accuracy !== true ? move.accuracy + '%' : '—') + '</span> ';
|
||||
text += '<span class="col pplabelcol"><em>PP</em><br />' + ((move.pp !== 1 && !move.noPPBoosts) ? move.pp * 8 / 5 : move.pp) + '</span> ';
|
||||
|
||||
text += '<span class="col movedesccol">' + Tools.escapeHTML(move.shortDesc || move.desc) + '</span> ';
|
||||
|
||||
|
|
@ -287,35 +261,30 @@ function BattleChart()
|
|||
var buckets = thisArrange();
|
||||
var things = [];
|
||||
|
||||
switch (type)
|
||||
{
|
||||
switch (type) {
|
||||
case 'pokemon':
|
||||
if (thisSort !== self.lastPokemonSort)
|
||||
{
|
||||
if (thisSort !== self.lastPokemonSort) {
|
||||
self.pokemon.sort(thisSort);
|
||||
self.lastPokemonSort = thisSort;
|
||||
}
|
||||
things = self.pokemon;
|
||||
break;
|
||||
case 'item':
|
||||
if (thisSort !== self.lastItemSort)
|
||||
{
|
||||
if (thisSort !== self.lastItemSort) {
|
||||
self.items.sort(thisSort);
|
||||
self.lastItemSort = thisSort;
|
||||
}
|
||||
things = self.items;
|
||||
break;
|
||||
case 'ability':
|
||||
if (thisSort !== self.lastAbilitySort)
|
||||
{
|
||||
if (thisSort !== self.lastAbilitySort) {
|
||||
self.abilities.sort(thisSort);
|
||||
self.lastAbilitySort = thisSort;
|
||||
}
|
||||
things = self.abilities;
|
||||
break;
|
||||
case 'move':
|
||||
if (thisSort !== self.lastMoveSort)
|
||||
{
|
||||
if (thisSort !== self.lastMoveSort) {
|
||||
self.moves.sort(thisSort);
|
||||
self.lastMoveSort = thisSort;
|
||||
}
|
||||
|
|
@ -323,10 +292,9 @@ function BattleChart()
|
|||
break;
|
||||
}
|
||||
|
||||
for (var i=0; i<things.length; i++)
|
||||
{
|
||||
for (var i = 0; i < things.length; i++) {
|
||||
var thing = things[i];
|
||||
if (type==='pokemon' && !thing.species || thing.jp) continue;
|
||||
if (type === 'pokemon' && !thing.species || thing.jp) continue;
|
||||
|
||||
// fill our buckets!
|
||||
var bucket = thisArrange(thing);
|
||||
|
|
@ -335,37 +303,31 @@ function BattleChart()
|
|||
var matchType = 'other';
|
||||
var index = -1;
|
||||
|
||||
if (searchTerm)
|
||||
{
|
||||
if (searchTerm) {
|
||||
index = thing.name.toLowerCase().indexOf(searchTerm);
|
||||
|
||||
if (index === 0)
|
||||
{
|
||||
if (index === 0) {
|
||||
matchType = 'start';
|
||||
match.name = {
|
||||
start: index,
|
||||
end: index+searchTerm.length
|
||||
end: index + searchTerm.length
|
||||
};
|
||||
if (searchTerm.length === thing.name.length)
|
||||
{
|
||||
if (searchTerm.length === thing.name.length) {
|
||||
self.exactResult = thing.name;
|
||||
matchType = 'exact';
|
||||
}
|
||||
}
|
||||
else if (index >= 0)
|
||||
{
|
||||
else if (index >= 0) {
|
||||
matchType = 'contains';
|
||||
match.name = {
|
||||
start: index,
|
||||
end: index+searchTerm.length
|
||||
end: index + searchTerm.length
|
||||
};
|
||||
}
|
||||
else if (type === 'pokemon')
|
||||
{
|
||||
else if (type === 'pokemon') {
|
||||
index = thing.types[0].toLowerCase().indexOf(searchTerm);
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
if (index == 0) {
|
||||
matchType = 'fullstart';
|
||||
match.type = {0:{
|
||||
start: 0,
|
||||
|
|
@ -373,12 +335,10 @@ function BattleChart()
|
|||
}};
|
||||
}
|
||||
|
||||
if (thing.types[1])
|
||||
{
|
||||
if (thing.types[1]) {
|
||||
index = thing.types[1].toLowerCase().indexOf(searchTerm);
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
if (index == 0) {
|
||||
matchType = 'fullstart';
|
||||
match.type = {1:{
|
||||
start: 0,
|
||||
|
|
@ -388,8 +348,7 @@ function BattleChart()
|
|||
}
|
||||
|
||||
index = thing.abilities['0'].toLowerCase().indexOf(searchTerm);
|
||||
if (index == 0)
|
||||
{
|
||||
if (index == 0) {
|
||||
matchType = 'fullstart';
|
||||
match.ability = {0:{
|
||||
start: 0,
|
||||
|
|
@ -397,11 +356,9 @@ function BattleChart()
|
|||
}};
|
||||
}
|
||||
|
||||
if (thing.abilities['1'])
|
||||
{
|
||||
if (thing.abilities['1']) {
|
||||
index = thing.abilities['1'].toLowerCase().indexOf(searchTerm);
|
||||
if (index == 0)
|
||||
{
|
||||
if (index == 0) {
|
||||
matchType = 'fullstart';
|
||||
match.ability = {1:{
|
||||
start: 0,
|
||||
|
|
@ -410,11 +367,9 @@ function BattleChart()
|
|||
}
|
||||
}
|
||||
|
||||
if (thing.abilities['H'])
|
||||
{
|
||||
if (thing.abilities['H']) {
|
||||
index = thing.abilities['H'].toLowerCase().indexOf(searchTerm);
|
||||
if (index == 0)
|
||||
{
|
||||
if (index == 0) {
|
||||
matchType = 'fullstart';
|
||||
match.ability = {H:{
|
||||
start: 0,
|
||||
|
|
@ -427,8 +382,7 @@ function BattleChart()
|
|||
{
|
||||
index = thing.type.toLowerCase().indexOf(searchTerm);
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
if (index == 0) {
|
||||
matchType = 'fullstart';
|
||||
match.type = {
|
||||
start: 0,
|
||||
|
|
@ -438,8 +392,7 @@ function BattleChart()
|
|||
|
||||
index = thing.category.toLowerCase().indexOf(searchTerm);
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
if (index == 0) {
|
||||
matchType = 'fullstart';
|
||||
match.category = {
|
||||
start: 0,
|
||||
|
|
@ -449,10 +402,8 @@ function BattleChart()
|
|||
}
|
||||
}
|
||||
|
||||
if (self.illegalBuckets[bucket])
|
||||
{
|
||||
if (matchType === 'start' || matchType === 'contains' || matchType === 'fullstart')
|
||||
{
|
||||
if (self.illegalBuckets[bucket]) {
|
||||
if (matchType === 'start' || matchType === 'contains' || matchType === 'fullstart') {
|
||||
matchType = 'illegal' + matchType;
|
||||
}
|
||||
}
|
||||
|
|
@ -469,17 +420,13 @@ function BattleChart()
|
|||
var noNameMatch = false;
|
||||
|
||||
var matchTypes = ['exact', 'start', 'contains', 'illegalstart', 'illegalcontains'];
|
||||
for (var mtIndex = 0; mtIndex < 5; mtIndex++)
|
||||
{
|
||||
for (var mtIndex = 0; mtIndex < 5; mtIndex++) {
|
||||
var matchType = matchTypes[mtIndex];
|
||||
for (var i in chartData[matchType])
|
||||
{
|
||||
for (var i in chartData[matchType]) {
|
||||
if (!chartData[matchType][i]) continue;
|
||||
for (var j=0; j<chartData[matchType][i].length; j++)
|
||||
{
|
||||
for (var j = 0; j < chartData[matchType][i].length; j++) {
|
||||
var match = chartData[matchType][i][j];
|
||||
if (firstMatch)
|
||||
{
|
||||
if (firstMatch) {
|
||||
text += '<li><h3>Matches</h3></li>';
|
||||
}
|
||||
text += self.row(match.thing, '', match, firstMatch);
|
||||
|
|
@ -488,8 +435,7 @@ function BattleChart()
|
|||
}
|
||||
}
|
||||
|
||||
if (searchTerm && firstMatch)
|
||||
{
|
||||
if (searchTerm && firstMatch) {
|
||||
text += '<li><h3>Matches</h3></li><li><em>No matches</em></li>';
|
||||
firstMatch = false;
|
||||
noNameMatch = true;
|
||||
|
|
@ -497,28 +443,22 @@ function BattleChart()
|
|||
|
||||
firstMatch = true;
|
||||
|
||||
for (var i in chartData.fullstart)
|
||||
{
|
||||
for (var i in chartData.fullstart) {
|
||||
if (!chartData.fullstart[i]) continue;
|
||||
for (var j=0; j<chartData.fullstart[i].length; j++)
|
||||
{
|
||||
for (var j = 0; j < chartData.fullstart[i].length; j++) {
|
||||
var match = chartData.fullstart[i][j];
|
||||
if (firstMatch)
|
||||
{
|
||||
if (firstMatch) {
|
||||
text += '<li><h3>Details Matches</h3></li>';
|
||||
}
|
||||
text += self.row(match.thing, '', match, firstMatch && noNameMatch);
|
||||
firstMatch = false;
|
||||
}
|
||||
}
|
||||
for (var i in chartData.illegalfullstart)
|
||||
{
|
||||
for (var i in chartData.illegalfullstart) {
|
||||
if (!chartData.illegalfullstart[i]) continue;
|
||||
for (var j=0; j<chartData.illegalfullstart[i].length; j++)
|
||||
{
|
||||
for (var j = 0; j < chartData.illegalfullstart[i].length; j++) {
|
||||
var match = chartData.illegalfullstart[i][j];
|
||||
if (firstMatch)
|
||||
{
|
||||
if (firstMatch) {
|
||||
text += '<li><h3>Details Matches</h3></li>';
|
||||
}
|
||||
text += self.row(match.thing, '', match, firstMatch && noNameMatch);
|
||||
|
|
@ -526,18 +466,14 @@ function BattleChart()
|
|||
}
|
||||
}
|
||||
|
||||
if (!searchTerm || init)
|
||||
{
|
||||
for (var i=0; i<buckets.length; i++)
|
||||
{
|
||||
if (!searchTerm || init) {
|
||||
for (var i = 0; i < buckets.length; i++) {
|
||||
var ib = buckets[i];
|
||||
if (!chartData.other[ib]) continue;
|
||||
firstMatch = true;
|
||||
for (var j=0; j<chartData.other[ib].length; j++)
|
||||
{
|
||||
for (var j = 0; j < chartData.other[ib].length; j++) {
|
||||
var match = chartData.other[ib][j];
|
||||
if (firstMatch)
|
||||
{
|
||||
if (firstMatch) {
|
||||
text += '<li><h3>' + buckets[i] + '</h3></li>';
|
||||
firstMatch = false;
|
||||
}
|
||||
|
|
@ -551,14 +487,13 @@ function BattleChart()
|
|||
};
|
||||
|
||||
this.defaultArrange = function (thing) {
|
||||
if (!thing)
|
||||
{
|
||||
if (!thing) {
|
||||
// we want the list of buckets
|
||||
return ['All'];
|
||||
}
|
||||
return 'All';
|
||||
};
|
||||
this.defaultSort = function (a,b) {
|
||||
this.defaultSort = function (a, b) {
|
||||
/* if (!a.num) a.num = 1000;
|
||||
if (!b.num) b.num = 1000;
|
||||
if (a.num != b.num)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user