single loop in format_level

This commit is contained in:
Gwenhael Le Moine 2011-07-05 09:32:38 +02:00
parent 575f1b92f5
commit f775d6ec8e
2 changed files with 7 additions and 10 deletions

View file

@ -28,7 +28,7 @@
<div id="main" role="main">
<style>
#blackboard{width:16em;background:#333}
#blackboard{width:16em;background:#333;float:left}
.starcell{width:1em;height:1em;display:block;float:left;text-align:center}
.selected{font-weight:bold}
.wall{color:#000}

View file

@ -97,16 +97,13 @@ function won_or_not( state ) {
function format_level( state ) {
dl = "";
for ( i = 0 ; i < LEVEL_HEIGHT ; i++ ) {
for ( j = 0 ; j < LEVEL_WIDTH ; j++ ) {
c = get_cell( state, j, i );
classes = "starcell " + css_classes[ c ];
if ( state.moving == c) {
classes = classes + " selected ";
}
dl = dl + "<span class=\"" + classes + "\">" + c + "</span>";
for ( i = 0 ; i < LEVEL_HEIGHT * LEVEL_WIDTH ; i++ ) {
c = state.board[ i ];
classes = "starcell " + css_classes[ c ];
if ( state.moving == c) {
classes = classes + " selected ";
}
dl = dl + "<br />";
dl = dl + "<span class=\"" + classes + "\">" + c + "</span>";
}
return dl;
}