diff --git a/js/battle.js b/js/battle.js index 8ed9d4d7b..b392956db 100755 --- a/js/battle.js +++ b/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 = '
' + pokemonhtml + '
'; if (this.n === 1) { if (this.initialized) { - this.battle.rightbarElem.html('
' + Tools.escapeHTML(this.name) + '
' + pokemonhtml + '
').find('.trainer').css('opacity',1); + this.battle.rightbarElem.html('
' + Tools.escapeHTML(this.name) + '
' + pokemonhtml + '
').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('
' + Tools.escapeHTML(this.name) + '
' + pokemonhtml + '
').find('.trainer').css('opacity',1); + this.battle.leftbarElem.html('
' + Tools.escapeHTML(this.name) + '
' + pokemonhtml + '
').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('
' + newWeather.upkeepMessage + '
'); this.weatherTimeLeft = 0; this.weatherMinTimeLeft = 0; - } else if (weather === 'deltastream' || weather === 'desolateland' || weather === 'primordialsea'){ + } else if (weather === 'deltastream' || weather === 'desolateland' || weather === 'primordialsea') { this.message('' + newWeather.startMessage + ''); 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 ' + move.name + '!'); @@ -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('
' + Tools.escapeHTML(name) + ': ' + button + '
'); button = (name === 'Diatom' ? "thanks diatom" : null); } @@ -3084,7 +3093,7 @@ var Battle = (function () { this.message('' + pokemon.getName() + (move.name ? ' can\'t use ' + move.name + '' : ' can\'t move') + '!'); 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' + Tools.escapeHTML(ruleArgs[0]) + (ruleArgs[1]?':':'') + ' ' + Tools.escapeHTML(ruleArgs[1]||'') + ''); + this.log('
' + Tools.escapeHTML(ruleArgs[0]) + (ruleArgs[1] ? ':' : '') + ' ' + Tools.escapeHTML(ruleArgs[1] || '') + '
'); 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('
' + clickableName + ': ' + Tools.parseMessage(message.substr(1)) + '
', preempt); - } else if (message.substr(0,4).toLowerCase() === '/me ') { + } else if (message.substr(0, 4).toLowerCase() === '/me ') { this.log('
' + clickableName + ' ' + Tools.parseMessage(message.substr(4)) + '
', preempt); - } else if (message.substr(0,14).toLowerCase() === '/data-pokemon ') { - if (window.Chart) this.log('
    ' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)),'',{},false,true) + '
', preempt); - } else if (message.substr(0,11).toLowerCase() === '/data-item ') { - if (window.Chart) this.log('
    ' + Chart.itemRow(Tools.getItem(message.substr(11)),'',{},false,true) + '
', preempt); - } else if (message.substr(0,14).toLowerCase() === '/data-ability ') { - if (window.Chart) this.log('
    ' + Chart.abilityRow(Tools.getAbility(message.substr(14)),'',{},false,true) + '
', preempt); - } else if (message.substr(0,11).toLowerCase() === '/data-move ') { - if (window.Chart) this.log('
    ' + Chart.moveRow(Tools.getMove(message.substr(11)),'',{},false,true) + '
', preempt); + } else if (message.substr(0, 14).toLowerCase() === '/data-pokemon ') { + if (window.Chart) this.log('
    ' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)), '', {}, false, true) + '
', preempt); + } else if (message.substr(0, 11).toLowerCase() === '/data-item ') { + if (window.Chart) this.log('
    ' + Chart.itemRow(Tools.getItem(message.substr(11)), '', {}, false, true) + '
', preempt); + } else if (message.substr(0, 14).toLowerCase() === '/data-ability ') { + if (window.Chart) this.log('
    ' + Chart.abilityRow(Tools.getAbility(message.substr(14)), '', {}, false, true) + '
', preempt); + } else if (message.substr(0, 11).toLowerCase() === '/data-move ') { + if (window.Chart) this.log('
    ' + Chart.moveRow(Tools.getMove(message.substr(11)), '', {}, false, true) + '
', preempt); } else { this.log('
' + clickableName + ': ' + Tools.parseMessage(message) + '
', preempt); } @@ -5425,7 +5428,7 @@ var Battle = (function () { case 'clearpoke': this.p1.pokemon = []; this.p2.pokemon = []; - for (var i=0; i' + Tools.escapeHTML(str) + '', 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('
Error parsing: ' + Tools.escapeHTML(str) + '
', 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('
' + Tools.escapeHTML(stack) + '
', preempt); } else { this.log('
Error: ' + Tools.escapeHTML('' + e) + '
', preempt); diff --git a/js/battledata.js b/js/battledata.js index 171de1cc6..6f92d788c 100755 --- a/js/battledata.js +++ b/js/battledata.js @@ -43,7 +43,7 @@ for (var i=0; i$1'); + options.hidemonospace ? '$1' : '$1'); // ~~strikethrough~~ str = str.replace(/\~\~([^< ](?:[^<]*?[^< ])??)\~\~/g, - options.hidestrikethrough ? '$1' : '$1'); + options.hidestrikethrough ? '$1' : '$1'); // <> str = str.replace(/<<([a-z0-9-]+)>>/g, - options.hidelinks ? '«$1»' : '«$1»'); + options.hidelinks ? '«$1»' : '«$1»'); // 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 '' + p1 +''; + '" target="_blank">' + p1 + ''; }); } // __italics__ str = str.replace(/\_\_([^< ](?:[^<]*?[^< ])??)\_\_(?![^<]*?<\/a)/g, - options.hideitalics ? '$1' : '$1'); + options.hideitalics ? '$1' : '$1'); // **bold** str = str.replace(/\*\*([^< ](?:[^<]*?[^< ])??)\*\*/g, options.hidebold ? '$1' : '$1'); @@ -496,14 +495,14 @@ var Tools = { }, escapeHTML: function (str, jsEscapeToo) { - str = (str?'' + str:''); + str = (str ? '' + str : ''); str = str.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 '' + type + ''; + var sanitizedType = type.replace(/\?/g, '%3f'); + return '' + type + ''; } }; diff --git a/js/client-battle.js b/js/client-battle.js index 486d94176..bbf3f30fb 100755 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -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 += ' '; } else if (!pokemon || pokemon.zerohp) { - controls += ' '; + controls += ' '; } else { - controls += ' '; + controls += ' '; } } controls += '
'; @@ -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 += ' '; } else if (!pokemon || pokemon.zerohp) { - controls += ' '; + controls += ' '; } else { - controls += ' '; + controls += ' '; } } controls += '
'; @@ -407,7 +407,7 @@ movebuttons += ' '; @@ -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 += ' '; + controls += ' '; } else { - controls += ' '; + controls += ' '; } } 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?'; @@ -489,11 +489,11 @@ pokemon = this.battle.mySide.pokemon[i]; if (pokemon && !pokemon.zerohp || this.choice.switchOutFlags[i]) { - controls += ' '; + controls += ' '; } else if (!pokemon) { controls += ' '; } else { - controls += ' '; + controls += ' '; } } controls += ''; @@ -514,7 +514,7 @@ } else { controls += ' '; + controls += '' + Tools.escapeHTML(pokemon.name) + (!pokemon.zerohp ? '' + (pokemon.status ? '' : '') : '') + ' '; } controls += ''; this.$controls.html(controls); @@ -525,7 +525,7 @@ var controls = '
'; 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 += ' '; } - 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 += '
'; } else { controls += ' What about the rest of your team?
'; - controls += '
'; + controls += '
'; 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 += ' '; + controls += ' '; } else { - controls += ' '; + controls += ' '; } } controls += '
'; @@ -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 = ' (' + pokemon.hp + '/' + pokemon.maxhp + ' pixels)'; - text += '

HP: ' + pokemon.hpDisplay() +exacthp+(pokemon.status?' ' + pokemon.status.toUpperCase() + '':'') +'

'; + text += '

HP: ' + pokemon.hpDisplay() + exacthp + (pokemon.status ? ' ' + pokemon.status.toUpperCase() + '' : '') + '

'; 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 += '

' + minSpe + ' to ' + maxSpe + ' Spe (before items/abilities/modifiers)

'; } diff --git a/js/client-chat-tournament.js b/js/client-chat-tournament.js old mode 100644 new mode 100755 index 7abaef6d2..4e2840af2 --- a/js/client-chat-tournament.js +++ b/js/client-chat-tournament.js @@ -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("
The tournament has started!
"); @@ -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("
Congratulations to " + Tools.escapeHTML(arrayToPhrase(endData.results[0])) + " for winning the " + Tools.escapeHTML(format) + " " + Tools.escapeHTML(type) + " Tournament!
"); if (endData.results[1]) - this.room.$chat.append("
Runner-up" + (endData.results[1].length > 1 ? "s" : "") +": " + Tools.escapeHTML(arrayToPhrase(endData.results[1])) + "
"); + this.room.$chat.append("
Runner-up" + (endData.results[1].length > 1 ? "s" : "") + ": " + Tools.escapeHTML(arrayToPhrase(endData.results[1])) + "
"); // Fallthrough diff --git a/js/client-chat.js b/js/client-chat.js index ec62aa490..0ac66c1b7 100755 --- a/js/client-chat.js +++ b/js/client-chat.js @@ -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; iGXEGlicko-1COILWLT'; var hiddenFormats = []; var formatLength = data.length; - for (var i=0; i' + Math.round(row.acre) + '' + Math.round(row.gxe,1) + ''; + buffer += '' + row.formatid + '' + Math.round(row.acre) + '' + Math.round(row.gxe, 1) + ''; if (row.rprd > 100) { buffer += '' + Math.round(row.rpr) + ' ± ' + Math.round(row.rprd) + ' (provisional)'; } else { buffer += '' + Math.round(row.rpr) + ' ± ' + Math.round(row.rprd) + ''; } - 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 += '' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-17.0/N),0) + ''; + buffer += '' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -17.0 / N), 0) + ''; } else if (row.formatid === 'uberssuspecttest') { - buffer += '' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-29.0/N),0) + ''; + buffer += '' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -29.0 / N), 0) + ''; } else if (row.formatid === 'uususpecttest') { - buffer += '' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-20.0/N),0) + ''; + buffer += '' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -20.0 / N), 0) + ''; } else if (row.formatid === 'rususpecttest') { - buffer += '' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-9.0/N),0) + ''; + buffer += '' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -9.0 / N), 0) + ''; } else if (row.formatid === 'nususpecttest') { - buffer += '' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-20.0/N),0) + ''; + buffer += '' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -20.0 / N), 0) + ''; } else if (row.formatid === 'lcsuspecttest') { - buffer += '' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-43.0/N),0) + ''; + buffer += '' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -43.0 / N), 0) + ''; } else if (row.formatid === 'doublesoucurrent' || row.formatid === 'doublesoususpecttest') { - buffer += '' + Math.round(40.0*parseFloat(row.gxe)*Math.pow(2.0,-16.0/N),0) + ''; + buffer += '' + Math.round(40.0 * parseFloat(row.gxe) * Math.pow(2.0, -16.0 / N), 0) + ''; } else { buffer += '--'; } @@ -804,7 +804,7 @@ } buffer += '
'; 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' + timestamp + '' + clickableName + ': (Private to ' + Tools.escapeHTML(pm) + ') ' + Tools.parseMessage(message) + '
'); - } 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 + ' ' + clickableName + ' ' + Tools.parseMessage(message) + '
'); @@ -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 + ' ' + clickableName + '' + Tools.parseMessage(message) + ''); @@ -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 + '' + clickableName + ': ' + Tools.parseMessage(message.substr(10)) + ''); Storage.logChat(this.id, '' + name + ': /announce ' + message); - } else if (message.substr(0,14) === '/data-pokemon ') { - this.$chat.append('
    ' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)),'',{},false,true) + '
'); - } else if (message.substr(0,11) === '/data-item ') { - this.$chat.append('
    ' + Chart.itemRow(Tools.getItem(message.substr(11)),'',{},false,true) + '
'); - } else if (message.substr(0,14) === '/data-ability ') { - this.$chat.append('
    ' + Chart.abilityRow(Tools.getAbility(message.substr(14)),'',{},false,true) + '
'); - } else if (message.substr(0,11) === '/data-move ') { - this.$chat.append('
    ' + Chart.moveRow(Tools.getMove(message.substr(11)),'',{},false,true) + '
'); + } else if (message.substr(0, 14) === '/data-pokemon ') { + this.$chat.append('
    ' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)), '', {}, false, true) + '
'); + } else if (message.substr(0, 11) === '/data-item ') { + this.$chat.append('
    ' + Chart.itemRow(Tools.getItem(message.substr(11)), '', {}, false, true) + '
'); + } else if (message.substr(0, 14) === '/data-ability ') { + this.$chat.append('
    ' + Chart.abilityRow(Tools.getAbility(message.substr(14)), '', {}, false, true) + '
'); + } else if (message.substr(0, 11) === '/data-move ') { + this.$chat.append('
    ' + Chart.moveRow(Tools.getMove(message.substr(11)), '', {}, false, true) + '
'); } 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'; + text += ''; text += '

'; buf += '

' + format + ' Top 500

'; diff --git a/js/client-mainmenu.js b/js/client-mainmenu.js index b28ebd1da..a21ba4bdf 100755 --- a/js/client-mainmenu.js +++ b/js/client-mainmenu.js @@ -99,7 +99,7 @@ if (newsId === '' + Tools.prefs('readnews')) return; this.addPseudoPM({ title: 'Latest News', - html: '', + html: '', 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 = '' + Tools.escapeHTML(name.substr(1)) + ''; if (name.substr(0, 1) !== ' ') clickableName = '' + Tools.escapeHTML(name.substr(0, 1)) + '' + clickableName; - if (message.substr(0,4) === '/me ') { + if (message.substr(0, 4) === '/me ') { $chat.append('
' + timestamp + ' ' + clickableName + ' ' + Tools.parseMessage(message.substr(4)) + '
'); - } else if (message.substr(0,5) === '/mee ') { + } else if (message.substr(0, 5) === '/mee ') { $chat.append('
' + timestamp + ' ' + clickableName + '' + Tools.parseMessage(message.substr(5)) + '
'); - } else if (message.substr(0,8) === '/invite ') { + } else if (message.substr(0, 8) === '/invite ') { var roomid = toRoomid(message.substr(8)); $chat.append('
' + timestamp + '' + clickableName + ' invited you to join the room "' + roomid + '"
'); $chat.append('
'); - } else if (message.substr(0,10) === '/announce ') { + } else if (message.substr(0, 10) === '/announce ') { $chat.append('
' + timestamp + '' + clickableName + ': ' + Tools.parseMessage(message.substr(10)) + '
'); - } else if (message.substr(0,14) === '/data-pokemon ') { - $chat.append('
    ' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)),'',{},false,true) + '
'); - } else if (message.substr(0,11) === '/data-item ') { - $chat.append('
    ' + Chart.itemRow(Tools.getItem(message.substr(11)),'',{},false,true) + '
'); - } else if (message.substr(0,14) === '/data-ability ') { - $chat.append('
    ' + Chart.abilityRow(Tools.getAbility(message.substr(14)),'',{},false,true) + '
'); - } else if (message.substr(0,11) === '/data-move ') { - $chat.append('
    ' + Chart.moveRow(Tools.getMove(message.substr(11)),'',{},false,true) + '
'); - } else if (message.substr(0,6) === '/text ') { + } else if (message.substr(0, 14) === '/data-pokemon ') { + $chat.append('
    ' + Chart.pokemonRow(Tools.getTemplate(message.substr(14)), '', {}, false, true) + '
'); + } else if (message.substr(0, 11) === '/data-item ') { + $chat.append('
    ' + Chart.itemRow(Tools.getItem(message.substr(11)), '', {}, false, true) + '
'); + } else if (message.substr(0, 14) === '/data-ability ') { + $chat.append('
    ' + Chart.abilityRow(Tools.getAbility(message.substr(14)), '', {}, false, true) + '
'); + } else if (message.substr(0, 11) === '/data-move ') { + $chat.append('
    ' + Chart.moveRow(Tools.getMove(message.substr(11)), '', {}, false, true) + '
'); + } else if (message.substr(0, 6) === '/text ') { $chat.append('
' + Tools.escapeHTML(message.substr(6)) + '
'); - } else if (message.substr(0,7) === '/error ') { + } else if (message.substr(0, 7) === '/error ') { $chat.append('
' + Tools.escapeHTML(message.substr(7)) + '
'); - } else if (message.substr(0,6) === '/html ') { + } else if (message.substr(0, 6) === '/html ') { $chat.append('
' + Tools.sanitizeHTML(message.substr(6)) + '
'); } else { // Normal chat message. - if (message.substr(0,2) === '//') message = message.substr(1); + if (message.substr(0, 2) === '//') message = message.substr(1); $chat.append('
' + timestamp + '' + clickableName + ': ' + Tools.parseMessage(message) + '
'); } @@ -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 ''; + return ''; }, curTeamFormat: '', curTeamIndex: -1, @@ -653,7 +653,7 @@ teamIndex = this.curTeamIndex; } if (this.curTeamFormat !== formatid) { - for (var i=0; ijoining the Help room?"}); + app.addPopup(Popup, {htmlMessage: "Zarel is very busy; please don't contact him this way. If you're looking for help, try joining the Help room?"}); 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] += '
  • '; + bufs[curBuf] += '
  • '; 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] += '
  • '; + bufs[curBuf] += '
  • '; 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('
      ' + bufs.join('
      ') + '
    '); } else { this.$el.html('
      ' + bufs[0] + '
    '); @@ -845,7 +845,7 @@ renderTeam: function (i) { if (i === 'random') { var buf = 'Random team
    '; - for (var i=0; i<6; i++) { + for (var i = 0; i < 6; i++) { buf += ''; } 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 += ''; } } @@ -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 ? '[' + Tools.escapeFormat(format) + ']
    ' : ''); var roomDesc = formatBuf + '' + Tools.escapeHTML(roomData.p1) + ' vs. ' + Tools.escapeHTML(roomData.p2) + ''; diff --git a/js/client-rooms.js b/js/client-rooms.js index b3f4e7d23..7d1bf391c 100755 --- a/js/client-rooms.js +++ b/js/client-rooms.js @@ -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 += '

    '; - buf += '' + userCount + ' ' + (userCount==1?'user':'users') + ' online '; - buf += '' + battleCount + ' active ' + (battleCount==1?'battle':'battles') + ''; + buf += '' + userCount + ' ' + (userCount == 1 ? 'user' : 'users') + ' online '; + buf += '' + battleCount + ' active ' + (battleCount == 1 ? 'battle' : 'battles') + ''; buf += '

    '; } buf += '

    Official chat rooms

    '; - for (var i=0; i(' + Number(roomData.userCount) + ' users) ' + Tools.escapeHTML(roomData.title) + '
    ' + Tools.escapeHTML(roomData.desc||'') + ''; + buf += ''; } buf += '

    Chat rooms

    '; rooms.chat.sort(function (a, b) { return b.userCount - a.userCount; }); - for (var i=0; i(' + Number(roomData.userCount) + ' users) ' + Tools.escapeHTML(roomData.title) + '
    ' + escapedDesc + ''; } diff --git a/js/client-teambuilder.js b/js/client-teambuilder.js index c439c6acb..1fe872846 100755 --- a/js/client-teambuilder.js +++ b/js/client-teambuilder.js @@ -154,7 +154,7 @@ buf += '
  • you don\'t have any teams lol
  • '; } else { buf += '
  • '; - for (var i=0; i 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 += '
    '; buf += '
      '; buf += '
    1. ' + this.clipboardHTML() + '
    2. '; - 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 += '
    3. '; buf += '
    '; buf += '
    '; @@ -543,10 +543,10 @@ 'F': 'Female', 'N': '—' }; - buf += '' + (set.level||100) + ''; - buf += '' + GenderChart[template.gender||set.gender||'N'] + ''; - buf += '' + (typeof set.happiness === 'number'?set.happiness:255) + ''; - buf += '' + (set.shiny?'Yes':'No') + ''; + buf += '' + (set.level || 100) + ''; + buf += '' + GenderChart[template.gender || set.gender || 'N'] + ''; + buf += '' + (typeof set.happiness === 'number' ? set.happiness : 255) + ''; + buf += '' + (set.shiny ? 'Yes' : 'No') + ''; buf += '
    '; buf += '
    '; @@ -575,12 +575,12 @@ } else if (BattleNatures[set.nature] && BattleNatures[set.nature].minus === j) { ev += ''; } - 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 += ' ' + ev + ''; + 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 += ' ' + ev + ''; } buf += '
    '; @@ -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'; if (!set.name) { @@ -947,12 +947,12 @@ else if (BattleNatures[set.nature] && BattleNatures[set.nature].minus === stat) { ev += ''; } - 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 += ' ' + ev + ''; + buf += ' ' + ev + ''; } this.$('button[name=stats]').html(buf); @@ -967,23 +967,23 @@ buf = '
    '; 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 += '
    '; - totalev += (set.evs[stat]||0); + totalev += (set.evs[stat] || 0); } buf += '
    Remaining:
    '; this.$chart.find('.graphcol').html(buf); if (totalev <= 510) { - this.$chart.find('.totalev').html('' + (totalev>508?0:508-totalev) + ''); + this.$chart.find('.totalev').html('' + (totalev > 508 ? 0 : 508 - totalev) + ''); } else { - this.$chart.find('.totalev').html('' + (510-totalev) + ''); + this.$chart.find('.totalev').html('' + (510 - totalev) + ''); } - 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)

    '; } 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 += '

    '; //buf += ' (' + role + ' | bulk: phys ' + Math.round(this.moveCount.physicalBulk/1000) + ' + spec ' + Math.round(this.moveCount.specialBulk/1000) + ' = ' + Math.round(this.moveCount.bulk/1000) + ')'; @@ -1121,11 +1123,11 @@ buf += '
    '; 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 += '
    '; } buf += '
    Remaining:
    '; @@ -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 += '
    '; - totalev += (set.evs[i]||0); + totalev += (set.evs[i] || 0); } if (totalev <= 510) { - buf += '
    ' + (totalev>508?0:508-totalev) + '
    '; + buf += '
    ' + (totalev > 508 ? 0 : 508 - totalev) + '
    '; } else { - buf += '
    ' + (510-totalev) + '
    '; + buf += '
    ' + (510 - totalev) + '
    '; } buf += '
    '; buf += '
    '; for (var i in stats) { - buf += '
    '; + buf += '
    '; } buf += '
    '; @@ -1183,9 +1185,9 @@ buf += '

    Nature: '; + buf += '

    '; buf += '
    '; if (template.gender) { var genderTable = {'M': "Male", 'F': "Female", 'N': "Genderless"}; buf += genderTable[template.gender]; } else { - buf += ' '; - buf += ' '; - buf += ''; + buf += ' '; + buf += ' '; + buf += ''; } buf += '
    '; - buf += '
    '; + buf += '
    '; buf += '
    '; - buf += ' '; - buf += ''; + buf += ' '; + buf += ''; buf += '
    '; buf += ''; @@ -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 += '' + (set.level||100) + ''; - buf += '' + GenderChart[set.gender||'N'] + ''; - buf += '' + (typeof set.happiness==='number'?set.happiness:255) + ''; - buf += '' + (set.shiny?'Yes':'No') + ''; + buf += '' + (set.level || 100) + ''; + buf += '' + GenderChart[set.gender || 'N'] + ''; + buf += '' + (typeof set.happiness === 'number' ? set.happiness : 255) + ''; + buf += '' + (set.shiny ? 'Yes' : 'No') + ''; 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 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 = ''; diff --git a/js/client.js b/js/client.js index 0d83111e2..b09f6bc4b 100755 --- a/js/client.js +++ b/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') { + 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 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 = ' ' + Tools.escapeHTML(name) + ' '; + buf = ' ' + Tools.escapeHTML(name) + ' '; } else { - buf = ' '; + buf = ' '; } this.$userbar.html(buf); }, @@ -1650,9 +1650,9 @@ var curId = (app.curRoom ? app.curRoom.id : ''); var curSideId = (app.curSideRoom ? app.curSideRoom.id : ''); - var buf = '
    • Home
    • '; - if (app.rooms['teambuilder']) buf += '
    • Teambuilder
    • '; - if (app.rooms['ladder']) buf += '
    • Ladder
    • '; + var buf = ''; 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 = ' ' + (Tools.escapeHTML(room.title)||(id==='lobby'?'Lobby':id)) + ''; - if (id.substr(0,7) === 'battle-') { + var name = ' ' + (Tools.escapeHTML(room.title) || (id === 'lobby' ? 'Lobby' : id)) + ''; + 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 += '
    • ' + name + '
    • '; + sideBuf += '
    • ' + name + '
    • '; if (curSideId) { // get left/right for side rooms if (curSideId === id) { @@ -1715,7 +1715,7 @@ buf += '
        '; atLeastOne = true; } - buf += '
      • ' + name + '
      • '; + buf += '
      • ' + name + '
      • '; // get left/right if (curId === id) { passedCurRoom = true; @@ -1729,12 +1729,12 @@ if (nwWindow.setBadgeLabel) nwWindow.setBadgeLabel(notificationCount || ''); } if (app.supports['rooms']) { - sideBuf += '
      •  
      • '; + sideBuf += '
      •  
      • '; } if (atLeastOne) buf += '
      '; if (sideBuf) { if (app.curSideRoom) { - buf += '
        ' + sideBuf + '
      '; + buf += '
        ' + sideBuf + '
      '; } else { buf += '
        ' + sideBuf + '
      '; } @@ -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('

      ' + (data.htmlMessage||Tools.parseMessage(data.message)) + '

      ').css('max-width', data.maxWidth || 480); + this.$el.html('

      ' + (data.htmlMessage || Tools.parseMessage(data.message)) + '

      ').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'; + if (avatar) buf += ''; buf += '' + Tools.escapeHTML(name) + '
      '; buf += '' + (group || ' ') + ''; 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 = '
      Battles: '; @@ -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 += '

      ' + (muted?'(muted)':'') + '

      '; - buf += '

      ' + (muted?'(muted)':'') + '

      '; - buf += '

      '; + buf += '

      ' + (muted ? '(muted)' : '') + '

      '; + buf += '

      ' + (muted ? '(muted)' : '') + '

      '; + buf += '

      '; this.$el.html(buf).css('min-width', 160); }, events: { @@ -2514,15 +2514,15 @@ BattleSound.setMute(muted); if (!muted) { - this.$('.effect-volume').html(''); - this.$('.music-volume').html(''); + this.$('.effect-volume').html(''); + this.$('.music-volume').html(''); this.domInitialize(); } else { this.$('.effect-volume').html('(muted)'); this.$('.music-volume').html('(muted)'); } - app.topbar.$('button[name=openSounds]').html(''); + app.topbar.$('button[name=openSounds]').html(''); }, setEffectVolume: function (volume) { BattleSound.setEffectVolume(volume); @@ -2559,32 +2559,32 @@ var avatar = app.user.get('avatar'); var buf = ''; - buf += '

      ' + (avatar?'':'') + '' + Tools.escapeHTML(name) + '

      '; + buf += '

      ' + (avatar ? '' : '') + '' + Tools.escapeHTML(name) + '

      '; buf += '

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

      '; - buf += '

      '; - buf += '

      '; - buf += '

      '; - buf += '

      '; - buf += '

      '; - buf += '

      '; + buf += '

      '; + buf += '

      '; + buf += '

      '; + buf += '

      '; + buf += '

      '; + buf += '

      '; + buf += '

      '; if (window.Notification) { - buf += '

      '; + buf += '

      '; } var timestamps = this.timestamps = (Tools.prefs('timestamps') || {}); - buf += '

      '; - buf += '

      '; + buf += '

      '; + buf += '

      '; buf += '

      '; if (window.nodewebkit) { buf += '
      '; buf += '

      Desktop app

      '; - buf += '

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

      '; + buf += ''; } buf += '
      '; @@ -2720,9 +2720,9 @@ buf += '

      Choose an avatar or

      '; buf += '
      '; - for (var i=1; i<=293; i++) { - var offset = '-' + (((i-1)%16)*80) + 'px -' + (Math.floor((i-1)/16)*80) + 'px'; - buf += ''; + for (var i = 1; i <= 293; i++) { + var offset = '-' + (((i - 1) % 16) * 80) + 'px -' + (Math.floor((i - 1) / 16) * 80) + 'px'; + buf += ''; } buf += '
      '; @@ -2764,7 +2764,7 @@ var warning = ('warning' in data); var buf = ''; if (warning) { - buf += '

      ' + (Tools.escapeHTML(data.warning)||'You have been warned for breaking the rules.') + '

      '; + buf += '

      ' + (Tools.escapeHTML(data.warning) || 'You have been warned for breaking the rules.') + '

      '; } buf += '

      Pokémon Showdown Rules

      '; buf += 'Global

      1. Be nice to people. Respect people. Don\'t be rude to people.

      2. 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.

      3. 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).

      4. English only.

      5. The First Amendment does not apply to PS, since PS is not a government organization.

      6. 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.

      '; @@ -2793,9 +2793,9 @@ var curId = (app.curRoom ? app.curRoom.id : ''); var curSideId = (app.curSideRoom ? app.curSideRoom.id : ''); - var buf = '
      • Home
      • '; - if (app.rooms['teambuilder']) buf += '
      • Teambuilder
      • '; - if (app.rooms['ladder']) buf += '
      • Ladder
      • '; + var buf = ''; var atLeastOne = false; var sideBuf = ''; @@ -2804,7 +2804,7 @@ var room = app.rooms[id]; var name = ' ' + id + ''; if (id === 'lobby') name = ' Lobby'; - 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 = '' + parts[0] + '' + name + ''; } if (room.isSideRoom) { - if (room.id !== 'rooms') sideBuf += '
      • ' + name + '
      • '; + if (room.id !== 'rooms') sideBuf += '
      • ' + name + '
      • '; continue; } if (!atLeastOne) { buf += '
          '; atLeastOne = true; } - buf += '
        • ' + name + '
        • '; + buf += '
        • ' + name + '
        • '; } if (app.supports['rooms']) { - sideBuf += '
        •  
        • '; + sideBuf += '
        •  
        • '; } if (atLeastOne) buf += '
        '; if (sideBuf) { diff --git a/js/search.js b/js/search.js index 90f56c244..670483325 100755 --- a/js/search.js +++ b/js/search.js @@ -9,13 +9,14 @@ * @author Guangcong Luo */ -(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]] = '
      • ' + typeName[type] + '

      • '; - 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 = '
      • '; // number - buf += '' + (pokemon.num>=0 ? pokemon.num : 'CAP') + ' '; + buf += '' + (pokemon.num >= 0 ? pokemon.num : 'CAP') + ' '; // icon buf += ''; @@ -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) + '' + name.substr(matchStart, matchLength) + '' + 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 += '' + pokemon.species.substr(tagStart, matchStart-tagStart) + '' + pokemon.species.substr(matchStart, matchLength) + '' + pokemon.species.substr(matchStart + matchLength) + ''; + name += '' + pokemon.species.substr(tagStart, matchStart - tagStart) + '' + pokemon.species.substr(matchStart, matchLength) + '' + pokemon.species.substr(matchStart + matchLength) + ''; } else { name += '' + pokemon.species.substr(tagStart) + ''; } @@ -190,7 +191,7 @@ // type buf += ''; - for (var i=0; i' + pokemon.species.substr(tagStart) + ''; buf += '' + name + ' '; @@ -259,7 +260,7 @@ // type buf += ''; - for (var i=0; i' + move.name.substr(matchStart, matchLength) + '' + move.name.substr(matchStart + matchLength) + ''; + name += '' + move.name.substr(tagStart, matchStart - tagStart) + '' + move.name.substr(matchStart, matchLength) + '' + move.name.substr(matchStart + matchLength) + ''; } else { name += '' + move.name.substr(tagStart) + ''; } @@ -396,9 +397,9 @@ buf += ' '; // power, accuracy, pp - buf += '' + (move.category!=='Status'?('Power
        ' + (move.basePower||'—')):'') + '
        '; - buf += 'Accuracy
        ' + (move.accuracy && move.accuracy!==true?move.accuracy + '%':'—') + '
        '; - buf += 'PP
        ' + (move.pp!==1?move.pp*8/5:move.pp) + '
        '; + buf += '' + (move.category !== 'Status' ? ('Power
        ' + (move.basePower || '—')) : '') + '
        '; + buf += 'Accuracy
        ' + (move.accuracy && move.accuracy !== true ? move.accuracy + '%' : '—') + '
        '; + buf += 'PP
        ' + (move.pp !== 1 ? move.pp * 8 / 5 : move.pp) + '
        '; // desc buf += '' + Tools.escapeHTML(move.shortDesc || move.desc) + ' '; @@ -432,9 +433,9 @@ buf += '
        '; // power, accuracy, pp - buf += '' + (move.category!=='Status'?('Power
        ' + (move.basePower||'—')):'') + '
        '; - buf += 'Accuracy
        ' + (move.accuracy && move.accuracy!==true?move.accuracy + '%':'—') + '
        '; - buf += 'PP
        ' + (move.pp!==1?move.pp*8/5:move.pp) + '
        '; + buf += '' + (move.category !== 'Status' ? ('Power
        ' + (move.basePower || '—')) : '') + '
        '; + buf += 'Accuracy
        ' + (move.accuracy && move.accuracy !== true ? move.accuracy + '%' : '—') + '
        '; + buf += 'PP
        ' + (move.pp !== 1 ? move.pp * 8 / 5 : move.pp) + '
        '; // desc buf += '' + Tools.escapeHTML(move.shortDesc || move.desc) + ' '; @@ -470,9 +471,9 @@ buf += '
        '; // power, accuracy, pp - buf += '' + (move.category!=='Status'?('Power
        ' + (move.basePower||'—')):'') + '
        '; - buf += 'Accuracy
        ' + (move.accuracy && move.accuracy!==true?move.accuracy + '%':'—') + '
        '; - buf += 'PP
        ' + (move.pp!==1?move.pp*8/5:move.pp) + '
        '; + buf += '' + (move.category !== 'Status' ? ('Power
        ' + (move.basePower || '—')) : '') + '
        '; + buf += 'Accuracy
        ' + (move.accuracy && move.accuracy !== true ? move.accuracy + '%' : '—') + '
        '; + buf += 'PP
        ' + (move.pp !== 1 ? move.pp * 8 / 5 : move.pp) + '
        '; // desc buf += '' + Tools.escapeHTML(move.shortDesc || move.desc) + ' '; @@ -490,7 +491,7 @@ // name var name = type.name; if (matchLength) { - name = name.substr(0, matchStart) + '' + name.substr(matchStart, matchLength) + '' + name.substr(matchStart+matchLength); + name = name.substr(0, matchStart) + '' + name.substr(matchStart, matchLength) + '' + name.substr(matchStart + matchLength); } buf += '' + name + ' '; @@ -518,7 +519,7 @@ // name var name = category.name; if (matchLength) { - name = name.substr(0, matchStart) + '' + name.substr(matchStart, matchLength) + '' + name.substr(matchStart+matchLength); + name = name.substr(0, matchStart) + '' + name.substr(matchStart, matchLength) + '' + name.substr(matchStart + matchLength); } buf += '' + name + ' '; @@ -546,7 +547,7 @@ // name var name = egggroup.name; if (matchLength) { - name = name.substr(0, matchStart) + '' + name.substr(matchStart, matchLength) + '' + name.substr(matchStart+matchLength); + name = name.substr(0, matchStart) + '' + name.substr(matchStart, matchLength) + '' + name.substr(matchStart + matchLength); } buf += '' + name + ' '; diff --git a/js/storage.js b/js/storage.js index 1513e95ce..64992b742 100755 --- a/js/storage.js +++ b/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= 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
      • <' + 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) + '' + name.substr(match.name.start, match.name.end-match.name.start) + '' + name.substr(match.name.end); + if (match.name) { + name = name.substr(0, match.name.start) + '' + name.substr(match.name.start, match.name.end - match.name.start) + '' + 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 += '-' + pokemon.forme.substr(0, match.name.start-(pokemon.baseSpecies.length+1)) + '' + pokemon.name.substr(match.name.start, match.name.end-match.name.start) + '' + pokemon.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 += '-' + pokemon.forme.substr(0, match.name.start - (pokemon.baseSpecies.length + 1)) + '' + pokemon.name.substr(match.name.start, match.name.end - match.name.start) + '' + pokemon.name.substr(match.name.end) + ''; } - else - { + else { name += '-' + pokemon.forme + ''; } } @@ -104,38 +93,32 @@ function BattleChart() text += ' '; text += '' + name + ' '; - if (self.illegalBuckets[match.bucket]) - { + if (self.illegalBuckets[match.bucket]) { text += '' + self.illegalBuckets[match.bucket] + ' '; text += '
      • '; return text; } text += ''; - if (pokemon.types) for (var i=0; i' + ability.substr(match.ability[i].start, match.ability[i].end-match.ability[i].start) + '' + ability.substr(match.ability[i].end); + if (match.ability && match.ability[i]) { + ability = ability.substr(0, match.ability[i].start) + '' + ability.substr(match.ability[i].start, match.ability[i].end - match.ability[i].start) + '' + ability.substr(match.ability[i].end); } if (i == 'H') { ability = '' + (pokemon.unreleasedHidden ? '' + ability + '' : ability) + ''; @@ -163,7 +146,7 @@ function BattleChart() return text; }; this.itemRow = function (item, attrs, match, isFirst) { - var text = '
      • '; + var text = '
      • '; 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) + '' + name.substr(match.name.start, match.name.end-match.name.start) + '' + name.substr(match.name.end); + if (match.name) { + name = name.substr(0, match.name.start) + '' + name.substr(match.name.start, match.name.end - match.name.start) + '' + name.substr(match.name.end); } text += '' + name + ' '; - if (self.illegalBuckets[match.bucket]) - { + if (self.illegalBuckets[match.bucket]) { text += '' + self.illegalBuckets[match.bucket] + ' '; text += '
      • '; return text; @@ -194,17 +175,15 @@ function BattleChart() return text; }; this.abilityRow = function (ability, attrs, match, isFirst) { - var text = '
      • '; + var text = '
      • '; var name = Tools.escapeHTML(ability.name); - if (match.name) - { - name = name.substr(0, match.name.start) + '' + name.substr(match.name.start, match.name.end-match.name.start) + '' + name.substr(match.name.end); + if (match.name) { + name = name.substr(0, match.name.start) + '' + name.substr(match.name.start, match.name.end - match.name.start) + '' + name.substr(match.name.end); } text += '' + name + ' '; - if (self.illegalBuckets[match.bucket]) - { + if (self.illegalBuckets[match.bucket]) { text += '' + self.illegalBuckets[match.bucket] + ' '; text += '
      • '; return text; @@ -217,31 +196,26 @@ function BattleChart() return text; }; this.moveRow = function (move, attrs, match, isFirst) { - var text = '
      • '; + var text = '
      • '; 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) + '' + name.substr(match.name.start, match.name.end-match.name.start) + '' + name.substr(match.name.end); + if (match.name) { + name = name.substr(0, match.name.start) + '' + name.substr(match.name.start, match.name.end - match.name.start) + '' + 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 += ' ' + move.name.substr(hplen+1, match.name.start-(hplen+1)) + '' + move.name.substr(match.name.start, match.name.end-match.name.start) + '' + move.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 += ' ' + move.name.substr(hplen + 1, match.name.start - (hplen + 1)) + '' + move.name.substr(match.name.start, match.name.end - match.name.start) + '' + move.name.substr(match.name.end) + ''; } - else - { - name += ' ' + move.name.substr(hplen+1) +''; + else { + name += ' ' + move.name.substr(hplen + 1) + ''; } } text += '' + name + ' '; - if (self.illegalBuckets[match.bucket]) - { + if (self.illegalBuckets[match.bucket]) { text += '' + self.illegalBuckets[match.bucket] + ' '; text += '
      • '; return text; @@ -249,12 +223,12 @@ function BattleChart() text += ''; text += Tools.getTypeIcon(move.type, match.type); - text += '' + move.category + ''; + text += '' + move.category + ''; text += ' '; - text += '' + (move.category!=='Status'?('Power
        ' + (move.basePower||'—')):'') + '
        '; - text += 'Accuracy
        ' + (move.accuracy && move.accuracy!==true?move.accuracy + '%':'—') + '
        '; - text += 'PP
        ' + ((move.pp!==1 && !move.noPPBoosts)?move.pp*8/5:move.pp) + '
        '; + text += '' + (move.category !== 'Status' ? ('Power
        ' + (move.basePower || '—')) : '') + '
        '; + text += 'Accuracy
        ' + (move.accuracy && move.accuracy !== true ? move.accuracy + '%' : '—') + '
        '; + text += 'PP
        ' + ((move.pp !== 1 && !move.noPPBoosts) ? move.pp * 8 / 5 : move.pp) + '
        '; text += '' + Tools.escapeHTML(move.shortDesc || move.desc) + ' '; @@ -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= 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'; 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)