New function escapeFormat for format names

This commit is contained in:
Guangcong Luo
2013-05-03 01:26:29 -07:00
parent c5626f44da
commit e0aefb84ba
3 changed files with 9 additions and 2 deletions

View File

@@ -79,7 +79,7 @@
</script>
<script src="//play.pokemonshowdown.com/js/config.js?"></script>
<script src="//play.pokemonshowdown.com/js/battledata.js?"></script>
<script src="/js/battledata.js"></script>
<script src="//play.pokemonshowdown.com/data/pokedex-mini.js?"></script>
<script src="//play.pokemonshowdown.com/js/battle.js?"></script>
<script src="//play.pokemonshowdown.com/js/sockjs-0.3.min.js"></script>

View File

@@ -353,6 +353,13 @@ var Tools = {
return Tools.resolveAvatar(sprites[Math.floor(Math.random() * sprites.length)]);
},
escapeFormat: function(formatid) {
if (window.BattleFormats && BattleFormats[formatid]) {
return Tools.escapeHTML(BattleFormats[formatid].name)
}
return Tools.escapeHTML(formatid);
},
escapeHTML: function(str, jsEscapeToo) {
str = (str?''+str:'');
str = str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');

View File

@@ -185,7 +185,7 @@
if (!matches) {
return; // bogus room ID could be used to inject JavaScript
}
var format = (matches ? matches[1] : '');
var format = Tools.escapeFormat(matches ? matches[1] : '');
if (silent && !Tools.prefs('showbattles')) return;