single loop in format_level

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

View file

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

View file

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