displaying characters is optional and off by default

This commit is contained in:
Gwenhael Le Moine 2011-07-06 23:04:46 +02:00
parent 3c79be7be4
commit aad2f4a3e0

View file

@ -95,7 +95,7 @@ function won_or_not( state ) {
return count_gifts( state ) === 0; return count_gifts( state ) === 0;
} }
function format_level( state ) { function format_level( state, text ) {
function Replacer( conversionObject ) { function Replacer( conversionObject ) {
var regexpStr = ''; var regexpStr = '';
@ -119,6 +119,11 @@ function format_level( state ) {
'@': '<span class="starcell ball">@</span>' '@': '<span class="starcell ball">@</span>'
}; };
substitutions[ state.moving ] = substitutions[ state.moving ].replace( '">', '_selected">' ); substitutions[ state.moving ] = substitutions[ state.moving ].replace( '">', '_selected">' );
if ( text == false ) {
for ( var c in substitutions ) {
substitutions[ c ] = substitutions[ c ].replace( />.</, '><' );
}
}
var myReplacer = Replacer( substitutions ); var myReplacer = Replacer( substitutions );
return myReplacer( state.board ); return myReplacer( state.board );
} }
@ -132,7 +137,7 @@ function load_level( levelset, nb ) {
} }
function display_level( state, elt ) { function display_level( state, elt ) {
$( elt ).html( format_level( state ) ); $( elt ).html( format_level( state, false ) );
} }