replace if by string.replace

This commit is contained in:
Gwenhael Le Moine 2011-07-05 10:39:56 +02:00
parent c0d82707cc
commit 98f5851b47

View file

@ -114,16 +114,11 @@ function format_level( state ) {
var substitutions = {
'#': '<span class="starcell wall">#</span>',
'x': '<span class="starcell gift">x</span>',
' ': '<span class="starcell void"> </span>'
' ': '<span class="starcell void"> </span>',
'H': '<span class="starcell cube">H</span>',
'@': '<span class="starcell ball">@</span>'
};
if ( state.moving == cell.BALL ) {
substitutions[ '@' ] = '<span class="starcell ball selected">@</span>';
substitutions[ 'H' ] = '<span class="starcell cube">H</span>';
}
else {
substitutions[ '@' ] = '<span class="starcell ball">@</span>';
substitutions[ 'H' ] = '<span class="starcell cube selected">H</span>';
}
substitutions[ state.moving ] = substitutions[ state.moving ].replace( '">', ' selected">' );
var myReplacer = Replacer( substitutions );
return myReplacer( state.board );
}